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

Unified Diff: media/filters/video_frame_stream.cc

Issue 14348007: Reland: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/video_frame_stream.h ('k') | media/filters/video_frame_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_frame_stream.cc
diff --git a/media/filters/video_frame_stream.cc b/media/filters/video_frame_stream.cc
index 72ee20df8723644a816ec22db8a4138edd4a94b7..93f2a0ea16d304a138a2963beb190c989ca4c513 100644
--- a/media/filters/video_frame_stream.cc
+++ b/media/filters/video_frame_stream.cc
@@ -19,10 +19,12 @@ namespace media {
VideoFrameStream::VideoFrameStream(
const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ ScopedVector<VideoDecoder> decoders,
const SetDecryptorReadyCB& set_decryptor_ready_cb)
: message_loop_(message_loop),
weak_factory_(this),
state_(UNINITIALIZED),
+ decoders_(decoders.Pass()),
set_decryptor_ready_cb_(set_decryptor_ready_cb) {
}
@@ -31,7 +33,6 @@ VideoFrameStream::~VideoFrameStream() {
}
void VideoFrameStream::Initialize(const scoped_refptr<DemuxerStream>& stream,
- const VideoDecoderList& decoders,
const StatisticsCB& statistics_cb,
const InitCB& init_cb) {
DCHECK(message_loop_->BelongsToCurrentThread());
@@ -44,20 +45,18 @@ void VideoFrameStream::Initialize(const scoped_refptr<DemuxerStream>& stream,
init_cb_ = init_cb;
stream_ = stream;
- scoped_ptr<VideoDecoderSelector> decoder_selector(
- new VideoDecoderSelector(message_loop_,
- decoders,
- set_decryptor_ready_cb_));
+ // TODO(scherkus): Make |decoder_selector| a member variable after
+ // DemuxerStream is no longer refcounted. Today we're forced to do this
+ // because it creates a refcount loop between |this| and |decoder_selector|.
+ scoped_ptr<VideoDecoderSelector> decoder_selector(new VideoDecoderSelector(
+ message_loop_, decoders_.Pass(), set_decryptor_ready_cb_));
+ set_decryptor_ready_cb_.Reset();
- // To avoid calling |decoder_selector| methods and passing ownership of
- // |decoder_selector| in the same line.
VideoDecoderSelector* decoder_selector_ptr = decoder_selector.get();
- decoder_selector_ptr->SelectVideoDecoder(
- this,
- statistics_cb,
- base::Bind(&VideoFrameStream::OnDecoderSelected, weak_this_,
- base::Passed(&decoder_selector)));
+ decoder_selector_ptr->SelectVideoDecoder(this, statistics_cb, base::Bind(
+ &VideoFrameStream::OnDecoderSelected, weak_this_,
+ base::Passed(&decoder_selector)));
}
void VideoFrameStream::ReadFrame(const VideoDecoder::ReadCB& read_cb) {
@@ -128,7 +127,7 @@ void VideoFrameStream::Stop(const base::Closure& closure) {
// we don't need this here. See: http://crbug.com/173313
stream_ = NULL;
decrypting_demuxer_stream_ = NULL;
- decoder_ = NULL;
+ decoder_.reset();
message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_));
}
@@ -165,7 +164,7 @@ void VideoFrameStream::EnableBitstreamConverter() {
void VideoFrameStream::OnDecoderSelected(
scoped_ptr<VideoDecoderSelector> decoder_selector,
- const scoped_refptr<VideoDecoder>& selected_decoder,
+ scoped_ptr<VideoDecoder> selected_decoder,
const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream) {
DCHECK(message_loop_->BelongsToCurrentThread());
DCHECK_EQ(state_, UNINITIALIZED);
@@ -175,7 +174,7 @@ void VideoFrameStream::OnDecoderSelected(
state_ = UNINITIALIZED;
base::ResetAndReturn(&init_cb_).Run(false, false);
} else {
- decoder_ = selected_decoder;
+ decoder_ = selected_decoder.Pass();
decrypting_demuxer_stream_ = decrypting_demuxer_stream;
state_ = NORMAL;
base::ResetAndReturn(&init_cb_).Run(true, decoder_->HasAlpha());
@@ -239,7 +238,7 @@ void VideoFrameStream::OnDecoderStopped() {
// we don't need this here. See: http://crbug.com/173313
stream_ = NULL;
decrypting_demuxer_stream_ = NULL;
- decoder_ = NULL;
+ decoder_.reset();
base::ResetAndReturn(&stop_cb_).Run();
}
« no previous file with comments | « media/filters/video_frame_stream.h ('k') | media/filters/video_frame_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698