Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: media/remoting/rpc/proto_utils.h

Issue 2643253003: Media Remoting Clean-up: Less-redundant naming, style consistency, etc. (Closed)
Patch Set: REBASE Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/remoting/rpc/proto_enum_utils.cc ('k') | media/remoting/rpc/proto_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/cdm_promise.h"
18 #include "media/base/decoder_buffer.h"
19 #include "media/base/demuxer_stream.h"
20 #include "media/base/eme_constants.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 // Utility class to convert data between ::media::DecoderBuffer and byte array.
31 // It is to serialize ::media::DecoderBuffer structure except for actual data
32 // into pb::DecoderBuffer followed by byte array of decoder buffer. The reason
33 // data is not part of proto buffer because it would cost unnecessary time to
34 // wait for whole proto received before conversion given the fact that decoder
35 // buffer data can vary from hundred bytes to 3~5MB. Also, it would costs extra
36 // CPU to sirealize/de-serialize decoder buffer which is encoded and encrypted
37 // as wire format for data transmission.
38 //
39 // DecoderBufferSegment {
40 // // Payload version. Default value is 0.
41 // u8 payload_version;
42 //
43 // // Length of pb::DecoderBuffer (protobuf-encoded of ::media::DecoderBuffer
44 // except for data).
45 // u16 buffer_segment_size;
46 // // pb::DecoderBuffer.
47 // u8[buffer_segment_size] buffer_segment;
48 //
49 // // Length of data in media::DecoderBuffer.
50 // u32 data_buffer_size;
51 // // media::DecoderBuffer data.
52 // u8[data_buffer_size] data_buffer;
53 //};
54
55 // Converts DecoderBufferSegment into byte array.
56 std::vector<uint8_t> DecoderBufferToByteArray(
57 const scoped_refptr<::media::DecoderBuffer>& decoder_buffer);
58
59 // Converts byte array into DecoderBufferSegment.
60 scoped_refptr<::media::DecoderBuffer> ByteArrayToDecoderBuffer(
61 const uint8_t* data,
62 uint32_t size);
63
64 // Data type conversion between ::media::AudioDecoderConfig and proto buffer.
65 void ConvertAudioDecoderConfigToProto(
66 const ::media::AudioDecoderConfig& audio_config,
67 pb::AudioDecoderConfig* audio_message);
68 bool ConvertProtoToAudioDecoderConfig(
69 const pb::AudioDecoderConfig& audio_message,
70 ::media::AudioDecoderConfig* audio_config);
71
72 // Data type conversion between ::media::VideoDecoderConfig and proto buffer.
73 void ConvertVideoDecoderConfigToProto(
74 const ::media::VideoDecoderConfig& video_config,
75 pb::VideoDecoderConfig* video_message);
76 bool ConvertProtoToVideoDecoderConfig(
77 const pb::VideoDecoderConfig& video_message,
78 ::media::VideoDecoderConfig* video_config);
79
80 // Data type conversion between ::media::CdmKeysInfo and proto buffer.
81 void ConvertCdmKeyInfoToProto(
82 const ::media::CdmKeysInfo& keys_information,
83 pb::CdmClientOnSessionKeysChange* key_change_message);
84 void ConvertProtoToCdmKeyInfo(
85 const pb::CdmClientOnSessionKeysChange keychange_message,
86 CdmKeysInfo* key_information);
87
88 // Data type conversion between CdmPromiseResult and proto buffer.
89 void ConvertCdmPromiseToProto(const CdmPromiseResult& result,
90 pb::CdmPromise* promise_message);
91 void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result,
92 const std::string& session_id,
93 pb::CdmPromise* promise_message);
94 void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result,
95 int cdm_id,
96 pb::CdmPromise* promise_message);
97 bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message,
98 CdmPromiseResult* result);
99 bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message,
100 CdmPromiseResult* result,
101 int* cdm_id,
102 std::string* session_id);
103
104 //==================================================================
105 class CdmPromiseResult {
106 public:
107 CdmPromiseResult();
108 CdmPromiseResult(::media::CdmPromise::Exception exception,
109 uint32_t system_code,
110 std::string error_message);
111 CdmPromiseResult(const CdmPromiseResult& other);
112 ~CdmPromiseResult();
113
114 static CdmPromiseResult SuccessResult();
115
116 bool success() const { return success_; }
117 ::media::CdmPromise::Exception exception() const { return exception_; }
118 uint32_t system_code() const { return system_code_; }
119 const std::string& error_message() const { return error_message_; }
120
121 private:
122 bool success_;
123 ::media::CdmPromise::Exception exception_;
124 uint32_t system_code_;
125 std::string error_message_;
126 };
127
128 } // namespace remoting
129 } // namespace media
130
131 #endif // MEDIA_REMOTING_RPC_PROTO_UTILS_H_
OLDNEW
« no previous file with comments | « media/remoting/rpc/proto_enum_utils.cc ('k') | media/remoting/rpc/proto_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698