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

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

Issue 100085: Adds a second vector of streams to FFmpegDemuxer to handle re-mapped audio/video streams. (Closed)
Patch Set: Created 11 years, 8 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/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "media/base/filter_host.h" 8 #include "media/base/filter_host.h"
9 #include "media/filters/ffmpeg_common.h" 9 #include "media/filters/ffmpeg_common.h"
10 #include "media/filters/ffmpeg_demuxer.h" 10 #include "media/filters/ffmpeg_demuxer.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // Create demuxer streams for all supported streams. 271 // Create demuxer streams for all supported streams.
272 base::TimeDelta max_duration; 272 base::TimeDelta max_duration;
273 for (size_t i = 0; i < format_context_->nb_streams; ++i) { 273 for (size_t i = 0; i < format_context_->nb_streams; ++i) {
274 CodecType codec_type = format_context_->streams[i]->codec->codec_type; 274 CodecType codec_type = format_context_->streams[i]->codec->codec_type;
275 if (codec_type == CODEC_TYPE_AUDIO || codec_type == CODEC_TYPE_VIDEO) { 275 if (codec_type == CODEC_TYPE_AUDIO || codec_type == CODEC_TYPE_VIDEO) {
276 AVStream* stream = format_context_->streams[i]; 276 AVStream* stream = format_context_->streams[i];
277 FFmpegDemuxerStream* demuxer_stream 277 FFmpegDemuxerStream* demuxer_stream
278 = new FFmpegDemuxerStream(this, stream); 278 = new FFmpegDemuxerStream(this, stream);
279 DCHECK(demuxer_stream); 279 DCHECK(demuxer_stream);
280 streams_.push_back(demuxer_stream); 280 streams_.push_back(demuxer_stream);
281 packet_streams_.push_back(demuxer_stream);
281 max_duration = std::max(max_duration, demuxer_stream->duration()); 282 max_duration = std::max(max_duration, demuxer_stream->duration());
283 } else {
284 packet_streams_.push_back(NULL);
282 } 285 }
283 } 286 }
284 if (streams_.empty()) { 287 if (streams_.empty()) {
285 host_->Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS); 288 host_->Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
286 return; 289 return;
287 } 290 }
288 291
289 // Good to go: set the duration and notify we're done initializing. 292 // Good to go: set the duration and notify we're done initializing.
290 host_->SetDuration(max_duration); 293 host_->SetDuration(max_duration);
291 host_->InitializationComplete(); 294 host_->InitializationComplete();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // of stream flag. 328 // of stream flag.
326 NOTIMPLEMENTED(); 329 NOTIMPLEMENTED();
327 return; 330 return;
328 } 331 }
329 332
330 // Queue the packet with the appropriate stream. 333 // Queue the packet with the appropriate stream.
331 // TODO(scherkus): should we post this back to the pipeline thread? I'm 334 // TODO(scherkus): should we post this back to the pipeline thread? I'm
332 // worried about downstream filters (i.e., decoders) executing on this 335 // worried about downstream filters (i.e., decoders) executing on this
333 // thread. 336 // thread.
334 DCHECK(packet->stream_index >= 0); 337 DCHECK(packet->stream_index >= 0);
335 DCHECK(packet->stream_index < static_cast<int>(streams_.size())); 338 DCHECK(packet->stream_index < static_cast<int>(packet_streams_.size()));
336 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; 339 FFmpegDemuxerStream* demuxer_stream = packet_streams_[packet->stream_index];
337 current_timestamp_ = demuxer_stream->EnqueuePacket(packet.release()); 340 if (demuxer_stream) {
341 current_timestamp_ = demuxer_stream->EnqueuePacket(packet.release());
342 } else {
343 av_free_packet(packet.get());
344 }
338 345
339 // Create a loop by posting another task. This allows seek and message loop 346 // Create a loop by posting another task. This allows seek and message loop
340 // quit tasks to get processed. 347 // quit tasks to get processed.
341 if (StreamsHavePendingReads()) { 348 if (StreamsHavePendingReads()) {
342 PostDemuxTask(); 349 PostDemuxTask();
343 } 350 }
344 } 351 }
345 352
346 bool FFmpegDemuxer::StreamsHavePendingReads() { 353 bool FFmpegDemuxer::StreamsHavePendingReads() {
347 StreamVector::iterator iter; 354 StreamVector::iterator iter;
348 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 355 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
349 if ((*iter)->HasPendingReads()) { 356 if ((*iter)->HasPendingReads()) {
350 return true; 357 return true;
351 } 358 }
352 } 359 }
353 return false; 360 return false;
354 } 361 }
355 362
356 } // namespace media 363 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698