[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ppapi / cpp / private / content_decryptor_private.h
blob18d2367fc4beafa54a7136ec80c0c24d154c16a0
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 <string>
9 #include <vector>
11 #include "ppapi/c/private/pp_content_decryptor.h"
12 #include "ppapi/c/private/ppb_content_decryptor_private.h"
13 #include "ppapi/c/private/ppp_content_decryptor_private.h"
15 #include "ppapi/cpp/dev/buffer_dev.h"
16 #include "ppapi/cpp/instance_handle.h"
17 #include "ppapi/cpp/var.h"
18 #include "ppapi/cpp/var_array_buffer.h"
20 namespace pp {
22 class Instance;
24 // TODO(tomfinegan): Remove redundant pp:: usage, and pass VarArrayBuffers as
25 // const references.
27 class ContentDecryptor_Private {
28 public:
29 explicit ContentDecryptor_Private(Instance* instance);
30 virtual ~ContentDecryptor_Private();
32 // PPP_ContentDecryptor_Private functions exposed as virtual functions
33 // for you to override.
34 // TODO(tomfinegan): This could be optimized to pass pp::Var instead of
35 // strings. The change would allow the CDM wrapper to reuse vars when
36 // replying to the browser.
37 virtual void Initialize(uint32_t promise_id,
38 const std::string& key_system,
39 bool allow_distinctive_identifier,
40 bool allow_persistent_state) = 0;
41 virtual void SetServerCertificate(uint32_t promise_id,
42 pp::VarArrayBuffer server_certificate) = 0;
43 virtual void CreateSessionAndGenerateRequest(
44 uint32_t promise_id,
45 PP_SessionType session_type,
46 PP_InitDataType init_data_type,
47 pp::VarArrayBuffer init_data) = 0;
48 virtual void LoadSession(uint32_t promise_id,
49 PP_SessionType session_type,
50 const std::string& session_id) = 0;
51 virtual void UpdateSession(uint32_t promise_id,
52 const std::string& session_id,
53 pp::VarArrayBuffer response) = 0;
54 virtual void CloseSession(uint32_t promise_id,
55 const std::string& session_id) = 0;
56 virtual void RemoveSession(uint32_t promise_id,
57 const std::string& session_id) = 0;
58 virtual void Decrypt(pp::Buffer_Dev encrypted_buffer,
59 const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
60 virtual void InitializeAudioDecoder(
61 const PP_AudioDecoderConfig& decoder_config,
62 pp::Buffer_Dev extra_data_resource) = 0;
63 virtual void InitializeVideoDecoder(
64 const PP_VideoDecoderConfig& decoder_config,
65 pp::Buffer_Dev extra_data_resource) = 0;
66 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
67 uint32_t request_id) = 0;
68 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type,
69 uint32_t request_id) = 0;
70 // Null |encrypted_frame| means end-of-stream buffer.
71 virtual void DecryptAndDecode(
72 PP_DecryptorStreamType decoder_type,
73 pp::Buffer_Dev encrypted_buffer,
74 const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
76 // PPB_ContentDecryptor_Private methods for passing data from the decryptor
77 // to the browser.
78 void PromiseResolved(uint32_t promise_id);
79 void PromiseResolvedWithSession(uint32_t promise_id,
80 const std::string& session_id);
81 void PromiseRejected(uint32_t promise_id,
82 PP_CdmExceptionCode exception_code,
83 uint32_t system_code,
84 const std::string& error_description);
85 void SessionMessage(const std::string& session_id,
86 PP_CdmMessageType message_type,
87 pp::VarArrayBuffer message,
88 const std::string& legacy_destination_url);
89 void SessionKeysChange(const std::string& session_id,
90 bool has_additional_usable_key,
91 const std::vector<PP_KeyInformation>& key_information);
92 void SessionExpirationChange(const std::string& session_id,
93 PP_Time new_expiry_time);
94 void SessionClosed(const std::string& session_id);
95 void LegacySessionError(const std::string& session_id,
96 PP_CdmExceptionCode exception_code,
97 uint32_t system_code,
98 const std::string& error_description);
100 // The plugin must not hold a reference to the encrypted buffer resource
101 // provided to Decrypt() when it calls this method. The browser will reuse
102 // the buffer in a subsequent Decrypt() call.
103 void DeliverBlock(pp::Buffer_Dev decrypted_block,
104 const PP_DecryptedBlockInfo& decrypted_block_info);
106 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type,
107 uint32_t request_id,
108 bool status);
109 void DecoderDeinitializeDone(PP_DecryptorStreamType decoder_type,
110 uint32_t request_id);
111 void DecoderResetDone(PP_DecryptorStreamType decoder_type,
112 uint32_t request_id);
114 // The plugin must not hold a reference to the encrypted buffer resource
115 // provided to DecryptAndDecode() when it calls this method. The browser will
116 // reuse the buffer in a subsequent DecryptAndDecode() call.
117 void DeliverFrame(pp::Buffer_Dev decrypted_frame,
118 const PP_DecryptedFrameInfo& decrypted_frame_info);
120 // The plugin must not hold a reference to the encrypted buffer resource
121 // provided to DecryptAndDecode() when it calls this method. The browser will
122 // reuse the buffer in a subsequent DecryptAndDecode() call.
123 void DeliverSamples(pp::Buffer_Dev audio_frames,
124 const PP_DecryptedSampleInfo& decrypted_sample_info);
126 private:
127 InstanceHandle associated_instance_;
130 } // namespace pp
132 #endif // PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_