OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return CONTAINS_STRING(arg, "Sample encryption info is not available."); | 44 return CONTAINS_STRING(arg, "Sample encryption info is not available."); |
45 } | 45 } |
46 | 46 |
47 MATCHER_P(ErrorLog, error_string, "") { | 47 MATCHER_P(ErrorLog, error_string, "") { |
48 return CONTAINS_STRING(arg, error_string); | 48 return CONTAINS_STRING(arg, error_string); |
49 } | 49 } |
50 | 50 |
51 class MP4StreamParserTest : public testing::Test { | 51 class MP4StreamParserTest : public testing::Test { |
52 public: | 52 public: |
53 MP4StreamParserTest() | 53 MP4StreamParserTest() |
54 : media_log_(new StrictMock<MockMediaLog>()), | 54 : configs_received_(false), |
55 configs_received_(false), | |
56 lower_bound_( | 55 lower_bound_( |
57 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { | 56 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { |
58 std::set<int> audio_object_types; | 57 std::set<int> audio_object_types; |
59 audio_object_types.insert(kISO_14496_3); | 58 audio_object_types.insert(kISO_14496_3); |
60 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 59 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
61 } | 60 } |
62 | 61 |
63 protected: | 62 protected: |
64 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 63 StrictMock<MockMediaLog> media_log_; |
65 std::unique_ptr<MP4StreamParser> parser_; | 64 std::unique_ptr<MP4StreamParser> parser_; |
66 bool configs_received_; | 65 bool configs_received_; |
67 std::unique_ptr<MediaTracks> media_tracks_; | 66 std::unique_ptr<MediaTracks> media_tracks_; |
68 AudioDecoderConfig audio_decoder_config_; | 67 AudioDecoderConfig audio_decoder_config_; |
69 VideoDecoderConfig video_decoder_config_; | 68 VideoDecoderConfig video_decoder_config_; |
70 DecodeTimestamp lower_bound_; | 69 DecodeTimestamp lower_bound_; |
71 StreamParser::TrackId audio_track_id_; | 70 StreamParser::TrackId audio_track_id_; |
72 StreamParser::TrackId video_track_id_; | 71 StreamParser::TrackId video_track_id_; |
73 | 72 |
74 bool AppendData(const uint8_t* data, size_t length) { | 73 bool AppendData(const uint8_t* data, size_t length) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void InitializeParserWithInitParametersExpectations( | 184 void InitializeParserWithInitParametersExpectations( |
186 StreamParser::InitParameters params) { | 185 StreamParser::InitParameters params) { |
187 parser_->Init( | 186 parser_->Init( |
188 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this), params), | 187 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this), params), |
189 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), | 188 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), |
190 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), | 189 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), |
191 true, | 190 true, |
192 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), | 191 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), |
193 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), | 192 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), |
194 base::Bind(&MP4StreamParserTest::EndOfSegmentF, base::Unretained(this)), | 193 base::Bind(&MP4StreamParserTest::EndOfSegmentF, base::Unretained(this)), |
195 media_log_); | 194 &media_log_); |
196 } | 195 } |
197 | 196 |
198 StreamParser::InitParameters GetDefaultInitParametersExpectations() { | 197 StreamParser::InitParameters GetDefaultInitParametersExpectations() { |
199 // Most unencrypted test mp4 files have zero duration and are treated as | 198 // Most unencrypted test mp4 files have zero duration and are treated as |
200 // live streams. | 199 // live streams. |
201 StreamParser::InitParameters params(kInfiniteDuration); | 200 StreamParser::InitParameters params(kInfiniteDuration); |
202 params.liveness = DemuxerStream::LIVENESS_LIVE; | 201 params.liveness = DemuxerStream::LIVENESS_LIVE; |
203 params.detected_audio_track_count = 1; | 202 params.detected_audio_track_count = 1; |
204 params.detected_video_track_count = 1; | 203 params.detected_video_track_count = 1; |
205 params.detected_text_track_count = 0; | 204 params.detected_text_track_count = 0; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 const MediaTrack& audio_track2 = *(media_tracks_->tracks()[3]); | 543 const MediaTrack& audio_track2 = *(media_tracks_->tracks()[3]); |
545 EXPECT_EQ(audio_track2.type(), MediaTrack::Audio); | 544 EXPECT_EQ(audio_track2.type(), MediaTrack::Audio); |
546 EXPECT_EQ(audio_track2.bytestream_track_id(), 4); | 545 EXPECT_EQ(audio_track2.bytestream_track_id(), 4); |
547 EXPECT_EQ(audio_track2.kind(), ""); | 546 EXPECT_EQ(audio_track2.kind(), ""); |
548 EXPECT_EQ(audio_track2.label(), "SoundHandler"); | 547 EXPECT_EQ(audio_track2.label(), "SoundHandler"); |
549 EXPECT_EQ(audio_track2.language(), "und"); | 548 EXPECT_EQ(audio_track2.language(), "und"); |
550 } | 549 } |
551 | 550 |
552 } // namespace mp4 | 551 } // namespace mp4 |
553 } // namespace media | 552 } // namespace media |
OLD | NEW |