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 32 /// ANSWER message fields. 33 constexpr char kMessageTypeAnswer[] = "ANSWER"; 34 constexpr char kAnswerMessageBody[] = "answer"; 35 constexpr char kResult[] = "result"; 36 constexpr char kResultOk[] = "ok"; 37 constexpr char kResultError[] = "error"; 38 constexpr char kErrorMessageBody[] = "error"; 39 constexpr char kErrorCode[] = "code"; 40 constexpr char kErrorDescription[] = "description"; 41 42 // Other message fields. 43 constexpr char kRpcMessageBody[] = "rpc"; 44 constexpr char kCapabilitiesMessageBody[] = "capabilities"; 45 constexpr char kStatusMessageBody[] = "status"; 46 47 // Conversion methods for codec message fields. 48 const char* CodecToString(AudioCodec codec); 49 ErrorOr<AudioCodec> StringToAudioCodec(absl::string_view name); 50 51 const char* CodecToString(VideoCodec codec); 52 ErrorOr<VideoCodec> StringToVideoCodec(absl::string_view name); 53 54 } // namespace cast 55 } // namespace openscreen 56 57 #endif // CAST_STREAMING_MESSAGE_FIELDS_H_ 58