OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef MEDIA_REMOTING_RPC_PROTO_UTILS_H_ | |
6 #define MEDIA_REMOTING_RPC_PROTO_UTILS_H_ | |
7 | |
8 #include <cstdint> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "media/base/audio_decoder_config.h" | |
15 #include "media/base/cdm_config.h" | |
16 #include "media/base/cdm_key_information.h" | |
17 #include "media/base/decoder_buffer.h" | |
18 #include "media/base/demuxer_stream.h" | |
19 #include "media/base/eme_constants.h" | |
20 #include "media/base/media_keys.h" | |
21 #include "media/base/pipeline_status.h" | |
22 #include "media/base/video_decoder_config.h" | |
23 #include "media/remoting/remoting_rpc_message.pb.h" | |
24 | |
25 namespace media { | |
26 namespace remoting { | |
27 | |
28 class CdmPromiseResult; | |
29 | |
30 extern const int kInvalidHandle; | |
miu
2016/09/16 18:14:13
C++11 provides a cleaner solution to things like t
erickung1
2016/09/19 17:04:35
Done.
| |
31 extern const int kReceiverHandle; | |
32 | |
33 // Utility class to serialize and de-serialize between media::DecoderBuffer and | |
34 // byte array. The idea is to serialize media::DecoderBuffer except for actual | |
miu
2016/09/16 18:14:14
The second sentence here is a bit confusing. I thi
erickung1
2016/09/19 17:04:35
Done.
| |
35 // decoder buffer using proto buffer and append the decoder buffer at the end. | |
36 // into byte array for data transmission. | |
37 // | |
38 // DecoderBufferSegment { | |
39 // // Payload version. Default value is 0. | |
40 // u8 payload_version; | |
41 // | |
42 // // Length of protobuf-encoded media::DecoderBuffer(except for data). | |
43 // u16 buffer_segment_size; | |
44 // // Protobuf-encoded media::DecoderBuffer. | |
45 // u8[buffer_segment_size] buffer_segment; | |
46 // | |
47 // // Length of data in media::DecoderBuffer. | |
48 // u32 data_buffer_size; | |
49 // // media::DecoderBuffer data. | |
50 // u8[data_buffer_size] data_buffer; | |
51 //}; | |
52 | |
53 // Converts DecoderBufferSegment into byte array. | |
54 std::vector<uint8_t> DecoderBufferToByteArray( | |
55 const scoped_refptr<::media::DecoderBuffer>& decoder_buffer); | |
56 | |
57 // Converts byte array into DecoderBufferSegment. | |
58 scoped_refptr<::media::DecoderBuffer> ByteArrayToDecoderBuffer( | |
59 const uint8_t* data, | |
60 uint32_t size); | |
61 | |
62 // Data type conversion between ::media::AudioDecoderConfig and proto buffer. | |
63 void ConvertAudioDecoderConfigToProto( | |
64 const ::media::AudioDecoderConfig& audio_config, | |
65 pb::AudioDecoderConfig* audio_message); | |
66 bool ConvertProtoToAudioDecoderConfig( | |
67 const pb::AudioDecoderConfig& audio_message, | |
68 ::media::AudioDecoderConfig* audio_config); | |
69 | |
70 // Data type conversion between ::media::VideoDecoderConfig and proto buffer. | |
71 void ConvertVideoDecoderConfigToProto( | |
72 const ::media::VideoDecoderConfig& video_config, | |
73 pb::VideoDecoderConfig* video_message); | |
74 bool ConvertProtoToVideoDecoderConfig( | |
75 const pb::VideoDecoderConfig& video_message, | |
76 ::media::VideoDecoderConfig* video_config); | |
77 | |
78 // Data type conversion between ::media::CdmKeysInfo and proto buffer. | |
79 void ConvertCdmKeyInfoToProto( | |
80 const ::media::CdmKeysInfo& keys_information, | |
81 pb::CdmClientOnSessionKeysChange* key_change_message); | |
82 void ConvertProtoToCdmKeyInfo( | |
83 const pb::CdmClientOnSessionKeysChange keychange_message, | |
84 CdmKeysInfo* key_information); | |
85 | |
86 // Data type conversion between CdmPromiseResult and proto buffer. | |
87 void ConvertCdmPromiseToProto(const CdmPromiseResult& result, | |
88 pb::CdmPromise* promise_message); | |
89 void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result, | |
90 const std::string& session_id, | |
91 pb::CdmPromise* promise_message); | |
92 void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result, | |
93 int cdm_id, | |
94 pb::CdmPromise* promise_message); | |
95 bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message, | |
96 CdmPromiseResult* result); | |
97 bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message, | |
98 CdmPromiseResult* result, | |
99 int* cdm_id, | |
100 std::string* session_id); | |
101 | |
102 //================================================================== | |
103 class CdmPromiseResult { | |
104 public: | |
105 CdmPromiseResult(); | |
106 CdmPromiseResult(::media::MediaKeys::Exception exception, | |
107 uint32_t system_code, | |
108 std::string error_message); | |
109 CdmPromiseResult(const CdmPromiseResult& other); | |
110 ~CdmPromiseResult(); | |
111 | |
112 static CdmPromiseResult SuccessResult(); | |
113 | |
114 bool success() const { return success_; } | |
115 ::media::MediaKeys::Exception exception() const { return exception_; } | |
116 uint32_t system_code() const { return system_code_; } | |
117 const std::string& error_message() const { return error_message_; } | |
118 | |
119 private: | |
120 bool success_; | |
121 ::media::MediaKeys::Exception exception_; | |
122 uint32_t system_code_; | |
123 std::string error_message_; | |
124 }; | |
125 | |
126 } // namespace remoting | |
127 } // namespace media | |
128 | |
129 #endif // MEDIA_REMOTING_RPC_PROTO_UTILS_H_ | |
OLD | NEW |