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

Unified Diff: content/renderer/media/android/proxy_media_keys.h

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: latest CDM_5 Created 6 years, 7 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: content/renderer/media/android/proxy_media_keys.h
diff --git a/content/renderer/media/android/proxy_media_keys.h b/content/renderer/media/android/proxy_media_keys.h
index afe1719b5739f99c7f3db2fb4bc2154f95893ad5..a18b4f87c2c25ba2ddf04511e3b68f3b9a6d014d 100644
--- a/content/renderer/media/android/proxy_media_keys.h
+++ b/content/renderer/media/android/proxy_media_keys.h
@@ -5,7 +5,11 @@
#ifndef CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_
#define CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_
+#include <map>
+#include <string>
+
#include "base/basictypes.h"
+#include "base/containers/hash_tables.h"
#include "media/base/media_keys.h"
class GURL;
@@ -24,7 +28,6 @@ class ProxyMediaKeys : public media::MediaKeys {
const std::string& key_system,
const GURL& security_origin,
RendererMediaPlayerManager* manager,
- const media::SessionCreatedCB& session_created_cb,
const media::SessionMessageCB& session_message_cb,
const media::SessionReadyCB& session_ready_cb,
const media::SessionClosedCB& session_closed_cb,
@@ -33,16 +36,23 @@ class ProxyMediaKeys : public media::MediaKeys {
virtual ~ProxyMediaKeys();
// MediaKeys implementation.
- virtual bool CreateSession(uint32 session_id,
- const std::string& content_type,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void LoadSession(uint32 session_id,
- const std::string& web_session_id) OVERRIDE;
- virtual void UpdateSession(uint32 session_id,
- const uint8* response,
- int response_length) OVERRIDE;
- virtual void ReleaseSession(uint32 session_id) OVERRIDE;
+ virtual void CreateSession(
+ const std::string& init_data_type,
+ const uint8* init_data,
+ int init_data_length,
+ SessionType session_type,
+ scoped_ptr<media::CdmNewSessionPromise> promise) OVERRIDE;
+ virtual void LoadSession(
+ const std::string& web_session_id,
+ scoped_ptr<media::CdmNewSessionPromise> promise) OVERRIDE;
+ virtual void UpdateSession(
+ const std::string& web_session_id,
+ const uint8* response,
+ int response_length,
+ scoped_ptr<media::CdmChangeSessionPromise> promise) OVERRIDE;
+ virtual void ReleaseSession(
+ const std::string& web_session_id,
+ scoped_ptr<media::CdmChangeSessionPromise> promise) OVERRIDE;
// Callbacks.
void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
@@ -58,8 +68,11 @@ class ProxyMediaKeys : public media::MediaKeys {
int GetCdmId() const;
private:
+ typedef base::hash_map<std::string, uint32_t> SessionMap;
ddorwin 2014/05/13 22:44:02 Is this a SessionId to Promise ID map?
jrummell 2014/05/15 22:38:09 Nope. This goes with the Android API comment below
+ typedef std::map<uint32_t, media::CdmChangeSessionPromise*> VoidPromiseMap;
ddorwin 2014/05/13 22:44:02 Can the pointer type just be CdmPromise? It's odd
jrummell 2014/05/15 22:38:09 CdmPromise is currently just a template -- there i
+ typedef std::map<uint32_t, media::CdmNewSessionPromise*> SessionPromiseMap;
+
ProxyMediaKeys(RendererMediaPlayerManager* manager,
- const media::SessionCreatedCB& session_created_cb,
const media::SessionMessageCB& session_message_cb,
const media::SessionReadyCB& session_ready_cb,
const media::SessionClosedCB& session_closed_cb,
@@ -68,18 +81,48 @@ class ProxyMediaKeys : public media::MediaKeys {
void InitializeCdm(const std::string& key_system,
const GURL& security_origin);
+ // The Android API uses integer session ids (basically a reference id),
+ // but media::MediaKeys bases everything on web_session_id (a string
+ // representing the actual session id as generated by the CDM). These
+ // functions keep track of session_ids <-> web_session_ids mappings.
+ // TODO(jrummell): Remove this once the Android API changes to support
ddorwin 2014/05/13 22:44:02 Do you mean the Chromium code or the actual Androi
jrummell 2014/05/15 22:38:09 The Chromium code for Android. Reworded.
+ // string session ids.
+ uint32_t CreateSessionId();
+ void AssignWebSessionId(uint32_t session_id,
+ const std::string& web_session_id);
+ uint32_t LookupSessionId(const std::string& web_session_id);
+ std::string LookupWebSessionId(uint32_t session_id);
+ void DropWebSessionId(std::string web_session_id);
+
+ // Helper function to keep track of promises. Adding takes ownership of the
+ // promise, transferred back to caller on lookup.
+ void RegisterVoidPromise(uint32_t session_id,
+ scoped_ptr<media::CdmChangeSessionPromise> promise);
+ scoped_ptr<media::CdmChangeSessionPromise> RetrieveVoidPromise(
+ uint32_t session_id);
+ void RegisterSessionPromise(uint32_t session_id,
+ scoped_ptr<media::CdmNewSessionPromise> promise);
+ scoped_ptr<media::CdmNewSessionPromise> RetrieveSessionPromise(
+ uint32_t session_id);
+
// CDM ID should be unique per renderer process.
// TODO(xhwang): Use uint32 to prevent undefined overflow behavior.
static int next_cdm_id_;
RendererMediaPlayerManager* manager_;
int cdm_id_;
- media::SessionCreatedCB session_created_cb_;
media::SessionMessageCB session_message_cb_;
media::SessionReadyCB session_ready_cb_;
media::SessionClosedCB session_closed_cb_;
media::SessionErrorCB session_error_cb_;
+ uint32_t next_session_id_;
ddorwin 2014/05/13 22:44:02 Do we want them to be unique per process (static)?
jrummell 2014/05/15 22:38:09 I don't think it matters. We are looking them up i
+ SessionMap web_session_to_session_id_map_;
+
+ // Keep track of outstanding promises. These maps owns the promise object.
+ VoidPromiseMap session_id_to_promise_map_;
+ SessionPromiseMap session_id_to_new_session_promise_map_;
+
DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys);
};

Powered by Google App Engine
This is Rietveld 408576698