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

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

Issue 1833053005: Remove MediaTracks::getFirstAudio/VideoConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control
Patch Set: Avoid crashes in tests Created 4 years, 6 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_stream_parser_unittest.cc ('k') | no next file » | 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/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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 EXPECT_EQ(expected_params.detected_video_track_count, 110 EXPECT_EQ(expected_params.detected_video_track_count,
111 params.detected_video_track_count); 111 params.detected_video_track_count);
112 EXPECT_EQ(expected_params.detected_text_track_count, 112 EXPECT_EQ(expected_params.detected_text_track_count,
113 params.detected_text_track_count); 113 params.detected_text_track_count);
114 } 114 }
115 115
116 bool NewConfigF(std::unique_ptr<MediaTracks> tracks, 116 bool NewConfigF(std::unique_ptr<MediaTracks> tracks,
117 const StreamParser::TextTrackConfigMap& tc) { 117 const StreamParser::TextTrackConfigMap& tc) {
118 configs_received_ = true; 118 configs_received_ = true;
119 CHECK(tracks.get()); 119 CHECK(tracks.get());
120 DVLOG(1) << "NewConfigF: got " << tracks->tracks().size() << " tracks";
121 for (const auto& track : tracks->tracks()) {
122 const auto& track_id = track->bytestream_track_id();
123 if (track->type() == MediaTrack::Audio) {
124 audio_decoder_config_ = tracks->getAudioConfig(track_id);
125 DVLOG(1) << "Audio track " << track_id << " config="
126 << (audio_decoder_config_.IsValidConfig()
127 ? audio_decoder_config_.AsHumanReadableString()
128 : "INVALID");
129 } else if (track->type() == MediaTrack::Video) {
130 video_decoder_config_ = tracks->getVideoConfig(track_id);
131 DVLOG(1) << "Video track " << track_id << " config="
132 << (video_decoder_config_.IsValidConfig()
133 ? video_decoder_config_.AsHumanReadableString()
134 : "INVALID");
135 }
136 }
120 media_tracks_ = std::move(tracks); 137 media_tracks_ = std::move(tracks);
121 audio_decoder_config_ = media_tracks_->getFirstAudioConfig();
122 video_decoder_config_ = media_tracks_->getFirstVideoConfig();
123 DVLOG(1) << "NewConfigF: track count=" << media_tracks_->tracks().size()
124 << " audio=" << audio_decoder_config_.IsValidConfig()
125 << " video=" << video_decoder_config_.IsValidConfig();
126 return true; 138 return true;
127 } 139 }
128 140
129 void DumpBuffers(const std::string& label, 141 void DumpBuffers(const std::string& label,
130 const StreamParser::BufferQueue& buffers) { 142 const StreamParser::BufferQueue& buffers) {
131 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); 143 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
132 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); 144 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin();
133 buf != buffers.end(); buf++) { 145 buf != buffers.end(); buf++) {
134 DVLOG(3) << " n=" << buf - buffers.begin() 146 DVLOG(3) << " n=" << buf - buffers.begin()
135 << ", size=" << (*buf)->data_size() 147 << ", size=" << (*buf)->data_size()
(...skipping 15 matching lines...) Expand all
151 // Find the second highest timestamp so that we know what the 163 // Find the second highest timestamp so that we know what the
152 // timestamps on the next set of buffers must be >= than. 164 // timestamps on the next set of buffers must be >= than.
153 DecodeTimestamp audio = !audio_buffers.empty() ? 165 DecodeTimestamp audio = !audio_buffers.empty() ?
154 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); 166 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp();
155 DecodeTimestamp video = !video_buffers.empty() ? 167 DecodeTimestamp video = !video_buffers.empty() ?
156 video_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); 168 video_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp();
157 DecodeTimestamp second_highest_timestamp = 169 DecodeTimestamp second_highest_timestamp =
158 (audio == kNoDecodeTimestamp() || 170 (audio == kNoDecodeTimestamp() ||
159 (video != kNoDecodeTimestamp() && audio > video)) ? video : audio; 171 (video != kNoDecodeTimestamp() && audio > video)) ? video : audio;
160 172
161 DCHECK(second_highest_timestamp != kNoDecodeTimestamp()); 173 EXPECT_NE(second_highest_timestamp, kNoDecodeTimestamp());
162 174
163 if (lower_bound_ != kNoDecodeTimestamp() && 175 if (lower_bound_ != kNoDecodeTimestamp() &&
164 second_highest_timestamp < lower_bound_) { 176 second_highest_timestamp < lower_bound_) {
165 return false; 177 return false;
166 } 178 }
167 179
168 lower_bound_ = second_highest_timestamp; 180 lower_bound_ = second_highest_timestamp;
169 return true; 181 return true;
170 } 182 }
171 183
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 scoped_refptr<DecoderBuffer> buffer = 532 scoped_refptr<DecoderBuffer> buffer =
521 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); 533 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4");
522 534
523 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); 535 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2"));
524 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); 536 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F"));
525 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); 537 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512));
526 } 538 }
527 539
528 } // namespace mp4 540 } // namespace mp4
529 } // namespace media 541 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/mp2t_stream_parser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698