Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: media/mp4/mp4_stream_parser_unittest.cc

Issue 11313016: Add "type" in GenerateKeyRequest() and OnNeedKey(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the DCHECK where init_data_type_ is set but NeedKey from decoder passes empty "type". Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | media/webm/webm_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "media/base/audio_decoder_config.h" 13 #include "media/base/audio_decoder_config.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/stream_parser_buffer.h" 15 #include "media/base/stream_parser_buffer.h"
16 #include "media/base/test_data_util.h" 16 #include "media/base/test_data_util.h"
17 #include "media/base/video_decoder_config.h" 17 #include "media/base/video_decoder_config.h"
18 #include "media/mp4/mp4_stream_parser.h" 18 #include "media/mp4/mp4_stream_parser.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using base::TimeDelta; 21 using base::TimeDelta;
22 22
23 namespace media { 23 namespace media {
24 namespace mp4 { 24 namespace mp4 {
25 25
26 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
27 static const char kMp4InitDataType[] = "video/mp4";
28
26 class MP4StreamParserTest : public testing::Test { 29 class MP4StreamParserTest : public testing::Test {
27 public: 30 public:
28 MP4StreamParserTest() 31 MP4StreamParserTest()
29 : parser_(new MP4StreamParser(false)), 32 : parser_(new MP4StreamParser(false)),
30 configs_received_(false) { 33 configs_received_(false) {
31 } 34 }
32 35
33 protected: 36 protected:
34 scoped_ptr<MP4StreamParser> parser_; 37 scoped_ptr<MP4StreamParser> parser_;
35 base::TimeDelta segment_start_; 38 base::TimeDelta segment_start_;
(...skipping 11 matching lines...) Expand all
47 static_cast<size_t>(end - start)); 50 static_cast<size_t>(end - start));
48 if (!AppendData(start, append_size)) 51 if (!AppendData(start, append_size))
49 return false; 52 return false;
50 start += append_size; 53 start += append_size;
51 } 54 }
52 return true; 55 return true;
53 } 56 }
54 57
55 void InitF(bool init_ok, base::TimeDelta duration) { 58 void InitF(bool init_ok, base::TimeDelta duration) {
56 DVLOG(1) << "InitF: ok=" << init_ok 59 DVLOG(1) << "InitF: ok=" << init_ok
57 << ", dur=" << duration.InMilliseconds(); 60 << ", dur=" << duration.InMilliseconds();
58 } 61 }
59 62
60 bool NewConfigF(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { 63 bool NewConfigF(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) {
61 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig() 64 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig()
62 << ", video=" << vc.IsValidConfig(); 65 << ", video=" << vc.IsValidConfig();
63 configs_received_ = true; 66 configs_received_ = true;
64 return true; 67 return true;
65 } 68 }
66 69
67 bool NewBuffersF(const StreamParser::BufferQueue& bufs) { 70 bool NewBuffersF(const StreamParser::BufferQueue& bufs) {
68 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers"; 71 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers";
69 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin(); 72 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin();
70 buf != bufs.end(); buf++) { 73 buf != bufs.end(); buf++) {
71 DVLOG(3) << " n=" << buf - bufs.begin() 74 DVLOG(3) << " n=" << buf - bufs.begin()
72 << ", size=" << (*buf)->GetDataSize() 75 << ", size=" << (*buf)->GetDataSize()
73 << ", dur=" << (*buf)->GetDuration().InMilliseconds(); 76 << ", dur=" << (*buf)->GetDuration().InMilliseconds();
74 EXPECT_GE((*buf)->GetTimestamp(), segment_start_); 77 EXPECT_GE((*buf)->GetTimestamp(), segment_start_);
75 } 78 }
76 return true; 79 return true;
77 } 80 }
78 81
79 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) { 82 bool KeyNeededF(const std::string& type,
83 scoped_array<uint8> init_data, int init_data_size) {
80 DVLOG(1) << "KeyNeededF: " << init_data_size; 84 DVLOG(1) << "KeyNeededF: " << init_data_size;
85 EXPECT_EQ(kMp4InitDataType, type);
86 EXPECT_TRUE(init_data.get());
87 EXPECT_GT(init_data_size, 0);
81 return true; 88 return true;
82 } 89 }
83 90
84 void NewSegmentF(TimeDelta start_dts) { 91 void NewSegmentF(TimeDelta start_dts) {
85 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds(); 92 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds();
86 segment_start_ = start_dts; 93 segment_start_ = start_dts;
87 } 94 }
88 95
89 void EndOfSegmentF() { 96 void EndOfSegmentF() {
90 DVLOG(1) << "EndOfSegmentF()"; 97 DVLOG(1) << "EndOfSegmentF()";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 161 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(),
155 buffer->GetDataSize(), 162 buffer->GetDataSize(),
156 512)); 163 512));
157 } 164 }
158 165
159 // TODO(strobe): Create and test media which uses CENC auxiliary info stored 166 // TODO(strobe): Create and test media which uses CENC auxiliary info stored
160 // inside a private box 167 // inside a private box
161 168
162 } // namespace mp4 169 } // namespace mp4
163 } // namespace media 170 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | media/webm/webm_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698