xref: /aosp_15_r20/external/openscreen/cast/streaming/message_fields.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
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_MESSAGE_FIELDS_H_
6 #define CAST_STREAMING_MESSAGE_FIELDS_H_
7 
8 #include <string>
9 
10 #include "absl/strings/string_view.h"
11 #include "cast/streaming/constants.h"
12 #include "platform/base/error.h"
13 
14 namespace openscreen {
15 namespace cast {
16 
17 /// NOTE: Constants here are all taken from the Cast V2: Mirroring Control
18 /// Protocol specification.
19 
20 // Namespace for OFFER/ANSWER messages.
21 constexpr char kCastWebrtcNamespace[] = "urn:x-cast:com.google.cast.webrtc";
22 constexpr char kCastRemotingNamespace[] = "urn:x-cast:com.google.cast.remoting";
23 
24 // JSON message field values specific to the Sender Session.
25 constexpr char kMessageType[] = "type";
26 
27 // List of OFFER message fields.
28 constexpr char kMessageTypeOffer[] = "OFFER";
29 constexpr char kOfferMessageBody[] = "offer";
30 constexpr char kSequenceNumber[] = "seqNum";
31 constexpr char kCodecName[] = "codecName";
32 
33 /// ANSWER message fields.
34 constexpr char kMessageTypeAnswer[] = "ANSWER";
35 constexpr char kAnswerMessageBody[] = "answer";
36 constexpr char kResult[] = "result";
37 constexpr char kResultOk[] = "ok";
38 constexpr char kResultError[] = "error";
39 constexpr char kErrorMessageBody[] = "error";
40 constexpr char kErrorCode[] = "code";
41 constexpr char kErrorDescription[] = "description";
42 
43 // Other message fields.
44 constexpr char kRpcMessageBody[] = "rpc";
45 constexpr char kCapabilitiesMessageBody[] = "capabilities";
46 constexpr char kStatusMessageBody[] = "status";
47 
48 // Conversion methods for codec message fields.
49 const char* CodecToString(AudioCodec codec);
50 ErrorOr<AudioCodec> StringToAudioCodec(absl::string_view name);
51 
52 const char* CodecToString(VideoCodec codec);
53 ErrorOr<VideoCodec> StringToVideoCodec(absl::string_view name);
54 
55 }  // namespace cast
56 }  // namespace openscreen
57 
58 #endif  // CAST_STREAMING_MESSAGE_FIELDS_H_
59