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

Side by Side Diff: media/remoting/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/proto_enum_utils.cc ('k') | media/remoting/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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_REMOTING_RPC_PROTO_UTILS_H_ 5 #ifndef MEDIA_REMOTING_PROTO_UTILS_H_
6 #define MEDIA_REMOTING_RPC_PROTO_UTILS_H_ 6 #define MEDIA_REMOTING_PROTO_UTILS_H_
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "media/base/audio_decoder_config.h" 14 #include "media/base/audio_decoder_config.h"
15 #include "media/base/cdm_config.h" 15 #include "media/base/cdm_config.h"
16 #include "media/base/cdm_key_information.h" 16 #include "media/base/cdm_key_information.h"
17 #include "media/base/cdm_promise.h" 17 #include "media/base/cdm_promise.h"
18 #include "media/base/decoder_buffer.h" 18 #include "media/base/decoder_buffer.h"
19 #include "media/base/demuxer_stream.h" 19 #include "media/base/demuxer_stream.h"
20 #include "media/base/eme_constants.h" 20 #include "media/base/eme_constants.h"
21 #include "media/base/pipeline_status.h" 21 #include "media/base/pipeline_status.h"
22 #include "media/base/video_decoder_config.h" 22 #include "media/base/video_decoder_config.h"
23 #include "media/remoting/remoting_rpc_message.pb.h" 23 #include "media/remoting/rpc.pb.h"
24 24
25 namespace media { 25 namespace media {
26 namespace remoting { 26 namespace remoting {
27 27
28 class CdmPromiseResult; 28 class CdmPromiseResult;
29 29
30 // Utility class to convert data between ::media::DecoderBuffer and byte array. 30 // Utility class to convert data between media::DecoderBuffer and byte array.
31 // It is to serialize ::media::DecoderBuffer structure except for actual data 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 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 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 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 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 36 // CPU to sirealize/de-serialize decoder buffer which is encoded and encrypted
37 // as wire format for data transmission. 37 // as wire format for data transmission.
38 // 38 //
39 // DecoderBufferSegment { 39 // DecoderBufferSegment {
40 // // Payload version. Default value is 0. 40 // // Payload version. Default value is 0.
41 // u8 payload_version; 41 // u8 payload_version;
42 // 42 //
43 // // Length of pb::DecoderBuffer (protobuf-encoded of ::media::DecoderBuffer 43 // // Length of pb::DecoderBuffer (protobuf-encoded of media::DecoderBuffer
44 // except for data). 44 // except for data).
45 // u16 buffer_segment_size; 45 // u16 buffer_segment_size;
46 // // pb::DecoderBuffer. 46 // // pb::DecoderBuffer.
47 // u8[buffer_segment_size] buffer_segment; 47 // u8[buffer_segment_size] buffer_segment;
48 // 48 //
49 // // Length of data in media::DecoderBuffer. 49 // // Length of data in media::DecoderBuffer.
50 // u32 data_buffer_size; 50 // u32 data_buffer_size;
51 // // media::DecoderBuffer data. 51 // // media::DecoderBuffer data.
52 // u8[data_buffer_size] data_buffer; 52 // u8[data_buffer_size] data_buffer;
53 //}; 53 //};
54 54
55 // Converts DecoderBufferSegment into byte array. 55 // Converts DecoderBufferSegment into byte array.
56 std::vector<uint8_t> DecoderBufferToByteArray( 56 std::vector<uint8_t> DecoderBufferToByteArray(
57 const scoped_refptr<::media::DecoderBuffer>& decoder_buffer); 57 const DecoderBuffer& decoder_buffer);
58 58
59 // Converts byte array into DecoderBufferSegment. 59 // Converts byte array into DecoderBufferSegment.
60 scoped_refptr<::media::DecoderBuffer> ByteArrayToDecoderBuffer( 60 scoped_refptr<DecoderBuffer> ByteArrayToDecoderBuffer(const uint8_t* data,
61 const uint8_t* data, 61 uint32_t size);
62 uint32_t size);
63 62
64 // Data type conversion between ::media::AudioDecoderConfig and proto buffer. 63 // Data type conversion between media::AudioDecoderConfig and proto buffer.
65 void ConvertAudioDecoderConfigToProto( 64 void ConvertAudioDecoderConfigToProto(const AudioDecoderConfig& audio_config,
66 const ::media::AudioDecoderConfig& audio_config, 65 pb::AudioDecoderConfig* audio_message);
67 pb::AudioDecoderConfig* audio_message);
68 bool ConvertProtoToAudioDecoderConfig( 66 bool ConvertProtoToAudioDecoderConfig(
69 const pb::AudioDecoderConfig& audio_message, 67 const pb::AudioDecoderConfig& audio_message,
70 ::media::AudioDecoderConfig* audio_config); 68 AudioDecoderConfig* audio_config);
71 69
72 // Data type conversion between ::media::VideoDecoderConfig and proto buffer. 70 // Data type conversion between media::VideoDecoderConfig and proto buffer.
73 void ConvertVideoDecoderConfigToProto( 71 void ConvertVideoDecoderConfigToProto(const VideoDecoderConfig& video_config,
74 const ::media::VideoDecoderConfig& video_config, 72 pb::VideoDecoderConfig* video_message);
75 pb::VideoDecoderConfig* video_message);
76 bool ConvertProtoToVideoDecoderConfig( 73 bool ConvertProtoToVideoDecoderConfig(
77 const pb::VideoDecoderConfig& video_message, 74 const pb::VideoDecoderConfig& video_message,
78 ::media::VideoDecoderConfig* video_config); 75 VideoDecoderConfig* video_config);
79 76
80 // Data type conversion between ::media::CdmKeysInfo and proto buffer. 77 // Data type conversion between media::VideoDecoderConfig and proto buffer.
78 void ConvertProtoToPipelineStatistics(
79 const pb::PipelineStatistics& stats_message,
80 PipelineStatistics* stats);
81
82 // Data type conversion between media::CdmKeysInfo and proto buffer.
81 void ConvertCdmKeyInfoToProto( 83 void ConvertCdmKeyInfoToProto(
82 const ::media::CdmKeysInfo& keys_information, 84 const CdmKeysInfo& keys_information,
83 pb::CdmClientOnSessionKeysChange* key_change_message); 85 pb::CdmClientOnSessionKeysChange* key_change_message);
84 void ConvertProtoToCdmKeyInfo( 86 void ConvertProtoToCdmKeyInfo(
85 const pb::CdmClientOnSessionKeysChange keychange_message, 87 const pb::CdmClientOnSessionKeysChange keychange_message,
86 CdmKeysInfo* key_information); 88 CdmKeysInfo* key_information);
87 89
88 // Data type conversion between CdmPromiseResult and proto buffer. 90 // Data type conversion between CdmPromiseResult and proto buffer.
89 void ConvertCdmPromiseToProto(const CdmPromiseResult& result, 91 void ConvertCdmPromiseToProto(const CdmPromiseResult& result,
90 pb::CdmPromise* promise_message); 92 pb::CdmPromise* promise_message);
91 void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result, 93 void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result,
92 const std::string& session_id, 94 const std::string& session_id,
93 pb::CdmPromise* promise_message); 95 pb::CdmPromise* promise_message);
94 void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result, 96 void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result,
95 int cdm_id, 97 int cdm_id,
96 pb::CdmPromise* promise_message); 98 pb::CdmPromise* promise_message);
97 bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message, 99 bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message,
98 CdmPromiseResult* result); 100 CdmPromiseResult* result);
99 bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message, 101 bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message,
100 CdmPromiseResult* result, 102 CdmPromiseResult* result,
101 int* cdm_id, 103 int* cdm_id,
102 std::string* session_id); 104 std::string* session_id);
103 105
104 //================================================================== 106 //==================================================================
105 class CdmPromiseResult { 107 class CdmPromiseResult {
106 public: 108 public:
107 CdmPromiseResult(); 109 CdmPromiseResult();
108 CdmPromiseResult(::media::CdmPromise::Exception exception, 110 CdmPromiseResult(CdmPromise::Exception exception,
109 uint32_t system_code, 111 uint32_t system_code,
110 std::string error_message); 112 std::string error_message);
111 CdmPromiseResult(const CdmPromiseResult& other); 113 CdmPromiseResult(const CdmPromiseResult& other);
112 ~CdmPromiseResult(); 114 ~CdmPromiseResult();
113 115
114 static CdmPromiseResult SuccessResult(); 116 static CdmPromiseResult SuccessResult();
115 117
116 bool success() const { return success_; } 118 bool success() const { return success_; }
117 ::media::CdmPromise::Exception exception() const { return exception_; } 119 CdmPromise::Exception exception() const { return exception_; }
118 uint32_t system_code() const { return system_code_; } 120 uint32_t system_code() const { return system_code_; }
119 const std::string& error_message() const { return error_message_; } 121 const std::string& error_message() const { return error_message_; }
120 122
121 private: 123 private:
122 bool success_; 124 bool success_;
123 ::media::CdmPromise::Exception exception_; 125 CdmPromise::Exception exception_;
124 uint32_t system_code_; 126 uint32_t system_code_;
125 std::string error_message_; 127 std::string error_message_;
126 }; 128 };
127 129
128 } // namespace remoting 130 } // namespace remoting
129 } // namespace media 131 } // namespace media
130 132
131 #endif // MEDIA_REMOTING_RPC_PROTO_UTILS_H_ 133 #endif // MEDIA_REMOTING_PROTO_UTILS_H_
OLDNEW
« no previous file with comments | « media/remoting/proto_enum_utils.cc ('k') | media/remoting/proto_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698