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

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

Issue 1735003004: Implement reading of media track info from WebM and MP4 containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@demuxer-tracks2
Patch Set: Mark WebMStreamParser with MEDIA_EXPORT to allow usage in unit tests Created 4 years, 9 months 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
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { 62 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) {
63 std::set<int> audio_object_types; 63 std::set<int> audio_object_types;
64 audio_object_types.insert(kISO_14496_3); 64 audio_object_types.insert(kISO_14496_3);
65 parser_.reset(new MP4StreamParser(audio_object_types, false)); 65 parser_.reset(new MP4StreamParser(audio_object_types, false));
66 } 66 }
67 67
68 protected: 68 protected:
69 scoped_refptr<StrictMock<MockMediaLog>> media_log_; 69 scoped_refptr<StrictMock<MockMediaLog>> media_log_;
70 scoped_ptr<MP4StreamParser> parser_; 70 scoped_ptr<MP4StreamParser> parser_;
71 bool configs_received_; 71 bool configs_received_;
72 scoped_ptr<MediaTracks> media_tracks_;
72 AudioDecoderConfig audio_decoder_config_; 73 AudioDecoderConfig audio_decoder_config_;
73 VideoDecoderConfig video_decoder_config_; 74 VideoDecoderConfig video_decoder_config_;
74 DecodeTimestamp lower_bound_; 75 DecodeTimestamp lower_bound_;
75 76
76 bool AppendData(const uint8_t* data, size_t length) { 77 bool AppendData(const uint8_t* data, size_t length) {
77 return parser_->Parse(data, length); 78 return parser_->Parse(data, length);
78 } 79 }
79 80
80 bool AppendDataInPieces(const uint8_t* data, 81 bool AppendDataInPieces(const uint8_t* data,
81 size_t length, 82 size_t length,
(...skipping 13 matching lines...) Expand all
95 void InitF(DemuxerStream::Liveness expected_liveness, 96 void InitF(DemuxerStream::Liveness expected_liveness,
96 const StreamParser::InitParameters& params) { 97 const StreamParser::InitParameters& params) {
97 DVLOG(1) << "InitF: dur=" << params.duration.InMilliseconds() 98 DVLOG(1) << "InitF: dur=" << params.duration.InMilliseconds()
98 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; 99 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset;
99 EXPECT_EQ(expected_liveness, params.liveness); 100 EXPECT_EQ(expected_liveness, params.liveness);
100 } 101 }
101 102
102 bool NewConfigF(scoped_ptr<MediaTracks> tracks, 103 bool NewConfigF(scoped_ptr<MediaTracks> tracks,
103 const StreamParser::TextTrackConfigMap& tc) { 104 const StreamParser::TextTrackConfigMap& tc) {
104 configs_received_ = true; 105 configs_received_ = true;
105 audio_decoder_config_ = tracks->getFirstAudioConfig(); 106 CHECK(tracks.get());
106 video_decoder_config_ = tracks->getFirstVideoConfig(); 107 media_tracks_ = std::move(tracks);
107 DVLOG(1) << "NewConfigF: track count=" << tracks->tracks().size() 108 audio_decoder_config_ = media_tracks_->getFirstAudioConfig();
109 video_decoder_config_ = media_tracks_->getFirstVideoConfig();
110 DVLOG(1) << "NewConfigF: track count=" << media_tracks_->tracks().size()
108 << " audio=" << audio_decoder_config_.IsValidConfig() 111 << " audio=" << audio_decoder_config_.IsValidConfig()
109 << " video=" << video_decoder_config_.IsValidConfig(); 112 << " video=" << video_decoder_config_.IsValidConfig();
110 return true; 113 return true;
111 } 114 }
112 115
113 void DumpBuffers(const std::string& label, 116 void DumpBuffers(const std::string& label,
114 const StreamParser::BufferQueue& buffers) { 117 const StreamParser::BufferQueue& buffers) {
115 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); 118 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
116 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); 119 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin();
117 buf != buffers.end(); buf++) { 120 buf != buffers.end(); buf++) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // A real FOURCC should print. 399 // A real FOURCC should print.
397 EXPECT_EQ("mvex", FourCCToString(FOURCC_MVEX)); 400 EXPECT_EQ("mvex", FourCCToString(FOURCC_MVEX));
398 401
399 // Invalid FOURCC should also print whenever ASCII values are printable. 402 // Invalid FOURCC should also print whenever ASCII values are printable.
400 EXPECT_EQ("fake", FourCCToString(static_cast<FourCC>(0x66616b65))); 403 EXPECT_EQ("fake", FourCCToString(static_cast<FourCC>(0x66616b65)));
401 404
402 // Invalid FORCC with non-printable values should not give error message. 405 // Invalid FORCC with non-printable values should not give error message.
403 EXPECT_EQ("0x66616b00", FourCCToString(static_cast<FourCC>(0x66616b00))); 406 EXPECT_EQ("0x66616b00", FourCCToString(static_cast<FourCC>(0x66616b00)));
404 } 407 }
405 408
409 TEST_F(MP4StreamParserTest, MediaTrackInfoSourcing) {
410 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F"));
411 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2"));
412 ParseMP4File("bear-1280x720-av_frag.mp4", 4096);
wolenetz 2016/03/05 03:26:21 nit: we probably need (for webm and mp4 across bot
servolk 2016/03/07 23:45:01 Opened crbug.com/592717 for tracking this.
wolenetz 2016/03/10 19:53:29 Acknowledged.
413
414 EXPECT_EQ(media_tracks_->tracks().size(), 2u);
415 const MediaTrack& video_track = *(media_tracks_->tracks()[0]);
416 EXPECT_EQ(video_track.type(), MediaTrack::Video);
417 EXPECT_EQ(video_track.id(), "1");
418 EXPECT_EQ(video_track.kind(), "main");
419 EXPECT_EQ(video_track.label(), "VideoHandler");
420 EXPECT_EQ(video_track.language(), "und");
421
422 const MediaTrack& audio_track = *(media_tracks_->tracks()[1]);
423 EXPECT_EQ(audio_track.type(), MediaTrack::Audio);
424 EXPECT_EQ(audio_track.id(), "2");
425 EXPECT_EQ(audio_track.kind(), "main");
426 EXPECT_EQ(audio_track.label(), "SoundHandler");
427 EXPECT_EQ(audio_track.language(), "und");
428 }
429
406 } // namespace mp4 430 } // namespace mp4
407 } // namespace media 431 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698