Chromium Code Reviews| Index: webkit/media/webmediaplayer_impl.cc |
| diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc |
| index 891398f9be4d8f2dafa5030e89d26fcb9ab57ef1..3e5e3c8451debc15b0b70edf2f1f95d1e637b62a 100644 |
| --- a/webkit/media/webmediaplayer_impl.cc |
| +++ b/webkit/media/webmediaplayer_impl.cc |
| @@ -22,7 +22,6 @@ |
| #include "media/base/media_switches.h" |
| #include "media/base/pipeline.h" |
| #include "media/base/video_frame.h" |
| -#include "media/crypto/aes_decryptor.h" |
| #include "media/filters/audio_renderer_impl.h" |
| #include "media/filters/video_renderer_base.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| @@ -33,8 +32,9 @@ |
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| #include "v8/include/v8.h" |
| #include "webkit/media/buffered_data_source.h" |
| +#include "webkit/media/crypto/key_systems.h" |
| +#include "webkit/media/crypto/proxy_decryptor.h" |
| #include "webkit/media/filter_helpers.h" |
| -#include "webkit/media/key_systems.h" |
| #include "webkit/media/webmediaplayer_delegate.h" |
| #include "webkit/media/webmediaplayer_proxy.h" |
| #include "webkit/media/webmediaplayer_util.h" |
| @@ -82,9 +82,9 @@ const float kMaxRate = 16.0f; |
| namespace webkit_media { |
| -#define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| +#define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayer::CORSMode ## name) == \ |
| - static_cast<int>(BufferedResourceLoader::k ## name), \ |
| + static_cast<int>(BufferedResourceLoader::k ## name), \ |
| mismatching_enums) |
| COMPILE_ASSERT_MATCHING_ENUM(Unspecified); |
| COMPILE_ASSERT_MATCHING_ENUM(Anonymous); |
| @@ -155,7 +155,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( |
| filter_collection_->AddAudioRenderer( |
| new media::AudioRendererImpl(new media::NullAudioSink())); |
| - decryptor_.reset(new media::AesDecryptor(proxy_.get())); |
| + decryptor_.reset(new ProxyDecryptor(proxy_.get())); |
| } |
| WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| @@ -714,10 +714,17 @@ WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
| if (!IsSupportedKeySystem(key_system)) |
| return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| + // We do not support run-time switching between key systems for now. |
| + if (!current_key_system_.isEmpty() && key_system != current_key_system_) |
|
scherkus (not reviewing)
2012/06/27 01:10:18
you can move this into a helper of ProxyDecryptor
ddorwin
2012/06/27 04:00:08
Or even is_current_key_system(string) and is_key_s
xhwang
2012/06/27 21:41:26
As discussed, ProxyDecryptor will know nothing abo
|
| + return WebKit::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| + |
| DVLOG(1) << "generateKeyRequest: " << key_system.utf8().data() << ": " |
| << std::string(reinterpret_cast<const char*>(init_data), |
| static_cast<size_t>(init_data_length)); |
| + if (current_key_system_.isEmpty()) |
| + current_key_system_ = key_system; |
| + |
| decryptor_->GenerateKeyRequest(key_system.utf8(), |
| init_data, init_data_length); |
| return WebKit::WebMediaPlayer::MediaKeyExceptionNoError; |
| @@ -736,6 +743,9 @@ WebKit::WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey( |
| if (!IsSupportedKeySystem(key_system)) |
| return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| + if (current_key_system_.isEmpty() || key_system != current_key_system_) |
| + return WebKit::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| + |
| DVLOG(1) << "addKey: " << key_system.utf8().data() << ": " |
| << std::string(reinterpret_cast<const char*>(key), |
| static_cast<size_t>(key_length)) << ", " |
| @@ -754,6 +764,9 @@ WebKit::WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::cancelKeyRequest( |
| if (!IsSupportedKeySystem(key_system)) |
| return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| + if (current_key_system_.isEmpty() || key_system != current_key_system_) |
| + return WebKit::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| + |
| decryptor_->CancelKeyRequest(key_system.utf8(), session_id.utf8()); |
| return WebKit::WebMediaPlayer::MediaKeyExceptionNoError; |
| } |
| @@ -891,6 +904,18 @@ void WebMediaPlayerImpl::OnNeedKey(const std::string& key_system, |
| init_data_size); |
| } |
| +#define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
|
ddorwin
2012/06/27 04:00:08
Should all these be at the top of the file togethe
xhwang
2012/06/27 21:41:26
I am following the current style (at least in webk
|
| + COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ |
| + static_cast<int>(media::Decryptor::k ## name), \ |
| + mismatching_enums) |
| +COMPILE_ASSERT_MATCHING_ENUM(UnknownError); |
| +COMPILE_ASSERT_MATCHING_ENUM(ClientError); |
| +COMPILE_ASSERT_MATCHING_ENUM(ServiceError); |
| +COMPILE_ASSERT_MATCHING_ENUM(OutputError); |
| +COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); |
| +COMPILE_ASSERT_MATCHING_ENUM(DomainError); |
| +#undef COMPILE_ASSERT_MATCHING_ENUM |
| + |
| void WebMediaPlayerImpl::OnKeyError(const std::string& key_system, |
| const std::string& session_id, |
| media::Decryptor::KeyError error_code, |