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

Unified Diff: webkit/plugins/ppapi/content_decryptor_delegate.cc

Issue 11929015: Tighten up media::DecoderBuffer API contract for end of stream buffers (round 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
Index: webkit/plugins/ppapi/content_decryptor_delegate.cc
diff --git a/webkit/plugins/ppapi/content_decryptor_delegate.cc b/webkit/plugins/ppapi/content_decryptor_delegate.cc
index 069f367c6f47b8d2e3496372b09e7a259c90c311..e93bc93c7e2dbdef62e5f65e68c93172d43460b3 100644
--- a/webkit/plugins/ppapi/content_decryptor_delegate.cc
+++ b/webkit/plugins/ppapi/content_decryptor_delegate.cc
@@ -79,29 +79,29 @@ bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) {
}
// Fills the |block_info| with information from |decrypt_config|, |timestamp|
-// and |request_id|. |decrypt_config| can be NULL if the block is not encrypted.
-// This is useful for end-of-stream blocks.
+// and |request_id|.
+//
// Returns true if |block_info| is successfully filled. Returns false
// otherwise.
-bool MakeEncryptedBlockInfo(int data_size,
- const media::DecryptConfig* decrypt_config,
- int64_t timestamp,
- uint32_t request_id,
- PP_EncryptedBlockInfo* block_info) {
- DCHECK(block_info);
-
+static bool MakeEncryptedBlockInfo(
+ const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
+ uint32_t request_id,
+ PP_EncryptedBlockInfo* block_info) {
// TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and
// anywhere else.
memset(block_info, 0, sizeof(*block_info));
-
block_info->tracking_info.request_id = request_id;
- block_info->tracking_info.timestamp = timestamp;
- if (!decrypt_config)
+ // EOS buffers need a request ID and nothing more.
+ if (encrypted_buffer->IsEndOfStream())
return true;
- DCHECK(data_size) << "DecryptConfig is set on an empty buffer";
- block_info->data_size = data_size;
+ block_info->tracking_info.timestamp =
+ encrypted_buffer->GetTimestamp().InMicroseconds();
+ block_info->data_size = encrypted_buffer->GetDataSize();
+
+ const media::DecryptConfig* decrypt_config =
+ encrypted_buffer->GetDecryptConfig();
block_info->data_offset = decrypt_config->data_offset();
if (!CopyStringToArray(decrypt_config->key_id(), block_info->key_id) ||
@@ -365,11 +365,7 @@ bool ContentDecryptorDelegate::Decrypt(
PP_EncryptedBlockInfo block_info = {};
DCHECK(encrypted_buffer->GetDecryptConfig());
- if (!MakeEncryptedBlockInfo(encrypted_buffer->GetDataSize(),
- encrypted_buffer->GetDecryptConfig(),
- encrypted_buffer->GetTimestamp().InMicroseconds(),
- request_id,
- &block_info)) {
+ if (!MakeEncryptedBlockInfo(encrypted_buffer, request_id, &block_info)) {
return false;
}
@@ -535,13 +531,13 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio(
// because there is only one pending audio decode request at any time.
// This is enforced by the media pipeline.
scoped_refptr<PPB_Buffer_Impl> encrypted_resource;
- if (!MakeMediaBufferResource(media::Decryptor::kAudio,
+ if (!encrypted_buffer->IsEndOfStream() &&
+ !MakeMediaBufferResource(media::Decryptor::kAudio,
encrypted_buffer->GetData(),
encrypted_buffer->GetDataSize(),
&encrypted_resource)) {
return false;
}
- ScopedPPResource pp_resource(encrypted_resource.get());
// The resource should not be NULL for non-EOS buffer.
if (!encrypted_buffer->IsEndOfStream() && !encrypted_resource)
@@ -551,12 +547,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio(
DVLOG(2) << "DecryptAndDecodeAudio() - request_id " << request_id;
PP_EncryptedBlockInfo block_info = {};
- if (!MakeEncryptedBlockInfo(
- encrypted_buffer->GetDataSize(),
- encrypted_buffer->GetDecryptConfig(),
- encrypted_buffer->GetTimestamp().InMicroseconds(),
- request_id,
- &block_info)) {
+ if (!MakeEncryptedBlockInfo(encrypted_buffer, request_id, &block_info)) {
return false;
}
@@ -571,6 +562,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio(
pending_audio_decode_request_id_ = request_id;
pending_audio_decode_cb_ = audio_decode_cb;
+ ScopedPPResource pp_resource(encrypted_resource.get());
plugin_decryption_interface_->DecryptAndDecode(pp_instance_,
PP_DECRYPTORSTREAMTYPE_AUDIO,
pp_resource,
@@ -581,20 +573,17 @@ bool ContentDecryptorDelegate::DecryptAndDecodeAudio(
bool ContentDecryptorDelegate::DecryptAndDecodeVideo(
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
const media::Decryptor::VideoDecodeCB& video_decode_cb) {
- // If |encrypted_buffer| is end-of-stream buffer, GetData() and GetDataSize()
- // return NULL and 0 respectively. In that case, we'll just get a NULL
- // resource.
// |video_input_resource_| is not being used by the plugin now
// because there is only one pending video decode request at any time.
// This is enforced by the media pipeline.
scoped_refptr<PPB_Buffer_Impl> encrypted_resource;
- if (!MakeMediaBufferResource(media::Decryptor::kVideo,
+ if (!encrypted_buffer->IsEndOfStream() &&
+ !MakeMediaBufferResource(media::Decryptor::kVideo,
encrypted_buffer->GetData(),
encrypted_buffer->GetDataSize(),
&encrypted_resource)) {
return false;
}
- ScopedPPResource pp_resource(encrypted_resource.get());
// The resource should not be 0 for non-EOS buffer.
if (!encrypted_buffer->IsEndOfStream() && !encrypted_resource)
@@ -606,12 +595,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeVideo(
"eme", "ContentDecryptorDelegate::DecryptAndDecodeVideo", request_id);
PP_EncryptedBlockInfo block_info = {};
- if (!MakeEncryptedBlockInfo(
- encrypted_buffer->GetDataSize(),
- encrypted_buffer->GetDecryptConfig(),
- encrypted_buffer->GetTimestamp().InMicroseconds(),
- request_id,
- &block_info)) {
+ if (!MakeEncryptedBlockInfo(encrypted_buffer, request_id, &block_info)) {
return false;
}
@@ -627,6 +611,7 @@ bool ContentDecryptorDelegate::DecryptAndDecodeVideo(
pending_video_decode_cb_ = video_decode_cb;
// TODO(tomfinegan): Need to get stream type from media stack.
+ ScopedPPResource pp_resource(encrypted_resource.get());
plugin_decryption_interface_->DecryptAndDecode(pp_instance_,
PP_DECRYPTORSTREAMTYPE_VIDEO,
pp_resource,
@@ -984,13 +969,6 @@ bool ContentDecryptorDelegate::MakeMediaBufferResource(
TRACE_EVENT0("eme", "ContentDecryptorDelegate::MakeMediaBufferResource");
DCHECK(resource);
-
- if (!data || !size) {
- DCHECK(!data && !size);
- resource = NULL;
- return true;
- }
-
DCHECK(stream_type == media::Decryptor::kAudio ||
stream_type == media::Decryptor::kVideo);
scoped_refptr<PPB_Buffer_Impl>& media_resource =

Powered by Google App Engine
This is Rietveld 408576698