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

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

Issue 2239013002: Assign correct track ids to buffers emitted from StreamParsers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 "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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 protected: 71 protected:
72 scoped_refptr<StrictMock<MockMediaLog>> media_log_; 72 scoped_refptr<StrictMock<MockMediaLog>> media_log_;
73 std::unique_ptr<MP4StreamParser> parser_; 73 std::unique_ptr<MP4StreamParser> parser_;
74 bool configs_received_; 74 bool configs_received_;
75 std::unique_ptr<MediaTracks> media_tracks_; 75 std::unique_ptr<MediaTracks> media_tracks_;
76 AudioDecoderConfig audio_decoder_config_; 76 AudioDecoderConfig audio_decoder_config_;
77 VideoDecoderConfig video_decoder_config_; 77 VideoDecoderConfig video_decoder_config_;
78 DecodeTimestamp lower_bound_; 78 DecodeTimestamp lower_bound_;
79 StreamParser::TrackId audio_track_id_;
80 StreamParser::TrackId video_track_id_;
79 81
80 bool AppendData(const uint8_t* data, size_t length) { 82 bool AppendData(const uint8_t* data, size_t length) {
81 return parser_->Parse(data, length); 83 return parser_->Parse(data, length);
82 } 84 }
83 85
84 bool AppendDataInPieces(const uint8_t* data, 86 bool AppendDataInPieces(const uint8_t* data,
85 size_t length, 87 size_t length,
86 size_t piece_size) { 88 size_t piece_size) {
87 const uint8_t* start = data; 89 const uint8_t* start = data;
88 const uint8_t* end = data + length; 90 const uint8_t* end = data + length;
(...skipping 25 matching lines...) Expand all
114 } 116 }
115 117
116 bool NewConfigF(std::unique_ptr<MediaTracks> tracks, 118 bool NewConfigF(std::unique_ptr<MediaTracks> tracks,
117 const StreamParser::TextTrackConfigMap& tc) { 119 const StreamParser::TextTrackConfigMap& tc) {
118 configs_received_ = true; 120 configs_received_ = true;
119 CHECK(tracks.get()); 121 CHECK(tracks.get());
120 DVLOG(1) << "NewConfigF: got " << tracks->tracks().size() << " tracks"; 122 DVLOG(1) << "NewConfigF: got " << tracks->tracks().size() << " tracks";
121 for (const auto& track : tracks->tracks()) { 123 for (const auto& track : tracks->tracks()) {
122 const auto& track_id = track->bytestream_track_id(); 124 const auto& track_id = track->bytestream_track_id();
123 if (track->type() == MediaTrack::Audio) { 125 if (track->type() == MediaTrack::Audio) {
126 audio_track_id_ = track_id;
124 audio_decoder_config_ = tracks->getAudioConfig(track_id); 127 audio_decoder_config_ = tracks->getAudioConfig(track_id);
125 DVLOG(1) << "Audio track " << track_id << " config=" 128 DVLOG(1) << "Audio track " << track_id << " config="
126 << (audio_decoder_config_.IsValidConfig() 129 << (audio_decoder_config_.IsValidConfig()
127 ? audio_decoder_config_.AsHumanReadableString() 130 ? audio_decoder_config_.AsHumanReadableString()
128 : "INVALID"); 131 : "INVALID");
129 } else if (track->type() == MediaTrack::Video) { 132 } else if (track->type() == MediaTrack::Video) {
133 video_track_id_ = track_id;
130 video_decoder_config_ = tracks->getVideoConfig(track_id); 134 video_decoder_config_ = tracks->getVideoConfig(track_id);
131 DVLOG(1) << "Video track " << track_id << " config=" 135 DVLOG(1) << "Video track " << track_id << " config="
132 << (video_decoder_config_.IsValidConfig() 136 << (video_decoder_config_.IsValidConfig()
133 ? video_decoder_config_.AsHumanReadableString() 137 ? video_decoder_config_.AsHumanReadableString()
134 : "INVALID"); 138 : "INVALID");
135 } 139 }
136 } 140 }
137 media_tracks_ = std::move(tracks); 141 media_tracks_ = std::move(tracks);
138 return true; 142 return true;
139 } 143 }
140 144
141 void DumpBuffers(const std::string& label, 145 void DumpBuffers(const std::string& label,
142 const StreamParser::BufferQueue& buffers) { 146 const StreamParser::BufferQueue& buffers) {
143 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); 147 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
144 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); 148 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin();
145 buf != buffers.end(); buf++) { 149 buf != buffers.end(); buf++) {
146 DVLOG(3) << " n=" << buf - buffers.begin() 150 DVLOG(3) << " n=" << buf - buffers.begin()
147 << ", size=" << (*buf)->data_size() 151 << ", size=" << (*buf)->data_size()
148 << ", dur=" << (*buf)->duration().InMilliseconds(); 152 << ", dur=" << (*buf)->duration().InMilliseconds();
149 } 153 }
150 } 154 }
151 155
152 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers, 156 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers,
153 const StreamParser::BufferQueue& video_buffers, 157 const StreamParser::BufferQueue& video_buffers,
154 const StreamParser::TextBufferQueueMap& text_map) { 158 const StreamParser::TextBufferQueueMap& text_map) {
155 DumpBuffers("audio_buffers", audio_buffers); 159 DumpBuffers("audio_buffers", audio_buffers);
156 DumpBuffers("video_buffers", video_buffers); 160 DumpBuffers("video_buffers", video_buffers);
157 161
162 // Ensure that track ids are properly assigned on all emitted buffers.
163 for (const auto& buf : audio_buffers) {
164 EXPECT_EQ(audio_track_id_, buf->track_id());
165 }
166 for (const auto& buf : video_buffers) {
167 EXPECT_EQ(video_track_id_, buf->track_id());
168 }
169
158 // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See 170 // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See
159 // http://crbug.com/336926. 171 // http://crbug.com/336926.
160 if (!text_map.empty()) 172 if (!text_map.empty())
161 return false; 173 return false;
162 174
163 // Find the second highest timestamp so that we know what the 175 // Find the second highest timestamp so that we know what the
164 // timestamps on the next set of buffers must be >= than. 176 // timestamps on the next set of buffers must be >= than.
165 DecodeTimestamp audio = !audio_buffers.empty() ? 177 DecodeTimestamp audio = !audio_buffers.empty() ?
166 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); 178 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp();
167 DecodeTimestamp video = !video_buffers.empty() ? 179 DecodeTimestamp video = !video_buffers.empty() ?
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 scoped_refptr<DecoderBuffer> buffer = 544 scoped_refptr<DecoderBuffer> buffer =
533 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); 545 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4");
534 546
535 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); 547 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2"));
536 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); 548 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F"));
537 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); 549 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
538 } 550 }
539 551
540 } // namespace mp4 552 } // namespace mp4
541 } // namespace media 553 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.cc ('k') | media/formats/mpeg/mpeg_audio_stream_parser_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698