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

Side by Side Diff: media/formats/mp2t/mp2t_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
« no previous file with comments | « media/formats/mp2t/mp2t_common.h ('k') | media/formats/mp4/mp4_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 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/mp2t/mp2t_stream_parser.h" 5 #include "media/formats/mp2t/mp2t_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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 std::unique_ptr<Mp2tStreamParser> parser_; 73 std::unique_ptr<Mp2tStreamParser> parser_;
74 int segment_count_; 74 int segment_count_;
75 int config_count_; 75 int config_count_;
76 int audio_frame_count_; 76 int audio_frame_count_;
77 int video_frame_count_; 77 int video_frame_count_;
78 bool has_video_; 78 bool has_video_;
79 DecodeTimestamp audio_min_dts_; 79 DecodeTimestamp audio_min_dts_;
80 DecodeTimestamp audio_max_dts_; 80 DecodeTimestamp audio_max_dts_;
81 DecodeTimestamp video_min_dts_; 81 DecodeTimestamp video_min_dts_;
82 DecodeTimestamp video_max_dts_; 82 DecodeTimestamp video_max_dts_;
83 StreamParser::TrackId audio_track_id_;
84 StreamParser::TrackId video_track_id_;
83 85
84 void ResetStats() { 86 void ResetStats() {
85 segment_count_ = 0; 87 segment_count_ = 0;
86 config_count_ = 0; 88 config_count_ = 0;
87 audio_frame_count_ = 0; 89 audio_frame_count_ = 0;
88 video_frame_count_ = 0; 90 video_frame_count_ = 0;
89 audio_min_dts_ = kNoDecodeTimestamp(); 91 audio_min_dts_ = kNoDecodeTimestamp();
90 audio_max_dts_ = kNoDecodeTimestamp(); 92 audio_max_dts_ = kNoDecodeTimestamp();
91 video_min_dts_ = kNoDecodeTimestamp(); 93 video_min_dts_ = kNoDecodeTimestamp();
92 video_max_dts_ = kNoDecodeTimestamp(); 94 video_max_dts_ = kNoDecodeTimestamp();
(...skipping 24 matching lines...) Expand all
117 } 119 }
118 120
119 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks, 121 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks,
120 const StreamParser::TextTrackConfigMap& tc) { 122 const StreamParser::TextTrackConfigMap& tc) {
121 DVLOG(1) << "OnNewConfig: got " << tracks->tracks().size() << " tracks"; 123 DVLOG(1) << "OnNewConfig: got " << tracks->tracks().size() << " tracks";
122 bool found_audio_track = false; 124 bool found_audio_track = false;
123 bool found_video_track = false; 125 bool found_video_track = false;
124 for (const auto& track : tracks->tracks()) { 126 for (const auto& track : tracks->tracks()) {
125 const auto& track_id = track->bytestream_track_id(); 127 const auto& track_id = track->bytestream_track_id();
126 if (track->type() == MediaTrack::Audio) { 128 if (track->type() == MediaTrack::Audio) {
129 audio_track_id_ = track_id;
127 found_audio_track = true; 130 found_audio_track = true;
128 EXPECT_TRUE(tracks->getAudioConfig(track_id).IsValidConfig()); 131 EXPECT_TRUE(tracks->getAudioConfig(track_id).IsValidConfig());
129 } else if (track->type() == MediaTrack::Video) { 132 } else if (track->type() == MediaTrack::Video) {
133 video_track_id_ = track_id;
130 found_video_track = true; 134 found_video_track = true;
131 EXPECT_TRUE(tracks->getVideoConfig(track_id).IsValidConfig()); 135 EXPECT_TRUE(tracks->getVideoConfig(track_id).IsValidConfig());
132 } else { 136 } else {
133 // Unexpected track type. 137 // Unexpected track type.
134 LOG(ERROR) << "Unexpected track type " << track->type(); 138 LOG(ERROR) << "Unexpected track type " << track->type();
135 EXPECT_TRUE(false); 139 EXPECT_TRUE(false);
136 } 140 }
137 } 141 }
138 EXPECT_TRUE(found_audio_track); 142 EXPECT_TRUE(found_audio_track);
139 EXPECT_EQ(has_video_, found_video_track); 143 EXPECT_EQ(has_video_, found_video_track);
(...skipping 13 matching lines...) Expand all
153 } 157 }
154 } 158 }
155 159
156 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, 160 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers,
157 const StreamParser::BufferQueue& video_buffers, 161 const StreamParser::BufferQueue& video_buffers,
158 const StreamParser::TextBufferQueueMap& text_map) { 162 const StreamParser::TextBufferQueueMap& text_map) {
159 EXPECT_GT(config_count_, 0); 163 EXPECT_GT(config_count_, 0);
160 DumpBuffers("audio_buffers", audio_buffers); 164 DumpBuffers("audio_buffers", audio_buffers);
161 DumpBuffers("video_buffers", video_buffers); 165 DumpBuffers("video_buffers", video_buffers);
162 166
167 // Ensure that track ids are properly assigned on all emitted buffers.
168 for (const auto& buf : audio_buffers) {
169 EXPECT_EQ(audio_track_id_, buf->track_id());
170 }
171 for (const auto& buf : video_buffers) {
172 EXPECT_EQ(video_track_id_, buf->track_id());
173 }
174
163 // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See 175 // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See
164 // http://crbug.com/336926. 176 // http://crbug.com/336926.
165 if (!text_map.empty()) 177 if (!text_map.empty())
166 return false; 178 return false;
167 179
168 // Verify monotonicity. 180 // Verify monotonicity.
169 if (!IsMonotonic(video_buffers)) 181 if (!IsMonotonic(video_buffers))
170 return false; 182 return false;
171 if (!IsMonotonic(audio_buffers)) 183 if (!IsMonotonic(audio_buffers))
172 return false; 184 return false;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 parser_->Flush(); 323 parser_->Flush();
312 EXPECT_EQ(audio_frame_count_, 40); 324 EXPECT_EQ(audio_frame_count_, 40);
313 EXPECT_EQ(video_frame_count_, 0); 325 EXPECT_EQ(video_frame_count_, 0);
314 // This stream has no mid-stream configuration change. 326 // This stream has no mid-stream configuration change.
315 EXPECT_EQ(config_count_, 1); 327 EXPECT_EQ(config_count_, 1);
316 EXPECT_EQ(segment_count_, 1); 328 EXPECT_EQ(segment_count_, 1);
317 } 329 }
318 330
319 } // namespace mp2t 331 } // namespace mp2t
320 } // namespace media 332 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/mp2t_common.h ('k') | media/formats/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698