1/* 2 * libjingle 3 * Copyright 2013, Google Inc. 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 30#include "talk/app/webrtc/peerconnectioninterface.h" 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; 51 } 52} 53 54+ (RTCICEGatheringState)convertIceGatheringStateToObjC: 55 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState { 56 switch (nativeState) { 57 case webrtc::PeerConnectionInterface::kIceGatheringNew: 58 return RTCICEGatheringNew; 59 case webrtc::PeerConnectionInterface::kIceGatheringGathering: 60 return RTCICEGatheringGathering; 61 case webrtc::PeerConnectionInterface::kIceGatheringComplete: 62 return RTCICEGatheringComplete; 63 } 64} 65 66+ (RTCSignalingState)convertSignalingStateToObjC: 67 (webrtc::PeerConnectionInterface::SignalingState)nativeState { 68 switch (nativeState) { 69 case webrtc::PeerConnectionInterface::kStable: 70 return RTCSignalingStable; 71 case webrtc::PeerConnectionInterface::kHaveLocalOffer: 72 return RTCSignalingHaveLocalOffer; 73 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: 74 return RTCSignalingHaveLocalPrAnswer; 75 case webrtc::PeerConnectionInterface::kHaveRemoteOffer: 76 return RTCSignalingHaveRemoteOffer; 77 case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer: 78 return RTCSignalingHaveRemotePrAnswer; 79 case webrtc::PeerConnectionInterface::kClosed: 80 return RTCSignalingClosed; 81 } 82} 83 84+ (webrtc::PeerConnectionInterface::StatsOutputLevel) 85 convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel { 86 switch (statsOutputLevel) { 87 case RTCStatsOutputLevelStandard: 88 return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard; 89 case RTCStatsOutputLevelDebug: 90 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; 91 } 92} 93 94+ (RTCSourceState)convertSourceStateToObjC: 95 (webrtc::MediaSourceInterface::SourceState)nativeState { 96 switch (nativeState) { 97 case webrtc::MediaSourceInterface::kInitializing: 98 return RTCSourceStateInitializing; 99 case webrtc::MediaSourceInterface::kLive: 100 return RTCSourceStateLive; 101 case webrtc::MediaSourceInterface::kEnded: 102 return RTCSourceStateEnded; 103 case webrtc::MediaSourceInterface::kMuted: 104 return RTCSourceStateMuted; 105 } 106} 107 108+ (webrtc::MediaStreamTrackInterface::TrackState) 109 convertTrackStateToNative:(RTCTrackState)state { 110 switch (state) { 111 case RTCTrackStateInitializing: 112 return webrtc::MediaStreamTrackInterface::kInitializing; 113 case RTCTrackStateLive: 114 return webrtc::MediaStreamTrackInterface::kLive; 115 case RTCTrackStateEnded: 116 return webrtc::MediaStreamTrackInterface::kEnded; 117 case RTCTrackStateFailed: 118 return webrtc::MediaStreamTrackInterface::kFailed; 119 } 120} 121 122+ (RTCTrackState)convertTrackStateToObjC: 123 (webrtc::MediaStreamTrackInterface::TrackState)nativeState { 124 switch (nativeState) { 125 case webrtc::MediaStreamTrackInterface::kInitializing: 126 return RTCTrackStateInitializing; 127 case webrtc::MediaStreamTrackInterface::kLive: 128 return RTCTrackStateLive; 129 case webrtc::MediaStreamTrackInterface::kEnded: 130 return RTCTrackStateEnded; 131 case webrtc::MediaStreamTrackInterface::kFailed: 132 return RTCTrackStateFailed; 133 } 134} 135 136@end 137