merge duplicate code in mojo_(audio, video)_decoder_service |
||
Issue description
from xhwang:
1. Previously we pass MojoCdmServiceContext as a weakptr, because MojoVideoDecoderService et al use StrongBinding, so that they can outlive InterfaceFactoryImpl (which owns MojoCdmServiceContext). Now that we use StrongBindingSet in InterfaceFactoryImpl, and this is not true anymore. We should just pass in a raw pointer of MojoCdmServiceContext and DCHECK that it is not null. This can help us get rid of the first check.
2. All users of MojoCdmServiceContext actually only need the |cdm_context|. The reason that they need the |cdm| is such the CDM will not be destroyed (it's ref-counted). Maybe we should fix this, e.g. instead of pass in a raw pointer of CdmContext, we pass in a unique_ptr<CdmContext>, such that each |cdm_context| will hold a ref to the actual CDM. Then we don't need to expose the CDM at all.
With that, the code will be much simpler:
std::unique_ptr<CdmContext> cdm_context = mojo_cdm_service_context_->GetCdm(cdm_id);
if (config.is_encrypted() && !cdm_context) {
std::move(callback).Run(false, false);
return;
}
// .... Initialize(..., std::move(cdm_context)...
We can do (1) easily but (2) would take more work.
,
Jan 22 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/24cfe2ca626220cf9b9c46a6a57ea753795d06e0 commit 24cfe2ca626220cf9b9c46a6a57ea753795d06e0 Author: Xiaohan Wang <xhwang@chromium.org> Date: Mon Jan 22 23:16:00 2018 media: Add CdmContextRef interface This new interface serves two purposes: 1. By holding this class, we can make sure the underlying CDM or CdmProxy are kept alive. This provides a unified way to support both CDM and CdmProxy. 2. This helps avoid the need to hold a reference to the CDM directly, further separating the media stack and the EME stack. After this change, we should be able to move content_decryption_module.h from media/base to media/cdm (in a later CL). This CL also adds CdmContextRefImpl, a default CdmContextRef impl that holds a reference to a media::ContentDecryptionModule. BUG=799310, 786736 ,803710 TEST=No functionality change. All existing tests pass. Change-Id: I64bae76d5a5a0912728ebd8af7ea1ef57a638305 Reviewed-on: https://chromium-review.googlesource.com/876767 Commit-Queue: Xiaohan Wang <xhwang@chromium.org> Reviewed-by: John Rummell <jrummell@chromium.org> Cr-Commit-Position: refs/heads/master@{#531049} [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/base/cdm_context.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/base/content_decryption_module.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/base/content_decryption_module.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/cdm_session_adapter.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/cdm_session_adapter.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/webcontentdecryptionmodule_impl.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/webcontentdecryptionmodule_impl.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/webmediaplayer_impl.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/blink/webmediaplayer_impl.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/cdm/BUILD.gn [add] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/cdm/cdm_context_ref_impl.cc [add] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/cdm/cdm_context_ref_impl.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_audio_decoder_service.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_audio_decoder_service.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_cdm_service_context.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_cdm_service_context.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_renderer_service.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_renderer_service.h [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_video_decoder_service.cc [modify] https://crrev.com/24cfe2ca626220cf9b9c46a6a57ea753795d06e0/media/mojo/services/mojo_video_decoder_service.h
,
Mar 24 2018
|
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Nov 22 2017