• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 CAST_STREAMING_SENDER_MESSAGE_H_
6 #define CAST_STREAMING_SENDER_MESSAGE_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "absl/types/variant.h"
13 #include "cast/streaming/offer_messages.h"
14 #include "json/value.h"
15 #include "platform/base/error.h"
16 #include "util/osp_logging.h"
17 
18 namespace openscreen {
19 namespace cast {
20 
21 struct SenderMessage {
22  public:
23   // Receiver response message type.
24   enum class Type {
25     // Unknown message type.
26     kUnknown,
27 
28     // OFFER request message.
29     kOffer,
30 
31     // GET_CAPABILITIES request message.
32     kGetCapabilities,
33 
34     // Rpc binary messages. The payload is base64-encoded.
35     kRpc,
36   };
37 
38   static ErrorOr<SenderMessage> Parse(const Json::Value& value);
39   ErrorOr<Json::Value> ToJson() const;
40 
41   Type type = Type::kUnknown;
42   int32_t sequence_number = -1;
43   bool valid = false;
44   absl::variant<absl::monostate,
45                 std::vector<uint8_t>,  // Binary-encoded RPC message.
46                 Offer,
47                 std::string>
48       body;
49 };
50 
51 }  // namespace cast
52 }  // namespace openscreen
53 
54 #endif  // CAST_STREAMING_SENDER_MESSAGE_H_
55