OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "media/base/cdm_context.h" |
| 14 #include "media/base/media_export.h" |
| 15 #include "media/base/player_tracker.h" |
| 16 |
| 17 namespace media { |
| 18 |
| 19 class MediaDrmBridge; |
| 20 |
| 21 // The CdmContext implementation for MediaDrmBridge. MediaDrmBridge supports |
| 22 // neither Decryptor nor CDM ID, but uses MediaCrypto to connect to MediaCodec. |
| 23 // MediaCodec-based decoders should cast the given CdmContext to this class to |
| 24 // access APIs defined in this class. |
| 25 // |
| 26 // Methods can be called on any thread. The registered callbacks will be fired |
| 27 // on the thread |media_drm_bridge_| is running on. The caller should make sure |
| 28 // that the callbacks are posted to the correct thread. |
| 29 // |
| 30 // TODO(xhwang): Remove PlayerTracker interface. |
| 31 class MEDIA_EXPORT MediaDrmBridgeCdmContext : public CdmContext, |
| 32 public PlayerTracker { |
| 33 public: |
| 34 using JavaObjectPtr = scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>>; |
| 35 |
| 36 // Notification called when MediaCrypto object is ready. |
| 37 // Parameters: |
| 38 // |media_crypto| - reference to MediaCrypto object |
| 39 // |needs_protected_surface| - true if protected surface is required |
| 40 using MediaCryptoReadyCB = base::Callback<void(JavaObjectPtr media_crypto, |
| 41 bool needs_protected_surface)>; |
| 42 |
| 43 // The |media_drm_bridge| owns |this| and is guaranteed to outlive |this|. |
| 44 explicit MediaDrmBridgeCdmContext(MediaDrmBridge* media_drm_bridge); |
| 45 |
| 46 ~MediaDrmBridgeCdmContext() final; |
| 47 |
| 48 // CdmContext implementation. |
| 49 Decryptor* GetDecryptor() final; |
| 50 int GetCdmId() const final; |
| 51 |
| 52 // PlayerTracker implementation. |
| 53 // Methods can be called on any thread. The registered callbacks will be fired |
| 54 // on |task_runner_|. The caller should make sure that the callbacks are |
| 55 // posted to the correct thread. |
| 56 // |
| 57 // Note: RegisterPlayer() must be called before SetMediaCryptoReadyCB() to |
| 58 // avoid missing any new key notifications. |
| 59 int RegisterPlayer(const base::Closure& new_key_cb, |
| 60 const base::Closure& cdm_unset_cb) final; |
| 61 void UnregisterPlayer(int registration_id) final; |
| 62 |
| 63 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb); |
| 64 |
| 65 private: |
| 66 MediaDrmBridge* const media_drm_bridge_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridgeCdmContext); |
| 69 }; |
| 70 |
| 71 } // namespace media |
| 72 |
| 73 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_ |
OLD | NEW |