Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / media / cdm / ppapi / cdm_wrapper.h
index f11672c..9e648b5 100644 (file)
@@ -42,6 +42,10 @@ class CdmWrapper {
 
   virtual ~CdmWrapper() {};
 
+  // TODO(jrummell): Remove return value when CDM4/5 are removed.
+  virtual bool SetServerCertificate(uint32_t promise_id,
+                                    const uint8_t* server_certificate_data,
+                                    uint32_t server_certificate_data_size) = 0;
   virtual void CreateSession(uint32_t promise_id,
                              const char* init_data_type,
                              uint32_t init_data_type_size,
@@ -103,11 +107,11 @@ class CdmWrapper {
   virtual std::string LookupWebSessionId(uint32_t session_id) = 0;
   virtual void DropWebSessionId(std::string web_session_id) = 0;
 
-  // Helper functions for the cdm::Host_4 and cdm::Host_5 methods.
+  // Helper functions for the cdm::Host_4 methods.
   // CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when
   // resolving LoadSession() and UpdateSession(). This needs to be simulated
   // for the older CDMs. These must not be called for cdm::Host_6 and later.
-  // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
+  // TODO(jrummell): Remove these once Host_4 interface is removed.
 
   // Query whether a SessionUsableKeys event is necessary for the specified
   // |promise_id|. Returns true if needed and |web_session_id| is updated,
@@ -122,16 +126,16 @@ class CdmWrapper {
       const char* web_session_id,
       uint32_t web_session_id_size) = 0;
 
-  // cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 and
-  // cdm::Host_5 methods still use InputBuffer_1, so this helper function
+  // cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4
+  // methods still use InputBuffer_1, so this helper function
   // converts InputBuffer_2 to InputBuffer_1.
-  // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
+  // TODO(jrummell): Remove these once Host_4 interfaces is removed.
   virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
                                   cdm::InputBuffer_1* v1) = 0;
 
   // Prior to CDM_6, |init_data_type| was a content type. This helper convererts
   // an |init_data_type| to a content type.
-  // TODO(sandersd): Remove once Host_4 and Host_5 interfaces are removed.
+  // TODO(sandersd): Remove once Host_4 interface is removed.
   virtual std::string ConvertInitDataTypeToContentType(
       const std::string& init_data_type) const = 0;
 
@@ -175,6 +179,15 @@ class CdmWrapperImpl : public CdmWrapper {
            std::equal(data, data + header.length(), header.begin());
   }
 
+  virtual bool SetServerCertificate(
+      uint32_t promise_id,
+      const uint8_t* server_certificate_data,
+      uint32_t server_certificate_data_size) OVERRIDE {
+    cdm_->SetServerCertificate(
+        promise_id, server_certificate_data, server_certificate_data_size);
+    return true;
+  }
+
   virtual void CreateSession(uint32_t promise_id,
                              const char* init_data_type,
                              uint32_t init_data_type_size,
@@ -221,13 +234,6 @@ class CdmWrapperImpl : public CdmWrapper {
                         response_size);
   }
 
-  virtual bool GetUsableKeyIds(uint32_t promise_id,
-                               const char* web_session_id,
-                               uint32_t web_session_id_size) OVERRIDE {
-    cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
-    return true;
-  }
-
   virtual bool CloseSession(uint32_t promise_id,
                             const char* web_session_id,
                             uint32_t web_session_id_size) OVERRIDE {
@@ -241,6 +247,13 @@ class CdmWrapperImpl : public CdmWrapper {
     cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
   }
 
+  virtual bool GetUsableKeyIds(uint32_t promise_id,
+                               const char* web_session_id,
+                               uint32_t web_session_id_size) OVERRIDE {
+    cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
+    return true;
+  }
+
   virtual void TimerExpired(void* context) OVERRIDE {
     cdm_->TimerExpired(context);
   }
@@ -406,6 +419,14 @@ class CdmWrapperImpl : public CdmWrapper {
 // TODO(jrummell): Remove these once Host_4 interface is removed.
 
 template <>
+bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::SetServerCertificate(
+    uint32_t promise_id,
+    const uint8_t* server_certificate_data,
+    uint32_t server_certificate_data_size) {
+  return false;
+}
+
+template <>
 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession(
     uint32_t promise_id,
     const char* init_data_type,
@@ -511,121 +532,6 @@ CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples(
   return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
 }
 
-// Overrides for the cdm::Host_5 methods.
-// TODO(jrummell): Remove these once Host_5 interface is removed.
-
-template <>
-void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession(
-    uint32_t promise_id,
-    const char* init_data_type,
-    uint32_t init_data_type_size,
-    const uint8_t* init_data,
-    uint32_t init_data_size,
-    cdm::SessionType session_type) {
-  std::string converted_init_data_type = ConvertInitDataTypeToContentType(
-      std::string(init_data_type, init_data_type_size));
-  // TODO(jrummell): Remove this code once |session_type| is passed through
-  // Pepper. When removing, add the header back in for CDM4.
-  PP_DCHECK(session_type == cdm::kTemporary);
-  const char kPersistentSessionHeader[] = "PERSISTENT|";
-  if (HasHeader(init_data, init_data_size, kPersistentSessionHeader)) {
-    cdm_->CreateSession(promise_id,
-                        converted_init_data_type.data(),
-                        converted_init_data_type.length(),
-                        init_data + strlen(kPersistentSessionHeader),
-                        init_data_size - strlen(kPersistentSessionHeader),
-                        cdm::kPersistent);
-    return;
-  }
-
-  cdm_->CreateSession(promise_id,
-                      converted_init_data_type.data(),
-                      converted_init_data_type.length(),
-                      init_data,
-                      init_data_size,
-                      session_type);
-}
-
-template <>
-void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession(
-    uint32_t promise_id,
-    const char* web_session_id,
-    uint32_t web_session_id_size) {
-  // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
-  // one when the promise is resolved. This may be overly aggressive.
-  SetSessionUsableKeysEventNeeded(
-      promise_id, web_session_id, web_session_id_size);
-  cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
-}
-
-template <>
-void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession(
-    uint32_t promise_id,
-    const char* web_session_id,
-    uint32_t web_session_id_size,
-    const uint8_t* response,
-    uint32_t response_size) {
-  // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
-  // one when the promise is resolved. This may be overly aggressive.
-  SetSessionUsableKeysEventNeeded(
-      promise_id, web_session_id, web_session_id_size);
-  cdm_->UpdateSession(
-      promise_id, web_session_id, web_session_id_size, response, response_size);
-}
-
-template <>
-bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession(
-    uint32_t promise_id,
-    const char* web_session_id,
-    uint32_t web_session_id_size) {
-  return false;
-}
-
-template <>
-void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession(
-    uint32_t promise_id,
-    const char* web_session_id,
-    uint32_t web_session_id_size) {
-  cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size);
-}
-
-template <>
-bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds(
-    uint32_t promise_id,
-    const char* web_session_id,
-    uint32_t web_session_id_size) {
-  return false;
-}
-
-template <>
-cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Decrypt(
-    const cdm::InputBuffer& encrypted_buffer,
-    cdm::DecryptedBlock* decrypted_buffer) {
-  cdm::InputBuffer_1 buffer;
-  ConvertInputBuffer(encrypted_buffer, &buffer);
-  return cdm_->Decrypt(buffer, decrypted_buffer);
-}
-
-template <>
-cdm::Status
-CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeFrame(
-    const cdm::InputBuffer& encrypted_buffer,
-    cdm::VideoFrame* video_frame) {
-  cdm::InputBuffer_1 buffer;
-  ConvertInputBuffer(encrypted_buffer, &buffer);
-  return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
-}
-
-template <>
-cdm::Status
-CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeSamples(
-    const cdm::InputBuffer& encrypted_buffer,
-    cdm::AudioFrames* audio_frames) {
-  cdm::InputBuffer_1 buffer;
-  ConvertInputBuffer(encrypted_buffer, &buffer);
-  return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
-}
-
 CdmWrapper* CdmWrapper::Create(const char* key_system,
                                uint32_t key_system_size,
                                GetCdmHostFunc get_cdm_host_func,
@@ -656,11 +562,6 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
 
   // If |cdm_wrapper| is NULL, try to create the CDM using older supported
   // versions of the CDM interface.
-  cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create(
-      key_system, key_system_size, get_cdm_host_func, user_data);
-  if (cdm_wrapper)
-    return cdm_wrapper;
-
   cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create(
       key_system, key_system_size, get_cdm_host_func, user_data);
   return cdm_wrapper;