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

Unified Diff: media/base/android/media_drm_bridge_cdm_context.h

Issue 1808983002: media: Add MediaDrmBridgeCdmContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 9 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: media/base/android/media_drm_bridge_cdm_context.h
diff --git a/media/base/android/media_drm_bridge_cdm_context.h b/media/base/android/media_drm_bridge_cdm_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..d49cb1f02c6e85f7cc7c0032fb257cbce74bbe0f
--- /dev/null
+++ b/media/base/android/media_drm_bridge_cdm_context.h
@@ -0,0 +1,73 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
+#define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/callback.h"
+#include "base/macros.h"
+#include "media/base/cdm_context.h"
+#include "media/base/media_export.h"
+#include "media/base/player_tracker.h"
+
+namespace media {
+
+class MediaDrmBridge;
+
+// The CdmContext implementation for MediaDrmBridge. MediaDrmBridge supports
+// neither Decryptor nor CDM ID, but uses MediaCrypto to connect to MediaCodec.
+// MediaCodec based decoders should cast the given CdmContext to this class to
ddorwin 2016/03/22 17:20:12 nit '-' before "based"
xhwang 2016/03/22 17:35:10 Done.
+// access APIs defined in this class.
+//
+// Methods can be called on any thread. The registered callbacks will be fired
+// on the thread |media_drm_bridge_| is running on. The caller should make sure
+// that the callbacks are posted to the correct thread.
+//
+// TODO(xhwang): Remove PlayerTracker interface.
+class MEDIA_EXPORT MediaDrmBridgeCdmContext : public CdmContext,
+ public PlayerTracker {
+ public:
+ using JavaObjectPtr = scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>>;
+
+ // Notification called when MediaCrypto object is ready.
+ // Parameters:
+ // |media_crypto| - reference to MediaCrypto object
+ // |needs_protected_surface| - true if protected surface is required
+ using MediaCryptoReadyCB = base::Callback<void(JavaObjectPtr media_crypto,
+ bool needs_protected_surface)>;
+
+ // The |media_drm_bridge| owns |this| and is guaranteed to outlive |this|.
+ explicit MediaDrmBridgeCdmContext(MediaDrmBridge* media_drm_bridge);
+
+ ~MediaDrmBridgeCdmContext() final;
+
+ // CdmContext implementation.
+ Decryptor* GetDecryptor() final;
+ int GetCdmId() const final;
+
+ // PlayerTracker implementation.
+ // Methods can be called on any thread. The registered callbacks will be fired
+ // on |task_runner_|. The caller should make sure that the callbacks are
+ // posted to the correct thread.
+ //
+ // Note: RegisterPlayer() must be called before SetMediaCryptoReadyCB() to
+ // avoid missing any new key notifications.
+ int RegisterPlayer(const base::Closure& new_key_cb,
+ const base::Closure& cdm_unset_cb) final;
+ void UnregisterPlayer(int registration_id) final;
+
+ void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb);
+
+ private:
+ MediaDrmBridge* const media_drm_bridge_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaDrmBridgeCdmContext);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_

Powered by Google App Engine
This is Rietveld 408576698