henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2013 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #import "RTCEnumConverter.h" |
| 29 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 30 | #include "webrtc/api/peerconnectioninterface.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 31 | |
| 32 | @implementation RTCEnumConverter |
| 33 | |
| 34 | + (RTCICEConnectionState)convertIceConnectionStateToObjC: |
| 35 | (webrtc::PeerConnectionInterface::IceConnectionState)nativeState { |
| 36 | switch (nativeState) { |
| 37 | case webrtc::PeerConnectionInterface::kIceConnectionNew: |
| 38 | return RTCICEConnectionNew; |
| 39 | case webrtc::PeerConnectionInterface::kIceConnectionChecking: |
| 40 | return RTCICEConnectionChecking; |
| 41 | case webrtc::PeerConnectionInterface::kIceConnectionConnected: |
| 42 | return RTCICEConnectionConnected; |
| 43 | case webrtc::PeerConnectionInterface::kIceConnectionCompleted: |
| 44 | return RTCICEConnectionCompleted; |
| 45 | case webrtc::PeerConnectionInterface::kIceConnectionFailed: |
| 46 | return RTCICEConnectionFailed; |
| 47 | case webrtc::PeerConnectionInterface::kIceConnectionDisconnected: |
| 48 | return RTCICEConnectionDisconnected; |
| 49 | case webrtc::PeerConnectionInterface::kIceConnectionClosed: |
| 50 | return RTCICEConnectionClosed; |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 51 | case webrtc::PeerConnectionInterface::kIceConnectionMax: |
| 52 | NSAssert(NO, @"kIceConnectionMax not allowed"); |
| 53 | return RTCICEConnectionMax; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
| 57 | + (RTCICEGatheringState)convertIceGatheringStateToObjC: |
| 58 | (webrtc::PeerConnectionInterface::IceGatheringState)nativeState { |
| 59 | switch (nativeState) { |
| 60 | case webrtc::PeerConnectionInterface::kIceGatheringNew: |
| 61 | return RTCICEGatheringNew; |
| 62 | case webrtc::PeerConnectionInterface::kIceGatheringGathering: |
| 63 | return RTCICEGatheringGathering; |
| 64 | case webrtc::PeerConnectionInterface::kIceGatheringComplete: |
| 65 | return RTCICEGatheringComplete; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | + (RTCSignalingState)convertSignalingStateToObjC: |
| 70 | (webrtc::PeerConnectionInterface::SignalingState)nativeState { |
| 71 | switch (nativeState) { |
| 72 | case webrtc::PeerConnectionInterface::kStable: |
| 73 | return RTCSignalingStable; |
| 74 | case webrtc::PeerConnectionInterface::kHaveLocalOffer: |
| 75 | return RTCSignalingHaveLocalOffer; |
| 76 | case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: |
| 77 | return RTCSignalingHaveLocalPrAnswer; |
| 78 | case webrtc::PeerConnectionInterface::kHaveRemoteOffer: |
| 79 | return RTCSignalingHaveRemoteOffer; |
| 80 | case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer: |
| 81 | return RTCSignalingHaveRemotePrAnswer; |
| 82 | case webrtc::PeerConnectionInterface::kClosed: |
| 83 | return RTCSignalingClosed; |
| 84 | } |
| 85 | } |
| 86 | |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 87 | + (webrtc::PeerConnectionInterface::StatsOutputLevel) |
| 88 | convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel { |
| 89 | switch (statsOutputLevel) { |
| 90 | case RTCStatsOutputLevelStandard: |
| 91 | return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard; |
| 92 | case RTCStatsOutputLevelDebug: |
| 93 | return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; |
| 94 | } |
| 95 | } |
| 96 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 97 | + (RTCSourceState)convertSourceStateToObjC: |
| 98 | (webrtc::MediaSourceInterface::SourceState)nativeState { |
| 99 | switch (nativeState) { |
| 100 | case webrtc::MediaSourceInterface::kInitializing: |
| 101 | return RTCSourceStateInitializing; |
| 102 | case webrtc::MediaSourceInterface::kLive: |
| 103 | return RTCSourceStateLive; |
| 104 | case webrtc::MediaSourceInterface::kEnded: |
| 105 | return RTCSourceStateEnded; |
| 106 | case webrtc::MediaSourceInterface::kMuted: |
| 107 | return RTCSourceStateMuted; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | + (webrtc::MediaStreamTrackInterface::TrackState) |
| 112 | convertTrackStateToNative:(RTCTrackState)state { |
| 113 | switch (state) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 114 | case RTCTrackStateLive: |
| 115 | return webrtc::MediaStreamTrackInterface::kLive; |
| 116 | case RTCTrackStateEnded: |
| 117 | return webrtc::MediaStreamTrackInterface::kEnded; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
| 121 | + (RTCTrackState)convertTrackStateToObjC: |
| 122 | (webrtc::MediaStreamTrackInterface::TrackState)nativeState { |
| 123 | switch (nativeState) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 124 | case webrtc::MediaStreamTrackInterface::kLive: |
| 125 | return RTCTrackStateLive; |
| 126 | case webrtc::MediaStreamTrackInterface::kEnded: |
| 127 | return RTCTrackStateEnded; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Zeke Chin | bc7dd7e | 2015-05-29 14:59:14 -0700 | [diff] [blame] | 131 | + (RTCIceTransportsType)iceTransportsTypeForNativeEnum: |
| 132 | (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnum { |
| 133 | switch (nativeEnum) { |
| 134 | case webrtc::PeerConnectionInterface::kNone: |
| 135 | return kRTCIceTransportsTypeNone; |
| 136 | case webrtc::PeerConnectionInterface::kRelay: |
| 137 | return kRTCIceTransportsTypeRelay; |
| 138 | case webrtc::PeerConnectionInterface::kNoHost: |
| 139 | return kRTCIceTransportsTypeNoHost; |
| 140 | case webrtc::PeerConnectionInterface::kAll: |
| 141 | return kRTCIceTransportsTypeAll; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | + (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnumForIceTransportsType: |
| 146 | (RTCIceTransportsType)iceTransportsType { |
| 147 | switch (iceTransportsType) { |
| 148 | case kRTCIceTransportsTypeNone: |
| 149 | return webrtc::PeerConnectionInterface::kNone; |
| 150 | case kRTCIceTransportsTypeRelay: |
| 151 | return webrtc::PeerConnectionInterface::kRelay; |
| 152 | case kRTCIceTransportsTypeNoHost: |
| 153 | return webrtc::PeerConnectionInterface::kNoHost; |
| 154 | case kRTCIceTransportsTypeAll: |
| 155 | return webrtc::PeerConnectionInterface::kAll; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | + (RTCBundlePolicy)bundlePolicyForNativeEnum: |
| 160 | (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnum { |
| 161 | switch (nativeEnum) { |
| 162 | case webrtc::PeerConnectionInterface::kBundlePolicyBalanced: |
| 163 | return kRTCBundlePolicyBalanced; |
| 164 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle: |
| 165 | return kRTCBundlePolicyMaxBundle; |
| 166 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat: |
| 167 | return kRTCBundlePolicyMaxCompat; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | + (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnumForBundlePolicy: |
| 172 | (RTCBundlePolicy)bundlePolicy { |
| 173 | switch (bundlePolicy) { |
| 174 | case kRTCBundlePolicyBalanced: |
| 175 | return webrtc::PeerConnectionInterface::kBundlePolicyBalanced; |
| 176 | case kRTCBundlePolicyMaxBundle: |
| 177 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 178 | case kRTCBundlePolicyMaxCompat: |
| 179 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativeEnum: |
| 184 | (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnum { |
| 185 | switch (nativeEnum) { |
| 186 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate: |
| 187 | return kRTCRtcpMuxPolicyNegotiate; |
| 188 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: |
| 189 | return kRTCRtcpMuxPolicyRequire; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnumForRtcpMuxPolicy: |
| 194 | (RTCRtcpMuxPolicy)rtcpMuxPolicy { |
| 195 | switch (rtcpMuxPolicy) { |
| 196 | case kRTCRtcpMuxPolicyNegotiate: |
| 197 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate; |
| 198 | case kRTCRtcpMuxPolicyRequire: |
| 199 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativeEnum: |
| 204 | (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnum { |
| 205 | switch (nativeEnum) { |
| 206 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: |
| 207 | return kRTCTcpCandidatePolicyEnabled; |
| 208 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: |
| 209 | return kRTCTcpCandidatePolicyDisabled; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnumForTcpCandidatePolicy: |
| 214 | (RTCTcpCandidatePolicy)tcpCandidatePolicy { |
| 215 | switch (tcpCandidatePolicy) { |
| 216 | case kRTCTcpCandidatePolicyEnabled: |
| 217 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; |
| 218 | case kRTCTcpCandidatePolicyDisabled: |
| 219 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; |
| 220 | } |
| 221 | } |
| 222 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 223 | @end |