Commit e3f1f4f8 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Misc cleanup of CdmContext

- Clarify lifetime model.
- Clarify thread model.
- Remove GetClassIdentifier(). Moving foreard, we should add virtual
  methods to CdmContext to support platform-specific interfaces, instead
  of using static_cast.

TBR=jrummell@chromium.org,rkuroiwa@chromium.org

Bug: 821288
Test: No functionality change.
Change-Id: I13e30ed2c508855727219edd3975abf5d67e6721
Reviewed-on: https://chromium-review.googlesource.com/1014284Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551128}
parent 0df1faf5
...@@ -30,10 +30,6 @@ MediaCryptoContext* CdmContext::GetMediaCryptoContext() { ...@@ -30,10 +30,6 @@ MediaCryptoContext* CdmContext::GetMediaCryptoContext() {
} }
#endif #endif
void* CdmContext::GetClassIdentifier() const {
return nullptr;
}
void IgnoreCdmAttached(bool /* success */) {} void IgnoreCdmAttached(bool /* success */) {}
} // namespace media } // namespace media
...@@ -20,6 +20,14 @@ class MediaCryptoContext; ...@@ -20,6 +20,14 @@ class MediaCryptoContext;
// An interface representing the context that a media player needs from a // An interface representing the context that a media player needs from a
// content decryption module (CDM) to decrypt (and decode) encrypted buffers. // content decryption module (CDM) to decrypt (and decode) encrypted buffers.
// Typically this will be passed to the media player (e.g. using SetCdm()). // Typically this will be passed to the media player (e.g. using SetCdm()).
//
// Lifetime: The returned raw pointers are only guaranteed to be valid when the
// CdmContext is alive, which is usually guaranteed by holding a CdmContextRef
// (see below).
//
// Thread Model: Since this interface is used in many different contexts (e.g.
// different processes or platforms), the thread model is not defined as part
// of this interface. Subclasses must ensure thread safty.
class MEDIA_EXPORT CdmContext { class MEDIA_EXPORT CdmContext {
public: public:
// Indicates an invalid CDM ID. See GetCdmId() for details. // Indicates an invalid CDM ID. See GetCdmId() for details.
...@@ -29,34 +37,27 @@ class MEDIA_EXPORT CdmContext { ...@@ -29,34 +37,27 @@ class MEDIA_EXPORT CdmContext {
// Gets the Decryptor object associated with the CDM. Returns nullptr if the // Gets the Decryptor object associated with the CDM. Returns nullptr if the
// CDM does not support a Decryptor (i.e. platform-based CDMs where decryption // CDM does not support a Decryptor (i.e. platform-based CDMs where decryption
// occurs implicitly along with decoding). The returned object is only // occurs implicitly along with decoding).
// guaranteed to be valid during the CDM's lifetime.
virtual Decryptor* GetDecryptor(); virtual Decryptor* GetDecryptor();
// Returns an ID that can be used to find a remote CDM, in which case this CDM // Returns an ID that can be used to find a remote CDM, in which case this CDM
// serves as a proxy to the remote one. Returns kInvalidCdmId when remote CDM // serves as a proxy to the remote one. Returns kInvalidCdmId when remote CDM
// is not supported (e.g. this CDM is a local CDM). // is not supported (e.g. this CDM is a local CDM).
// TODO(crbug.com/804397): Use base::UnguessableToken for CDM ID.
virtual int GetCdmId() const; virtual int GetCdmId() const;
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) #if BUILDFLAG(ENABLE_LIBRARY_CDMS)
// Returns a CdmProxyContext. The default implementation returns a nullptr // Returns a CdmProxyContext that can be used by hardware decoders/decryptors.
// to indidate that there is no context. // Returns nullptr if CdmProxyContext is not supported, e.g. |this| is not
// If CdmProxy is not used, then this returns a nullptr. // hosted by a CdmProxy.
// The pointer is owned by the callee.
virtual CdmProxyContext* GetCdmProxyContext(); virtual CdmProxyContext* GetCdmProxyContext();
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Returns a MediaCryptoContext that can be used by MediaCodec based decoders. // Returns a MediaCryptoContext that can be used by MediaCodec based decoders.
// The returned object is only guaranteed to be valid during the CDM's
// lifetime.
virtual MediaCryptoContext* GetMediaCryptoContext(); virtual MediaCryptoContext* GetMediaCryptoContext();
#endif #endif
// Returns a unique class identifier. Some subclasses override and use this
// method to provide safe down-casting to their type.
virtual void* GetClassIdentifier() const;
protected: protected:
CdmContext(); CdmContext();
......
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