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

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

Issue 14217008: Remove reference counting from media::DemuxerStream and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
« 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) 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 <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0); 371 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0);
372 372
373 // Open the AVFormatContext using our glue layer. 373 // Open the AVFormatContext using our glue layer.
374 CHECK(blocking_thread_.Start()); 374 CHECK(blocking_thread_.Start());
375 base::PostTaskAndReplyWithResult( 375 base::PostTaskAndReplyWithResult(
376 blocking_thread_.message_loop_proxy(), FROM_HERE, 376 blocking_thread_.message_loop_proxy(), FROM_HERE,
377 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())), 377 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())),
378 base::Bind(&FFmpegDemuxer::OnOpenContextDone, weak_this_, status_cb)); 378 base::Bind(&FFmpegDemuxer::OnOpenContextDone, weak_this_, status_cb));
379 } 379 }
380 380
381 scoped_refptr<DemuxerStream> FFmpegDemuxer::GetStream( 381 DemuxerStream* FFmpegDemuxer::GetStream(DemuxerStream::Type type) {
382 DemuxerStream::Type type) {
383 DCHECK(message_loop_->BelongsToCurrentThread()); 382 DCHECK(message_loop_->BelongsToCurrentThread());
384 return GetFFmpegStream(type); 383 return GetFFmpegStream(type);
385 } 384 }
386 385
387 scoped_refptr<FFmpegDemuxerStream> FFmpegDemuxer::GetFFmpegStream( 386 FFmpegDemuxerStream* FFmpegDemuxer::GetFFmpegStream(
388 DemuxerStream::Type type) const { 387 DemuxerStream::Type type) const {
389 StreamVector::const_iterator iter; 388 StreamVector::const_iterator iter;
390 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 389 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
391 if (*iter && (*iter)->type() == type) { 390 if (*iter && (*iter)->type() == type) {
392 return *iter; 391 return *iter;
393 } 392 }
394 } 393 }
395 return NULL; 394 return NULL;
396 } 395 }
397 396
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 codec_context->codec_id); 498 codec_context->codec_id);
500 // Ensure the codec is supported. 499 // Ensure the codec is supported.
501 if (CodecIDToVideoCodec(codec_context->codec_id) == kUnknownVideoCodec) 500 if (CodecIDToVideoCodec(codec_context->codec_id) == kUnknownVideoCodec)
502 continue; 501 continue;
503 found_video_stream = true; 502 found_video_stream = true;
504 } else { 503 } else {
505 continue; 504 continue;
506 } 505 }
507 506
508 AVStream* stream = format_context->streams[i]; 507 AVStream* stream = format_context->streams[i];
509 scoped_refptr<FFmpegDemuxerStream> demuxer_stream( 508 streams_[i] = new FFmpegDemuxerStream(this, stream);
510 new FFmpegDemuxerStream(this, stream)); 509 max_duration = std::max(max_duration, streams_[i]->duration());
511
512 streams_[i] = demuxer_stream;
513 max_duration = std::max(max_duration, demuxer_stream->duration());
514 510
515 if (stream->first_dts != static_cast<int64_t>(AV_NOPTS_VALUE)) { 511 if (stream->first_dts != static_cast<int64_t>(AV_NOPTS_VALUE)) {
516 const base::TimeDelta first_dts = ConvertFromTimeBase( 512 const base::TimeDelta first_dts = ConvertFromTimeBase(
517 stream->time_base, stream->first_dts); 513 stream->time_base, stream->first_dts);
518 if (start_time_ == kNoTimestamp() || first_dts < start_time_) 514 if (start_time_ == kNoTimestamp() || first_dts < start_time_)
519 start_time_ = first_dts; 515 start_time_ = first_dts;
520 } 516 }
521 } 517 }
522 518
523 if (!found_audio_stream && !found_video_stream) { 519 if (!found_audio_stream && !found_video_stream) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 731 }
736 732
737 void FFmpegDemuxer::NotifyCapacityAvailable() { 733 void FFmpegDemuxer::NotifyCapacityAvailable() {
738 DCHECK(message_loop_->BelongsToCurrentThread()); 734 DCHECK(message_loop_->BelongsToCurrentThread());
739 ReadFrameIfNeeded(); 735 ReadFrameIfNeeded();
740 } 736 }
741 737
742 void FFmpegDemuxer::NotifyBufferingChanged() { 738 void FFmpegDemuxer::NotifyBufferingChanged() {
743 DCHECK(message_loop_->BelongsToCurrentThread()); 739 DCHECK(message_loop_->BelongsToCurrentThread());
744 Ranges<base::TimeDelta> buffered; 740 Ranges<base::TimeDelta> buffered;
745 scoped_refptr<FFmpegDemuxerStream> audio = 741 FFmpegDemuxerStream* audio =
746 audio_disabled_ ? NULL : GetFFmpegStream(DemuxerStream::AUDIO); 742 audio_disabled_ ? NULL : GetFFmpegStream(DemuxerStream::AUDIO);
747 scoped_refptr<FFmpegDemuxerStream> video = 743 FFmpegDemuxerStream* video = GetFFmpegStream(DemuxerStream::VIDEO);
748 GetFFmpegStream(DemuxerStream::VIDEO);
749 if (audio && video) { 744 if (audio && video) {
750 buffered = audio->GetBufferedRanges().IntersectionWith( 745 buffered = audio->GetBufferedRanges().IntersectionWith(
751 video->GetBufferedRanges()); 746 video->GetBufferedRanges());
752 } else if (audio) { 747 } else if (audio) {
753 buffered = audio->GetBufferedRanges(); 748 buffered = audio->GetBufferedRanges();
754 } else if (video) { 749 } else if (video) {
755 buffered = video->GetBufferedRanges(); 750 buffered = video->GetBufferedRanges();
756 } 751 }
757 for (size_t i = 0; i < buffered.size(); ++i) 752 for (size_t i = 0; i < buffered.size(); ++i)
758 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 753 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
759 } 754 }
760 755
761 void FFmpegDemuxer::OnDataSourceError() { 756 void FFmpegDemuxer::OnDataSourceError() {
762 host_->OnDemuxerError(PIPELINE_ERROR_READ); 757 host_->OnDemuxerError(PIPELINE_ERROR_READ);
763 } 758 }
764 759
765 } // namespace media 760 } // 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