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

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

Issue 2261503002: Define remote playback proto buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove all change in src/BUILD.gn and media_options.gni Created 4 years, 2 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/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 // Predefined invalid handle value RPC message.
31 constexpr int kInvalidHandle = -1;
32
33 // Predefined handle value for RPC messages related to initialization.
34 constexpr int kReceiverHandle = 0;
35
36 // Utility class to convert data between ::media::DecoderBuffer and byte array.
37 // It is to serialize ::media::DecoderBuffer structure except for actual data
38 // into pb::DecoderBuffer followed by byte array of decoder buffer. The reason
39 // data is not part of proto buffer because it would cost unnecessary time to
40 // wait for whole proto received before conversion given the fact that decoder
41 // buffer data can vary from hundred bytes to 3~5MB. Also, it would costs extra
42 // CPU to sirealize/de-serialize decoder buffer which is encoded and encrypted
43 // as wire format for data transmission.
44 //
45 // DecoderBufferSegment {
46 // // Payload version. Default value is 0.
47 // u8 payload_version;
48 //
49 // // Length of pb::DecoderBuffer (protobuf-encoded of ::media::DecoderBuffer
50 // except for data).
51 // u16 buffer_segment_size;
52 // // pb::DecoderBuffer.
53 // u8[buffer_segment_size] buffer_segment;
54 //
55 // // Length of data in media::DecoderBuffer.
56 // u32 data_buffer_size;
57 // // media::DecoderBuffer data.
58 // u8[data_buffer_size] data_buffer;
59 //};
60
61 // Converts DecoderBufferSegment into byte array.
62 std::vector<uint8_t> DecoderBufferToByteArray(
63 const scoped_refptr<::media::DecoderBuffer>& decoder_buffer);
64
65 // Converts byte array into DecoderBufferSegment.
66 scoped_refptr<::media::DecoderBuffer> ByteArrayToDecoderBuffer(
67 const uint8_t* data,
68 uint32_t size);
69
70 // Data type conversion between ::media::AudioDecoderConfig and proto buffer.
71 void ConvertAudioDecoderConfigToProto(
72 const ::media::AudioDecoderConfig& audio_config,
73 pb::AudioDecoderConfig* audio_message);
74 bool ConvertProtoToAudioDecoderConfig(
75 const pb::AudioDecoderConfig& audio_message,
76 ::media::AudioDecoderConfig* audio_config);
77
78 // Data type conversion between ::media::VideoDecoderConfig and proto buffer.
79 void ConvertVideoDecoderConfigToProto(
80 const ::media::VideoDecoderConfig& video_config,
81 pb::VideoDecoderConfig* video_message);
82 bool ConvertProtoToVideoDecoderConfig(
83 const pb::VideoDecoderConfig& video_message,
84 ::media::VideoDecoderConfig* video_config);
85
86 // Data type conversion between ::media::CdmKeysInfo and proto buffer.
87 void ConvertCdmKeyInfoToProto(
88 const ::media::CdmKeysInfo& keys_information,
89 pb::CdmClientOnSessionKeysChange* key_change_message);
90 void ConvertProtoToCdmKeyInfo(
91 const pb::CdmClientOnSessionKeysChange keychange_message,
92 CdmKeysInfo* key_information);
93
94 // Data type conversion between CdmPromiseResult and proto buffer.
95 void ConvertCdmPromiseToProto(const CdmPromiseResult& result,
96 pb::CdmPromise* promise_message);
97 void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result,
98 const std::string& session_id,
99 pb::CdmPromise* promise_message);
100 void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result,
101 int cdm_id,
102 pb::CdmPromise* promise_message);
103 bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message,
104 CdmPromiseResult* result);
105 bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message,
106 CdmPromiseResult* result,
107 int* cdm_id,
108 std::string* session_id);
109
110 //==================================================================
111 class CdmPromiseResult {
112 public:
113 CdmPromiseResult();
114 CdmPromiseResult(::media::MediaKeys::Exception exception,
115 uint32_t system_code,
116 std::string error_message);
117 CdmPromiseResult(const CdmPromiseResult& other);
118 ~CdmPromiseResult();
119
120 static CdmPromiseResult SuccessResult();
121
122 bool success() const { return success_; }
123 ::media::MediaKeys::Exception exception() const { return exception_; }
124 uint32_t system_code() const { return system_code_; }
125 const std::string& error_message() const { return error_message_; }
126
127 private:
128 bool success_;
129 ::media::MediaKeys::Exception exception_;
130 uint32_t system_code_;
131 std::string error_message_;
132 };
133
134 } // namespace remoting
135 } // namespace media
136
137 #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