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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT 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/filters/chunk_demuxer_unittest.cc ('k') | media/filters/frame_processor_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 strstr(format_context->iformat->name, "matroska")) { 1216 strstr(format_context->iformat->name, "matroska")) {
1217 // TODO(servolk): FFmpeg doesn't set stream->id correctly for webm files. 1217 // TODO(servolk): FFmpeg doesn't set stream->id correctly for webm files.
1218 // Need to fix that and use it as track id. crbug.com/323183 1218 // Need to fix that and use it as track id. crbug.com/323183
1219 track_id = 1219 track_id =
1220 static_cast<StreamParser::TrackId>(media_tracks->tracks().size() + 1); 1220 static_cast<StreamParser::TrackId>(media_tracks->tracks().size() + 1);
1221 track_label = streams_[i]->GetMetadata("title"); 1221 track_label = streams_[i]->GetMetadata("title");
1222 } 1222 }
1223 1223
1224 // Note when we find our audio/video stream (we only want one of each) and 1224 // Note when we find our audio/video stream (we only want one of each) and
1225 // record src= playback UMA stats for the stream's decoder config. 1225 // record src= playback UMA stats for the stream's decoder config.
1226 MediaTrack* media_track = nullptr;
1226 if (codec_type == AVMEDIA_TYPE_AUDIO) { 1227 if (codec_type == AVMEDIA_TYPE_AUDIO) {
1227 CHECK(!audio_stream); 1228 CHECK(!audio_stream);
1228 audio_stream = stream; 1229 audio_stream = stream;
1229 audio_config = streams_[i]->audio_decoder_config(); 1230 audio_config = streams_[i]->audio_decoder_config();
1230 RecordAudioCodecStats(audio_config); 1231 RecordAudioCodecStats(audio_config);
1231 1232
1232 media_tracks->AddAudioTrack(audio_config, track_id, "main", track_label, 1233 media_track = media_tracks->AddAudioTrack(audio_config, track_id, "main",
1233 track_language); 1234 track_label, track_language);
1235 media_track->set_id(base::UintToString(track_id));
1234 } else if (codec_type == AVMEDIA_TYPE_VIDEO) { 1236 } else if (codec_type == AVMEDIA_TYPE_VIDEO) {
1235 CHECK(!video_stream); 1237 CHECK(!video_stream);
1236 video_stream = stream; 1238 video_stream = stream;
1237 video_config = streams_[i]->video_decoder_config(); 1239 video_config = streams_[i]->video_decoder_config();
1238 RecordVideoCodecStats(video_config, stream->codec->color_range); 1240 RecordVideoCodecStats(video_config, stream->codec->color_range);
1239 1241
1240 media_tracks->AddVideoTrack(video_config, track_id, "main", track_label, 1242 media_track = media_tracks->AddVideoTrack(video_config, track_id, "main",
1241 track_language); 1243 track_label, track_language);
1244 media_track->set_id(base::UintToString(track_id));
1242 } 1245 }
1243 1246
1244 max_duration = std::max(max_duration, streams_[i]->duration()); 1247 max_duration = std::max(max_duration, streams_[i]->duration());
1245 1248
1246 const base::TimeDelta start_time = 1249 const base::TimeDelta start_time =
1247 ExtractStartTime(stream, start_time_estimates[i]); 1250 ExtractStartTime(stream, start_time_estimates[i]);
1248 const bool has_start_time = start_time != kNoTimestamp(); 1251 const bool has_start_time = start_time != kNoTimestamp();
1249 1252
1250 // Always prefer the video stream for seeking. If none exists, we'll swap 1253 // Always prefer the video stream for seeking. If none exists, we'll swap
1251 // the fallback stream with the preferred stream below. 1254 // the fallback stream with the preferred stream below.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 1596
1594 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1597 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1595 DCHECK(task_runner_->BelongsToCurrentThread()); 1598 DCHECK(task_runner_->BelongsToCurrentThread());
1596 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. 1599 for (const auto& stream : streams_) { // |stream| is a ref to a pointer.
1597 if (stream) 1600 if (stream)
1598 stream->SetLiveness(liveness); 1601 stream->SetLiveness(liveness);
1599 } 1602 }
1600 } 1603 }
1601 1604
1602 } // namespace media 1605 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer_unittest.cc ('k') | media/filters/frame_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698