Commit e2ea5183 authored by acolwell's avatar acolwell Committed by Commit bot

Move EME code out of WebMediaPlayerImpl.

This change moves all the encrypted media code out of WebMediaPlayerImpl
and into a EncryptedMediaSupportImpl class. This removes the encrypted
media related content/ depencencies from WebMediaPlayerImpl so that it
will be easier to move WebMediaPlayerImpl to a location where it can
be reused by Mojo.

Review URL: https://codereview.chromium.org/501473003

Cr-Commit-Position: refs/heads/master@{#291776}
parent cc256f49
...@@ -251,6 +251,10 @@ ...@@ -251,6 +251,10 @@
'renderer/media/cdm_session_adapter.h', 'renderer/media/cdm_session_adapter.h',
'renderer/media/crypto/content_decryption_module_factory.cc', 'renderer/media/crypto/content_decryption_module_factory.cc',
'renderer/media/crypto/content_decryption_module_factory.h', 'renderer/media/crypto/content_decryption_module_factory.h',
'renderer/media/crypto/encrypted_media_player_support.cc',
'renderer/media/crypto/encrypted_media_player_support.h',
'renderer/media/crypto/encrypted_media_player_support_impl.cc',
'renderer/media/crypto/encrypted_media_player_support_impl.h',
'renderer/media/crypto/key_systems.cc', 'renderer/media/crypto/key_systems.cc',
'renderer/media/crypto/key_systems.h', 'renderer/media/crypto/key_systems.h',
'renderer/media/crypto/key_systems_support_uma.cc', 'renderer/media/crypto/key_systems_support_uma.cc',
...@@ -756,6 +760,7 @@ ...@@ -756,6 +760,7 @@
'renderer/accessibility/renderer_accessibility_focus_only.cc', 'renderer/accessibility/renderer_accessibility_focus_only.cc',
'renderer/media/audio_decoder.cc', 'renderer/media/audio_decoder.cc',
'renderer/media/filter_helpers.cc', 'renderer/media/filter_helpers.cc',
'renderer/media/crypto/encrypted_media_player_support_impl.cc',
'renderer/media/webmediaplayer_impl.cc', 'renderer/media/webmediaplayer_impl.cc',
], ],
'sources': [ 'sources': [
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/crypto/encrypted_media_player_support.h"
namespace content {
EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport() {
}
EncryptedMediaPlayerSupport::~EncryptedMediaPlayerSupport() {
}
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
#define CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
#include "media/base/decryptor.h"
#include "media/base/demuxer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
namespace blink {
class WebContentDecryptionModule;
class WebContentDecryptionModuleResult;
class WebLocalFrame;
class WebMediaPlayerClient;
class WebString;
}
namespace content {
class EncryptedMediaPlayerSupport {
public:
// Creates a new instance of EncryptedMediaPlayerSupport for |client|. This
// method must always return a valid pointer.
static scoped_ptr<EncryptedMediaPlayerSupport> Create(
blink::WebMediaPlayerClient* client);
EncryptedMediaPlayerSupport();
virtual ~EncryptedMediaPlayerSupport();
// Prefixed API methods.
virtual blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
blink::WebLocalFrame* frame,
const blink::WebString& key_system,
const unsigned char* init_data,
unsigned init_data_length) = 0;
virtual blink::WebMediaPlayer::MediaKeyException AddKey(
const blink::WebString& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const blink::WebString& session_id) = 0;
virtual blink::WebMediaPlayer::MediaKeyException CancelKeyRequest(
const blink::WebString& key_system,
const blink::WebString& session_id) = 0;
// Unprefixed API methods.
virtual void SetContentDecryptionModule(
blink::WebContentDecryptionModule* cdm) = 0;
virtual void SetContentDecryptionModule(
blink::WebContentDecryptionModule* cdm,
blink::WebContentDecryptionModuleResult result) = 0;
virtual void SetContentDecryptionModuleSync(
blink::WebContentDecryptionModule* cdm) = 0;
// Callback factory and notification methods used by WebMediaPlayerImpl.
// Creates a callback that Demuxers can use to signal that the content
// requires a key. This method make sure the callback returned can be safely
// invoked from any thread.
virtual media::Demuxer::NeedKeyCB CreateNeedKeyCB() = 0;
// Creates a callback that renderers can use to set decryptor
// ready callback. This method make sure the callback returned can be safely
// invoked from any thread.
virtual media::SetDecryptorReadyCB CreateSetDecryptorReadyCB() = 0;
// Called to inform this object that the media pipeline encountered
// and handled a decryption error.
virtual void OnPipelineDecryptError() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport);
};
} // namespace content
#endif // CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_IMPL_H_
#define CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_IMPL_H_
#include <string>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "content/renderer/media/crypto/encrypted_media_player_support.h"
#include "content/renderer/media/crypto/proxy_decryptor.h"
namespace content {
class WebContentDecryptionModuleImpl;
class EncryptedMediaPlayerSupportImpl
: public EncryptedMediaPlayerSupport,
public base::SupportsWeakPtr<EncryptedMediaPlayerSupportImpl> {
public:
explicit EncryptedMediaPlayerSupportImpl(blink::WebMediaPlayerClient* client);
virtual ~EncryptedMediaPlayerSupportImpl();
// EncryptedMediaPlayerSupport implementation.
virtual blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
blink::WebLocalFrame* frame,
const blink::WebString& key_system,
const unsigned char* init_data,
unsigned init_data_length) OVERRIDE;
virtual blink::WebMediaPlayer::MediaKeyException AddKey(
const blink::WebString& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const blink::WebString& session_id) OVERRIDE;
virtual blink::WebMediaPlayer::MediaKeyException CancelKeyRequest(
const blink::WebString& key_system,
const blink::WebString& session_id) OVERRIDE;
virtual void SetContentDecryptionModule(
blink::WebContentDecryptionModule* cdm) OVERRIDE;
virtual void SetContentDecryptionModule(
blink::WebContentDecryptionModule* cdm,
blink::WebContentDecryptionModuleResult result) OVERRIDE;
virtual void SetContentDecryptionModuleSync(
blink::WebContentDecryptionModule* cdm) OVERRIDE;
virtual media::SetDecryptorReadyCB CreateSetDecryptorReadyCB() OVERRIDE;
virtual media::Demuxer::NeedKeyCB CreateNeedKeyCB() OVERRIDE;
virtual void OnPipelineDecryptError() OVERRIDE;
private:
// Requests that this object notifies when a decryptor is ready through the
// |decryptor_ready_cb| provided.
// If |decryptor_ready_cb| is null, the existing callback will be fired with
// NULL immediately and reset.
void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb);
blink::WebMediaPlayer::MediaKeyException GenerateKeyRequestInternal(
blink::WebLocalFrame* frame,
const std::string& key_system,
const unsigned char* init_data,
unsigned init_data_length);
blink::WebMediaPlayer::MediaKeyException AddKeyInternal(
const std::string& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const std::string& session_id);
blink::WebMediaPlayer::MediaKeyException CancelKeyRequestInternal(
const std::string& key_system,
const std::string& session_id);
void OnNeedKey(const std::string& type,
const std::vector<uint8>& init_data);
void OnKeyAdded(const std::string& session_id);
void OnKeyError(const std::string& session_id,
media::MediaKeys::KeyError error_code,
uint32 system_code);
void OnKeyMessage(const std::string& session_id,
const std::vector<uint8>& message,
const GURL& destination_url);
void ContentDecryptionModuleAttached(
blink::WebContentDecryptionModuleResult result,
bool success);
blink::WebMediaPlayerClient* client_;
// The currently selected key system. Empty string means that no key system
// has been selected.
std::string current_key_system_;
// Temporary for EME v0.1. In the future the init data type should be passed
// through GenerateKeyRequest() directly from WebKit.
std::string init_data_type_;
// Manages decryption keys and decrypts encrypted frames.
scoped_ptr<ProxyDecryptor> proxy_decryptor_;
// Non-owned pointer to the CDM. Updated via calls to
// setContentDecryptionModule().
WebContentDecryptionModuleImpl* web_cdm_;
media::DecryptorReadyCB decryptor_ready_cb_;
DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupportImpl);
};
}
#endif // CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_PLAYER_SUPPORT_IMPL_H_
...@@ -14,10 +14,8 @@ ...@@ -14,10 +14,8 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "content/renderer/media/buffered_data_source_host_impl.h" #include "content/renderer/media/buffered_data_source_host_impl.h"
#include "content/renderer/media/crypto/proxy_decryptor.h"
#include "content/renderer/media/video_frame_compositor.h" #include "content/renderer/media/video_frame_compositor.h"
#include "media/base/audio_renderer_sink.h" #include "media/base/audio_renderer_sink.h"
#include "media/base/decryptor.h"
// TODO(xhwang): Remove when we remove prefixed EME implementation. // TODO(xhwang): Remove when we remove prefixed EME implementation.
#include "media/base/media_keys.h" #include "media/base/media_keys.h"
#include "media/base/pipeline.h" #include "media/base/pipeline.h"
...@@ -25,16 +23,13 @@ ...@@ -25,16 +23,13 @@
#include "media/filters/skcanvas_video_renderer.h" #include "media/filters/skcanvas_video_renderer.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h" #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
#include "url/gurl.h" #include "url/gurl.h"
class RenderAudioSourceProvider;
namespace blink { namespace blink {
class WebContentDecryptionModule;
class WebContentDecryptionModuleResult;
class WebLocalFrame; class WebLocalFrame;
} }
...@@ -55,9 +50,9 @@ class MediaLog; ...@@ -55,9 +50,9 @@ class MediaLog;
namespace content { namespace content {
class BufferedDataSource; class BufferedDataSource;
class EncryptedMediaPlayerSupport;
class VideoFrameCompositor; class VideoFrameCompositor;
class WebAudioSourceProviderImpl; class WebAudioSourceProviderImpl;
class WebContentDecryptionModuleImpl;
class WebMediaPlayerDelegate; class WebMediaPlayerDelegate;
class WebMediaPlayerParams; class WebMediaPlayerParams;
class WebTextTrackImpl; class WebTextTrackImpl;
...@@ -177,15 +172,6 @@ class WebMediaPlayerImpl ...@@ -177,15 +172,6 @@ class WebMediaPlayerImpl
void OnPipelineMetadata(media::PipelineMetadata metadata); void OnPipelineMetadata(media::PipelineMetadata metadata);
void OnPipelineBufferingStateChanged(media::BufferingState buffering_state); void OnPipelineBufferingStateChanged(media::BufferingState buffering_state);
void OnDemuxerOpened(); void OnDemuxerOpened();
void OnKeyAdded(const std::string& session_id);
void OnKeyError(const std::string& session_id,
media::MediaKeys::KeyError error_code,
uint32 system_code);
void OnKeyMessage(const std::string& session_id,
const std::vector<uint8>& message,
const GURL& destination_url);
void OnNeedKey(const std::string& type,
const std::vector<uint8>& init_data);
void OnAddTextTrack(const media::TextTrackConfig& config, void OnAddTextTrack(const media::TextTrackConfig& config,
const media::AddTextTrackDoneCB& done_cb); const media::AddTextTrackDoneCB& done_cb);
...@@ -216,20 +202,6 @@ class WebMediaPlayerImpl ...@@ -216,20 +202,6 @@ class WebMediaPlayerImpl
// Lets V8 know that player uses extra resources not managed by V8. // Lets V8 know that player uses extra resources not managed by V8.
void IncrementExternallyAllocatedMemory(); void IncrementExternallyAllocatedMemory();
// Actually do the work for generateKeyRequest/addKey so they can easily
// report results to UMA.
MediaKeyException GenerateKeyRequestInternal(const std::string& key_system,
const unsigned char* init_data,
unsigned init_data_length);
MediaKeyException AddKeyInternal(const std::string& key_system,
const unsigned char* key,
unsigned key_length,
const unsigned char* init_data,
unsigned init_data_length,
const std::string& session_id);
MediaKeyException CancelKeyRequestInternal(const std::string& key_system,
const std::string& session_id);
// Gets the duration value reported by the pipeline. // Gets the duration value reported by the pipeline.
double GetPipelineDuration() const; double GetPipelineDuration() const;
...@@ -242,12 +214,6 @@ class WebMediaPlayerImpl ...@@ -242,12 +214,6 @@ class WebMediaPlayerImpl
// painted. // painted.
void FrameReady(const scoped_refptr<media::VideoFrame>& frame); void FrameReady(const scoped_refptr<media::VideoFrame>& frame);
// Requests that this object notifies when a decryptor is ready through the
// |decryptor_ready_cb| provided.
// If |decryptor_ready_cb| is null, the existing callback will be fired with
// NULL immediately and reset.
void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb);
// Called when the ContentDecryptionModule has been attached to the // Called when the ContentDecryptionModule has been attached to the
// pipeline/decoders. // pipeline/decoders.
void ContentDecryptionModuleAttached( void ContentDecryptionModuleAttached(
...@@ -275,10 +241,6 @@ class WebMediaPlayerImpl ...@@ -275,10 +241,6 @@ class WebMediaPlayerImpl
scoped_refptr<media::MediaLog> media_log_; scoped_refptr<media::MediaLog> media_log_;
media::Pipeline pipeline_; media::Pipeline pipeline_;
// The currently selected key system. Empty string means that no key system
// has been selected.
std::string current_key_system_;
// The LoadType passed in the |load_type| parameter of the load() call. // The LoadType passed in the |load_type| parameter of the load() call.
LoadType load_type_; LoadType load_type_;
...@@ -342,10 +304,6 @@ class WebMediaPlayerImpl ...@@ -342,10 +304,6 @@ class WebMediaPlayerImpl
BufferedDataSourceHostImpl buffered_data_source_host_; BufferedDataSourceHostImpl buffered_data_source_host_;
// Temporary for EME v0.1. In the future the init data type should be passed
// through GenerateKeyRequest() directly from WebKit.
std::string init_data_type_;
// Video rendering members. // Video rendering members.
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|.
...@@ -358,14 +316,7 @@ class WebMediaPlayerImpl ...@@ -358,14 +316,7 @@ class WebMediaPlayerImpl
// Text track objects get a unique index value when they're created. // Text track objects get a unique index value when they're created.
int text_track_index_; int text_track_index_;
// Manages decryption keys and decrypts encrypted frames. scoped_ptr<EncryptedMediaPlayerSupport> encrypted_media_support_;
scoped_ptr<ProxyDecryptor> proxy_decryptor_;
// Non-owned pointer to the CDM. Updated via calls to
// setContentDecryptionModule().
WebContentDecryptionModuleImpl* web_cdm_;
media::DecryptorReadyCB decryptor_ready_cb_;
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
}; };
......
...@@ -39,6 +39,6 @@ class WebMediaPlayerParams { ...@@ -39,6 +39,6 @@ class WebMediaPlayerParams {
DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerParams); DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerParams);
}; };
} // namespace media } // namespace content
#endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_PARAMS_H_ #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_PARAMS_H_
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