Commit d46aea53 authored by acolwell@chromium.org's avatar acolwell@chromium.org

Remove WebMediaPlayerProxy::video_decoder_ & FFmpegVideoDecoder::set_decryptor.

BUG=None

Review URL: https://chromiumcodereview.appspot.com/10834183

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150360 0039d316-1c4b-4281-b951-d872f2087c98
parent b7c4f037
...@@ -54,13 +54,14 @@ static int GetThreadCount(CodecID codec_id) { ...@@ -54,13 +54,14 @@ static int GetThreadCount(CodecID codec_id) {
} }
FFmpegVideoDecoder::FFmpegVideoDecoder( FFmpegVideoDecoder::FFmpegVideoDecoder(
const base::Callback<MessageLoop*()>& message_loop_cb) const base::Callback<MessageLoop*()>& message_loop_cb,
Decryptor* decryptor)
: message_loop_factory_cb_(message_loop_cb), : message_loop_factory_cb_(message_loop_cb),
message_loop_(NULL), message_loop_(NULL),
state_(kUninitialized), state_(kUninitialized),
codec_context_(NULL), codec_context_(NULL),
av_frame_(NULL), av_frame_(NULL),
decryptor_(NULL) { decryptor_(decryptor) {
} }
int FFmpegVideoDecoder::GetVideoBuffer(AVCodecContext* codec_context, int FFmpegVideoDecoder::GetVideoBuffer(AVCodecContext* codec_context,
...@@ -256,11 +257,6 @@ void FFmpegVideoDecoder::DoStop() { ...@@ -256,11 +257,6 @@ void FFmpegVideoDecoder::DoStop() {
base::ResetAndReturn(&stop_cb_).Run(); base::ResetAndReturn(&stop_cb_).Run();
} }
void FFmpegVideoDecoder::set_decryptor(Decryptor* decryptor) {
DCHECK_EQ(state_, kUninitialized);
decryptor_ = decryptor;
}
FFmpegVideoDecoder::~FFmpegVideoDecoder() { FFmpegVideoDecoder::~FFmpegVideoDecoder() {
ReleaseFFmpegResources(); ReleaseFFmpegResources();
} }
......
...@@ -22,7 +22,8 @@ class DecoderBuffer; ...@@ -22,7 +22,8 @@ class DecoderBuffer;
class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
public: public:
FFmpegVideoDecoder(const base::Callback<MessageLoop*()>& message_loop_cb); FFmpegVideoDecoder(const base::Callback<MessageLoop*()>& message_loop_cb,
Decryptor* decryptor);
// VideoDecoder implementation. // VideoDecoder implementation.
virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
...@@ -32,10 +33,6 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { ...@@ -32,10 +33,6 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
virtual void Reset(const base::Closure& closure) OVERRIDE; virtual void Reset(const base::Closure& closure) OVERRIDE;
virtual void Stop(const base::Closure& closure) OVERRIDE; virtual void Stop(const base::Closure& closure) OVERRIDE;
// Must be called prior to initialization if decrypted buffers will be
// encountered.
void set_decryptor(Decryptor* decryptor);
// Callback called from within FFmpeg to allocate a buffer based on // Callback called from within FFmpeg to allocate a buffer based on
// the dimensions of |codec_context|. See AVCodecContext.get_buffer // the dimensions of |codec_context|. See AVCodecContext.get_buffer
// documentation inside FFmpeg. // documentation inside FFmpeg.
......
...@@ -71,14 +71,15 @@ class FFmpegVideoDecoderTest : public testing::Test { ...@@ -71,14 +71,15 @@ class FFmpegVideoDecoderTest : public testing::Test {
public: public:
FFmpegVideoDecoderTest() FFmpegVideoDecoderTest()
: decryptor_(new MockDecryptor()), : decryptor_(new MockDecryptor()),
decoder_(new FFmpegVideoDecoder(base::Bind(&Identity<MessageLoop*>, decoder_(NULL),
&message_loop_))),
demuxer_(new StrictMock<MockDemuxerStream>()), demuxer_(new StrictMock<MockDemuxerStream>()),
read_cb_(base::Bind(&FFmpegVideoDecoderTest::FrameReady, read_cb_(base::Bind(&FFmpegVideoDecoderTest::FrameReady,
base::Unretained(this))) { base::Unretained(this))) {
CHECK(FFmpegGlue::GetInstance()); CHECK(FFmpegGlue::GetInstance());
decoder_->set_decryptor(decryptor_.get()); decoder_ = new FFmpegVideoDecoder(base::Bind(&Identity<MessageLoop*>,
&message_loop_),
decryptor_.get());
// Initialize various test buffers. // Initialize various test buffers.
frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); frame_buffer_.reset(new uint8[kCodedSize.GetArea()]);
......
...@@ -185,13 +185,11 @@ class PipelineIntegrationTest ...@@ -185,13 +185,11 @@ class PipelineIntegrationTest
public: public:
void StartPipelineWithMediaSource(MockMediaSource* source) { void StartPipelineWithMediaSource(MockMediaSource* source) {
pipeline_->Start( pipeline_->Start(
CreateFilterCollection(source), CreateFilterCollection(source, NULL),
base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
QuitOnStatusCB(PIPELINE_OK)); QuitOnStatusCB(PIPELINE_OK));
ASSERT_TRUE(decoder_.get());
message_loop_.Run(); message_loop_.Run();
} }
...@@ -199,13 +197,11 @@ class PipelineIntegrationTest ...@@ -199,13 +197,11 @@ class PipelineIntegrationTest
MockMediaSource* source, MockMediaSource* source,
FakeDecryptorClient* encrypted_media) { FakeDecryptorClient* encrypted_media) {
pipeline_->Start( pipeline_->Start(
CreateFilterCollection(source), CreateFilterCollection(source, encrypted_media->decryptor()),
base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
QuitOnStatusCB(PIPELINE_OK)); QuitOnStatusCB(PIPELINE_OK));
ASSERT_TRUE(decoder_.get());
decoder_->set_decryptor(encrypted_media->decryptor());
source->set_decryptor_client(encrypted_media); source->set_decryptor_client(encrypted_media);
message_loop_.Run(); message_loop_.Run();
......
...@@ -171,29 +171,33 @@ scoped_ptr<FilterCollection> ...@@ -171,29 +171,33 @@ scoped_ptr<FilterCollection>
PipelineIntegrationTestBase::CreateFilterCollection(const std::string& url) { PipelineIntegrationTestBase::CreateFilterCollection(const std::string& url) {
scoped_refptr<FileDataSource> data_source = new FileDataSource(); scoped_refptr<FileDataSource> data_source = new FileDataSource();
CHECK(data_source->Initialize(url)); CHECK(data_source->Initialize(url));
return CreateFilterCollection(new FFmpegDemuxer(&message_loop_, data_source)); return CreateFilterCollection(new FFmpegDemuxer(&message_loop_, data_source),
NULL);
} }
scoped_ptr<FilterCollection> scoped_ptr<FilterCollection>
PipelineIntegrationTestBase::CreateFilterCollection( PipelineIntegrationTestBase::CreateFilterCollection(
ChunkDemuxerClient* client) { ChunkDemuxerClient* client,
return CreateFilterCollection(new ChunkDemuxer(client)); Decryptor* decryptor) {
return CreateFilterCollection(new ChunkDemuxer(client), decryptor);
} }
scoped_ptr<FilterCollection> scoped_ptr<FilterCollection>
PipelineIntegrationTestBase::CreateFilterCollection( PipelineIntegrationTestBase::CreateFilterCollection(
const scoped_refptr<Demuxer>& demuxer) { const scoped_refptr<Demuxer>& demuxer,
Decryptor* decryptor) {
scoped_ptr<FilterCollection> collection(new FilterCollection()); scoped_ptr<FilterCollection> collection(new FilterCollection());
collection->SetDemuxer(demuxer); collection->SetDemuxer(demuxer);
collection->AddAudioDecoder(new FFmpegAudioDecoder( collection->AddAudioDecoder(new FFmpegAudioDecoder(
base::Bind(&MessageLoopFactory::GetMessageLoop, base::Bind(&MessageLoopFactory::GetMessageLoop,
base::Unretained(message_loop_factory_.get()), base::Unretained(message_loop_factory_.get()),
"AudioDecoderThread"))); "AudioDecoderThread")));
decoder_ = new FFmpegVideoDecoder( scoped_refptr<VideoDecoder> decoder = new FFmpegVideoDecoder(
base::Bind(&MessageLoopFactory::GetMessageLoop, base::Bind(&MessageLoopFactory::GetMessageLoop,
base::Unretained(message_loop_factory_.get()), base::Unretained(message_loop_factory_.get()),
"VideoDecoderThread")); "VideoDecoderThread"),
collection->AddVideoDecoder(decoder_); decryptor);
collection->AddVideoDecoder(decoder);
// Disable frame dropping if hashing is enabled. // Disable frame dropping if hashing is enabled.
renderer_ = new VideoRendererBase( renderer_ = new VideoRendererBase(
base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint,
......
...@@ -12,12 +12,13 @@ ...@@ -12,12 +12,13 @@
#include "media/base/message_loop_factory.h" #include "media/base/message_loop_factory.h"
#include "media/base/pipeline.h" #include "media/base/pipeline.h"
#include "media/filters/chunk_demuxer.h" #include "media/filters/chunk_demuxer.h"
#include "media/filters/ffmpeg_video_decoder.h"
#include "media/filters/video_renderer_base.h" #include "media/filters/video_renderer_base.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
namespace media { namespace media {
class Decryptor;
// Empty MD5 hash string. Used to verify empty audio or video tracks. // Empty MD5 hash string. Used to verify empty audio or video tracks.
extern const char kNullHash[]; extern const char kNullHash[];
...@@ -53,7 +54,7 @@ class PipelineIntegrationTestBase { ...@@ -53,7 +54,7 @@ class PipelineIntegrationTestBase {
bool WaitUntilCurrentTimeIsAfter(const base::TimeDelta& wait_time); bool WaitUntilCurrentTimeIsAfter(const base::TimeDelta& wait_time);
scoped_ptr<FilterCollection> CreateFilterCollection(const std::string& url); scoped_ptr<FilterCollection> CreateFilterCollection(const std::string& url);
scoped_ptr<FilterCollection> CreateFilterCollection( scoped_ptr<FilterCollection> CreateFilterCollection(
ChunkDemuxerClient* client); ChunkDemuxerClient* client, Decryptor* decryptor);
// Returns the MD5 hash of all video frames seen. Should only be called once // Returns the MD5 hash of all video frames seen. Should only be called once
// after playback completes. First time hashes should be generated with // after playback completes. First time hashes should be generated with
...@@ -72,7 +73,6 @@ class PipelineIntegrationTestBase { ...@@ -72,7 +73,6 @@ class PipelineIntegrationTestBase {
bool hashing_enabled_; bool hashing_enabled_;
scoped_ptr<MessageLoopFactory> message_loop_factory_; scoped_ptr<MessageLoopFactory> message_loop_factory_;
scoped_refptr<Pipeline> pipeline_; scoped_refptr<Pipeline> pipeline_;
scoped_refptr<FFmpegVideoDecoder> decoder_;
scoped_refptr<VideoRendererBase> renderer_; scoped_refptr<VideoRendererBase> renderer_;
scoped_refptr<NullAudioSink> audio_sink_; scoped_refptr<NullAudioSink> audio_sink_;
bool ended_; bool ended_;
...@@ -86,7 +86,7 @@ class PipelineIntegrationTestBase { ...@@ -86,7 +86,7 @@ class PipelineIntegrationTestBase {
void OnError(PipelineStatus status); void OnError(PipelineStatus status);
void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time);
scoped_ptr<FilterCollection> CreateFilterCollection( scoped_ptr<FilterCollection> CreateFilterCollection(
const scoped_refptr<Demuxer>& demuxer); const scoped_refptr<Demuxer>& demuxer, Decryptor* decryptor);
void OnVideoRendererPaint(); void OnVideoRendererPaint();
MOCK_METHOD1(OnSetOpaque, void(bool)); MOCK_METHOD1(OnSetOpaque, void(bool));
......
...@@ -80,7 +80,8 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) { ...@@ -80,7 +80,8 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) {
collection->AddVideoDecoder(new FFmpegVideoDecoder( collection->AddVideoDecoder(new FFmpegVideoDecoder(
base::Bind(&MessageLoopFactory::GetMessageLoop, base::Bind(&MessageLoopFactory::GetMessageLoop,
base::Unretained(message_loop_factory_.get()), base::Unretained(message_loop_factory_.get()),
"VideoDecoderThread"))); "VideoDecoderThread"),
NULL));
// TODO(vrk): Re-enabled audio. (crbug.com/112159) // TODO(vrk): Re-enabled audio. (crbug.com/112159)
collection->AddAudioRenderer( collection->AddAudioRenderer(
......
...@@ -122,7 +122,8 @@ bool InitPipeline(MessageLoop* message_loop, ...@@ -122,7 +122,8 @@ bool InitPipeline(MessageLoop* message_loop,
collection->AddVideoDecoder(new media::FFmpegVideoDecoder( collection->AddVideoDecoder(new media::FFmpegVideoDecoder(
base::Bind(&media::MessageLoopFactory::GetMessageLoop, base::Bind(&media::MessageLoopFactory::GetMessageLoop,
base::Unretained(message_loop_factory), base::Unretained(message_loop_factory),
"VideoDecoderThread"))); "VideoDecoderThread"),
NULL));
// Create our video renderer and save a reference to it for painting. // Create our video renderer and save a reference to it for painting.
g_video_renderer = new media::VideoRendererBase( g_video_renderer = new media::VideoRendererBase(
......
...@@ -21,18 +21,19 @@ namespace webkit_media { ...@@ -21,18 +21,19 @@ namespace webkit_media {
static void AddDefaultDecodersToCollection( static void AddDefaultDecodersToCollection(
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
media::FilterCollection* filter_collection, media::FilterCollection* filter_collection,
media::Decryptor* decryptor, media::Decryptor* decryptor) {
scoped_refptr<media::FFmpegVideoDecoder>* ffmpeg_video_decoder) {
filter_collection->AddAudioDecoder(new media::FFmpegAudioDecoder( filter_collection->AddAudioDecoder(new media::FFmpegAudioDecoder(
base::Bind(&media::MessageLoopFactory::GetMessageLoop, base::Bind(&media::MessageLoopFactory::GetMessageLoop,
base::Unretained(message_loop_factory), base::Unretained(message_loop_factory),
"AudioDecoderThread"))); "AudioDecoderThread")));
*ffmpeg_video_decoder = new media::FFmpegVideoDecoder(
base::Bind(&media::MessageLoopFactory::GetMessageLoop, scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder =
base::Unretained(message_loop_factory), new media::FFmpegVideoDecoder(
"VideoDecoderThread")); base::Bind(&media::MessageLoopFactory::GetMessageLoop,
(*ffmpeg_video_decoder)->set_decryptor(decryptor); base::Unretained(message_loop_factory),
filter_collection->AddVideoDecoder(*ffmpeg_video_decoder); "VideoDecoderThread"),
decryptor);
filter_collection->AddVideoDecoder(ffmpeg_video_decoder);
} }
bool BuildMediaStreamCollection(const WebKit::WebURL& url, bool BuildMediaStreamCollection(const WebKit::WebURL& url,
...@@ -69,15 +70,14 @@ bool BuildMediaSourceCollection( ...@@ -69,15 +70,14 @@ bool BuildMediaSourceCollection(
media::ChunkDemuxerClient* client, media::ChunkDemuxerClient* client,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
media::FilterCollection* filter_collection, media::FilterCollection* filter_collection,
media::Decryptor* decryptor, media::Decryptor* decryptor) {
scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) {
if (media_source_url.isEmpty() || url != media_source_url) if (media_source_url.isEmpty() || url != media_source_url)
return false; return false;
filter_collection->SetDemuxer(new media::ChunkDemuxer(client)); filter_collection->SetDemuxer(new media::ChunkDemuxer(client));
AddDefaultDecodersToCollection(message_loop_factory, filter_collection, AddDefaultDecodersToCollection(message_loop_factory, filter_collection,
decryptor, video_decoder); decryptor);
return true; return true;
} }
...@@ -85,14 +85,13 @@ void BuildDefaultCollection( ...@@ -85,14 +85,13 @@ void BuildDefaultCollection(
const scoped_refptr<media::DataSource>& data_source, const scoped_refptr<media::DataSource>& data_source,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
media::FilterCollection* filter_collection, media::FilterCollection* filter_collection,
media::Decryptor* decryptor, media::Decryptor* decryptor) {
scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) {
filter_collection->SetDemuxer(new media::FFmpegDemuxer( filter_collection->SetDemuxer(new media::FFmpegDemuxer(
message_loop_factory->GetMessageLoop("PipelineThread"), message_loop_factory->GetMessageLoop("PipelineThread"),
data_source)); data_source));
AddDefaultDecodersToCollection(message_loop_factory, filter_collection, AddDefaultDecodersToCollection(message_loop_factory, filter_collection,
decryptor, video_decoder); decryptor);
} }
} // webkit_media } // webkit_media
...@@ -44,8 +44,7 @@ bool BuildMediaSourceCollection( ...@@ -44,8 +44,7 @@ bool BuildMediaSourceCollection(
media::ChunkDemuxerClient* client, media::ChunkDemuxerClient* client,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
media::FilterCollection* filter_collection, media::FilterCollection* filter_collection,
media::Decryptor* decryptor, media::Decryptor* decryptor);
scoped_refptr<media::FFmpegVideoDecoder>* video_decoder);
// Builds the required filters for handling regular URLs and adds them to // Builds the required filters for handling regular URLs and adds them to
// |filter_collection| and fills |video_decoder| returning true if successful. // |filter_collection| and fills |video_decoder| returning true if successful.
...@@ -53,8 +52,7 @@ void BuildDefaultCollection( ...@@ -53,8 +52,7 @@ void BuildDefaultCollection(
const scoped_refptr<media::DataSource>& data_source, const scoped_refptr<media::DataSource>& data_source,
media::MessageLoopFactory* message_loop_factory, media::MessageLoopFactory* message_loop_factory,
media::FilterCollection* filter_collection, media::FilterCollection* filter_collection,
media::Decryptor* decryptor, media::Decryptor* decryptor);
scoped_refptr<media::FFmpegVideoDecoder>* video_decoder);
} // webkit_media } // webkit_media
......
...@@ -241,13 +241,10 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) { ...@@ -241,13 +241,10 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
} }
// Media source pipelines can start immediately. // Media source pipelines can start immediately.
scoped_refptr<media::FFmpegVideoDecoder> video_decoder;
if (BuildMediaSourceCollection(url, GetClient()->sourceURL(), proxy_, if (BuildMediaSourceCollection(url, GetClient()->sourceURL(), proxy_,
message_loop_factory_.get(), message_loop_factory_.get(),
filter_collection_.get(), filter_collection_.get(),
&decryptor_, &decryptor_)) {
&video_decoder)) {
proxy_->set_video_decoder(video_decoder);
StartPipeline(); StartPipeline();
return; return;
} }
...@@ -268,9 +265,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) { ...@@ -268,9 +265,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
BuildDefaultCollection(proxy_->data_source(), BuildDefaultCollection(proxy_->data_source(),
message_loop_factory_.get(), message_loop_factory_.get(),
filter_collection_.get(), filter_collection_.get(),
&decryptor_, &decryptor_);
&video_decoder);
proxy_->set_video_decoder(video_decoder);
} }
void WebMediaPlayerImpl::cancelLoad() { void WebMediaPlayerImpl::cancelLoad() {
......
...@@ -87,7 +87,6 @@ void WebMediaPlayerProxy::Detach() { ...@@ -87,7 +87,6 @@ void WebMediaPlayerProxy::Detach() {
webmediaplayer_ = NULL; webmediaplayer_ = NULL;
data_source_ = NULL; data_source_ = NULL;
frame_provider_ = NULL; frame_provider_ = NULL;
video_decoder_ = NULL;
} }
void WebMediaPlayerProxy::PipelineInitializationCallback( void WebMediaPlayerProxy::PipelineInitializationCallback(
......
...@@ -60,11 +60,6 @@ class WebMediaPlayerProxy ...@@ -60,11 +60,6 @@ class WebMediaPlayerProxy
frame_provider_ = frame_provider; frame_provider_ = frame_provider;
} }
void set_video_decoder(
const scoped_refptr<media::FFmpegVideoDecoder>& video_decoder) {
video_decoder_ = video_decoder;
}
// Methods for Filter -> WebMediaPlayerImpl communication. // Methods for Filter -> WebMediaPlayerImpl communication.
void Repaint(); void Repaint();
void SetOpaque(bool opaque); void SetOpaque(bool opaque);
...@@ -177,7 +172,6 @@ class WebMediaPlayerProxy ...@@ -177,7 +172,6 @@ class WebMediaPlayerProxy
scoped_refptr<BufferedDataSource> data_source_; scoped_refptr<BufferedDataSource> data_source_;
scoped_refptr<media::VideoRendererBase> frame_provider_; scoped_refptr<media::VideoRendererBase> frame_provider_;
SkCanvasVideoRenderer video_renderer_; SkCanvasVideoRenderer video_renderer_;
scoped_refptr<media::FFmpegVideoDecoder> video_decoder_;
base::Lock lock_; base::Lock lock_;
int outstanding_repaints_; int outstanding_repaints_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment