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

Unified 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: Change some field to unit32 and add missing enum type in RPC Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/remoting/rpc/proto_utils.h
diff --git a/media/remoting/rpc/proto_utils.h b/media/remoting/rpc/proto_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..0549cc6ecda0450b0a02cbef52b60d833336ff5f
--- /dev/null
+++ b/media/remoting/rpc/proto_utils.h
@@ -0,0 +1,129 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_REMOTING_RPC_PROTO_UTILS_H_
+#define MEDIA_REMOTING_RPC_PROTO_UTILS_H_
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "media/base/audio_decoder_config.h"
+#include "media/base/cdm_config.h"
+#include "media/base/cdm_key_information.h"
+#include "media/base/decoder_buffer.h"
+#include "media/base/demuxer_stream.h"
+#include "media/base/eme_constants.h"
+#include "media/base/media_keys.h"
+#include "media/base/pipeline_status.h"
+#include "media/base/video_decoder_config.h"
+#include "media/remoting/remoting_rpc_message.pb.h"
+
+namespace media {
+namespace remoting {
+
+class CdmPromiseResult;
+
+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.
+extern const int kReceiverHandle;
+
+// Utility class to serialize and de-serialize between media::DecoderBuffer and
+// 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.
+// decoder buffer using proto buffer and append the decoder buffer at the end.
+// into byte array for data transmission.
+//
+// DecoderBufferSegment {
+// // Payload version. Default value is 0.
+// u8 payload_version;
+//
+// // Length of protobuf-encoded media::DecoderBuffer(except for data).
+// u16 buffer_segment_size;
+// // Protobuf-encoded media::DecoderBuffer.
+// u8[buffer_segment_size] buffer_segment;
+//
+// // Length of data in media::DecoderBuffer.
+// u32 data_buffer_size;
+// // media::DecoderBuffer data.
+// u8[data_buffer_size] data_buffer;
+//};
+
+// Converts DecoderBufferSegment into byte array.
+std::vector<uint8_t> DecoderBufferToByteArray(
+ const scoped_refptr<::media::DecoderBuffer>& decoder_buffer);
+
+// Converts byte array into DecoderBufferSegment.
+scoped_refptr<::media::DecoderBuffer> ByteArrayToDecoderBuffer(
+ const uint8_t* data,
+ uint32_t size);
+
+// Data type conversion between ::media::AudioDecoderConfig and proto buffer.
+void ConvertAudioDecoderConfigToProto(
+ const ::media::AudioDecoderConfig& audio_config,
+ pb::AudioDecoderConfig* audio_message);
+bool ConvertProtoToAudioDecoderConfig(
+ const pb::AudioDecoderConfig& audio_message,
+ ::media::AudioDecoderConfig* audio_config);
+
+// Data type conversion between ::media::VideoDecoderConfig and proto buffer.
+void ConvertVideoDecoderConfigToProto(
+ const ::media::VideoDecoderConfig& video_config,
+ pb::VideoDecoderConfig* video_message);
+bool ConvertProtoToVideoDecoderConfig(
+ const pb::VideoDecoderConfig& video_message,
+ ::media::VideoDecoderConfig* video_config);
+
+// Data type conversion between ::media::CdmKeysInfo and proto buffer.
+void ConvertCdmKeyInfoToProto(
+ const ::media::CdmKeysInfo& keys_information,
+ pb::CdmClientOnSessionKeysChange* key_change_message);
+void ConvertProtoToCdmKeyInfo(
+ const pb::CdmClientOnSessionKeysChange keychange_message,
+ CdmKeysInfo* key_information);
+
+// Data type conversion between CdmPromiseResult and proto buffer.
+void ConvertCdmPromiseToProto(const CdmPromiseResult& result,
+ pb::CdmPromise* promise_message);
+void ConvertCdmPromiseWithSessionIdToProto(const CdmPromiseResult& result,
+ const std::string& session_id,
+ pb::CdmPromise* promise_message);
+void ConvertCdmPromiseWithCdmIdToProto(const CdmPromiseResult& result,
+ int cdm_id,
+ pb::CdmPromise* promise_message);
+bool ConvertProtoToCdmPromise(const pb::CdmPromise& promise_message,
+ CdmPromiseResult* result);
+bool ConvertProtoToCdmPromiseWithCdmIdSessionId(const pb::RpcMessage& message,
+ CdmPromiseResult* result,
+ int* cdm_id,
+ std::string* session_id);
+
+//==================================================================
+class CdmPromiseResult {
+ public:
+ CdmPromiseResult();
+ CdmPromiseResult(::media::MediaKeys::Exception exception,
+ uint32_t system_code,
+ std::string error_message);
+ CdmPromiseResult(const CdmPromiseResult& other);
+ ~CdmPromiseResult();
+
+ static CdmPromiseResult SuccessResult();
+
+ bool success() const { return success_; }
+ ::media::MediaKeys::Exception exception() const { return exception_; }
+ uint32_t system_code() const { return system_code_; }
+ const std::string& error_message() const { return error_message_; }
+
+ private:
+ bool success_;
+ ::media::MediaKeys::Exception exception_;
+ uint32_t system_code_;
+ std::string error_message_;
+};
+
+} // namespace remoting
+} // namespace media
+
+#endif // MEDIA_REMOTING_RPC_PROTO_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698