1 // Copyright (c) 2012 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.
5 #ifndef PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_
6 #define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_
8 #include "ppapi/c/private/pp_content_decryptor.h"
9 #include "ppapi/c/private/ppb_content_decryptor_private.h"
10 #include "ppapi/c/private/ppp_content_decryptor_private.h"
12 #include "ppapi/cpp/dev/buffer_dev.h"
13 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/var.h"
15 #include "ppapi/cpp/var_array_buffer.h"
21 // TODO(tomfinegan): Remove redundant pp:: usage, and pass VarArrayBuffers as
24 class ContentDecryptor_Private {
26 explicit ContentDecryptor_Private(Instance* instance);
27 virtual ~ContentDecryptor_Private();
29 // PPP_ContentDecryptor_Private functions exposed as virtual functions
30 // for you to override.
31 // TODO(tomfinegan): This could be optimized to pass pp::Var instead of
32 // strings. The change would allow the CDM wrapper to reuse vars when
33 // replying to the browser.
34 virtual void Initialize(const std::string& key_system,
35 bool can_challenge_platform) = 0;
36 virtual void GenerateKeyRequest(const std::string& type,
37 pp::VarArrayBuffer init_data) = 0;
38 virtual void AddKey(const std::string& session_id,
39 pp::VarArrayBuffer key,
40 pp::VarArrayBuffer init_data) = 0;
41 virtual void CancelKeyRequest(const std::string& session_id) = 0;
42 virtual void Decrypt(pp::Buffer_Dev encrypted_buffer,
43 const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
44 virtual void InitializeAudioDecoder(
45 const PP_AudioDecoderConfig& decoder_config,
46 pp::Buffer_Dev extra_data_resource) = 0;
47 virtual void InitializeVideoDecoder(
48 const PP_VideoDecoderConfig& decoder_config,
49 pp::Buffer_Dev extra_data_resource) = 0;
50 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
51 uint32_t request_id) = 0;
52 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type,
53 uint32_t request_id) = 0;
54 // Null |encrypted_frame| means end-of-stream buffer.
55 virtual void DecryptAndDecode(
56 PP_DecryptorStreamType decoder_type,
57 pp::Buffer_Dev encrypted_buffer,
58 const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
60 // PPB_ContentDecryptor_Private methods for passing data from the decryptor
62 void KeyAdded(const std::string& key_system,
63 const std::string& session_id);
64 void KeyMessage(const std::string& key_system,
65 const std::string& session_id,
66 pp::VarArrayBuffer message,
67 const std::string& default_url);
68 void KeyError(const std::string& key_system,
69 const std::string& session_id,
73 // The plugin must not hold a reference to the encrypted buffer resource
74 // provided to Decrypt() when it calls this method. The browser will reuse
75 // the buffer in a subsequent Decrypt() call.
76 void DeliverBlock(pp::Buffer_Dev decrypted_block,
77 const PP_DecryptedBlockInfo& decrypted_block_info);
79 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type,
82 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type,
84 void DecoderResetDone(PP_DecryptorStreamType decoder_type,
87 // The plugin must not hold a reference to the encrypted buffer resource
88 // provided to DecryptAndDecode() when it calls this method. The browser will
89 // reuse the buffer in a subsequent DecryptAndDecode() call.
90 void DeliverFrame(pp::Buffer_Dev decrypted_frame,
91 const PP_DecryptedFrameInfo& decrypted_frame_info);
93 // The plugin must not hold a reference to the encrypted buffer resource
94 // provided to DecryptAndDecode() when it calls this method. The browser will
95 // reuse the buffer in a subsequent DecryptAndDecode() call.
96 void DeliverSamples(pp::Buffer_Dev audio_frames,
97 const PP_DecryptedSampleInfo& decrypted_sample_info);
100 InstanceHandle associated_instance_;
105 #endif // PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_