cdm_adapter.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file.
48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef MEDIA_CDM_PPAPI_CDM_ADAPTER_H_
68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_
78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <string>
98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <vector>
108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/basictypes.h"
128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/compiler_specific.h"
138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "build/build_config.h"
148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/api/content_decryption_module.h"
158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/cdm_helpers.h"
168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/cdm_wrapper.h"
178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "media/cdm/ppapi/linked_ptr.h"
188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/pp_stdint.h"
198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/c/private/pp_content_decryptor.h"
208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/completion_callback.h"
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/content_decryptor_private.h"
228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/var.h"
238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/var_array_buffer.h"
248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/utility/completion_callback_factory.h"
258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#if defined(OS_CHROMEOS)
278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/output_protection_private.h"
288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "ppapi/cpp/private/platform_verification.h"
298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif
308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace media {
328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// GetCdmHostFunc implementation.
348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void* GetCdmHost(int host_interface_version, void* user_data);
358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// An adapter class for abstracting away PPAPI interaction and threading for a
378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Content Decryption Module (CDM).
388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class CdmAdapter : public pp::Instance,
398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                   public pp::ContentDecryptor_Private,
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                   public cdm::Host_4 {
418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public:
428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  CdmAdapter(PP_Instance instance, pp::Module* module);
438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual ~CdmAdapter();
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // pp::Instance implementation.
468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return true;
488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // PPP_ContentDecryptor_Private implementation.
518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Note: Results of calls to these methods must be reported through the
528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // PPB_ContentDecryptor_Private interface.
53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void Initialize(const std::string& key_system) OVERRIDE;
54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void CreateSession(uint32_t session_id,
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             const std::string& content_type,
56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                             pp::VarArrayBuffer init_data) OVERRIDE;
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void LoadSession(uint32_t session_id,
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                           const std::string& web_session_id) OVERRIDE;
59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void UpdateSession(uint32_t session_id,
60a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                             pp::VarArrayBuffer response) OVERRIDE;
61a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void ReleaseSession(uint32_t session_id) OVERRIDE;
628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void Decrypt(
638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      pp::Buffer_Dev encrypted_buffer,
648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void InitializeAudioDecoder(
668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      const PP_AudioDecoderConfig& decoder_config,
678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      pp::Buffer_Dev extra_data_buffer) OVERRIDE;
688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void InitializeVideoDecoder(
698bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      const PP_VideoDecoderConfig& decoder_config,
708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      pp::Buffer_Dev extra_data_buffer) OVERRIDE;
718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                                   uint32_t request_id) OVERRIDE;
738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void ResetDecoder(PP_DecryptorStreamType decoder_type,
748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                            uint32_t request_id) OVERRIDE;
758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void DecryptAndDecode(
768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      PP_DecryptorStreamType decoder_type,
778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      pp::Buffer_Dev encrypted_buffer,
788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // cdm::Host implementation.
811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE;
828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnSessionCreated(uint32_t session_id,
85a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                const char* web_session_id,
86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                uint32_t web_session_id_length) OVERRIDE;
87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnSessionMessage(uint32_t session_id,
88a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                const char* message,
89a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                uint32_t message_length,
90a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                const char* destination_url,
91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                uint32_t destination_url_length) OVERRIDE;
92a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnSessionReady(uint32_t session_id) OVERRIDE;
93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnSessionClosed(uint32_t session_id) OVERRIDE;
94a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnSessionError(uint32_t session_id,
95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                              cdm::MediaKeyError error_code,
96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                              uint32_t system_code) OVERRIDE;
97c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void SendPlatformChallenge(
98c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      const char* service_id, uint32_t service_id_length,
99c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      const char* challenge, uint32_t challenge_length) OVERRIDE;
100c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void EnableOutputProtection(
101c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      uint32_t desired_protection_mask) OVERRIDE;
102c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void QueryOutputProtectionStatus() OVERRIDE;
103c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void OnDeferredInitializationDone(
104c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      cdm::StreamType stream_type,
105c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      cdm::Status decoder_status) OVERRIDE;
1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE;
107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private:
109010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // These are reported to UMA server. Do not change the existing values!
110010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  enum OutputProtectionStatus {
111010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    OUTPUT_PROTECTION_QUERIED = 0,
112010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    OUTPUT_PROTECTION_NO_EXTERNAL_LINK = 1,
113010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED = 2,
114010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    OUTPUT_PROTECTION_MAX = 3
115010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  };
116010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
1178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock;
1188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame;
1198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef linked_ptr<AudioFramesImpl> LinkedAudioFrames;
1208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool CreateCdmInstance(const std::string& key_system);
1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to
1248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // <code>callback_factory_</code> to ensure that calls into
1258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // <code>PPP_ContentDecryptor_Private</code> are asynchronous.
126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SendSessionCreatedInternal(int32_t result,
127a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  uint32_t session_id,
128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  const std::string& web_session_id);
129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SendSessionMessageInternal(int32_t result,
130a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  uint32_t session_id,
131a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  const std::vector<uint8>& message,
13246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)                                  const std::string& destination_url);
133a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SendSessionReadyInternal(int32_t result, uint32_t session_id);
134a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SendSessionClosedInternal(int32_t result, uint32_t session_id);
135a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void SendSessionErrorInternal(int32_t result,
136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                uint32_t session_id,
137a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                cdm::MediaKeyError error_code,
138a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                uint32_t system_code);
139a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DeliverBlock(int32_t result,
1418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const cdm::Status& status,
1428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const LinkedDecryptedBlock& decrypted_block,
1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const PP_DecryptTrackingInfo& tracking_info);
1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DecoderInitializeDone(int32_t result,
1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                             PP_DecryptorStreamType decoder_type,
1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                             uint32_t request_id,
1478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                             bool success);
1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DecoderDeinitializeDone(int32_t result,
1498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                               PP_DecryptorStreamType decoder_type,
1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                               uint32_t request_id);
1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DecoderResetDone(int32_t result,
1528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                        PP_DecryptorStreamType decoder_type,
1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                        uint32_t request_id);
1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DeliverFrame(int32_t result,
1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const cdm::Status& status,
1568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const LinkedVideoFrame& video_frame,
1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                    const PP_DecryptTrackingInfo& tracking_info);
1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void DeliverSamples(int32_t result,
1598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                      const cdm::Status& status,
1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                      const LinkedAudioFrames& audio_frames,
1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                      const PP_DecryptTrackingInfo& tracking_info);
1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Helper for SetTimer().
1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void TimerExpired(int32_t result, void* context);
1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool IsValidVideoFrame(const LinkedVideoFrame& video_frame);
1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if !defined(NDEBUG)
1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Logs the given message to the JavaScript console associated with the
1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // CDM adapter instance. The name of the CDM adapter issuing the log message
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // will be automatically prepended to the message.
1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void LogToConsole(const pp::Var& value);
1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // !defined(NDEBUG)
1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#if defined(OS_CHROMEOS)
176010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void ReportOutputProtectionUMA(OutputProtectionStatus status);
177010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void ReportOutputProtectionQuery();
178010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void ReportOutputProtectionQueryResult();
179010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
1808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void SendPlatformChallengeDone(int32_t result);
1818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void EnableProtectionDone(int32_t result);
1828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void QueryOutputProtectionStatusDone(int32_t result);
1838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::OutputProtection_Private output_protection_;
1858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::PlatformVerification platform_verification_;
1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Since PPAPI doesn't provide handlers for CompletionCallbacks with more than
1888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // one output we need to manage our own.  These values are only read by
1898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // SendPlatformChallengeDone().
1908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::Var signed_data_output_;
1918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::Var signed_data_signature_output_;
1928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::Var platform_key_certificate_output_;
1938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool challenge_in_progress_;
1948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Same as above, these are only read by QueryOutputProtectionStatusDone().
1968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  uint32_t output_link_mask_;
1978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  uint32_t output_protection_mask_;
1988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool query_output_protection_in_progress_;
199010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
200010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Tracks whether an output protection query and a positive query result (no
201010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // unprotected external link) have been reported to UMA.
202010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  bool uma_for_output_protection_query_reported_;
203010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  bool uma_for_output_protection_positive_result_reported_;
2048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif
2058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
2068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  PpbBufferAllocator allocator_;
2078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  pp::CompletionCallbackFactory<CdmAdapter> callback_factory_;
2088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  linked_ptr<CdmWrapper> cdm_;
2098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  std::string key_system_;
2108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
2111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // If the CDM returned kDeferredInitialization during InitializeAudioDecoder()
2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // or InitializeVideoDecoder(), the (Audio|Video)DecoderConfig.request_id is
2131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // saved for the future call to OnDeferredInitializationDone().
2141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool deferred_initialize_audio_decoder_;
2151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  uint32_t deferred_audio_decoder_config_id_;
2161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool deferred_initialize_video_decoder_;
2171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  uint32_t deferred_video_decoder_config_id_;
2181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(CdmAdapter);
2208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)};
2218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
2228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}  // namespace media
2238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
2248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif  // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_
225