jsep.cc (1679B)
1 /* 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "api/jsep.h" 12 13 #include <cstddef> 14 #include <optional> 15 #include <string> 16 17 namespace webrtc { 18 19 const char SessionDescriptionInterface::kOffer[] = "offer"; 20 const char SessionDescriptionInterface::kPrAnswer[] = "pranswer"; 21 const char SessionDescriptionInterface::kAnswer[] = "answer"; 22 const char SessionDescriptionInterface::kRollback[] = "rollback"; 23 24 const char* SdpTypeToString(SdpType type) { 25 switch (type) { 26 case SdpType::kOffer: 27 return SessionDescriptionInterface::kOffer; 28 case SdpType::kPrAnswer: 29 return SessionDescriptionInterface::kPrAnswer; 30 case SdpType::kAnswer: 31 return SessionDescriptionInterface::kAnswer; 32 case SdpType::kRollback: 33 return SessionDescriptionInterface::kRollback; 34 } 35 return ""; 36 } 37 38 std::optional<SdpType> SdpTypeFromString(const std::string& type_str) { 39 if (type_str == SessionDescriptionInterface::kOffer) { 40 return SdpType::kOffer; 41 } else if (type_str == SessionDescriptionInterface::kPrAnswer) { 42 return SdpType::kPrAnswer; 43 } else if (type_str == SessionDescriptionInterface::kAnswer) { 44 return SdpType::kAnswer; 45 } else if (type_str == SessionDescriptionInterface::kRollback) { 46 return SdpType::kRollback; 47 } else { 48 return std::nullopt; 49 } 50 } 51 52 } // namespace webrtc