summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxhwang@google.com <xhwang@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 22:19:06 +0000
committerxhwang@google.com <xhwang@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 22:19:06 +0000
commit1f1225be279e05a22e672284bf2f1a2200d70740 (patch)
tree418529ba236118291eb7c575a0c51e6f9b2fd124
parent4535550ecc9c8de8b2870ad9921ba90581abbc49 (diff)
downloadchromium_src-1f1225be279e05a22e672284bf2f1a2200d70740.zip
chromium_src-1f1225be279e05a22e672284bf2f1a2200d70740.tar.gz
chromium_src-1f1225be279e05a22e672284bf2f1a2200d70740.tar.bz2
Revert 191342 "VideoFrameStream implements DemuxerStream."
We suspect that this could have caused issue 225096 (hmm..). Let me revert this CL first to see if we can get our performance back. TBR=scherkus@chromium.org,shadi@chromium.org BUG=225096 > VideoFrameStream implements DemuxerStream. > > BUG=141788 > TEST=Need to update unittests to include DemuxerStream interactions. > > > Review URL: https://chromiumcodereview.appspot.com/12865015 TBR=xhwang@chromium.org Review URL: https://codereview.chromium.org/13354004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191455 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/filters/video_frame_stream.cc39
-rw-r--r--media/filters/video_frame_stream.h19
-rw-r--r--media/filters/video_frame_stream_unittest.cc27
-rw-r--r--media/filters/video_renderer_base.cc15
-rw-r--r--media/filters/video_renderer_base.h2
5 files changed, 25 insertions, 77 deletions
diff --git a/media/filters/video_frame_stream.cc b/media/filters/video_frame_stream.cc
index 56c9a0e..c9cca1b 100644
--- a/media/filters/video_frame_stream.cc
+++ b/media/filters/video_frame_stream.cc
@@ -42,7 +42,6 @@ void VideoFrameStream::Initialize(const scoped_refptr<DemuxerStream>& stream,
DCHECK(init_cb_.is_null());
DCHECK(!init_cb.is_null());
init_cb_ = init_cb;
- stream_ = stream;
scoped_ptr<VideoDecoderSelector> decoder_selector(
new VideoDecoderSelector(message_loop_,
@@ -54,7 +53,7 @@ void VideoFrameStream::Initialize(const scoped_refptr<DemuxerStream>& stream,
VideoDecoderSelector* decoder_selector_ptr = decoder_selector.get();
decoder_selector_ptr->SelectVideoDecoder(
- this,
+ stream,
statistics_cb,
base::Bind(&VideoFrameStream::OnDecoderSelected, weak_this_,
base::Passed(&decoder_selector)));
@@ -123,43 +122,13 @@ void VideoFrameStream::Stop(const base::Closure& closure) {
}
state_ = STOPPED;
- // Break the ref-count loop so we don't leak objects.
- // TODO(scherkus): Make DemuxerStream and/or VideoDecoder not ref-counted so
- // we don't need this here. See: http://crbug.com/173313
- stream_ = NULL;
- decrypting_demuxer_stream_ = NULL;
- decoder_ = NULL;
message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_));
}
bool VideoFrameStream::HasOutputFrameAvailable() const {
- DCHECK(message_loop_->BelongsToCurrentThread());
return decoder_->HasOutputFrameAvailable();
}
-void VideoFrameStream::Read(const ReadCB& read_cb) {
- DCHECK(message_loop_->BelongsToCurrentThread());
- stream_->Read(read_cb);
-}
-
-const AudioDecoderConfig& VideoFrameStream::audio_decoder_config() {
- DCHECK(message_loop_->BelongsToCurrentThread());
- LOG(FATAL) << "Method audio_decoder_config() called on VideoFrameStream";
- return stream_->audio_decoder_config();
-}
-
-const VideoDecoderConfig& VideoFrameStream::video_decoder_config() {
- DCHECK(message_loop_->BelongsToCurrentThread());
- return stream_->video_decoder_config();
-}
-
-DemuxerStream::Type VideoFrameStream::type() {
- DCHECK(message_loop_->BelongsToCurrentThread());
- return VIDEO;
-}
-
-void VideoFrameStream::EnableBitstreamConverter() {}
-
void VideoFrameStream::OnDecoderSelected(
scoped_ptr<VideoDecoderSelector> decoder_selector,
const scoped_refptr<VideoDecoder>& selected_decoder,
@@ -231,12 +200,6 @@ void VideoFrameStream::OnDecoderStopped() {
DCHECK(!stop_cb_.is_null());
state_ = STOPPED;
- // Break the ref-count loop so we don't leak objects.
- // TODO(scherkus): Make DemuxerStream and/or VideoDecoder not ref-counted so
- // we don't need this here. See: http://crbug.com/173313
- stream_ = NULL;
- decrypting_demuxer_stream_ = NULL;
- decoder_ = NULL;
base::ResetAndReturn(&stop_cb_).Run();
}
diff --git a/media/filters/video_frame_stream.h b/media/filters/video_frame_stream.h
index f815419..1fe2a07 100644
--- a/media/filters/video_frame_stream.h
+++ b/media/filters/video_frame_stream.h
@@ -9,11 +9,9 @@
#include "base/basictypes.h"
#include "base/callback.h"
-#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "media/base/decryptor.h"
-#include "media/base/demuxer_stream.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
#include "media/base/video_decoder.h"
@@ -25,11 +23,12 @@ class MessageLoopProxy;
namespace media {
class DecryptingDemuxerStream;
+class DemuxerStream;
class VideoDecoderSelector;
// Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
// VideoFrames to its client (e.g. VideoRendererBase).
-class MEDIA_EXPORT VideoFrameStream : public DemuxerStream {
+class MEDIA_EXPORT VideoFrameStream {
public:
typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList;
@@ -39,6 +38,8 @@ class MEDIA_EXPORT VideoFrameStream : public DemuxerStream {
VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
const SetDecryptorReadyCB& set_decryptor_ready_cb);
+ ~VideoFrameStream();
+
// Initializes the VideoFrameStream and returns the initialization result
// through |init_cb|. Note that |init_cb| is always called asynchronously.
void Initialize(const scoped_refptr<DemuxerStream>& stream,
@@ -70,16 +71,6 @@ class MEDIA_EXPORT VideoFrameStream : public DemuxerStream {
// a VideoFrame.
bool HasOutputFrameAvailable() const;
- // DemuxerStream implementation.
- virtual void Read(const ReadCB& read_cb) OVERRIDE;
- virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE;
- virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE;
- virtual Type type() OVERRIDE;
- virtual void EnableBitstreamConverter() OVERRIDE;
-
- protected:
- virtual ~VideoFrameStream();
-
private:
enum State {
UNINITIALIZED,
@@ -120,8 +111,6 @@ class MEDIA_EXPORT VideoFrameStream : public DemuxerStream {
SetDecryptorReadyCB set_decryptor_ready_cb_;
- scoped_refptr<DemuxerStream> stream_;
-
// These two will be set by VideoDecoderSelector::SelectVideoDecoder().
scoped_refptr<VideoDecoder> decoder_;
scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
diff --git a/media/filters/video_frame_stream_unittest.cc b/media/filters/video_frame_stream_unittest.cc
index e45c903..134becb 100644
--- a/media/filters/video_frame_stream_unittest.cc
+++ b/media/filters/video_frame_stream_unittest.cc
@@ -31,10 +31,10 @@ static const gfx::Size kNaturalSize(320, 240);
class VideoFrameStreamTest : public testing::TestWithParam<bool> {
public:
VideoFrameStreamTest()
- : video_frame_stream_(new VideoFrameStream(
- message_loop_.message_loop_proxy(),
- base::Bind(&VideoFrameStreamTest::SetDecryptorReadyCallback,
- base::Unretained(this)))),
+ : video_frame_stream_(
+ message_loop_.message_loop_proxy(),
+ base::Bind(&VideoFrameStreamTest::SetDecryptorReadyCallback,
+ base::Unretained(this))),
video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
kCodedSize, kVisibleRect, kNaturalSize, NULL, 0,
GetParam()),
@@ -48,9 +48,6 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
.WillRepeatedly(Return(DemuxerStream::VIDEO));
EXPECT_CALL(*demuxer_stream_, video_decoder_config())
.WillRepeatedly(ReturnRef(video_config_));
- EXPECT_CALL(*demuxer_stream_, Read(_))
- .WillRepeatedly(RunCallback<0>(DemuxerStream::kOk,
- scoped_refptr<DecoderBuffer>()));
EXPECT_CALL(*this, SetDecryptorReadyCallback(_))
.WillRepeatedly(RunCallback<0>(decryptor_.get()));
@@ -86,7 +83,7 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
void EnterPendingInitializationState() {
EXPECT_CALL(*decoder_, Initialize(_, _, _))
.WillOnce(SaveArg<1>(&decoder_init_cb_));
- video_frame_stream_->Initialize(
+ video_frame_stream_.Initialize(
demuxer_stream_,
decoders_,
base::Bind(&VideoFrameStreamTest::OnStatistics, base::Unretained(this)),
@@ -107,8 +104,8 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
EXPECT_CALL(*decoder_, Read(_))
.WillOnce(SaveArg<0>(&decoder_read_cb_));
EXPECT_CALL(*this, OnFrameRead(VideoDecoder::kOk, _));
- video_frame_stream_->ReadFrame(base::Bind(
- &VideoFrameStreamTest::OnFrameRead, base::Unretained(this)));
+ video_frame_stream_.ReadFrame(base::Bind(&VideoFrameStreamTest::OnFrameRead,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
}
@@ -122,8 +119,8 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
EXPECT_CALL(*decoder_, Reset(_))
.WillOnce(SaveArg<0>(&decoder_reset_cb_));
EXPECT_CALL(*this, OnReset());
- video_frame_stream_->Reset(base::Bind(&VideoFrameStreamTest::OnReset,
- base::Unretained(this)));
+ video_frame_stream_.Reset(base::Bind(&VideoFrameStreamTest::OnReset,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
}
@@ -140,8 +137,8 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
.WillRepeatedly(SaveArg<0>(&decoder_stop_cb_));
EXPECT_CALL(*this, OnStopped())
.WillOnce(Assign(&is_initialized_, false));
- video_frame_stream_->Stop(base::Bind(&VideoFrameStreamTest::OnStopped,
- base::Unretained(this)));
+ video_frame_stream_.Stop(base::Bind(&VideoFrameStreamTest::OnStopped,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
}
@@ -182,7 +179,7 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
private:
MessageLoop message_loop_;
- scoped_refptr<VideoFrameStream> video_frame_stream_;
+ VideoFrameStream video_frame_stream_;
VideoDecoderConfig video_config_;
scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_stream_;
// Use NiceMock since we don't care about most of calls on the decryptor, e.g.
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 98439c6..78f27b3 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -29,8 +29,7 @@ VideoRendererBase::VideoRendererBase(
bool drop_frames)
: message_loop_(message_loop),
weak_factory_(this),
- video_frame_stream_(new VideoFrameStream(message_loop,
- set_decryptor_ready_cb)),
+ video_frame_stream_(message_loop, set_decryptor_ready_cb),
received_end_of_stream_(false),
frame_available_(&lock_),
state_(kUninitialized),
@@ -77,7 +76,7 @@ void VideoRendererBase::Flush(const base::Closure& callback) {
// needs to drain it before flushing it.
ready_frames_.clear();
received_end_of_stream_ = false;
- video_frame_stream_->Reset(base::Bind(
+ video_frame_stream_.Reset(base::Bind(
&VideoRendererBase::OnVideoFrameStreamResetDone, weak_this_));
}
@@ -112,7 +111,7 @@ void VideoRendererBase::Stop(const base::Closure& callback) {
base::PlatformThread::Join(thread_to_join);
}
- video_frame_stream_->Stop(callback);
+ video_frame_stream_.Stop(callback);
}
void VideoRendererBase::SetPlaybackRate(float playback_rate) {
@@ -170,7 +169,7 @@ void VideoRendererBase::Initialize(const scoped_refptr<DemuxerStream>& stream,
get_duration_cb_ = get_duration_cb;
state_ = kInitializing;
- video_frame_stream_->Initialize(
+ video_frame_stream_.Initialize(
stream,
decoders,
statistics_cb,
@@ -398,7 +397,7 @@ void VideoRendererBase::FrameReady(VideoDecoder::Status status,
AddReadyFrame_Locked(frame);
if (state_ == kPrerolling) {
- if (!video_frame_stream_->HasOutputFrameAvailable() ||
+ if (!video_frame_stream_.HasOutputFrameAvailable() ||
ready_frames_.size() >= static_cast<size_t>(limits::kMaxVideoFrames)) {
TransitionToPrerolled_Locked();
}
@@ -462,8 +461,8 @@ void VideoRendererBase::AttemptRead_Locked() {
case kPrerolling:
case kPlaying:
pending_read_ = true;
- video_frame_stream_->ReadFrame(base::Bind(&VideoRendererBase::FrameReady,
- weak_this_));
+ video_frame_stream_.ReadFrame(base::Bind(&VideoRendererBase::FrameReady,
+ weak_this_));
return;
case kUninitialized:
diff --git a/media/filters/video_renderer_base.h b/media/filters/video_renderer_base.h
index 7b01653..b1a7a3e 100644
--- a/media/filters/video_renderer_base.h
+++ b/media/filters/video_renderer_base.h
@@ -139,7 +139,7 @@ class MEDIA_EXPORT VideoRendererBase
base::Lock lock_;
// Provides video frames to VideoRendererBase.
- scoped_refptr<VideoFrameStream> video_frame_stream_;
+ VideoFrameStream video_frame_stream_;
// Queue of incoming frames yet to be painted.
typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue;