Chromium Code Reviews| 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 // Methods can be called on any thread. The registered callbacks will be fired | |
| 22 // on the thread |media_drm_bridge_| is running on. The caller should make sure | |
| 23 // that the callbacks are posted to the correct thread. | |
| 24 // TODO(xhwang): Remove PlayerTracker interface. | |
| 25 class MEDIA_EXPORT MediaDrmBridgeCdmContext : public CdmContext, | |
| 26 public PlayerTracker { | |
| 27 public: | |
| 28 using JavaObjectPtr = scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>>; | |
| 29 | |
| 30 // Notification called when MediaCrypto object is ready. | |
| 31 // Parameters: | |
| 32 // |media_crypto| - reference to MediaCrypto object | |
| 33 // |needs_protected_surface| - true if protected surface is required | |
| 34 using MediaCryptoReadyCB = base::Callback<void(JavaObjectPtr media_crypto, | |
| 35 bool needs_protected_surface)>; | |
| 36 | |
| 37 // The |media_drm_bridge| owns |this| and is guaranteed to outlive |this|. | |
| 38 explicit MediaDrmBridgeCdmContext(MediaDrmBridge* media_drm_bridge); | |
| 39 | |
| 40 ~MediaDrmBridgeCdmContext() final; | |
| 41 | |
| 42 // CdmContext implementation. | |
| 43 Decryptor* GetDecryptor() final; | |
| 44 int GetCdmId() const final; | |
| 45 | |
| 46 // PlayerTracker implementation. Can be called on any thread. | |
|
ddorwin
2016/03/21 18:06:09
I shouldn't have used "newline." I meant:
// Play
xhwang
2016/03/22 17:08:32
Done.
| |
| 47 | |
| 48 // The registered callbacks will be fired on |task_runner_|. The caller | |
| 49 // should make sure that the callbacks are posted to the correct thread. | |
| 50 // | |
| 51 // Note: RegisterPlayer() must be called before SetMediaCryptoReadyCB() to | |
| 52 // avoid missing any new key notifications. | |
| 53 int RegisterPlayer(const base::Closure& new_key_cb, | |
| 54 const base::Closure& cdm_unset_cb) final; | |
| 55 void UnregisterPlayer(int registration_id) final; | |
| 56 | |
| 57 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb); | |
| 58 | |
| 59 private: | |
| 60 MediaDrmBridge* const media_drm_bridge_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridgeCdmContext); | |
| 63 }; | |
| 64 | |
| 65 } // namespace media | |
| 66 | |
| 67 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_ | |
| OLD | NEW |