├── .travis.yml ├── WebRTC_iOS ├── Pods │ ├── Headers │ │ ├── Private │ │ │ └── SocketRocket │ │ │ │ ├── SRWebSocket.h │ │ │ │ └── SocketRocket.h │ │ └── Public │ │ │ └── SocketRocket │ │ │ ├── SRWebSocket.h │ │ │ └── SocketRocket.h │ ├── Target Support Files │ │ ├── SocketRocket │ │ │ ├── SocketRocket-dummy.m │ │ │ ├── SocketRocket-prefix.pch │ │ │ └── SocketRocket.xcconfig │ │ └── Pods-WebRTC_iOS │ │ │ ├── Pods-WebRTC_iOS-dummy.m │ │ │ ├── Pods-WebRTC_iOS.debug.xcconfig │ │ │ ├── Pods-WebRTC_iOS.release.xcconfig │ │ │ ├── Pods-WebRTC_iOS-acknowledgements.markdown │ │ │ ├── Pods-WebRTC_iOS-acknowledgements.plist │ │ │ ├── Pods-WebRTC_iOS-frameworks.sh │ │ │ └── Pods-WebRTC_iOS-resources.sh │ ├── Manifest.lock │ └── SocketRocket │ │ ├── LICENSE │ │ ├── SocketRocket │ │ ├── SocketRocket.h │ │ └── SRWebSocket.h │ │ └── README.rst ├── Podfile ├── WebRTC_iOS │ ├── WebRTC │ │ └── WebRTC.framework │ │ │ ├── WebRTC │ │ │ ├── Info.plist │ │ │ ├── Modules │ │ │ └── module.modulemap │ │ │ └── Headers │ │ │ ├── RTCSSLAdapter.h │ │ │ ├── RTCTracing.h │ │ │ ├── RTCAudioTrack.h │ │ │ ├── RTCIntervalRange.h │ │ │ ├── RTCMetrics.h │ │ │ ├── RTCVideoRenderer.h │ │ │ ├── RTCMediaSource.h │ │ │ ├── RTCVideoCapturer.h │ │ │ ├── RTCMacros.h │ │ │ ├── RTCCameraPreviewView.h │ │ │ ├── RTCAudioSource.h │ │ │ ├── RTCRtpParameters.h │ │ │ ├── RTCRtpEncodingParameters.h │ │ │ ├── RTCVideoCodecH264.h │ │ │ ├── RTCVideoTrack.h │ │ │ ├── RTCMTLVideoView.h │ │ │ ├── RTCLegacyStatsReport.h │ │ │ ├── RTCVideoCodecFactory.h │ │ │ ├── RTCVideoSource.h │ │ │ ├── RTCMetricsSampleInfo.h │ │ │ ├── RTCRtpSender.h │ │ │ ├── RTCEAGLVideoView.h │ │ │ ├── RTCSessionDescription.h │ │ │ ├── RTCMediaStreamTrack.h │ │ │ ├── RTCVideoViewShading.h │ │ │ ├── RTCIceCandidate.h │ │ │ ├── RTCMediaStream.h │ │ │ ├── RTCDispatcher.h │ │ │ ├── RTCCameraVideoCapturer.h │ │ │ ├── RTCDataChannelConfiguration.h │ │ │ ├── RTCAudioSessionConfiguration.h │ │ │ ├── UIDevice+RTCDevice.h │ │ │ ├── RTCAVFoundationVideoSource.h │ │ │ ├── RTCFieldTrials.h │ │ │ ├── WebRTC.h │ │ │ ├── RTCMediaConstraints.h │ │ │ ├── RTCRtpCodecParameters.h │ │ │ ├── RTCLogging.h │ │ │ ├── RTCFileLogger.h │ │ │ ├── RTCRtpReceiver.h │ │ │ ├── RTCIceServer.h │ │ │ ├── RTCPeerConnectionFactory.h │ │ │ ├── RTCVideoFrameBuffer.h │ │ │ ├── RTCVideoFrame.h │ │ │ ├── RTCDataChannel.h │ │ │ ├── RTCConfiguration.h │ │ │ ├── RTCVideoCodec.h │ │ │ ├── RTCPeerConnection.h │ │ │ └── RTCAudioSession.h │ ├── ViewController.h │ ├── ViewController │ │ ├── FriendListViewController.h │ │ ├── ChatViewController.h │ │ ├── ChatViewController.m │ │ └── FriendListViewController.m │ ├── AppDelegate.h │ ├── main.m │ ├── ViewController.m │ ├── Info.plist │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── WebRTCHelper │ │ ├── WebRTCHelper.h │ │ └── WebRTCHelper.m │ └── AppDelegate.m ├── WebRTC_iOS.xcodeproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Podfile.lock ├── WebRTC_iOS.xcworkspace │ └── contents.xcworkspacedata ├── WebRTC_iOSTests │ ├── Info.plist │ └── WebRTC_iOSTests.m └── WebRTC_iOSUITests │ ├── Info.plist │ └── WebRTC_iOSUITests.m ├── LICENSE ├── README.md └── .gitignore /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode8.3 2 | language: objective-c 3 | xcode_workspace: WebRTC_iOS.xcworkspace 4 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Headers/Private/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SRWebSocket.h -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Headers/Private/SocketRocket/SocketRocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SocketRocket.h -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Headers/Public/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SRWebSocket.h -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Headers/Public/SocketRocket/SocketRocket.h: -------------------------------------------------------------------------------- 1 | ../../../SocketRocket/SocketRocket/SocketRocket.h -------------------------------------------------------------------------------- /WebRTC_iOS/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios,"8.0" 2 | 3 | target "WebRTC_iOS" do 4 | pod 'SocketRocket' 5 | end 6 | 7 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/WebRTC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MFJun/WebRTC_iOS/HEAD/WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/WebRTC -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MFJun/WebRTC_iOS/HEAD/WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Info.plist -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module WebRTC { 2 | umbrella header "WebRTC.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/SocketRocket/SocketRocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SocketRocket : NSObject 3 | @end 4 | @implementation PodsDummy_SocketRocket 5 | @end 6 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_WebRTC_iOS : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_WebRTC_iOS 5 | @end 6 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WebRTC_iOS/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SocketRocket (0.5.1) 3 | 4 | DEPENDENCIES: 5 | - SocketRocket 6 | 7 | SPEC CHECKSUMS: 8 | SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531 9 | 10 | PODFILE CHECKSUM: 7738991303dc4e0b2311edbca937896f52416536 11 | 12 | COCOAPODS: 1.2.0 13 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SocketRocket (0.5.1) 3 | 4 | DEPENDENCIES: 5 | - SocketRocket 6 | 7 | SPEC CHECKSUMS: 8 | SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531 9 | 10 | PODFILE CHECKSUM: 7738991303dc4e0b2311edbca937896f52416536 11 | 12 | COCOAPODS: 1.2.0 13 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/SocketRocket/SocketRocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController/FriendListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FriendListViewController.h 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/11. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FriendListViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController/ChatViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChatViewController.h 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/11. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ChatViewController : UIViewController 12 | 13 | @property (nonatomic, copy) NSString *userId; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/SocketRocket/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright 2012 Square Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SocketRocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SocketRocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SocketRocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SocketRocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"SocketRocket" -l"icucore" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/SocketRocket/SocketRocket.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SocketRocket 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SocketRocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SocketRocket" 4 | OTHER_LDFLAGS = -l"icucore" -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/SocketRocket 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/SocketRocket/SocketRocket/SocketRocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2012 Square Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOSUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCSSLAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | /** 16 | * Initialize and clean up the SSL library. Failure is fatal. These call the 17 | * corresponding functions in webrtc/rtc_base/ssladapter.h. 18 | */ 19 | RTC_EXTERN BOOL RTCInitializeSSL(); 20 | RTC_EXTERN BOOL RTCCleanupSSL(); 21 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SocketRocket 5 | 6 | 7 | Copyright 2012 Square Inc. 8 | 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the License is distributed on an "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | See the License for the specific language governing permissions and 19 | limitations under the License. 20 | 21 | 22 | Generated by CocoaPods - https://cocoapods.org 23 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCTracing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | RTC_EXTERN void RTCSetupInternalTracer(); 16 | /** Starts capture to specified file. Must be a valid writable path. 17 | * Returns YES if capture starts. 18 | */ 19 | RTC_EXTERN BOOL RTCStartInternalCapture(NSString *filePath); 20 | RTC_EXTERN void RTCStopInternalCapture(); 21 | RTC_EXTERN void RTCShutdownInternalTracer(); 22 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCAudioTrack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @class RTCAudioSource; 17 | 18 | RTC_EXPORT 19 | @interface RTCAudioTrack : RTCMediaStreamTrack 20 | 21 | - (instancetype)init NS_UNAVAILABLE; 22 | 23 | /** The audio source for this audio track. */ 24 | @property(nonatomic, readonly) RTCAudioSource *source; 25 | 26 | @end 27 | 28 | NS_ASSUME_NONNULL_END 29 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCIntervalRange.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface RTCIntervalRange : NSObject 16 | 17 | @property(nonatomic, readonly) NSInteger min; 18 | @property(nonatomic, readonly) NSInteger max; 19 | 20 | - (instancetype)init; 21 | - (instancetype)initWithMin:(NSInteger)min 22 | max:(NSInteger)max 23 | NS_DESIGNATED_INITIALIZER; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | 29 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMetrics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | #import 15 | 16 | /** 17 | * Enables gathering of metrics (which can be fetched with 18 | * RTCGetAndResetMetrics). Must be called before any other call into WebRTC. 19 | */ 20 | RTC_EXTERN void RTCEnableMetrics(); 21 | 22 | /** Gets and clears native histograms. */ 23 | RTC_EXTERN NSArray *RTCGetAndResetMetrics(); 24 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #if TARGET_OS_IPHONE 13 | #import 14 | #endif 15 | 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | @class RTCVideoFrame; 21 | 22 | RTC_EXPORT 23 | @protocol RTCVideoRenderer 24 | 25 | /** The size of the frame. */ 26 | - (void)setSize:(CGSize)size; 27 | 28 | /** The frame to be displayed. */ 29 | - (void)renderFrame:(nullable RTCVideoFrame *)frame; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMediaSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | typedef NS_ENUM(NSInteger, RTCSourceState) { 16 | RTCSourceStateInitializing, 17 | RTCSourceStateLive, 18 | RTCSourceStateEnded, 19 | RTCSourceStateMuted, 20 | }; 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | RTC_EXPORT 25 | @interface RTCMediaSource : NSObject 26 | 27 | /** The current state of the RTCMediaSource. */ 28 | @property(nonatomic, readonly) RTCSourceState state; 29 | 30 | - (instancetype)init NS_UNAVAILABLE; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoCapturer.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @class RTCVideoCapturer; 16 | 17 | RTC_EXPORT 18 | @protocol RTCVideoCapturerDelegate 19 | - (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame; 20 | @end 21 | 22 | RTC_EXPORT 23 | @interface RTCVideoCapturer : NSObject 24 | 25 | @property(nonatomic, readonly, weak) id delegate; 26 | 27 | - (instancetype)initWithDelegate:(id)delegate; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #ifndef WEBRTC_SDK_OBJC_FRAMEWORK_HEADERS_WEBRTC_RTCMACROS_H_ 12 | #define WEBRTC_SDK_OBJC_FRAMEWORK_HEADERS_WEBRTC_RTCMACROS_H_ 13 | 14 | #define RTC_EXPORT __attribute__((visibility("default"))) 15 | 16 | #if defined(__cplusplus) 17 | #define RTC_EXTERN extern "C" RTC_EXPORT 18 | #else 19 | #define RTC_EXTERN extern RTC_EXPORT 20 | #endif 21 | 22 | #ifdef __OBJC__ 23 | #define RTC_FWD_DECL_OBJC_CLASS(classname) @class classname 24 | #else 25 | #define RTC_FWD_DECL_OBJC_CLASS(classname) typedef struct objc_object classname 26 | #endif 27 | 28 | #endif // WEBRTC_SDK_OBJC_FRAMEWORK_HEADERS_WEBRTC_RTCMACROS_H_ 29 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOSTests/WebRTC_iOSTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebRTC_iOSTests.m 3 | // WebRTC_iOSTests 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebRTC_iOSTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WebRTC_iOSTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 MFJun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WebRTC_iOS 2 | [![Build Status](https://travis-ci.org/MFJun/WebRTC_iOS.svg?branch=master)](https://travis-ci.org/MFJun/WebRTC_iOS) 3 | 4 | ### 下载与编译 5 | WebRTC.framework下载与编译,可以看这篇文章[iOS下载、编译WebRTC](http://www.jianshu.com/p/64bd7f5b18b1) 6 | 7 | ### 使用 8 | 9 | 需要一个服务器端,交换sdp、ice,使用的是[tuyaohui](https://github.com/tuyaohui)用nodejs写好的后台,交互用的是WebSocket,请在[WebRTC](https://github.com/tuyaohui/WebRTC_iOS)中下载[SkyRTC-demo-master](https://github.com/tuyaohui/WebRTC_iOS/tree/master/iOS下音视频通信的实现-基于WebRTC/Server%26WebClient),我刚开始学习WebRTC也是从[iOS下音视频通信-基于WebRTC](http://www.jianshu.com/p/c49da1d93df4)学习,写的很棒,但是因为该WebRTC版本与openssl冲突,所以,我从官网下载了新的版本,编译后,用新版本写了demo 10 | 11 | 安装Node.js及npm环境,SkyRTC-demo-master下载后,启动 12 | ``` 13 | cd SkyRTC-demo-master 14 | node server.js 15 | ``` 16 | 17 | 修改IP地址为你电脑的IP地址,172.16.102.59是我的IP地址 18 | ``` 19 | [[WebRTCHelper sharedInstance] connectServer:@"172.16.102.59" port:@"3000" room:@"100"]; 20 | ``` 21 | 22 | ### 测试 23 | 24 | 模拟器无法进行视频通信,如果进行视频测试,请准备两个iPhone 25 | 手机需要和电脑同处一个局域网(wifi下),跨网通信需要有效的STUN Server,我没有找到,所以只能在局域网中使用,如果有人找到了,可以分享给我(捂脸) 26 | 27 | ### 参考文章 28 | [iOS下音视频通信-基于WebRTC](http://www.jianshu.com/p/c49da1d93df4) 29 | 30 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCCameraPreviewView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | #import 15 | 16 | @class AVCaptureSession; 17 | @class RTCAVFoundationVideoSource; 18 | 19 | /** RTCCameraPreviewView is a view that renders local video from an 20 | * AVCaptureSession. 21 | */ 22 | RTC_EXPORT 23 | @interface RTCCameraPreviewView : UIView 24 | 25 | /** The capture session being rendered in the view. Capture session 26 | * is assigned to AVCaptureVideoPreviewLayer async in the same 27 | * queue that the AVCaptureSession is started/stopped. 28 | */ 29 | @property(nonatomic, strong) AVCaptureSession *captureSession; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCAudioSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | RTC_EXPORT 19 | @interface RTCAudioSource : RTCMediaSource 20 | 21 | - (instancetype)init NS_UNAVAILABLE; 22 | 23 | // Sets the volume for the RTCMediaSource. |volume| is a gain value in the range 24 | // [0, 10]. 25 | // Temporary fix to be able to modify volume of remote audio tracks. 26 | // TODO(kthelgason): Property stays here temporarily until a proper volume-api 27 | // is available on the surface exposed by webrtc. 28 | @property(nonatomic, assign) double volume; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCRtpParameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | RTC_EXPORT 20 | @interface RTCRtpParameters : NSObject 21 | 22 | /** The currently active encodings in the order of preference. */ 23 | @property(nonatomic, copy) NSArray *encodings; 24 | 25 | /** The negotiated set of send codecs in order of preference. */ 26 | @property(nonatomic, copy) NSArray *codecs; 27 | 28 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCRtpEncodingParameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | RTC_EXPORT 18 | @interface RTCRtpEncodingParameters : NSObject 19 | 20 | /** Controls whether the encoding is currently transmitted. */ 21 | @property(nonatomic, assign) BOOL isActive; 22 | 23 | /** The maximum bitrate to use for the encoding, or nil if there is no 24 | * limit. 25 | */ 26 | @property(nonatomic, copy, nullable) NSNumber *maxBitrateBps; 27 | 28 | /** The SSRC being used by this encoding. */ 29 | @property(nonatomic, readonly, nullable) NSNumber *ssrc; 30 | 31 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoCodecH264.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | #import 14 | #import 15 | 16 | /** Encoder. */ 17 | RTC_EXPORT 18 | @interface RTCVideoEncoderH264 : NSObject 19 | 20 | - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo; 21 | 22 | @end 23 | 24 | /** Decoder. */ 25 | RTC_EXPORT 26 | @interface RTCVideoDecoderH264 : NSObject 27 | @end 28 | 29 | /** Encoder factory. */ 30 | RTC_EXPORT 31 | @interface RTCVideoEncoderFactoryH264 : NSObject 32 | @end 33 | 34 | /** Decoder factory. */ 35 | RTC_EXPORT 36 | @interface RTCVideoDecoderFactoryH264 : NSObject 37 | @end 38 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoTrack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @protocol RTCVideoRenderer; 18 | @class RTCPeerConnectionFactory; 19 | @class RTCVideoSource; 20 | 21 | RTC_EXPORT 22 | @interface RTCVideoTrack : RTCMediaStreamTrack 23 | 24 | /** The video source for this video track. */ 25 | @property(nonatomic, readonly) RTCVideoSource *source; 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | /** Register a renderer that will render all frames received on this track. */ 30 | - (void)addRenderer:(id)renderer; 31 | 32 | /** Deregister a renderer. */ 33 | - (void)removeRenderer:(id)renderer; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMTLVideoView.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | #import "WebRTC/RTCVideoRenderer.h" 14 | 15 | // Check if metal is supported in WebRTC. 16 | // NOTE: Currently arm64 == Metal. 17 | #if defined(__aarch64__) 18 | #define RTC_SUPPORTS_METAL 19 | #endif 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | /** 24 | * RTCMTLVideoView is thin wrapper around MTKView. 25 | * 26 | * It has id property that renders video frames in the view's 27 | * bounds using Metal. 28 | * NOTE: always check if metal is available on the running device via 29 | * RTC_SUPPORTS_METAL macro before initializing this class. 30 | */ 31 | NS_CLASS_AVAILABLE_IOS(9) 32 | 33 | RTC_EXPORT 34 | @interface RTCMTLVideoView : UIView 35 | 36 | @end 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCLegacyStatsReport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | /** This does not currently conform to the spec. */ 18 | RTC_EXPORT 19 | @interface RTCLegacyStatsReport : NSObject 20 | 21 | /** Time since 1970-01-01T00:00:00Z in milliseconds. */ 22 | @property(nonatomic, readonly) CFTimeInterval timestamp; 23 | 24 | /** The type of stats held by this object. */ 25 | @property(nonatomic, readonly) NSString *type; 26 | 27 | /** The identifier for this object. */ 28 | @property(nonatomic, readonly) NSString *reportId; 29 | 30 | /** A dictionary holding the actual stats. */ 31 | @property(nonatomic, readonly) NSDictionary *values; 32 | 33 | - (instancetype)init NS_UNAVAILABLE; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoCodecFactory.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | #import 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | /** RTCVideoEncoderFactory is an Objective-C version of cricket::WebRtcVideoEncoderFactory. */ 19 | RTC_EXPORT 20 | @protocol RTCVideoEncoderFactory 21 | 22 | - (id)createEncoder:(RTCVideoCodecInfo *)info; 23 | - (NSArray *)supportedCodecs; 24 | 25 | @end 26 | 27 | /** RTCVideoDecoderFactory is an Objective-C version of cricket::WebRtcVideoDecoderFactory. */ 28 | RTC_EXPORT 29 | @protocol RTCVideoDecoderFactory 30 | 31 | - (id)createDecoder:(RTCVideoCodecInfo *)info; 32 | - (NSArray *)supportedCodecs; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "FriendListViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | 22 | UIButton *connectBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 23 | connectBtn.frame = CGRectMake(0, 0, 150, 40); 24 | connectBtn.center = self.view.center; 25 | connectBtn.backgroundColor = [UIColor blackColor]; 26 | [connectBtn setTitle:@"进入聊天室" forState:UIControlStateNormal]; 27 | [connectBtn addTarget:self action:@selector(enterChatRoom) forControlEvents:UIControlEventTouchUpInside]; 28 | [self.view addSubview:connectBtn]; 29 | } 30 | 31 | - (void)enterChatRoom 32 | { 33 | FriendListViewController *friendListViewController = [[FriendListViewController alloc] init]; 34 | [self.navigationController pushViewController:friendListViewController animated:YES]; 35 | } 36 | 37 | - (void)didReceiveMemoryWarning { 38 | [super didReceiveMemoryWarning]; 39 | // Dispose of any resources that can be recreated. 40 | } 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | RTC_EXPORT 20 | 21 | @interface RTCVideoSource : RTCMediaSource 22 | 23 | - (instancetype)init NS_UNAVAILABLE; 24 | 25 | /** 26 | * Calling this function will cause frames to be scaled down to the 27 | * requested resolution. Also, frames will be cropped to match the 28 | * requested aspect ratio, and frames will be dropped to match the 29 | * requested fps. The requested aspect ratio is orientation agnostic and 30 | * will be adjusted to maintain the input orientation, so it doesn't 31 | * matter if e.g. 1280x720 or 720x1280 is requested. 32 | */ 33 | - (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOSUITests/WebRTC_iOSUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebRTC_iOSUITests.m 3 | // WebRTC_iOSUITests 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebRTC_iOSUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WebRTC_iOSUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMetricsSampleInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | RTC_EXPORT 18 | @interface RTCMetricsSampleInfo : NSObject 19 | 20 | /** 21 | * Example of RTCMetricsSampleInfo: 22 | * name: "WebRTC.Video.InputFramesPerSecond" 23 | * min: 1 24 | * max: 100 25 | * bucketCount: 50 26 | * samples: [29]:2 [30]:1 27 | */ 28 | 29 | /** The name of the histogram. */ 30 | @property(nonatomic, readonly) NSString *name; 31 | 32 | /** The minimum bucket value. */ 33 | @property(nonatomic, readonly) int min; 34 | 35 | /** The maximum bucket value. */ 36 | @property(nonatomic, readonly) int max; 37 | 38 | /** The number of buckets. */ 39 | @property(nonatomic, readonly) int bucketCount; 40 | 41 | /** A dictionary holding the samples . */ 42 | @property(nonatomic, readonly) NSDictionary *samples; 43 | 44 | - (instancetype)init NS_UNAVAILABLE; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCRtpSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | RTC_EXPORT 20 | @protocol RTCRtpSender 21 | 22 | /** A unique identifier for this sender. */ 23 | @property(nonatomic, readonly) NSString *senderId; 24 | 25 | /** The currently active RTCRtpParameters, as defined in 26 | * https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters. 27 | */ 28 | @property(nonatomic, copy) RTCRtpParameters *parameters; 29 | 30 | /** The RTCMediaStreamTrack associated with the sender. 31 | * Note: reading this property returns a new instance of 32 | * RTCMediaStreamTrack. Use isEqual: instead of == to compare 33 | * RTCMediaStreamTrack instances. 34 | */ 35 | @property(nonatomic, copy, nullable) RTCMediaStreamTrack *track; 36 | 37 | @end 38 | 39 | RTC_EXPORT 40 | @interface RTCRtpSender : NSObject 41 | 42 | - (instancetype)init NS_UNAVAILABLE; 43 | 44 | @end 45 | 46 | NS_ASSUME_NONNULL_END 47 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCEAGLVideoView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | #import 15 | #import 16 | #import 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | @class RTCEAGLVideoView; 21 | RTC_EXPORT 22 | @protocol RTCEAGLVideoViewDelegate 23 | 24 | - (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size; 25 | 26 | @end 27 | 28 | /** 29 | * RTCEAGLVideoView is an RTCVideoRenderer which renders video frames in its 30 | * bounds using OpenGLES 2.0 or OpenGLES 3.0. 31 | */ 32 | RTC_EXPORT 33 | @interface RTCEAGLVideoView : UIView 34 | 35 | @property(nonatomic, weak) id delegate; 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame 38 | shader:(id)shader NS_DESIGNATED_INITIALIZER; 39 | 40 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 41 | shader:(id)shader NS_DESIGNATED_INITIALIZER; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCSessionDescription.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | /** 16 | * Represents the session description type. This exposes the same types that are 17 | * in C++, which doesn't include the rollback type that is in the W3C spec. 18 | */ 19 | typedef NS_ENUM(NSInteger, RTCSdpType) { 20 | RTCSdpTypeOffer, 21 | RTCSdpTypePrAnswer, 22 | RTCSdpTypeAnswer, 23 | }; 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | RTC_EXPORT 28 | @interface RTCSessionDescription : NSObject 29 | 30 | /** The type of session description. */ 31 | @property(nonatomic, readonly) RTCSdpType type; 32 | 33 | /** The SDP string representation of this session description. */ 34 | @property(nonatomic, readonly) NSString *sdp; 35 | 36 | - (instancetype)init NS_UNAVAILABLE; 37 | 38 | /** Initialize a session description with a type and SDP string. */ 39 | - (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp 40 | NS_DESIGNATED_INITIALIZER; 41 | 42 | + (NSString *)stringForType:(RTCSdpType)type; 43 | 44 | + (RTCSdpType)typeForString:(NSString *)string; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMediaStreamTrack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | /** 16 | * Represents the state of the track. This exposes the same states in C++. 17 | */ 18 | typedef NS_ENUM(NSInteger, RTCMediaStreamTrackState) { 19 | RTCMediaStreamTrackStateLive, 20 | RTCMediaStreamTrackStateEnded 21 | }; 22 | 23 | NS_ASSUME_NONNULL_BEGIN 24 | 25 | RTC_EXTERN NSString * const kRTCMediaStreamTrackKindAudio; 26 | RTC_EXTERN NSString * const kRTCMediaStreamTrackKindVideo; 27 | 28 | RTC_EXPORT 29 | @interface RTCMediaStreamTrack : NSObject 30 | 31 | /** 32 | * The kind of track. For example, "audio" if this track represents an audio 33 | * track and "video" if this track represents a video track. 34 | */ 35 | @property(nonatomic, readonly) NSString *kind; 36 | 37 | /** An identifier string. */ 38 | @property(nonatomic, readonly) NSString *trackId; 39 | 40 | /** The enabled state of the track. */ 41 | @property(nonatomic, assign) BOOL isEnabled; 42 | 43 | /** The state of the track. */ 44 | @property(nonatomic, readonly) RTCMediaStreamTrackState readyState; 45 | 46 | - (instancetype)init NS_UNAVAILABLE; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | ceshi 25 | NSMicrophoneUsageDescription 26 | ceshi 27 | UIBackgroundModes 28 | 29 | voip 30 | 31 | UILaunchStoryboardName 32 | LaunchScreen 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoViewShading.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | /** 18 | * RTCVideoViewShading provides a way for apps to customize the OpenGL(ES) shaders used in 19 | * rendering for the RTCEAGLVideoView/RTCNSGLVideoView. 20 | */ 21 | RTC_EXPORT 22 | @protocol RTCVideoViewShading 23 | 24 | /** Callback for I420 frames. Each plane is given as a texture. */ 25 | - (void)applyShadingForFrameWithWidth:(int)width 26 | height:(int)height 27 | rotation:(RTCVideoRotation)rotation 28 | yPlane:(GLuint)yPlane 29 | uPlane:(GLuint)uPlane 30 | vPlane:(GLuint)vPlane; 31 | 32 | /** Callback for NV12 frames. Each plane is given as a texture. */ 33 | - (void)applyShadingForFrameWithWidth:(int)width 34 | height:(int)height 35 | rotation:(RTCVideoRotation)rotation 36 | yPlane:(GLuint)yPlane 37 | uvPlane:(GLuint)uvPlane; 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCIceCandidate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | RTC_EXPORT 18 | @interface RTCIceCandidate : NSObject 19 | 20 | /** 21 | * If present, the identifier of the "media stream identification" for the media 22 | * component this candidate is associated with. 23 | */ 24 | @property(nonatomic, readonly, nullable) NSString *sdpMid; 25 | 26 | /** 27 | * The index (starting at zero) of the media description this candidate is 28 | * associated with in the SDP. 29 | */ 30 | @property(nonatomic, readonly) int sdpMLineIndex; 31 | 32 | /** The SDP string for this candidate. */ 33 | @property(nonatomic, readonly) NSString *sdp; 34 | 35 | /** The URL of the ICE server which this candidate is gathered from. */ 36 | @property(nonatomic, readonly, nullable) NSString *serverUrl; 37 | 38 | - (instancetype)init NS_UNAVAILABLE; 39 | 40 | /** 41 | * Initialize an RTCIceCandidate from SDP. 42 | */ 43 | - (instancetype)initWithSdp:(NSString *)sdp 44 | sdpMLineIndex:(int)sdpMLineIndex 45 | sdpMid:(nullable NSString *)sdpMid 46 | NS_DESIGNATED_INITIALIZER; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMediaStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @class RTCAudioTrack; 18 | @class RTCPeerConnectionFactory; 19 | @class RTCVideoTrack; 20 | 21 | RTC_EXPORT 22 | @interface RTCMediaStream : NSObject 23 | 24 | /** The audio tracks in this stream. */ 25 | @property(nonatomic, strong, readonly) NSArray *audioTracks; 26 | 27 | /** The video tracks in this stream. */ 28 | @property(nonatomic, strong, readonly) NSArray *videoTracks; 29 | 30 | /** An identifier for this media stream. */ 31 | @property(nonatomic, readonly) NSString *streamId; 32 | 33 | - (instancetype)init NS_UNAVAILABLE; 34 | 35 | /** Adds the given audio track to this media stream. */ 36 | - (void)addAudioTrack:(RTCAudioTrack *)audioTrack; 37 | 38 | /** Adds the given video track to this media stream. */ 39 | - (void)addVideoTrack:(RTCVideoTrack *)videoTrack; 40 | 41 | /** Removes the given audio track to this media stream. */ 42 | - (void)removeAudioTrack:(RTCAudioTrack *)audioTrack; 43 | 44 | /** Removes the given video track to this media stream. */ 45 | - (void)removeVideoTrack:(RTCVideoTrack *)videoTrack; 46 | 47 | @end 48 | 49 | NS_ASSUME_NONNULL_END 50 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCDispatcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | typedef NS_ENUM(NSInteger, RTCDispatcherQueueType) { 16 | // Main dispatcher queue. 17 | RTCDispatcherTypeMain, 18 | // Used for starting/stopping AVCaptureSession, and assigning 19 | // capture session to AVCaptureVideoPreviewLayer. 20 | RTCDispatcherTypeCaptureSession, 21 | // Used for operations on AVAudioSession. 22 | RTCDispatcherTypeAudioSession, 23 | }; 24 | 25 | /** Dispatcher that asynchronously dispatches blocks to a specific 26 | * shared dispatch queue. 27 | */ 28 | RTC_EXPORT 29 | @interface RTCDispatcher : NSObject 30 | 31 | - (instancetype)init NS_UNAVAILABLE; 32 | 33 | /** Dispatch the block asynchronously on the queue for dispatchType. 34 | * @param dispatchType The queue type to dispatch on. 35 | * @param block The block to dispatch asynchronously. 36 | */ 37 | + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType 38 | block:(dispatch_block_t)block; 39 | 40 | /** Returns YES if run on queue for the dispatchType otherwise NO. 41 | * Useful for asserting that a method is run on a correct queue. 42 | */ 43 | + (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCCameraVideoCapturer.h: -------------------------------------------------------------------------------- 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 | #import 12 | #import 13 | 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | RTC_EXPORT 20 | // Camera capture that implements RTCVideoCapturer. Delivers frames to a RTCVideoCapturerDelegate 21 | // (usually RTCVideoSource). 22 | @interface RTCCameraVideoCapturer : RTCVideoCapturer 23 | 24 | // Capture session that is used for capturing. Valid from initialization to dealloc. 25 | @property(readonly, nonatomic) AVCaptureSession *captureSession; 26 | 27 | // Returns list of available capture devices that support video capture. 28 | + (NSArray *)captureDevices; 29 | // Returns list of formats that are supported by this class for this device. 30 | + (NSArray *)supportedFormatsForDevice:(AVCaptureDevice *)device; 31 | 32 | // Starts and stops the capture session asynchronously. 33 | - (void)startCaptureWithDevice:(AVCaptureDevice *)device 34 | format:(AVCaptureDeviceFormat *)format 35 | fps:(NSInteger)fps; 36 | // Stops the capture session asynchronously. 37 | - (void)stopCapture; 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCDataChannelConfiguration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | RTC_EXPORT 19 | @interface RTCDataChannelConfiguration : NSObject 20 | 21 | /** Set to YES if ordered delivery is required. */ 22 | @property(nonatomic, assign) BOOL isOrdered; 23 | 24 | /** Deprecated. Use maxPacketLifeTime. */ 25 | @property(nonatomic, assign) NSInteger maxRetransmitTimeMs DEPRECATED_ATTRIBUTE; 26 | 27 | /** 28 | * Max period in milliseconds in which retransmissions will be sent. After this 29 | * time, no more retransmissions will be sent. -1 if unset. 30 | */ 31 | @property(nonatomic, assign) int maxPacketLifeTime; 32 | 33 | /** The max number of retransmissions. -1 if unset. */ 34 | @property(nonatomic, assign) int maxRetransmits; 35 | 36 | /** Set to YES if the channel has been externally negotiated and we do not send 37 | * an in-band signalling in the form of an "open" message. 38 | */ 39 | @property(nonatomic, assign) BOOL isNegotiated; 40 | 41 | /** Deprecated. Use channelId. */ 42 | @property(nonatomic, assign) int streamId DEPRECATED_ATTRIBUTE; 43 | 44 | /** The id of the data channel. */ 45 | @property(nonatomic, assign) int channelId; 46 | 47 | /** Set by the application and opaque to the WebRTC implementation. */ 48 | @property(nonatomic) NSString *protocol; 49 | 50 | @end 51 | 52 | NS_ASSUME_NONNULL_END 53 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | 18 | Copyright 2012 Square Inc. 19 | 20 | Licensed under the Apache License, Version 2.0 (the "License"); 21 | you may not use this file except in compliance with the License. 22 | You may obtain a copy of the License at 23 | 24 | http://www.apache.org/licenses/LICENSE-2.0 25 | 26 | Unless required by applicable law or agreed to in writing, software 27 | distributed under the License is distributed on an "AS IS" BASIS, 28 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | See the License for the specific language governing permissions and 30 | limitations under the License. 31 | 32 | 33 | License 34 | Apache License, Version 2.0 35 | Title 36 | SocketRocket 37 | Type 38 | PSGroupSpecifier 39 | 40 | 41 | FooterText 42 | Generated by CocoaPods - https://cocoapods.org 43 | Title 44 | 45 | Type 46 | PSGroupSpecifier 47 | 48 | 49 | StringsTable 50 | Acknowledgements 51 | Title 52 | Acknowledgements 53 | 54 | 55 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCAudioSessionConfiguration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | #import 13 | 14 | #import "WebRTC/RTCMacros.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | extern const int kRTCAudioSessionPreferredNumberOfChannels; 19 | extern const double kRTCAudioSessionHighPerformanceSampleRate; 20 | extern const double kRTCAudioSessionLowComplexitySampleRate; 21 | extern const double kRTCAudioSessionHighPerformanceIOBufferDuration; 22 | extern const double kRTCAudioSessionLowComplexityIOBufferDuration; 23 | 24 | // Struct to hold configuration values. 25 | RTC_EXPORT 26 | @interface RTCAudioSessionConfiguration : NSObject 27 | 28 | @property(nonatomic, strong) NSString *category; 29 | @property(nonatomic, assign) AVAudioSessionCategoryOptions categoryOptions; 30 | @property(nonatomic, strong) NSString *mode; 31 | @property(nonatomic, assign) double sampleRate; 32 | @property(nonatomic, assign) NSTimeInterval ioBufferDuration; 33 | @property(nonatomic, assign) NSInteger inputNumberOfChannels; 34 | @property(nonatomic, assign) NSInteger outputNumberOfChannels; 35 | 36 | /** Initializes configuration to defaults. */ 37 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 38 | 39 | /** Returns the current configuration of the audio session. */ 40 | + (instancetype)currentConfiguration; 41 | /** Returns the configuration that WebRTC needs. */ 42 | + (instancetype)webRTCConfiguration; 43 | /** Provide a way to override the default configuration. */ 44 | + (void)setWebRTCConfiguration:(RTCAudioSessionConfiguration *)configuration; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/UIDevice+RTCDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | typedef NS_ENUM(NSInteger, RTCDeviceType) { 14 | RTCDeviceTypeUnknown, 15 | RTCDeviceTypeIPhone1G, 16 | RTCDeviceTypeIPhone3G, 17 | RTCDeviceTypeIPhone3GS, 18 | RTCDeviceTypeIPhone4, 19 | RTCDeviceTypeIPhone4Verizon, 20 | RTCDeviceTypeIPhone4S, 21 | RTCDeviceTypeIPhone5GSM, 22 | RTCDeviceTypeIPhone5GSM_CDMA, 23 | RTCDeviceTypeIPhone5CGSM, 24 | RTCDeviceTypeIPhone5CGSM_CDMA, 25 | RTCDeviceTypeIPhone5SGSM, 26 | RTCDeviceTypeIPhone5SGSM_CDMA, 27 | RTCDeviceTypeIPhone6Plus, 28 | RTCDeviceTypeIPhone6, 29 | RTCDeviceTypeIPhone6S, 30 | RTCDeviceTypeIPhone6SPlus, 31 | RTCDeviceTypeIPodTouch1G, 32 | RTCDeviceTypeIPodTouch2G, 33 | RTCDeviceTypeIPodTouch3G, 34 | RTCDeviceTypeIPodTouch4G, 35 | RTCDeviceTypeIPodTouch5G, 36 | RTCDeviceTypeIPad, 37 | RTCDeviceTypeIPad2Wifi, 38 | RTCDeviceTypeIPad2GSM, 39 | RTCDeviceTypeIPad2CDMA, 40 | RTCDeviceTypeIPad2Wifi2, 41 | RTCDeviceTypeIPadMiniWifi, 42 | RTCDeviceTypeIPadMiniGSM, 43 | RTCDeviceTypeIPadMiniGSM_CDMA, 44 | RTCDeviceTypeIPad3Wifi, 45 | RTCDeviceTypeIPad3GSM_CDMA, 46 | RTCDeviceTypeIPad3GSM, 47 | RTCDeviceTypeIPad4Wifi, 48 | RTCDeviceTypeIPad4GSM, 49 | RTCDeviceTypeIPad4GSM_CDMA, 50 | RTCDeviceTypeIPadAirWifi, 51 | RTCDeviceTypeIPadAirCellular, 52 | RTCDeviceTypeIPadMini2GWifi, 53 | RTCDeviceTypeIPadMini2GCellular, 54 | RTCDeviceTypeSimulatori386, 55 | RTCDeviceTypeSimulatorx86_64, 56 | }; 57 | 58 | @interface UIDevice (RTCDevice) 59 | 60 | + (RTCDeviceType)deviceType; 61 | + (NSString *)stringForDeviceType:(RTCDeviceType)deviceType; 62 | + (BOOL)isIOS9OrLater; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCAVFoundationVideoSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | @class AVCaptureSession; 15 | @class RTCMediaConstraints; 16 | @class RTCPeerConnectionFactory; 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | /** 21 | * DEPRECATED Use RTCCameraVideoCapturer instead. 22 | * 23 | * RTCAVFoundationVideoSource is a video source that uses 24 | * webrtc::AVFoundationVideoCapturer. We do not currently provide a wrapper for 25 | * that capturer because cricket::VideoCapturer is not ref counted and we cannot 26 | * guarantee its lifetime. Instead, we expose its properties through the ref 27 | * counted video source interface. 28 | */ 29 | RTC_EXPORT 30 | @interface RTCAVFoundationVideoSource : RTCVideoSource 31 | 32 | - (instancetype)init NS_UNAVAILABLE; 33 | 34 | /** 35 | * Calling this function will cause frames to be scaled down to the 36 | * requested resolution. Also, frames will be cropped to match the 37 | * requested aspect ratio, and frames will be dropped to match the 38 | * requested fps. The requested aspect ratio is orientation agnostic and 39 | * will be adjusted to maintain the input orientation, so it doesn't 40 | * matter if e.g. 1280x720 or 720x1280 is requested. 41 | */ 42 | - (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps; 43 | 44 | /** Returns whether rear-facing camera is available for use. */ 45 | @property(nonatomic, readonly) BOOL canUseBackCamera; 46 | 47 | /** Switches the camera being used (either front or back). */ 48 | @property(nonatomic, assign) BOOL useBackCamera; 49 | 50 | /** Returns the active capture session. */ 51 | @property(nonatomic, readonly) AVCaptureSession *captureSession; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCFieldTrials.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | /** The only valid value for the following if set is kRTCFieldTrialEnabledValue. */ 16 | RTC_EXTERN NSString * const kRTCFieldTrialAudioSendSideBweKey; 17 | RTC_EXTERN NSString * const kRTCFieldTrialSendSideBweWithOverheadKey; 18 | RTC_EXTERN NSString * const kRTCFieldTrialFlexFec03AdvertisedKey; 19 | RTC_EXTERN NSString * const kRTCFieldTrialFlexFec03Key; 20 | RTC_EXTERN NSString * const kRTCFieldTrialImprovedBitrateEstimateKey; 21 | RTC_EXTERN NSString * const kRTCFieldTrialH264HighProfileKey; 22 | RTC_EXTERN NSString * const kRTCFieldTrialMinimizeResamplingOnMobileKey; 23 | 24 | /** The valid value for field trials above. */ 25 | RTC_EXTERN NSString * const kRTCFieldTrialEnabledValue; 26 | 27 | /** Use a string returned by RTCFieldTrialMedianSlopeFilterValue as the value. */ 28 | RTC_EXTERN NSString * const kRTCFieldTrialMedianSlopeFilterKey; 29 | RTC_EXTERN NSString *RTCFieldTrialMedianSlopeFilterValue( 30 | size_t windowSize, double thresholdGain); 31 | 32 | /** Use a string returned by RTCFieldTrialTrendlineFilterValue as the value. */ 33 | RTC_EXTERN NSString * const kRTCFieldTrialTrendlineFilterKey; 34 | /** Returns a valid value for kRTCFieldTrialTrendlineFilterKey. */ 35 | RTC_EXTERN NSString *RTCFieldTrialTrendlineFilterValue( 36 | size_t windowSize, double smoothingCoeff, double thresholdGain); 37 | 38 | /** Initialize field trials using a dictionary mapping field trial keys to their values. See above 39 | * for valid keys and values. 40 | * Must be called before any other call into WebRTC. See: 41 | * webrtc/system_wrappers/include/field_trial_default.h 42 | */ 43 | RTC_EXTERN void RTCInitFieldTrialDictionary(NSDictionary *fieldTrials); 44 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/WebRTC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | #import 13 | #import 14 | #import 15 | #if TARGET_OS_IPHONE 16 | #import 17 | #endif 18 | #import 19 | #import 20 | #import 21 | #import 22 | #if TARGET_OS_IPHONE 23 | #import 24 | #import 25 | #endif 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | #import 33 | #import 34 | #import 35 | #import 36 | #import 37 | #import 38 | #import 39 | #import 40 | #import 41 | #import 42 | #import 43 | #import 44 | #import 45 | #import 46 | #import 47 | #import 48 | #import 49 | #import 50 | #import 51 | #import 52 | #import 53 | #import 54 | #import 55 | #import 56 | #import 57 | #if TARGET_OS_IPHONE 58 | #import 59 | #endif 60 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCMediaConstraints.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | /** Constraint keys for media sources. */ 18 | RTC_EXTERN NSString * const kRTCMediaConstraintsMinAspectRatio; 19 | RTC_EXTERN NSString * const kRTCMediaConstraintsMaxAspectRatio; 20 | RTC_EXTERN NSString * const kRTCMediaConstraintsMaxWidth; 21 | RTC_EXTERN NSString * const kRTCMediaConstraintsMinWidth; 22 | RTC_EXTERN NSString * const kRTCMediaConstraintsMaxHeight; 23 | RTC_EXTERN NSString * const kRTCMediaConstraintsMinHeight; 24 | RTC_EXTERN NSString * const kRTCMediaConstraintsMaxFrameRate; 25 | RTC_EXTERN NSString * const kRTCMediaConstraintsMinFrameRate; 26 | RTC_EXTERN NSString * const kRTCMediaConstraintsLevelControl; 27 | /** The value for this key should be a base64 encoded string containing 28 | * the data from the serialized configuration proto. 29 | */ 30 | RTC_EXTERN NSString * const kRTCMediaConstraintsAudioNetworkAdaptorConfig; 31 | 32 | /** Constraint keys for generating offers and answers. */ 33 | RTC_EXTERN NSString * const kRTCMediaConstraintsIceRestart; 34 | RTC_EXTERN NSString * const kRTCMediaConstraintsOfferToReceiveAudio; 35 | RTC_EXTERN NSString * const kRTCMediaConstraintsOfferToReceiveVideo; 36 | RTC_EXTERN NSString * const kRTCMediaConstraintsVoiceActivityDetection; 37 | 38 | /** Constraint values for Boolean parameters. */ 39 | RTC_EXTERN NSString * const kRTCMediaConstraintsValueTrue; 40 | RTC_EXTERN NSString * const kRTCMediaConstraintsValueFalse; 41 | 42 | RTC_EXPORT 43 | @interface RTCMediaConstraints : NSObject 44 | 45 | - (instancetype)init NS_UNAVAILABLE; 46 | 47 | /** Initialize with mandatory and/or optional constraints. */ 48 | - (instancetype)initWithMandatoryConstraints: 49 | (nullable NSDictionary *)mandatory 50 | optionalConstraints: 51 | (nullable NSDictionary *)optional 52 | NS_DESIGNATED_INITIALIZER; 53 | 54 | @end 55 | 56 | NS_ASSUME_NONNULL_END 57 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTCHelper/WebRTCHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebRTCHelper.h 3 | // WebScoketTest 4 | // 5 | // Created by 涂耀辉 on 17/3/1. 6 | // Copyright © 2017年 涂耀辉. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SocketRocket.h" 11 | 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | 26 | @protocol WebRTCHelperFriendListDelegate; 27 | @protocol WebRTCHelperChatDelegate; 28 | 29 | @interface WebRTCHelper : NSObject 30 | 31 | + (instancetype)sharedInstance; 32 | 33 | @property (nonatomic, weak)id friendListDelegate; 34 | @property (nonatomic, weak)id chatdelegate; 35 | 36 | /** 37 | * 与服务器建立连接 38 | * 39 | * @param server 服务器地址 40 | @pram port 端口号 41 | * @param room 房间号 42 | */ 43 | - (void)connectServer:(NSString *)server port:(NSString *)port room:(NSString *)room; 44 | 45 | /** 46 | * 退出房间 47 | */ 48 | - (void)exitRoom; 49 | 50 | /* 51 | * 断开连接 52 | */ 53 | - (void)closePeerConnection; 54 | /* 55 | *建立与好友的WebRTC连接 56 | */ 57 | - (void)connectWithUserId:(NSString *)userId; 58 | 59 | /* 60 | *WebRTC连接建立成功后,发送消息方法 61 | */ 62 | - (void)sendMessage:(NSString *)message; 63 | 64 | @end 65 | 66 | /* 67 | * 好友列表协议 68 | */ 69 | @protocol WebRTCHelperFriendListDelegate 70 | @optional 71 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper gotFriendList:(NSArray *)friendList; 72 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper gotNewFriend:(NSString *)userId; 73 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper removeFriend:(NSString *)userId; 74 | - (void)requestConnectWithUserId:(NSString *)userId; 75 | 76 | @end 77 | 78 | /* 79 | * 聊天消息协议 80 | */ 81 | @protocol WebRTCHelperChatDelegate 82 | @optional 83 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper receiveMessage:(NSString *)message; 84 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper closeChatWithUserId:(NSString *)userId; 85 | 86 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper setLocalStream:(RTCMediaStream *)stream; 87 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper setRemoteStream:(RTCMediaStream *)stream; 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCRtpCodecParameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | RTC_EXTERN const NSString * const kRTCRtxCodecName; 18 | RTC_EXTERN const NSString * const kRTCRedCodecName; 19 | RTC_EXTERN const NSString * const kRTCUlpfecCodecName; 20 | RTC_EXTERN const NSString * const kRTCFlexfecCodecName; 21 | RTC_EXTERN const NSString * const kRTCOpusCodecName; 22 | RTC_EXTERN const NSString * const kRTCIsacCodecName; 23 | RTC_EXTERN const NSString * const kRTCL16CodecName; 24 | RTC_EXTERN const NSString * const kRTCG722CodecName; 25 | RTC_EXTERN const NSString * const kRTCIlbcCodecName; 26 | RTC_EXTERN const NSString * const kRTCPcmuCodecName; 27 | RTC_EXTERN const NSString * const kRTCPcmaCodecName; 28 | RTC_EXTERN const NSString * const kRTCDtmfCodecName; 29 | RTC_EXTERN const NSString * const kRTCComfortNoiseCodecName; 30 | RTC_EXTERN const NSString * const kRTCVp8CodecName; 31 | RTC_EXTERN const NSString * const kRTCVp9CodecName; 32 | RTC_EXTERN const NSString * const kRTCH264CodecName; 33 | 34 | /** Defined in http://w3c.github.io/webrtc-pc/#idl-def-RTCRtpCodecParameters */ 35 | RTC_EXPORT 36 | @interface RTCRtpCodecParameters : NSObject 37 | 38 | /** The RTP payload type. */ 39 | @property(nonatomic, assign) int payloadType; 40 | 41 | /** 42 | * The codec MIME subtype. Valid types are listed in: 43 | * http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-2 44 | * 45 | * Several supported types are represented by the constants above. 46 | */ 47 | @property(nonatomic, readonly, nonnull) NSString *name; 48 | 49 | /** 50 | * The media type of this codec. Equivalent to MIME top-level type. 51 | * 52 | * Valid values are kRTCMediaStreamTrackKindAudio and 53 | * kRTCMediaStreamTrackKindVideo. 54 | */ 55 | @property(nonatomic, readonly, nonnull) NSString *kind; 56 | 57 | /** The codec clock rate expressed in Hertz. */ 58 | @property(nonatomic, readonly, nullable) NSNumber *clockRate; 59 | 60 | /** 61 | * The number of channels (mono=1, stereo=2). 62 | * Set to null for video codecs. 63 | **/ 64 | @property(nonatomic, readonly, nullable) NSNumber *numChannels; 65 | 66 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 67 | 68 | @end 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCLogging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | // Subset of rtc::LoggingSeverity. 16 | typedef NS_ENUM(NSInteger, RTCLoggingSeverity) { 17 | RTCLoggingSeverityVerbose, 18 | RTCLoggingSeverityInfo, 19 | RTCLoggingSeverityWarning, 20 | RTCLoggingSeverityError, 21 | }; 22 | 23 | // Wrapper for C++ LOG(sev) macros. 24 | // Logs the log string to the webrtc logstream for the given severity. 25 | RTC_EXTERN void RTCLogEx(RTCLoggingSeverity severity, NSString* log_string); 26 | 27 | // Wrapper for rtc::LogMessage::LogToDebug. 28 | // Sets the minimum severity to be logged to console. 29 | RTC_EXTERN void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity); 30 | 31 | // Returns the filename with the path prefix removed. 32 | RTC_EXTERN NSString* RTCFileName(const char* filePath); 33 | 34 | // Some convenience macros. 35 | 36 | #define RTCLogString(format, ...) \ 37 | [NSString stringWithFormat:@"(%@:%d %s): " format, \ 38 | RTCFileName(__FILE__), \ 39 | __LINE__, \ 40 | __FUNCTION__, \ 41 | ##__VA_ARGS__] 42 | 43 | #define RTCLogFormat(severity, format, ...) \ 44 | do { \ 45 | NSString* log_string = RTCLogString(format, ##__VA_ARGS__); \ 46 | RTCLogEx(severity, log_string); \ 47 | } while (false) 48 | 49 | #define RTCLogVerbose(format, ...) \ 50 | RTCLogFormat(RTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \ 51 | 52 | #define RTCLogInfo(format, ...) \ 53 | RTCLogFormat(RTCLoggingSeverityInfo, format, ##__VA_ARGS__) \ 54 | 55 | #define RTCLogWarning(format, ...) \ 56 | RTCLogFormat(RTCLoggingSeverityWarning, format, ##__VA_ARGS__) \ 57 | 58 | #define RTCLogError(format, ...) \ 59 | RTCLogFormat(RTCLoggingSeverityError, format, ##__VA_ARGS__) \ 60 | 61 | #if !defined(NDEBUG) 62 | #define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__) 63 | #else 64 | #define RTCLogDebug(format, ...) \ 65 | do { \ 66 | } while (false) 67 | #endif 68 | 69 | #define RTCLog(format, ...) RTCLogInfo(format, ##__VA_ARGS__) 70 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCFileLogger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) { 16 | RTCFileLoggerSeverityVerbose, 17 | RTCFileLoggerSeverityInfo, 18 | RTCFileLoggerSeverityWarning, 19 | RTCFileLoggerSeverityError 20 | }; 21 | 22 | typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) { 23 | RTCFileLoggerTypeCall, 24 | RTCFileLoggerTypeApp, 25 | }; 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | // This class intercepts WebRTC logs and saves them to a file. The file size 30 | // will not exceed the given maximum bytesize. When the maximum bytesize is 31 | // reached, logs are rotated according to the rotationType specified. 32 | // For kRTCFileLoggerTypeCall, logs from the beginning and the end 33 | // are preserved while the middle section is overwritten instead. 34 | // For kRTCFileLoggerTypeApp, the oldest log is overwritten. 35 | // This class is not threadsafe. 36 | RTC_EXPORT 37 | @interface RTCFileLogger : NSObject 38 | 39 | // The severity level to capture. The default is kRTCFileLoggerSeverityInfo. 40 | @property(nonatomic, assign) RTCFileLoggerSeverity severity; 41 | 42 | // The rotation type for this file logger. The default is 43 | // kRTCFileLoggerTypeCall. 44 | @property(nonatomic, readonly) RTCFileLoggerRotationType rotationType; 45 | 46 | // Disables buffering disk writes. Should be set before |start|. Buffering 47 | // is enabled by default for performance. 48 | @property(nonatomic, assign) BOOL shouldDisableBuffering; 49 | 50 | // Default constructor provides default settings for dir path, file size and 51 | // rotation type. 52 | - (instancetype)init; 53 | 54 | // Create file logger with default rotation type. 55 | - (instancetype)initWithDirPath:(NSString *)dirPath 56 | maxFileSize:(NSUInteger)maxFileSize; 57 | 58 | - (instancetype)initWithDirPath:(NSString *)dirPath 59 | maxFileSize:(NSUInteger)maxFileSize 60 | rotationType:(RTCFileLoggerRotationType)rotationType 61 | NS_DESIGNATED_INITIALIZER; 62 | 63 | // Starts writing WebRTC logs to disk if not already started. Overwrites any 64 | // existing file(s). 65 | - (void)start; 66 | 67 | // Stops writing WebRTC logs to disk. This method is also called on dealloc. 68 | - (void)stop; 69 | 70 | // Returns the current contents of the logs, or nil if start has been called 71 | // without a stop. 72 | - (NSData *)logData; 73 | 74 | @end 75 | 76 | NS_ASSUME_NONNULL_END 77 | 78 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCRtpReceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | 13 | #import 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | /** Represents the media type of the RtpReceiver. */ 20 | typedef NS_ENUM(NSInteger, RTCRtpMediaType) { 21 | RTCRtpMediaTypeAudio, 22 | RTCRtpMediaTypeVideo, 23 | RTCRtpMediaTypeData, 24 | }; 25 | 26 | @class RTCRtpReceiver; 27 | 28 | RTC_EXPORT 29 | @protocol RTCRtpReceiverDelegate 30 | 31 | /** Called when the first RTP packet is received. 32 | * 33 | * Note: Currently if there are multiple RtpReceivers of the same media type, 34 | * they will all call OnFirstPacketReceived at once. 35 | * 36 | * For example, if we create three audio receivers, A/B/C, they will listen to 37 | * the same signal from the underneath network layer. Whenever the first audio packet 38 | * is received, the underneath signal will be fired. All the receivers A/B/C will be 39 | * notified and the callback of the receiver's delegate will be called. 40 | * 41 | * The process is the same for video receivers. 42 | */ 43 | - (void)rtpReceiver:(RTCRtpReceiver *)rtpReceiver 44 | didReceiveFirstPacketForMediaType:(RTCRtpMediaType)mediaType; 45 | 46 | @end 47 | 48 | RTC_EXPORT 49 | @protocol RTCRtpReceiver 50 | 51 | /** A unique identifier for this receiver. */ 52 | @property(nonatomic, readonly) NSString *receiverId; 53 | 54 | /** The currently active RTCRtpParameters, as defined in 55 | * https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters. 56 | * 57 | * The WebRTC specification only defines RTCRtpParameters in terms of senders, 58 | * but this API also applies them to receivers, similar to ORTC: 59 | * http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. 60 | */ 61 | @property(nonatomic, readonly) RTCRtpParameters *parameters; 62 | 63 | /** The RTCMediaStreamTrack associated with the receiver. 64 | * Note: reading this property returns a new instance of 65 | * RTCMediaStreamTrack. Use isEqual: instead of == to compare 66 | * RTCMediaStreamTrack instances. 67 | */ 68 | @property(nonatomic, readonly) RTCMediaStreamTrack *track; 69 | 70 | /** The delegate for this RtpReceiver. */ 71 | @property(nonatomic, weak) id delegate; 72 | 73 | @end 74 | 75 | RTC_EXPORT 76 | @interface RTCRtpReceiver : NSObject 77 | 78 | - (instancetype)init NS_UNAVAILABLE; 79 | 80 | @end 81 | 82 | NS_ASSUME_NONNULL_END 83 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCIceServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | typedef NS_ENUM(NSUInteger, RTCTlsCertPolicy) { 16 | RTCTlsCertPolicySecure, 17 | RTCTlsCertPolicyInsecureNoCheck 18 | }; 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | RTC_EXPORT 23 | @interface RTCIceServer : NSObject 24 | 25 | /** URI(s) for this server represented as NSStrings. */ 26 | @property(nonatomic, readonly) NSArray *urlStrings; 27 | 28 | /** Username to use if this RTCIceServer object is a TURN server. */ 29 | @property(nonatomic, readonly, nullable) NSString *username; 30 | 31 | /** Credential to use if this RTCIceServer object is a TURN server. */ 32 | @property(nonatomic, readonly, nullable) NSString *credential; 33 | 34 | /** 35 | * TLS certificate policy to use if this RTCIceServer object is a TURN server. 36 | */ 37 | @property(nonatomic, readonly) RTCTlsCertPolicy tlsCertPolicy; 38 | 39 | /** 40 | If the URIs in |urls| only contain IP addresses, this field can be used 41 | to indicate the hostname, which may be necessary for TLS (using the SNI 42 | extension). If |urls| itself contains the hostname, this isn't necessary. 43 | */ 44 | @property(nonatomic, readonly, nullable) NSString *hostname; 45 | 46 | - (nonnull instancetype)init NS_UNAVAILABLE; 47 | 48 | /** Convenience initializer for a server with no authentication (e.g. STUN). */ 49 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings; 50 | 51 | /** 52 | * Initialize an RTCIceServer with its associated URLs, optional username, 53 | * optional credential, and credentialType. 54 | */ 55 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings 56 | username:(nullable NSString *)username 57 | credential:(nullable NSString *)credential; 58 | 59 | /** 60 | * Initialize an RTCIceServer with its associated URLs, optional username, 61 | * optional credential, and TLS cert policy. 62 | */ 63 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings 64 | username:(nullable NSString *)username 65 | credential:(nullable NSString *)credential 66 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy; 67 | 68 | /** 69 | * Initialize an RTCIceServer with its associated URLs, optional username, 70 | * optional credential, TLS cert policy and hostname. 71 | */ 72 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings 73 | username:(nullable NSString *)username 74 | credential:(nullable NSString *)credential 75 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy 76 | hostname:(nullable NSString *)hostname NS_DESIGNATED_INITIALIZER; 77 | 78 | @end 79 | 80 | NS_ASSUME_NONNULL_END 81 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/15. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | 22 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 23 | self.window.backgroundColor = [UIColor whiteColor]; 24 | [self.window makeKeyAndVisible]; 25 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; 26 | 27 | return YES; 28 | } 29 | 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 34 | } 35 | 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | NSLog(@"applicationDidEnterBackground"); 41 | __block UIBackgroundTaskIdentifier bgTask; 42 | bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ 43 | dispatch_async(dispatch_get_main_queue(), ^{ 44 | if (bgTask != UIBackgroundTaskInvalid) 45 | { 46 | bgTask = UIBackgroundTaskInvalid; 47 | } 48 | }); 49 | }]; 50 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 51 | dispatch_async(dispatch_get_main_queue(), ^{ 52 | if (bgTask != UIBackgroundTaskInvalid) 53 | { 54 | bgTask = UIBackgroundTaskInvalid; 55 | } 56 | }); 57 | }); 58 | } 59 | 60 | - (void)applicationWillEnterForeground:(UIApplication *)application { 61 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 62 | } 63 | 64 | 65 | - (void)applicationDidBecomeActive:(UIApplication *)application { 66 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 67 | } 68 | 69 | 70 | - (void)applicationWillTerminate:(UIApplication *)application { 71 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 72 | } 73 | 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCPeerConnectionFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @class RTCAVFoundationVideoSource; 18 | @class RTCAudioSource; 19 | @class RTCAudioTrack; 20 | @class RTCConfiguration; 21 | @class RTCMediaConstraints; 22 | @class RTCMediaStream; 23 | @class RTCPeerConnection; 24 | @class RTCVideoSource; 25 | @class RTCVideoTrack; 26 | @protocol RTCPeerConnectionDelegate; 27 | @protocol RTCVideoDecoderFactory; 28 | @protocol RTCVideoEncoderFactory; 29 | 30 | RTC_EXPORT 31 | @interface RTCPeerConnectionFactory : NSObject 32 | 33 | /* Initialize object with default H264 video encoder/decoder factories */ 34 | - (instancetype)init; 35 | 36 | /* Initialize object with injectable video encoder/decoder factories */ 37 | - (instancetype)initWithEncoderFactory:(nullable id)encoderFactory 38 | decoderFactory:(nullable id)decoderFactory 39 | NS_DESIGNATED_INITIALIZER; 40 | 41 | /** Initialize an RTCAudioSource with constraints. */ 42 | - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints; 43 | 44 | /** Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio source with no 45 | * constraints. 46 | */ 47 | - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId; 48 | 49 | /** Initialize an RTCAudioTrack with a source and an id. */ 50 | - (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source 51 | trackId:(NSString *)trackId; 52 | 53 | /** Initialize an RTCAVFoundationVideoSource with constraints. */ 54 | - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: 55 | (nullable RTCMediaConstraints *)constraints; 56 | 57 | /** Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer 58 | * implementation, e.g. RTCCameraVideoCapturer, in order to produce frames. 59 | */ 60 | - (RTCVideoSource *)videoSource; 61 | 62 | /** Initialize an RTCVideoTrack with a source and an id. */ 63 | - (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source 64 | trackId:(NSString *)trackId; 65 | 66 | /** Initialize an RTCMediaStream with an id. */ 67 | - (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId; 68 | 69 | /** Initialize an RTCPeerConnection with a configuration, constraints, and 70 | * delegate. 71 | */ 72 | - (RTCPeerConnection *)peerConnectionWithConfiguration: 73 | (RTCConfiguration *)configuration 74 | constraints: 75 | (RTCMediaConstraints *)constraints 76 | delegate: 77 | (nullable id)delegate; 78 | 79 | /** Start an AecDump recording. This API call will likely change in the future. */ 80 | - (BOOL)startAecDumpWithFilePath:(NSString *)filePath 81 | maxSizeInBytes:(int64_t)maxSizeInBytes; 82 | 83 | /* Stop an active AecDump recording */ 84 | - (void)stopAecDump; 85 | 86 | @end 87 | 88 | NS_ASSUME_NONNULL_END 89 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoFrameBuffer.h: -------------------------------------------------------------------------------- 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 | #import 12 | #import 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @protocol RTCI420Buffer; 17 | 18 | // RTCVideoFrameBuffer is an ObjectiveC version of webrtc::VideoFrameBuffer. 19 | RTC_EXPORT 20 | @protocol RTCVideoFrameBuffer 21 | 22 | @property(nonatomic, readonly) int width; 23 | @property(nonatomic, readonly) int height; 24 | 25 | - (id)toI420; 26 | 27 | @end 28 | 29 | /** Protocol for RTCVideoFrameBuffers containing YUV planar data. */ 30 | @protocol RTCYUVPlanarBuffer 31 | 32 | @property(nonatomic, readonly) int chromaWidth; 33 | @property(nonatomic, readonly) int chromaHeight; 34 | @property(nonatomic, readonly) const uint8_t *dataY; 35 | @property(nonatomic, readonly) const uint8_t *dataU; 36 | @property(nonatomic, readonly) const uint8_t *dataV; 37 | @property(nonatomic, readonly) int strideY; 38 | @property(nonatomic, readonly) int strideU; 39 | @property(nonatomic, readonly) int strideV; 40 | 41 | - (instancetype)initWithWidth:(int)width height:(int)height; 42 | - (instancetype)initWithWidth:(int)width 43 | height:(int)height 44 | strideY:(int)strideY 45 | strideU:(int)strideU 46 | strideV:(int)strideV; 47 | 48 | @end 49 | 50 | /** Extension of the YUV planar data buffer with mutable data access */ 51 | @protocol RTCMutableYUVPlanarBuffer 52 | 53 | @property(nonatomic, readonly) uint8_t *mutableDataY; 54 | @property(nonatomic, readonly) uint8_t *mutableDataU; 55 | @property(nonatomic, readonly) uint8_t *mutableDataV; 56 | 57 | @end 58 | 59 | /** Protocol for RTCYUVPlanarBuffers containing I420 data */ 60 | @protocol RTCI420Buffer 61 | @end 62 | 63 | /** Extension of the I420 buffer with mutable data access */ 64 | @protocol RTCMutableI420Buffer 65 | @end 66 | 67 | /** RTCVideoFrameBuffer containing a CVPixelBufferRef */ 68 | RTC_EXPORT 69 | @interface RTCCVPixelBuffer : NSObject 70 | 71 | @property(nonatomic, readonly) CVPixelBufferRef pixelBuffer; 72 | 73 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer; 74 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 75 | adaptedWidth:(int)adaptedWidth 76 | adaptedHeight:(int)adaptedHeight 77 | cropWidth:(int)cropWidth 78 | cropHeight:(int)cropHeight 79 | cropX:(int)cropX 80 | cropY:(int)cropY; 81 | 82 | - (BOOL)requiresCropping; 83 | - (BOOL)requiresScalingToWidth:(int)width height:(int)height; 84 | - (int)bufferSizeForCroppingAndScalingToWidth:(int)width height:(int)height; 85 | /** The minimum size of the |tmpBuffer| must be the number of bytes returned from the 86 | * bufferSizeForCroppingAndScalingToWidth:height: method. 87 | */ 88 | - (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer withTempBuffer:(uint8_t *)tmpBuffer; 89 | 90 | @end 91 | 92 | /** RTCI420Buffer implements the RTCI420Buffer protocol */ 93 | RTC_EXPORT 94 | @interface RTCI420Buffer : NSObject 95 | @end 96 | 97 | /** Mutable version of RTCI420Buffer */ 98 | RTC_EXPORT 99 | @interface RTCMutableI420Buffer : RTCI420Buffer 100 | @end 101 | 102 | NS_ASSUME_NONNULL_END 103 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | typedef NS_ENUM(NSInteger, RTCVideoRotation) { 19 | RTCVideoRotation_0 = 0, 20 | RTCVideoRotation_90 = 90, 21 | RTCVideoRotation_180 = 180, 22 | RTCVideoRotation_270 = 270, 23 | }; 24 | 25 | @protocol RTCVideoFrameBuffer; 26 | 27 | // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame. 28 | RTC_EXPORT 29 | @interface RTCVideoFrame : NSObject 30 | 31 | /** Width without rotation applied. */ 32 | @property(nonatomic, readonly) int width; 33 | 34 | /** Height without rotation applied. */ 35 | @property(nonatomic, readonly) int height; 36 | @property(nonatomic, readonly) RTCVideoRotation rotation; 37 | /** Accessing YUV data should only be done for I420 frames, i.e. if nativeHandle 38 | * is null. It is always possible to get such a frame by calling 39 | * newI420VideoFrame. 40 | */ 41 | @property(nonatomic, readonly, nullable) 42 | const uint8_t *dataY DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 43 | @property(nonatomic, readonly, nullable) 44 | const uint8_t *dataU DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 45 | @property(nonatomic, readonly, nullable) 46 | const uint8_t *dataV DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 47 | @property(nonatomic, readonly) int strideY DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 48 | @property(nonatomic, readonly) int strideU DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 49 | @property(nonatomic, readonly) int strideV DEPRECATED_MSG_ATTRIBUTE("use [buffer toI420]"); 50 | 51 | /** Timestamp in nanoseconds. */ 52 | @property(nonatomic, readonly) int64_t timeStampNs; 53 | 54 | /** Timestamp 90 kHz. */ 55 | @property(nonatomic, assign) int32_t timeStamp; 56 | 57 | /** The native handle should be a pixel buffer on iOS. */ 58 | @property(nonatomic, readonly) 59 | CVPixelBufferRef nativeHandle DEPRECATED_MSG_ATTRIBUTE("use buffer instead"); 60 | 61 | @property(nonatomic, readonly) id buffer; 62 | 63 | - (instancetype)init NS_UNAVAILABLE; 64 | - (instancetype)new NS_UNAVAILABLE; 65 | 66 | /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp. 67 | * Deprecated - initialize with a RTCCVPixelBuffer instead 68 | */ 69 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 70 | rotation:(RTCVideoRotation)rotation 71 | timeStampNs:(int64_t)timeStampNs 72 | DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); 73 | 74 | /** Initialize an RTCVideoFrame from a pixel buffer combined with cropping and 75 | * scaling. Cropping will be applied first on the pixel buffer, followed by 76 | * scaling to the final resolution of scaledWidth x scaledHeight. 77 | */ 78 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 79 | scaledWidth:(int)scaledWidth 80 | scaledHeight:(int)scaledHeight 81 | cropWidth:(int)cropWidth 82 | cropHeight:(int)cropHeight 83 | cropX:(int)cropX 84 | cropY:(int)cropY 85 | rotation:(RTCVideoRotation)rotation 86 | timeStampNs:(int64_t)timeStampNs 87 | DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); 88 | 89 | /** Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp. 90 | */ 91 | - (instancetype)initWithBuffer:(id)frameBuffer 92 | rotation:(RTCVideoRotation)rotation 93 | timeStampNs:(int64_t)timeStampNs; 94 | 95 | /** Return a frame that is guaranteed to be I420, i.e. it is possible to access 96 | * the YUV data on it. 97 | */ 98 | - (RTCVideoFrame *)newI420VideoFrame; 99 | 100 | @end 101 | 102 | NS_ASSUME_NONNULL_END 103 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCDataChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | #import 13 | 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | RTC_EXPORT 19 | @interface RTCDataBuffer : NSObject 20 | 21 | /** NSData representation of the underlying buffer. */ 22 | @property(nonatomic, readonly) NSData *data; 23 | 24 | /** Indicates whether |data| contains UTF-8 or binary data. */ 25 | @property(nonatomic, readonly) BOOL isBinary; 26 | 27 | - (instancetype)init NS_UNAVAILABLE; 28 | 29 | /** 30 | * Initialize an RTCDataBuffer from NSData. |isBinary| indicates whether |data| 31 | * contains UTF-8 or binary data. 32 | */ 33 | - (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary; 34 | 35 | @end 36 | 37 | 38 | @class RTCDataChannel; 39 | RTC_EXPORT 40 | @protocol RTCDataChannelDelegate 41 | 42 | /** The data channel state changed. */ 43 | - (void)dataChannelDidChangeState:(RTCDataChannel *)dataChannel; 44 | 45 | /** The data channel successfully received a data buffer. */ 46 | - (void)dataChannel:(RTCDataChannel *)dataChannel 47 | didReceiveMessageWithBuffer:(RTCDataBuffer *)buffer; 48 | 49 | @optional 50 | /** The data channel's |bufferedAmount| changed. */ 51 | - (void)dataChannel:(RTCDataChannel *)dataChannel 52 | didChangeBufferedAmount:(uint64_t)amount; 53 | 54 | @end 55 | 56 | 57 | /** Represents the state of the data channel. */ 58 | typedef NS_ENUM(NSInteger, RTCDataChannelState) { 59 | RTCDataChannelStateConnecting, 60 | RTCDataChannelStateOpen, 61 | RTCDataChannelStateClosing, 62 | RTCDataChannelStateClosed, 63 | }; 64 | 65 | RTC_EXPORT 66 | @interface RTCDataChannel : NSObject 67 | 68 | /** 69 | * A label that can be used to distinguish this data channel from other data 70 | * channel objects. 71 | */ 72 | @property(nonatomic, readonly) NSString *label; 73 | 74 | /** Whether the data channel can send messages in unreliable mode. */ 75 | @property(nonatomic, readonly) BOOL isReliable DEPRECATED_ATTRIBUTE; 76 | 77 | /** Returns whether this data channel is ordered or not. */ 78 | @property(nonatomic, readonly) BOOL isOrdered; 79 | 80 | /** Deprecated. Use maxPacketLifeTime. */ 81 | @property(nonatomic, readonly) NSUInteger maxRetransmitTime 82 | DEPRECATED_ATTRIBUTE; 83 | 84 | /** 85 | * The length of the time window (in milliseconds) during which transmissions 86 | * and retransmissions may occur in unreliable mode. 87 | */ 88 | @property(nonatomic, readonly) uint16_t maxPacketLifeTime; 89 | 90 | /** 91 | * The maximum number of retransmissions that are attempted in unreliable mode. 92 | */ 93 | @property(nonatomic, readonly) uint16_t maxRetransmits; 94 | 95 | /** 96 | * The name of the sub-protocol used with this data channel, if any. Otherwise 97 | * this returns an empty string. 98 | */ 99 | @property(nonatomic, readonly) NSString *protocol; 100 | 101 | /** 102 | * Returns whether this data channel was negotiated by the application or not. 103 | */ 104 | @property(nonatomic, readonly) BOOL isNegotiated; 105 | 106 | /** Deprecated. Use channelId. */ 107 | @property(nonatomic, readonly) NSInteger streamId DEPRECATED_ATTRIBUTE; 108 | 109 | /** The identifier for this data channel. */ 110 | @property(nonatomic, readonly) int channelId; 111 | 112 | /** The state of the data channel. */ 113 | @property(nonatomic, readonly) RTCDataChannelState readyState; 114 | 115 | /** 116 | * The number of bytes of application data that have been queued using 117 | * |sendData:| but that have not yet been transmitted to the network. 118 | */ 119 | @property(nonatomic, readonly) uint64_t bufferedAmount; 120 | 121 | /** The delegate for this data channel. */ 122 | @property(nonatomic, weak) id delegate; 123 | 124 | - (instancetype)init NS_UNAVAILABLE; 125 | 126 | /** Closes the data channel. */ 127 | - (void)close; 128 | 129 | /** Attempt to send |data| on this data channel's underlying data transport. */ 130 | - (BOOL)sendData:(RTCDataBuffer *)data; 131 | 132 | @end 133 | 134 | NS_ASSUME_NONNULL_END 135 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCConfiguration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | @class RTCIceServer; 16 | @class RTCIntervalRange; 17 | 18 | /** 19 | * Represents the ice transport policy. This exposes the same states in C++, 20 | * which include one more state than what exists in the W3C spec. 21 | */ 22 | typedef NS_ENUM(NSInteger, RTCIceTransportPolicy) { 23 | RTCIceTransportPolicyNone, 24 | RTCIceTransportPolicyRelay, 25 | RTCIceTransportPolicyNoHost, 26 | RTCIceTransportPolicyAll 27 | }; 28 | 29 | /** Represents the bundle policy. */ 30 | typedef NS_ENUM(NSInteger, RTCBundlePolicy) { 31 | RTCBundlePolicyBalanced, 32 | RTCBundlePolicyMaxCompat, 33 | RTCBundlePolicyMaxBundle 34 | }; 35 | 36 | /** Represents the rtcp mux policy. */ 37 | typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { 38 | RTCRtcpMuxPolicyNegotiate, 39 | RTCRtcpMuxPolicyRequire 40 | }; 41 | 42 | /** Represents the tcp candidate policy. */ 43 | typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { 44 | RTCTcpCandidatePolicyEnabled, 45 | RTCTcpCandidatePolicyDisabled 46 | }; 47 | 48 | /** Represents the candidate network policy. */ 49 | typedef NS_ENUM(NSInteger, RTCCandidateNetworkPolicy) { 50 | RTCCandidateNetworkPolicyAll, 51 | RTCCandidateNetworkPolicyLowCost 52 | }; 53 | 54 | /** Represents the continual gathering policy. */ 55 | typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) { 56 | RTCContinualGatheringPolicyGatherOnce, 57 | RTCContinualGatheringPolicyGatherContinually 58 | }; 59 | 60 | /** Represents the encryption key type. */ 61 | typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) { 62 | RTCEncryptionKeyTypeRSA, 63 | RTCEncryptionKeyTypeECDSA, 64 | }; 65 | 66 | NS_ASSUME_NONNULL_BEGIN 67 | 68 | RTC_EXPORT 69 | @interface RTCConfiguration : NSObject 70 | 71 | /** An array of Ice Servers available to be used by ICE. */ 72 | @property(nonatomic, copy) NSArray *iceServers; 73 | 74 | /** Which candidates the ICE agent is allowed to use. The W3C calls it 75 | * |iceTransportPolicy|, while in C++ it is called |type|. */ 76 | @property(nonatomic, assign) RTCIceTransportPolicy iceTransportPolicy; 77 | 78 | /** The media-bundling policy to use when gathering ICE candidates. */ 79 | @property(nonatomic, assign) RTCBundlePolicy bundlePolicy; 80 | 81 | /** The rtcp-mux policy to use when gathering ICE candidates. */ 82 | @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; 83 | @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; 84 | @property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy; 85 | @property(nonatomic, assign) 86 | RTCContinualGatheringPolicy continualGatheringPolicy; 87 | 88 | /** By default, the PeerConnection will use a limited number of IPv6 network 89 | * interfaces, in order to avoid too many ICE candidate pairs being created 90 | * and delaying ICE completion. 91 | * 92 | * Can be set to INT_MAX to effectively disable the limit. 93 | */ 94 | @property(nonatomic, assign) int maxIPv6Networks; 95 | 96 | @property(nonatomic, assign) int audioJitterBufferMaxPackets; 97 | @property(nonatomic, assign) BOOL audioJitterBufferFastAccelerate; 98 | @property(nonatomic, assign) int iceConnectionReceivingTimeout; 99 | @property(nonatomic, assign) int iceBackupCandidatePairPingInterval; 100 | 101 | /** Key type used to generate SSL identity. Default is ECDSA. */ 102 | @property(nonatomic, assign) RTCEncryptionKeyType keyType; 103 | 104 | /** ICE candidate pool size as defined in JSEP. Default is 0. */ 105 | @property(nonatomic, assign) int iceCandidatePoolSize; 106 | 107 | /** Prune turn ports on the same network to the same turn server. 108 | * Default is NO. 109 | */ 110 | @property(nonatomic, assign) BOOL shouldPruneTurnPorts; 111 | 112 | /** If set to YES, this means the ICE transport should presume TURN-to-TURN 113 | * candidate pairs will succeed, even before a binding response is received. 114 | */ 115 | @property(nonatomic, assign) BOOL shouldPresumeWritableWhenFullyRelayed; 116 | 117 | /** If set to non-nil, controls the minimal interval between consecutive ICE 118 | * check packets. 119 | */ 120 | @property(nonatomic, copy, nullable) NSNumber *iceCheckMinInterval; 121 | 122 | /** ICE Periodic Regathering 123 | * If set, WebRTC will periodically create and propose candidates without 124 | * starting a new ICE generation. The regathering happens continuously with 125 | * interval specified in milliseconds by the uniform distribution [a, b]. 126 | */ 127 | @property(nonatomic, strong, nullable) RTCIntervalRange *iceRegatherIntervalRange; 128 | 129 | - (instancetype)init; 130 | 131 | @end 132 | 133 | NS_ASSUME_NONNULL_END 134 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/Target Support Files/Pods-WebRTC_iOS/Pods-WebRTC_iOS-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController/ChatViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChatViewController.m 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/11. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import "ChatViewController.h" 10 | #import "WebRTCHelper.h" 11 | 12 | #define KScreenWidth [UIScreen mainScreen].bounds.size.width 13 | #define KScreenHeight [UIScreen mainScreen].bounds.size.height 14 | 15 | #define KVedioWidth KScreenWidth/3.0 16 | #define KVedioHeight KVedioWidth*320/240 17 | 18 | @interface ChatViewController () 19 | { 20 | //本地摄像头追踪 21 | RTCVideoTrack *_localVideoTrack; 22 | //远程的视频追踪 23 | RTCVideoTrack *_remoteVideoTrack; 24 | 25 | } 26 | 27 | @property (nonatomic, strong) UITextField *textField; 28 | @property (nonatomic, strong) UILabel *messageLabel; 29 | 30 | @end 31 | 32 | @implementation ChatViewController 33 | 34 | - (void)dealloc 35 | { 36 | [WebRTCHelper sharedInstance].chatdelegate = nil; 37 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 38 | 39 | } 40 | 41 | - (void)viewDidLoad { 42 | [super viewDidLoad]; 43 | // Do any additional setup after loading the view. 44 | self.view.backgroundColor = [UIColor whiteColor]; 45 | 46 | [WebRTCHelper sharedInstance].chatdelegate = self; 47 | [self creatNavi]; 48 | [self creatSubViews]; 49 | [self handleKeyEvent]; 50 | [self connect]; 51 | } 52 | 53 | - (void)connect 54 | { 55 | if (self.userId) { 56 | [[WebRTCHelper sharedInstance] connectWithUserId:self.userId]; 57 | } 58 | } 59 | 60 | - (void)creatNavi 61 | { 62 | self.title = @"聊天室"; 63 | UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonItemClicked)]; 64 | self.navigationItem.leftBarButtonItem = leftButtonItem; 65 | 66 | } 67 | 68 | - (void)creatSubViews 69 | { 70 | self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 64 + KVedioHeight, KScreenWidth, 40)]; 71 | self.messageLabel.textAlignment = NSTextAlignmentCenter; 72 | self.messageLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1]; 73 | [self.view addSubview:self.messageLabel]; 74 | 75 | self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 110 + KVedioHeight, KScreenWidth - 130, 40)]; 76 | self.textField.borderStyle = UITextBorderStyleRoundedRect; 77 | [self.view addSubview:self.textField]; 78 | 79 | UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 80 | btn1.frame = CGRectMake(KScreenWidth - 115, 110 + KVedioHeight, 100, 40); 81 | btn1.backgroundColor = [UIColor blackColor]; 82 | [btn1 setTitle:@"发送" forState:UIControlStateNormal]; 83 | [btn1 addTarget:self action:@selector(sendMessage) forControlEvents:UIControlEventTouchUpInside]; 84 | [self.view addSubview:btn1]; 85 | } 86 | 87 | - (void)leftButtonItemClicked 88 | { 89 | [[WebRTCHelper sharedInstance] closePeerConnection]; 90 | [self.navigationController popViewControllerAnimated:YES]; 91 | } 92 | 93 | //发送消息 94 | - (void)sendMessage 95 | { 96 | if (self.textField.text.length == 0) { 97 | return; 98 | } 99 | [[WebRTCHelper sharedInstance] sendMessage:self.textField.text]; 100 | self.textField.text = @""; 101 | } 102 | 103 | #pragma mark--WebRTCHelperChatDelegate 104 | //接收到消息 105 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper receiveMessage:(NSString *)message 106 | { 107 | self.messageLabel.text = message; 108 | } 109 | 110 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper setLocalStream:(RTCMediaStream *)stream 111 | { 112 | NSLog(@"setLocalStream"); 113 | 114 | RTCEAGLVideoView *localVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectMake(0, 64, KVedioWidth, KVedioHeight)]; 115 | _localVideoTrack = [stream.videoTracks lastObject]; 116 | [_localVideoTrack addRenderer:localVideoView]; 117 | 118 | [self.view addSubview:localVideoView]; 119 | 120 | } 121 | 122 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper setRemoteStream:(RTCMediaStream *)stream 123 | { 124 | NSLog(@"setRemoteStream"); 125 | 126 | RTCEAGLVideoView *remoteVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectMake(KScreenWidth - KVedioWidth, 64, KVedioWidth, KVedioHeight)]; 127 | _remoteVideoTrack = [stream.videoTracks lastObject]; 128 | [_remoteVideoTrack addRenderer:remoteVideoView]; 129 | 130 | [self.view addSubview:remoteVideoView]; 131 | 132 | } 133 | 134 | //连接断开 135 | - (void)webRTCHelper:(WebRTCHelper *)webRTChelper closeChatWithUserId:(NSString *)userId 136 | { 137 | [self.navigationController popViewControllerAnimated:YES]; 138 | } 139 | 140 | //键盘处理 141 | -(void)handleKeyEvent 142 | { 143 | [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resignKeyTap)]]; 144 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWillShow:) name:UIKeyboardWillShowNotification object:nil]; 145 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWillHiden:) name:UIKeyboardWillHideNotification object:nil]; 146 | } 147 | 148 | -(void)resignKeyTap 149 | { 150 | [self.view endEditing:YES]; 151 | } 152 | 153 | -(void)keyWillShow:(NSNotification *)noti 154 | { 155 | 156 | } 157 | 158 | -(void)keyWillHiden:(NSNotification *)noti 159 | { 160 | 161 | } 162 | 163 | - (void)didReceiveMemoryWarning { 164 | [super didReceiveMemoryWarning]; 165 | // Dispose of any resources that can be recreated. 166 | } 167 | 168 | /* 169 | #pragma mark - Navigation 170 | 171 | // In a storyboard-based application, you will often want to do a little preparation before navigation 172 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 173 | // Get the new view controller using [segue destinationViewController]. 174 | // Pass the selected object to the new view controller. 175 | } 176 | */ 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/ViewController/FriendListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FriendListViewController.m 3 | // WebRTC_iOS 4 | // 5 | // Created by MengFanJun on 2017/8/11. 6 | // Copyright © 2017年 MengFanJun. All rights reserved. 7 | // 8 | 9 | #import "FriendListViewController.h" 10 | #import "ChatViewController.h" 11 | #import "WebRTCHelper.h" 12 | 13 | @interface FriendListViewController () 14 | 15 | @property (nonatomic, strong) UITableView *tableView; 16 | @property (nonatomic, strong) NSMutableArray *informationArray; 17 | 18 | @end 19 | 20 | @implementation FriendListViewController 21 | 22 | - (void)dealloc 23 | { 24 | [WebRTCHelper sharedInstance].friendListDelegate = nil; 25 | } 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | 31 | self.view.backgroundColor = [UIColor whiteColor]; 32 | self.informationArray = [NSMutableArray array]; 33 | [self creatNavi]; 34 | [self creatSubViews]; 35 | [WebRTCHelper sharedInstance].friendListDelegate = self; 36 | [self connectAction]; 37 | 38 | } 39 | 40 | - (void)creatNavi 41 | { 42 | self.title = @"好友列表"; 43 | UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonItemClicked)]; 44 | self.navigationItem.leftBarButtonItem = leftButtonItem; 45 | } 46 | 47 | - (void)creatSubViews 48 | { 49 | self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped]; 50 | [self.view addSubview:self.tableView]; 51 | self.tableView.delegate = self; 52 | self.tableView.dataSource = self; 53 | [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuse"]; 54 | _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 55 | _tableView.backgroundColor = [UIColor clearColor]; 56 | 57 | } 58 | 59 | - (void)leftButtonItemClicked 60 | { 61 | [[WebRTCHelper sharedInstance] exitRoom]; 62 | [self.navigationController popViewControllerAnimated:YES]; 63 | } 64 | 65 | //连接到房间 66 | - (void)connectAction 67 | { 68 | [[WebRTCHelper sharedInstance] connectServer:@"172.16.102.59" port:@"3000" room:@"100"]; 69 | 70 | } 71 | 72 | #pragma mark ** WebRTCHelperFriendListDelegate协议方法 73 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper gotFriendList:(NSArray *)friendList 74 | { 75 | [self.informationArray removeAllObjects]; 76 | [self.informationArray addObjectsFromArray:friendList]; 77 | [self.tableView reloadData]; 78 | } 79 | 80 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper gotNewFriend:(NSString *)userId 81 | { 82 | [self.informationArray addObject:userId]; 83 | [self.tableView reloadData]; 84 | } 85 | 86 | - (void)webRTCHelper:(WebRTCHelper *)webRTCHelper removeFriend:(NSString *)userId 87 | { 88 | for (int i = 0; i < self.informationArray.count; i++) { 89 | NSString *friendId = self.informationArray[i]; 90 | if ([friendId isEqualToString:userId]) { 91 | [self.informationArray removeObjectAtIndex:i]; 92 | break; 93 | } 94 | } 95 | [self.tableView reloadData]; 96 | } 97 | 98 | - (void)requestConnectWithUserId:(NSString *)userId 99 | { 100 | ChatViewController *chatViewController = [[ChatViewController alloc] init]; 101 | [self.navigationController pushViewController:chatViewController animated:YES]; 102 | } 103 | 104 | #pragma mark ** tableView协议方法 105 | //分区个数 106 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 107 | return 1; 108 | } 109 | 110 | //每个分区cell个数 111 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 112 | return self.informationArray.count; 113 | } 114 | 115 | //重用cell 116 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 117 | if (indexPath.section == 0) { 118 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"]; 119 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 120 | cell.textLabel.text = self.informationArray[indexPath.row]; 121 | return cell; 122 | } 123 | return nil; 124 | } 125 | 126 | //cell高度 127 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 128 | { 129 | return 50; 130 | } 131 | 132 | //分区header高度 133 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 134 | { 135 | return 0.01; 136 | } 137 | 138 | //分区headView 139 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 140 | { 141 | return nil; 142 | } 143 | 144 | //分区footer高度 145 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 146 | return 0.01; 147 | } 148 | 149 | //分区footView 150 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 151 | { 152 | return nil; 153 | } 154 | 155 | //点击cell跳转至详情页 156 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 157 | { 158 | ChatViewController *chatViewController = [[ChatViewController alloc] init]; 159 | chatViewController.userId = self.informationArray[indexPath.row]; 160 | [self.navigationController pushViewController:chatViewController animated:YES]; 161 | } 162 | 163 | - (void)didReceiveMemoryWarning { 164 | [super didReceiveMemoryWarning]; 165 | // Dispose of any resources that can be recreated. 166 | } 167 | 168 | /* 169 | #pragma mark - Navigation 170 | 171 | // In a storyboard-based application, you will often want to do a little preparation before navigation 172 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 173 | // Get the new view controller using [segue destinationViewController]. 174 | // Pass the selected object to the new view controller. 175 | } 176 | */ 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/SocketRocket/SocketRocket/SRWebSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2012 Square Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import 19 | 20 | typedef NS_ENUM(NSInteger, SRReadyState) { 21 | SR_CONNECTING = 0, 22 | SR_OPEN = 1, 23 | SR_CLOSING = 2, 24 | SR_CLOSED = 3, 25 | }; 26 | 27 | typedef enum SRStatusCode : NSInteger { 28 | // 0–999: Reserved and not used. 29 | SRStatusCodeNormal = 1000, 30 | SRStatusCodeGoingAway = 1001, 31 | SRStatusCodeProtocolError = 1002, 32 | SRStatusCodeUnhandledType = 1003, 33 | // 1004 reserved. 34 | SRStatusNoStatusReceived = 1005, 35 | SRStatusCodeAbnormal = 1006, 36 | SRStatusCodeInvalidUTF8 = 1007, 37 | SRStatusCodePolicyViolated = 1008, 38 | SRStatusCodeMessageTooBig = 1009, 39 | SRStatusCodeMissingExtension = 1010, 40 | SRStatusCodeInternalError = 1011, 41 | SRStatusCodeServiceRestart = 1012, 42 | SRStatusCodeTryAgainLater = 1013, 43 | // 1014: Reserved for future use by the WebSocket standard. 44 | SRStatusCodeTLSHandshake = 1015, 45 | // 1016–1999: Reserved for future use by the WebSocket standard. 46 | // 2000–2999: Reserved for use by WebSocket extensions. 47 | // 3000–3999: Available for use by libraries and frameworks. May not be used by applications. Available for registration at the IANA via first-come, first-serve. 48 | // 4000–4999: Available for use by applications. 49 | } SRStatusCode; 50 | 51 | @class SRWebSocket; 52 | 53 | extern NSString *const SRWebSocketErrorDomain; 54 | extern NSString *const SRHTTPResponseErrorKey; 55 | 56 | #pragma mark - SRWebSocketDelegate 57 | 58 | @protocol SRWebSocketDelegate; 59 | 60 | #pragma mark - SRWebSocket 61 | 62 | @interface SRWebSocket : NSObject 63 | 64 | @property (nonatomic, weak) id delegate; 65 | 66 | @property (nonatomic, readonly) SRReadyState readyState; 67 | @property (nonatomic, readonly, retain) NSURL *url; 68 | 69 | 70 | @property (nonatomic, readonly) CFHTTPMessageRef receivedHTTPHeaders; 71 | 72 | // Optional array of cookies (NSHTTPCookie objects) to apply to the connections 73 | @property (nonatomic, readwrite) NSArray * requestCookies; 74 | 75 | // This returns the negotiated protocol. 76 | // It will be nil until after the handshake completes. 77 | @property (nonatomic, readonly, copy) NSString *protocol; 78 | 79 | // Protocols should be an array of strings that turn into Sec-WebSocket-Protocol. 80 | - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols allowsUntrustedSSLCertificates:(BOOL)allowsUntrustedSSLCertificates; 81 | - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; 82 | - (id)initWithURLRequest:(NSURLRequest *)request; 83 | 84 | // Some helper constructors. 85 | - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols allowsUntrustedSSLCertificates:(BOOL)allowsUntrustedSSLCertificates; 86 | - (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols; 87 | - (id)initWithURL:(NSURL *)url; 88 | 89 | // Delegate queue will be dispatch_main_queue by default. 90 | // You cannot set both OperationQueue and dispatch_queue. 91 | - (void)setDelegateOperationQueue:(NSOperationQueue*) queue; 92 | - (void)setDelegateDispatchQueue:(dispatch_queue_t) queue; 93 | 94 | // By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes. 95 | - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; 96 | - (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; 97 | 98 | // SRWebSockets are intended for one-time-use only. Open should be called once and only once. 99 | - (void)open; 100 | 101 | - (void)close; 102 | - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; 103 | 104 | // Send a UTF8 String or Data. 105 | - (void)send:(id)data; 106 | 107 | // Send Data (can be nil) in a ping message. 108 | - (void)sendPing:(NSData *)data; 109 | 110 | @end 111 | 112 | #pragma mark - SRWebSocketDelegate 113 | 114 | @protocol SRWebSocketDelegate 115 | 116 | // message will either be an NSString if the server is using text 117 | // or NSData if the server is using binary. 118 | - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message; 119 | 120 | @optional 121 | 122 | - (void)webSocketDidOpen:(SRWebSocket *)webSocket; 123 | - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error; 124 | - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean; 125 | - (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload; 126 | 127 | // Return YES to convert messages sent as Text to an NSString. Return NO to skip NSData -> NSString conversion for Text messages. Defaults to YES. 128 | - (BOOL)webSocketShouldConvertTextFrameToString:(SRWebSocket *)webSocket; 129 | 130 | @end 131 | 132 | #pragma mark - NSURLRequest (SRCertificateAdditions) 133 | 134 | @interface NSURLRequest (SRCertificateAdditions) 135 | 136 | @property (nonatomic, retain, readonly) NSArray *SR_SSLPinnedCertificates; 137 | 138 | @end 139 | 140 | #pragma mark - NSMutableURLRequest (SRCertificateAdditions) 141 | 142 | @interface NSMutableURLRequest (SRCertificateAdditions) 143 | 144 | @property (nonatomic, retain) NSArray *SR_SSLPinnedCertificates; 145 | 146 | @end 147 | 148 | #pragma mark - NSRunLoop (SRWebSocket) 149 | 150 | @interface NSRunLoop (SRWebSocket) 151 | 152 | + (NSRunLoop *)SR_networkRunLoop; 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCVideoCodec.h: -------------------------------------------------------------------------------- 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 | #import 12 | 13 | #import 14 | 15 | @class RTCVideoFrame; 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | /** Represents an encoded frame's type. */ 20 | typedef NS_ENUM(NSUInteger, RTCFrameType) { 21 | RTCFrameTypeEmptyFrame = 0, 22 | RTCFrameTypeAudioFrameSpeech = 1, 23 | RTCFrameTypeAudioFrameCN = 2, 24 | RTCFrameTypeVideoFrameKey = 3, 25 | RTCFrameTypeVideoFrameDelta = 4, 26 | }; 27 | 28 | typedef NS_ENUM(NSUInteger, RTCVideoContentType) { 29 | RTCVideoContentTypeUnspecified, 30 | RTCVideoContentTypeScreenshare, 31 | }; 32 | 33 | /** Represents an encoded frame. Corresponds to webrtc::EncodedImage. */ 34 | RTC_EXPORT 35 | @interface RTCEncodedImage : NSObject 36 | 37 | @property(nonatomic, strong) NSData *buffer; 38 | @property(nonatomic, assign) int encodedWidth; 39 | @property(nonatomic, assign) int encodedHeight; 40 | @property(nonatomic, assign) uint32_t timeStamp; 41 | @property(nonatomic, assign) long captureTimeMs; 42 | @property(nonatomic, assign) long ntpTimeMs; 43 | @property(nonatomic, assign) BOOL isTimingFrame; 44 | @property(nonatomic, assign) long encodeStartMs; 45 | @property(nonatomic, assign) long encodeFinishMs; 46 | @property(nonatomic, assign) RTCFrameType frameType; 47 | @property(nonatomic, assign) int rotation; 48 | @property(nonatomic, assign) BOOL completeFrame; 49 | @property(nonatomic, strong) NSNumber *qp; 50 | @property(nonatomic, assign) RTCVideoContentType contentType; 51 | 52 | @end 53 | 54 | /** Information for header. Corresponds to webrtc::RTPFragmentationHeader. */ 55 | RTC_EXPORT 56 | @interface RTCRtpFragmentationHeader : NSObject 57 | 58 | @property(nonatomic, strong) NSArray *fragmentationOffset; 59 | @property(nonatomic, strong) NSArray *fragmentationLength; 60 | @property(nonatomic, strong) NSArray *fragmentationTimeDiff; 61 | @property(nonatomic, strong) NSArray *fragmentationPlType; 62 | 63 | @end 64 | 65 | /** Implement this protocol to pass codec specific info from the encoder. 66 | * Corresponds to webrtc::CodecSpecificInfo. 67 | */ 68 | RTC_EXPORT 69 | @protocol RTCCodecSpecificInfo 70 | 71 | @end 72 | 73 | /** Class for H264 specific config. */ 74 | typedef NS_ENUM(NSUInteger, RTCH264PacketizationMode) { 75 | RTCH264PacketizationModeNonInterleaved = 0, // Mode 1 - STAP-A, FU-A is allowed 76 | RTCH264PacketizationModeSingleNalUnit // Mode 0 - only single NALU allowed 77 | }; 78 | 79 | RTC_EXPORT 80 | @interface RTCCodecSpecificInfoH264 : NSObject 81 | 82 | @property(nonatomic, assign) RTCH264PacketizationMode packetizationMode; 83 | 84 | @end 85 | 86 | /** Callback block for encoder. */ 87 | typedef BOOL (^RTCVideoEncoderCallback)(RTCEncodedImage *frame, 88 | id info, 89 | RTCRtpFragmentationHeader *header); 90 | 91 | /** Callback block for decoder. */ 92 | typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame); 93 | 94 | typedef NS_ENUM(NSUInteger, RTCVideoCodecMode) { 95 | RTCVideoCodecModeRealtimeVideo, 96 | RTCVideoCodecModeScreensharing, 97 | }; 98 | 99 | /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. */ 100 | RTC_EXPORT 101 | @interface RTCVideoCodecInfo : NSObject 102 | 103 | - (instancetype)initWithPayload:(NSInteger)payload 104 | name:(NSString *)name 105 | parameters:(NSDictionary *)parameters; 106 | 107 | @property(nonatomic, readonly) NSInteger payload; 108 | @property(nonatomic, readonly) NSString *name; 109 | @property(nonatomic, readonly) NSDictionary *parameters; 110 | 111 | @end 112 | 113 | /** Settings for encoder. Corresponds to webrtc::VideoCodec. */ 114 | RTC_EXPORT 115 | @interface RTCVideoEncoderSettings : NSObject 116 | 117 | @property(nonatomic, strong) NSString *name; 118 | 119 | @property(nonatomic, assign) unsigned short width; 120 | @property(nonatomic, assign) unsigned short height; 121 | 122 | @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec. 123 | @property(nonatomic, assign) unsigned int maxBitrate; 124 | @property(nonatomic, assign) unsigned int minBitrate; 125 | @property(nonatomic, assign) unsigned int targetBitrate; 126 | 127 | @property(nonatomic, assign) uint32_t maxFramerate; 128 | 129 | @property(nonatomic, assign) unsigned int qpMax; 130 | @property(nonatomic, assign) RTCVideoCodecMode mode; 131 | 132 | @end 133 | 134 | /** QP thresholds for encoder. Corresponds to webrtc::VideoEncoder::QpThresholds. */ 135 | RTC_EXPORT 136 | @interface RTCVideoEncoderQpThresholds : NSObject 137 | 138 | - (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high; 139 | 140 | @property(nonatomic, readonly) NSInteger low; 141 | @property(nonatomic, readonly) NSInteger high; 142 | 143 | @end 144 | 145 | /** Protocol for encoder implementations. */ 146 | RTC_EXPORT 147 | @protocol RTCVideoEncoder 148 | 149 | - (void)setCallback:(RTCVideoEncoderCallback)callback; 150 | - (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings 151 | numberOfCores:(int)numberOfCores; 152 | - (NSInteger)releaseEncoder; 153 | - (NSInteger)encode:(RTCVideoFrame *)frame 154 | codecSpecificInfo:(id)info 155 | frameTypes:(NSArray *)frameTypes; 156 | - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; 157 | - (NSString *)implementationName; 158 | 159 | /** Returns QP scaling settings for encoder. The quality scaler adjusts the resolution in order to 160 | * keep the QP from the encoded images within the given range. Returning nil from this function 161 | * disables quality scaling. */ 162 | - (RTCVideoEncoderQpThresholds *)scalingSettings; 163 | 164 | @end 165 | 166 | /** Protocol for decoder implementations. */ 167 | RTC_EXPORT 168 | @protocol RTCVideoDecoder 169 | 170 | - (void)setCallback:(RTCVideoDecoderCallback)callback; 171 | - (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings 172 | numberOfCores:(int)numberOfCores; 173 | - (NSInteger)releaseDecoder; 174 | - (NSInteger)decode:(RTCEncodedImage *)encodedImage 175 | missingFrames:(BOOL)missingFrames 176 | fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader 177 | codecSpecificInfo:(__nullable id)info 178 | renderTimeMs:(int64_t)renderTimeMs; 179 | - (NSString *)implementationName; 180 | 181 | @end 182 | 183 | NS_ASSUME_NONNULL_END 184 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCPeerConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 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 | #import 12 | 13 | #import 14 | 15 | @class RTCConfiguration; 16 | @class RTCDataChannel; 17 | @class RTCDataChannelConfiguration; 18 | @class RTCIceCandidate; 19 | @class RTCMediaConstraints; 20 | @class RTCMediaStream; 21 | @class RTCMediaStreamTrack; 22 | @class RTCPeerConnectionFactory; 23 | @class RTCRtpReceiver; 24 | @class RTCRtpSender; 25 | @class RTCSessionDescription; 26 | @class RTCLegacyStatsReport; 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | extern NSString * const kRTCPeerConnectionErrorDomain; 31 | extern int const kRTCSessionDescriptionErrorCode; 32 | 33 | /** Represents the signaling state of the peer connection. */ 34 | typedef NS_ENUM(NSInteger, RTCSignalingState) { 35 | RTCSignalingStateStable, 36 | RTCSignalingStateHaveLocalOffer, 37 | RTCSignalingStateHaveLocalPrAnswer, 38 | RTCSignalingStateHaveRemoteOffer, 39 | RTCSignalingStateHaveRemotePrAnswer, 40 | // Not an actual state, represents the total number of states. 41 | RTCSignalingStateClosed, 42 | }; 43 | 44 | /** Represents the ice connection state of the peer connection. */ 45 | typedef NS_ENUM(NSInteger, RTCIceConnectionState) { 46 | RTCIceConnectionStateNew, 47 | RTCIceConnectionStateChecking, 48 | RTCIceConnectionStateConnected, 49 | RTCIceConnectionStateCompleted, 50 | RTCIceConnectionStateFailed, 51 | RTCIceConnectionStateDisconnected, 52 | RTCIceConnectionStateClosed, 53 | RTCIceConnectionStateCount, 54 | }; 55 | 56 | /** Represents the ice gathering state of the peer connection. */ 57 | typedef NS_ENUM(NSInteger, RTCIceGatheringState) { 58 | RTCIceGatheringStateNew, 59 | RTCIceGatheringStateGathering, 60 | RTCIceGatheringStateComplete, 61 | }; 62 | 63 | /** Represents the stats output level. */ 64 | typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { 65 | RTCStatsOutputLevelStandard, 66 | RTCStatsOutputLevelDebug, 67 | }; 68 | 69 | @class RTCPeerConnection; 70 | 71 | RTC_EXPORT 72 | @protocol RTCPeerConnectionDelegate 73 | 74 | /** Called when the SignalingState changed. */ 75 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 76 | didChangeSignalingState:(RTCSignalingState)stateChanged; 77 | 78 | /** Called when media is received on a new stream from remote peer. */ 79 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 80 | didAddStream:(RTCMediaStream *)stream; 81 | 82 | /** Called when a remote peer closes a stream. */ 83 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 84 | didRemoveStream:(RTCMediaStream *)stream; 85 | 86 | /** Called when negotiation is needed, for example ICE has restarted. */ 87 | - (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection; 88 | 89 | /** Called any time the IceConnectionState changes. */ 90 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 91 | didChangeIceConnectionState:(RTCIceConnectionState)newState; 92 | 93 | /** Called any time the IceGatheringState changes. */ 94 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 95 | didChangeIceGatheringState:(RTCIceGatheringState)newState; 96 | 97 | /** New ice candidate has been found. */ 98 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 99 | didGenerateIceCandidate:(RTCIceCandidate *)candidate; 100 | 101 | /** Called when a group of local Ice candidates have been removed. */ 102 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 103 | didRemoveIceCandidates:(NSArray *)candidates; 104 | 105 | /** New data channel has been opened. */ 106 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 107 | didOpenDataChannel:(RTCDataChannel *)dataChannel; 108 | 109 | @end 110 | 111 | RTC_EXPORT 112 | @interface RTCPeerConnection : NSObject 113 | 114 | /** The object that will be notifed about events such as state changes and 115 | * streams being added or removed. 116 | */ 117 | @property(nonatomic, weak, nullable) id delegate; 118 | @property(nonatomic, readonly) NSArray *localStreams; 119 | @property(nonatomic, readonly, nullable) 120 | RTCSessionDescription *localDescription; 121 | @property(nonatomic, readonly, nullable) 122 | RTCSessionDescription *remoteDescription; 123 | @property(nonatomic, readonly) RTCSignalingState signalingState; 124 | @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; 125 | @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; 126 | @property(nonatomic, readonly, copy) RTCConfiguration *configuration; 127 | 128 | /** Gets all RTCRtpSenders associated with this peer connection. 129 | * Note: reading this property returns different instances of RTCRtpSender. 130 | * Use isEqual: instead of == to compare RTCRtpSender instances. 131 | */ 132 | @property(nonatomic, readonly) NSArray *senders; 133 | 134 | /** Gets all RTCRtpReceivers associated with this peer connection. 135 | * Note: reading this property returns different instances of RTCRtpReceiver. 136 | * Use isEqual: instead of == to compare RTCRtpReceiver instances. 137 | */ 138 | @property(nonatomic, readonly) NSArray *receivers; 139 | 140 | - (instancetype)init NS_UNAVAILABLE; 141 | 142 | /** Sets the PeerConnection's global configuration to |configuration|. 143 | * Any changes to STUN/TURN servers or ICE candidate policy will affect the 144 | * next gathering phase, and cause the next call to createOffer to generate 145 | * new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies 146 | * cannot be changed with this method. 147 | */ 148 | - (BOOL)setConfiguration:(RTCConfiguration *)configuration; 149 | 150 | /** Terminate all media and close the transport. */ 151 | - (void)close; 152 | 153 | /** Provide a remote candidate to the ICE Agent. */ 154 | - (void)addIceCandidate:(RTCIceCandidate *)candidate; 155 | 156 | /** Remove a group of remote candidates from the ICE Agent. */ 157 | - (void)removeIceCandidates:(NSArray *)candidates; 158 | 159 | /** Add a new media stream to be sent on this peer connection. */ 160 | - (void)addStream:(RTCMediaStream *)stream; 161 | 162 | /** Remove the given media stream from this peer connection. */ 163 | - (void)removeStream:(RTCMediaStream *)stream; 164 | 165 | /** Generate an SDP offer. */ 166 | - (void)offerForConstraints:(RTCMediaConstraints *)constraints 167 | completionHandler:(nullable void (^) 168 | (RTCSessionDescription * _Nullable sdp, 169 | NSError * _Nullable error))completionHandler; 170 | 171 | /** Generate an SDP answer. */ 172 | - (void)answerForConstraints:(RTCMediaConstraints *)constraints 173 | completionHandler:(nullable void (^) 174 | (RTCSessionDescription * _Nullable sdp, 175 | NSError * _Nullable error))completionHandler; 176 | 177 | /** Apply the supplied RTCSessionDescription as the local description. */ 178 | - (void)setLocalDescription:(RTCSessionDescription *)sdp 179 | completionHandler: 180 | (nullable void (^)(NSError * _Nullable error))completionHandler; 181 | 182 | /** Apply the supplied RTCSessionDescription as the remote description. */ 183 | - (void)setRemoteDescription:(RTCSessionDescription *)sdp 184 | completionHandler: 185 | (nullable void (^)(NSError * _Nullable error))completionHandler; 186 | 187 | /** Start or stop recording an Rtc EventLog. */ 188 | - (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath 189 | maxSizeInBytes:(int64_t)maxSizeInBytes; 190 | - (void)stopRtcEventLog; 191 | 192 | @end 193 | 194 | @interface RTCPeerConnection (Media) 195 | 196 | /** 197 | * Create an RTCRtpSender with the specified kind and media stream ID. 198 | * See RTCMediaStreamTrack.h for available kinds. 199 | */ 200 | - (RTCRtpSender *)senderWithKind:(NSString *)kind streamId:(NSString *)streamId; 201 | 202 | @end 203 | 204 | @interface RTCPeerConnection (DataChannel) 205 | 206 | /** Create a new data channel with the given label and configuration. */ 207 | - (RTCDataChannel *)dataChannelForLabel:(NSString *)label 208 | configuration:(RTCDataChannelConfiguration *)configuration; 209 | 210 | @end 211 | 212 | @interface RTCPeerConnection (Stats) 213 | 214 | /** Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil 215 | * statistics are gathered for all tracks. 216 | */ 217 | - (void)statsForTrack: 218 | (nullable RTCMediaStreamTrack *)mediaStreamTrack 219 | statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel 220 | completionHandler: 221 | (nullable void (^)(NSArray *stats))completionHandler; 222 | 223 | @end 224 | 225 | NS_ASSUME_NONNULL_END 226 | -------------------------------------------------------------------------------- /WebRTC_iOS/Pods/SocketRocket/README.rst: -------------------------------------------------------------------------------- 1 | SocketRocket Objective-C WebSocket Client (beta) 2 | ================================================ 3 | A conforming WebSocket (`RFC 6455 `_) 4 | client library. 5 | 6 | `Test results for SocketRocket here `_. 7 | You can compare to what `modern browsers look like here 8 | `_. 9 | 10 | SocketRocket currently conforms to all ~300 of `Autobahn 11 | `_'s fuzzing tests (aside from 12 | two UTF-8 ones where it is merely *non-strict*. tests 6.4.2 and 6.4.4) 13 | 14 | Features/Design 15 | --------------- 16 | - TLS (wss) support. It uses CFStream so we get this for *free* 17 | - Uses NSStream/CFNetworking. Earlier implementations used ``dispatch_io``, 18 | however, this proved to be make TLS nearly impossible. Also I wanted this to 19 | work in iOS 4.x. (SocketRocket only supports 5.0 and above now) 20 | - Uses ARC. It uses the 4.0 compatible subset (no weak refs). 21 | - Seems to perform quite well 22 | - Parallel architecture. Most of the work is done in background worker queues. 23 | - Delegate-based. Had older versions that could use blocks too, but I felt it 24 | didn't blend well with retain cycles and just objective C in general. 25 | 26 | Changes 27 | ------- 28 | 29 | v0.3.1-beta2 - 2013-01-12 30 | ````````````````````````` 31 | 32 | - Stability fix for ``closeWithCode:reason:`` (Thanks @michaelpetrov!) 33 | - Actually clean up the NSStreams and remove them from their runloops 34 | - ``_SRRunLoopThread``'s ``main`` wasn't correctly wrapped with 35 | ``@autoreleasepool`` 36 | 37 | v0.3.1-beta1 - 2013-01-12 38 | ````````````````````````` 39 | 40 | - Cleaned up GCD so OS_OBJECT_USE_OBJC_RETAIN_RELEASE is optional 41 | - Removed deprecated ``dispatch_get_current_queue`` in favor of ``dispatch_queue_set_specific`` and ``dispatch_get_specific`` 42 | - Dropping support for iOS 4.0 (it may still work) 43 | 44 | 45 | Installing (iOS) 46 | ---------------- 47 | There's a few options. Choose one, or just figure it out 48 | 49 | - You can copy all the files in the SocketRocket group into your app. 50 | - Include SocketRocket as a subproject and use libSocketRocket 51 | 52 | If you do this, you must add -ObjC to your "other linker flags" option 53 | 54 | - For OS X you will have to repackage make a .framework target. I will take 55 | contributions. Message me if you are interested. 56 | 57 | 58 | Depending on how you configure your project you may need to ``#import`` either 59 | ```` or ``"SRWebSocket.h"`` 60 | 61 | Framework Dependencies 62 | `````````````````````` 63 | Your .app must be linked against the following frameworks/dylibs 64 | 65 | - libicucore.dylib 66 | - CFNetwork.framework 67 | - Security.framework 68 | - Foundation.framework 69 | 70 | Installing (OS X) 71 | ----------------- 72 | SocketRocket now has (64-bit only) OS X support. ``SocketRocket.framework`` 73 | inside Xcode project is for OS X only. It should be identical in function aside 74 | from the unicode validation. ICU isn't shipped with OS X which is what the 75 | original implementation used for unicode validation. The workaround is much 76 | more rudimentary and less robust. 77 | 78 | 1. Add SocketRocket.xcodeproj as either a subproject of your app or in your workspace. 79 | 2. Add ``SocketRocket.framework`` to the link libraries 80 | 3. If you don't have a "copy files" step for ``Framework``, create one 81 | 4. Add ``SocketRocket.framework`` to the "copy files" step. 82 | 83 | API 84 | --- 85 | The classes 86 | 87 | ``SRWebSocket`` 88 | ``````````````` 89 | The Web Socket. 90 | 91 | .. note:: ``SRWebSocket`` will retain itself between ``-(void)open`` and when it 92 | closes, errors, or fails. This is similar to how ``NSURLConnection`` behaves. 93 | (unlike ``NSURLConnection``, ``SRWebSocket`` won't retain the delegate) 94 | 95 | What you need to know 96 | 97 | .. code-block:: objective-c 98 | 99 | @interface SRWebSocket : NSObject 100 | 101 | // Make it with this 102 | - (id)initWithURLRequest:(NSURLRequest *)request; 103 | 104 | // Set this before opening 105 | @property (nonatomic, assign) id delegate; 106 | 107 | - (void)open; 108 | 109 | // Close it with this 110 | - (void)close; 111 | 112 | // Send a UTF8 String or Data 113 | - (void)send:(id)data; 114 | 115 | @end 116 | 117 | ``SRWebSocketDelegate`` 118 | ``````````````````````` 119 | You implement this 120 | 121 | .. code-block:: objective-c 122 | 123 | @protocol SRWebSocketDelegate 124 | 125 | - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message; 126 | 127 | @optional 128 | 129 | - (void)webSocketDidOpen:(SRWebSocket *)webSocket; 130 | - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error; 131 | - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean; 132 | 133 | @end 134 | 135 | Known Issues/Server Todo's 136 | -------------------------- 137 | - Needs auth delegates (like in NSURLConnection) 138 | - Move the streams off the main runloop (most of the work is backgrounded uses 139 | GCD, but I just haven't gotten around to moving it off the main loop since I 140 | converted it from dispatch_io) 141 | - Re-implement server. I removed an existing implementation as well because it 142 | wasn't being used and I wasn't super happy with the interface. Will revisit 143 | this. 144 | - Separate framer and client logic. This will make it nicer when having a 145 | server. 146 | 147 | Testing 148 | ------- 149 | Included are setup scripts for the python testing environment. It comes 150 | packaged with vitualenv so all the dependencies are installed in userland. 151 | 152 | To run the short test from the command line, run:: 153 | 154 | make test 155 | 156 | To run all the tests, run:: 157 | 158 | make test_all 159 | 160 | The short tests don't include the performance tests. (the test harness is 161 | actually the bottleneck, not SocketRocket). 162 | 163 | The first time this is run, it may take a while to install the dependencies. It 164 | will be smooth sailing after that. After the test runs the makefile will open 165 | the results page in your browser. If nothing comes up, you failed. Working on 166 | making this interface a bit nicer. 167 | 168 | To run from the app, choose the ``SocketRocket`` target and run the test action 169 | (``cmd+u``). It runs the same thing, but makes it easier to debug. There is 170 | some serious pre/post hooks in the Test action. You can edit it to customize 171 | behavior. 172 | 173 | .. note:: Xcode only up to version 4.4 is currently supported for the test 174 | harness 175 | 176 | TestChat Demo Application 177 | ------------------------- 178 | SocketRocket includes a demo app, TestChat. It will "chat" with a listening 179 | websocket on port 9900. 180 | 181 | It's a simple project. Uses storyboard. Storyboard is sweet. 182 | 183 | 184 | TestChat Server 185 | ``````````````` 186 | We've included a small server for the chat app. It has a simple function. 187 | It will take a message and broadcast it to all other connected clients. 188 | 189 | We have to get some dependencies. We also want to reuse the virtualenv we made 190 | when we ran the tests. If you haven't run the tests yet, go into the 191 | SocketRocket root directory and type:: 192 | 193 | make test 194 | 195 | This will set up your `virtualenv `_. 196 | Now, in your terminal:: 197 | 198 | source .env/bin/activate 199 | pip install git+https://github.com/tornadoweb/tornado.git 200 | 201 | In the same terminal session, start the chatroom server:: 202 | 203 | python TestChatServer/py/chatroom.py 204 | 205 | There's also a Go implementation (with the latest weekly) where you can:: 206 | 207 | cd TestChatServer/go 208 | go run chatroom.go 209 | 210 | Chatting 211 | ```````` 212 | Now, start TestChat.app (just run the target in the Xcode project). If you had 213 | it started already you can hit the refresh button to reconnect. It should say 214 | "Connected!" on top. 215 | 216 | To talk with the app, open up your browser to `http://localhost:9000 `_ and 217 | start chatting. 218 | 219 | 220 | WebSocket Server Implementation Recommendations 221 | ----------------------------------------------- 222 | SocketRocket has been used with the following libraries: 223 | 224 | - `Tornado `_ 225 | - Go's `WebSocket package `_ or Gorilla's `version `_ 226 | - `Autobahn `_ (using its fuzzing 227 | client) 228 | 229 | The Tornado one is dirt simple and works like a charm. (`IPython notebook 230 | `_ uses it 231 | too). It's much easier to configure handlers and routes than in 232 | Autobahn/twisted. 233 | 234 | As far as Go's goes, it works in my limited testing. I much prefer go's 235 | concurrency model as well. Try it! You may like it. 236 | It could use some more control over things such as pings, etc., but I 237 | am sure it will come in time. 238 | 239 | Autobahn is a great test suite. The Python server code is good, and conforms 240 | well (obviously). However for me, twisted would be a deal-breaker for writing 241 | something new. I find it a bit too complex and heavy for a simple service. If 242 | you are already using twisted though, Autobahn is probably for you. 243 | 244 | Contributing 245 | ------------ 246 | We’re glad you’re interested in SocketRocket, and we’d love to see where you take it. Please read our `contributing guidelines `_ prior to submitting a Pull Request. -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTC/WebRTC.framework/Headers/RTCAudioSession.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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 | #import 12 | #import 13 | 14 | #import "WebRTC/RTCMacros.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | extern NSString * const kRTCAudioSessionErrorDomain; 19 | /** Method that requires lock was called without lock. */ 20 | extern NSInteger const kRTCAudioSessionErrorLockRequired; 21 | /** Unknown configuration error occurred. */ 22 | extern NSInteger const kRTCAudioSessionErrorConfiguration; 23 | 24 | @class RTCAudioSession; 25 | @class RTCAudioSessionConfiguration; 26 | 27 | // Surfaces AVAudioSession events. WebRTC will listen directly for notifications 28 | // from AVAudioSession and handle them before calling these delegate methods, 29 | // at which point applications can perform additional processing if required. 30 | RTC_EXPORT 31 | @protocol RTCAudioSessionDelegate 32 | 33 | @optional 34 | /** Called on a system notification thread when AVAudioSession starts an 35 | * interruption event. 36 | */ 37 | - (void)audioSessionDidBeginInterruption:(RTCAudioSession *)session; 38 | 39 | /** Called on a system notification thread when AVAudioSession ends an 40 | * interruption event. 41 | */ 42 | - (void)audioSessionDidEndInterruption:(RTCAudioSession *)session 43 | shouldResumeSession:(BOOL)shouldResumeSession; 44 | 45 | /** Called on a system notification thread when AVAudioSession changes the 46 | * route. 47 | */ 48 | - (void)audioSessionDidChangeRoute:(RTCAudioSession *)session 49 | reason:(AVAudioSessionRouteChangeReason)reason 50 | previousRoute:(AVAudioSessionRouteDescription *)previousRoute; 51 | 52 | /** Called on a system notification thread when AVAudioSession media server 53 | * terminates. 54 | */ 55 | - (void)audioSessionMediaServerTerminated:(RTCAudioSession *)session; 56 | 57 | /** Called on a system notification thread when AVAudioSession media server 58 | * restarts. 59 | */ 60 | - (void)audioSessionMediaServerReset:(RTCAudioSession *)session; 61 | 62 | // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification. 63 | 64 | - (void)audioSession:(RTCAudioSession *)session 65 | didChangeCanPlayOrRecord:(BOOL)canPlayOrRecord; 66 | 67 | /** Called on a WebRTC thread when the audio device is notified to begin 68 | * playback or recording. 69 | */ 70 | - (void)audioSessionDidStartPlayOrRecord:(RTCAudioSession *)session; 71 | 72 | /** Called on a WebRTC thread when the audio device is notified to stop 73 | * playback or recording. 74 | */ 75 | - (void)audioSessionDidStopPlayOrRecord:(RTCAudioSession *)session; 76 | 77 | /** Called when the AVAudioSession output volume value changes. */ 78 | - (void)audioSession:(RTCAudioSession *)audioSession 79 | didChangeOutputVolume:(float)outputVolume; 80 | 81 | /** Called when the audio device detects a playout glitch. The argument is the 82 | * number of glitches detected so far in the current audio playout session. 83 | */ 84 | - (void)audioSession:(RTCAudioSession *)audioSession 85 | didDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches; 86 | 87 | @end 88 | 89 | /** This is a protocol used to inform RTCAudioSession when the audio session 90 | * activation state has changed outside of RTCAudioSession. The current known use 91 | * case of this is when CallKit activates the audio session for the application 92 | */ 93 | RTC_EXPORT 94 | @protocol RTCAudioSessionActivationDelegate 95 | 96 | /** Called when the audio session is activated outside of the app by iOS. */ 97 | - (void)audioSessionDidActivate:(AVAudioSession *)session; 98 | 99 | /** Called when the audio session is deactivated outside of the app by iOS. */ 100 | - (void)audioSessionDidDeactivate:(AVAudioSession *)session; 101 | 102 | @end 103 | 104 | /** Proxy class for AVAudioSession that adds a locking mechanism similar to 105 | * AVCaptureDevice. This is used to that interleaving configurations between 106 | * WebRTC and the application layer are avoided. 107 | * 108 | * RTCAudioSession also coordinates activation so that the audio session is 109 | * activated only once. See |setActive:error:|. 110 | */ 111 | RTC_EXPORT 112 | @interface RTCAudioSession : NSObject 113 | 114 | /** Convenience property to access the AVAudioSession singleton. Callers should 115 | * not call setters on AVAudioSession directly, but other method invocations 116 | * are fine. 117 | */ 118 | @property(nonatomic, readonly) AVAudioSession *session; 119 | 120 | /** Our best guess at whether the session is active based on results of calls to 121 | * AVAudioSession. 122 | */ 123 | @property(nonatomic, readonly) BOOL isActive; 124 | /** Whether RTCAudioSession is currently locked for configuration. */ 125 | @property(nonatomic, readonly) BOOL isLocked; 126 | 127 | /** If YES, WebRTC will not initialize the audio unit automatically when an 128 | * audio track is ready for playout or recording. Instead, applications should 129 | * call setIsAudioEnabled. If NO, WebRTC will initialize the audio unit 130 | * as soon as an audio track is ready for playout or recording. 131 | */ 132 | @property(nonatomic, assign) BOOL useManualAudio; 133 | 134 | /** This property is only effective if useManualAudio is YES. 135 | * Represents permission for WebRTC to initialize the VoIP audio unit. 136 | * When set to NO, if the VoIP audio unit used by WebRTC is active, it will be 137 | * stopped and uninitialized. This will stop incoming and outgoing audio. 138 | * When set to YES, WebRTC will initialize and start the audio unit when it is 139 | * needed (e.g. due to establishing an audio connection). 140 | * This property was introduced to work around an issue where if an AVPlayer is 141 | * playing audio while the VoIP audio unit is initialized, its audio would be 142 | * either cut off completely or played at a reduced volume. By preventing 143 | * the audio unit from being initialized until after the audio has completed, 144 | * we are able to prevent the abrupt cutoff. 145 | */ 146 | @property(nonatomic, assign) BOOL isAudioEnabled; 147 | 148 | // Proxy properties. 149 | @property(readonly) NSString *category; 150 | @property(readonly) AVAudioSessionCategoryOptions categoryOptions; 151 | @property(readonly) NSString *mode; 152 | @property(readonly) BOOL secondaryAudioShouldBeSilencedHint; 153 | @property(readonly) AVAudioSessionRouteDescription *currentRoute; 154 | @property(readonly) NSInteger maximumInputNumberOfChannels; 155 | @property(readonly) NSInteger maximumOutputNumberOfChannels; 156 | @property(readonly) float inputGain; 157 | @property(readonly) BOOL inputGainSettable; 158 | @property(readonly) BOOL inputAvailable; 159 | @property(readonly, nullable) 160 | NSArray * inputDataSources; 161 | @property(readonly, nullable) 162 | AVAudioSessionDataSourceDescription *inputDataSource; 163 | @property(readonly, nullable) 164 | NSArray * outputDataSources; 165 | @property(readonly, nullable) 166 | AVAudioSessionDataSourceDescription *outputDataSource; 167 | @property(readonly) double sampleRate; 168 | @property(readonly) double preferredSampleRate; 169 | @property(readonly) NSInteger inputNumberOfChannels; 170 | @property(readonly) NSInteger outputNumberOfChannels; 171 | @property(readonly) float outputVolume; 172 | @property(readonly) NSTimeInterval inputLatency; 173 | @property(readonly) NSTimeInterval outputLatency; 174 | @property(readonly) NSTimeInterval IOBufferDuration; 175 | @property(readonly) NSTimeInterval preferredIOBufferDuration; 176 | 177 | /** Default constructor. */ 178 | + (instancetype)sharedInstance; 179 | - (instancetype)init NS_UNAVAILABLE; 180 | 181 | /** Adds a delegate, which is held weakly. */ 182 | - (void)addDelegate:(id)delegate; 183 | /** Removes an added delegate. */ 184 | - (void)removeDelegate:(id)delegate; 185 | 186 | /** Request exclusive access to the audio session for configuration. This call 187 | * will block if the lock is held by another object. 188 | */ 189 | - (void)lockForConfiguration; 190 | /** Relinquishes exclusive access to the audio session. */ 191 | - (void)unlockForConfiguration; 192 | 193 | /** If |active|, activates the audio session if it isn't already active. 194 | * Successful calls must be balanced with a setActive:NO when activation is no 195 | * longer required. If not |active|, deactivates the audio session if one is 196 | * active and this is the last balanced call. When deactivating, the 197 | * AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation option is passed to 198 | * AVAudioSession. 199 | */ 200 | - (BOOL)setActive:(BOOL)active 201 | error:(NSError **)outError; 202 | 203 | // The following methods are proxies for the associated methods on 204 | // AVAudioSession. |lockForConfiguration| must be called before using them 205 | // otherwise they will fail with kRTCAudioSessionErrorLockRequired. 206 | 207 | - (BOOL)setCategory:(NSString *)category 208 | withOptions:(AVAudioSessionCategoryOptions)options 209 | error:(NSError **)outError; 210 | - (BOOL)setMode:(NSString *)mode error:(NSError **)outError; 211 | - (BOOL)setInputGain:(float)gain error:(NSError **)outError; 212 | - (BOOL)setPreferredSampleRate:(double)sampleRate error:(NSError **)outError; 213 | - (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration 214 | error:(NSError **)outError; 215 | - (BOOL)setPreferredInputNumberOfChannels:(NSInteger)count 216 | error:(NSError **)outError; 217 | - (BOOL)setPreferredOutputNumberOfChannels:(NSInteger)count 218 | error:(NSError **)outError; 219 | - (BOOL)overrideOutputAudioPort:(AVAudioSessionPortOverride)portOverride 220 | error:(NSError **)outError; 221 | - (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort 222 | error:(NSError **)outError; 223 | - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 224 | error:(NSError **)outError; 225 | - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 226 | error:(NSError **)outError; 227 | @end 228 | 229 | @interface RTCAudioSession (Configuration) 230 | 231 | /** Applies the configuration to the current session. Attempts to set all 232 | * properties even if previous ones fail. Only the last error will be 233 | * returned. 234 | * |lockForConfiguration| must be called first. 235 | */ 236 | - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration 237 | error:(NSError **)outError; 238 | 239 | /** Convenience method that calls both setConfiguration and setActive. 240 | * |lockForConfiguration| must be called first. 241 | */ 242 | - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration 243 | active:(BOOL)active 244 | error:(NSError **)outError; 245 | 246 | @end 247 | 248 | NS_ASSUME_NONNULL_END 249 | -------------------------------------------------------------------------------- /WebRTC_iOS/WebRTC_iOS/WebRTCHelper/WebRTCHelper.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebRTCHelper.m 3 | // WebScoketTest 4 | // 5 | // Created by 涂耀辉 on 17/3/1. 6 | // Copyright © 2017年 涂耀辉. All rights reserved. 7 | // 8 | 9 | // WebRTCHelper.m 10 | // WebRTCDemo 11 | // 12 | 13 | 14 | #import "WebRTCHelper.h" 15 | #import 16 | #import 17 | 18 | //google提供的 19 | static NSString *const RTCSTUNServerURL = @"stun:stun.l.google.com:19302"; 20 | static NSString *const RTCSTUNServerURL2 = @"stun:23.21.150.121"; 21 | 22 | typedef enum : NSUInteger { 23 | //发送者 24 | RoleCaller, 25 | //被发送者 26 | RoleCallee, 27 | 28 | } Role; 29 | 30 | @interface WebRTCHelper () 31 | 32 | @end 33 | 34 | @implementation WebRTCHelper 35 | { 36 | SRWebSocket *_socket; 37 | NSString *_server; 38 | NSString *_room; 39 | 40 | RTCPeerConnectionFactory *_factory; 41 | RTCPeerConnection *_peerConnection; 42 | RTCMediaStream *_localStream; 43 | RTCMediaStream *_remoteStream; 44 | 45 | RTCDataChannel *_localDataChannel; 46 | RTCDataChannel *_remoteDataChannel; 47 | 48 | NSString *_connectId; 49 | 50 | Role _role; 51 | 52 | NSMutableArray *ICEServers; 53 | 54 | } 55 | 56 | static WebRTCHelper *instance = nil; 57 | 58 | + (instancetype)sharedInstance 59 | { 60 | static dispatch_once_t onceToken; 61 | dispatch_once(&onceToken, ^{ 62 | instance = [[[self class] alloc] init]; 63 | }); 64 | return instance; 65 | } 66 | 67 | /** 68 | * 与服务器建立连接 69 | * 70 | * @param server 服务器地址 71 | * @param room 房间号 72 | */ 73 | //初始化socket并且连接 74 | - (void)connectServer:(NSString *)server port:(NSString *)port room:(NSString *)room 75 | { 76 | _server = server; 77 | _room = room; 78 | 79 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"ws://%@:%@",server,port]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10]; 80 | _socket = [[SRWebSocket alloc] initWithURLRequest:request]; 81 | _socket.delegate = self; 82 | [_socket open]; 83 | 84 | } 85 | 86 | /** 87 | * 加入房间 88 | * 89 | * @param room 房间号 90 | */ 91 | - (void)joinRoom:(NSString *)room 92 | { 93 | //如果socket是打开状态 94 | if (_socket.readyState == SR_OPEN) 95 | { 96 | //初始化加入房间的类型参数 room房间号 97 | NSDictionary *dic = @{@"eventName": @"__join", @"data": @{@"room": room}}; 98 | //得到json的data 99 | NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; 100 | //发送加入房间的数据 101 | [_socket send:data]; 102 | } 103 | } 104 | 105 | /** 106 | * 退出房间 107 | */ 108 | - (void)exitRoom 109 | { 110 | [self closePeerConnection]; 111 | [_socket close]; 112 | } 113 | 114 | /* 115 | * 与目标建立连接 116 | */ 117 | - (void)connectWithUserId:(NSString *)userId 118 | { 119 | _peerConnection = [self createPeerConnection:userId]; 120 | _connectId = userId; 121 | [self createLocalStream]; 122 | [_peerConnection addStream:_localStream]; 123 | [self createDataChannel]; 124 | [self createOffer]; 125 | } 126 | 127 | /** 128 | * 关闭peerConnection 129 | * 130 | */ 131 | - (void)closePeerConnection 132 | { 133 | _connectId = nil; 134 | [_peerConnection close]; 135 | _localDataChannel = nil; 136 | _localStream = nil; 137 | _remoteDataChannel = nil; 138 | _remoteStream = nil; 139 | _peerConnection = nil; 140 | } 141 | 142 | /** 143 | * 创建点对点连接 144 | * 145 | * @param connectionId <#connectionId description#> 146 | * 147 | * @return <#return value description#> 148 | */ 149 | - (RTCPeerConnection *)createPeerConnection:(NSString *)connectionId 150 | { 151 | //如果点对点工厂为空 152 | if (!_factory) 153 | { 154 | //先初始化工厂 155 | _factory = [[RTCPeerConnectionFactory alloc] init]; 156 | } 157 | 158 | //得到ICEServer 159 | if (!ICEServers) { 160 | ICEServers = [NSMutableArray array]; 161 | [ICEServers addObject:[self defaultSTUNServer]]; 162 | } 163 | 164 | //用工厂来创建连接 165 | RTCConfiguration *configuration = [[RTCConfiguration alloc] init]; 166 | configuration.iceServers = ICEServers; 167 | RTCPeerConnection *connection = [_factory peerConnectionWithConfiguration:configuration constraints:[self creatPeerConnectionConstraint] delegate:self]; 168 | 169 | return connection; 170 | } 171 | 172 | - (RTCMediaConstraints *)creatPeerConnectionConstraint 173 | { 174 | RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{kRTCMediaConstraintsOfferToReceiveAudio:kRTCMediaConstraintsValueTrue,kRTCMediaConstraintsOfferToReceiveVideo:kRTCMediaConstraintsValueTrue} optionalConstraints:nil]; 175 | return constraints; 176 | } 177 | 178 | //初始化STUN Server (ICE Server) 179 | - (RTCIceServer *)defaultSTUNServer{ 180 | return [[RTCIceServer alloc] initWithURLStrings:@[RTCSTUNServerURL,RTCSTUNServerURL2]]; 181 | } 182 | 183 | /** 184 | * 创建本地流,并且把本地流回调出去 185 | */ 186 | - (void)createLocalStream 187 | { 188 | _localStream = [_factory mediaStreamWithStreamId:@"ARDAMS"]; 189 | 190 | //音频 191 | RTCAudioTrack *audioTrack = [_factory audioTrackWithTrackId:@"ARDAMSa0"]; 192 | [_localStream addAudioTrack:audioTrack]; 193 | 194 | //视频 195 | NSArray *deviceArray = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; 196 | AVCaptureDevice *device = [deviceArray lastObject]; 197 | //检测摄像头权限 198 | AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 199 | if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) 200 | { 201 | NSLog(@"相机访问受限"); 202 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"相机访问受限" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; 203 | [alertView show]; 204 | } 205 | else 206 | { 207 | if (device) 208 | { 209 | RTCAVFoundationVideoSource *videoSource = [_factory avFoundationVideoSourceWithConstraints:[self localVideoConstraints]]; 210 | RTCVideoTrack *videoTrack = [_factory videoTrackWithSource:videoSource trackId:@"ARDAMSv0"]; 211 | [_localStream addVideoTrack:videoTrack]; 212 | 213 | } 214 | else 215 | { 216 | NSLog(@"该设备不能打开摄像头"); 217 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该设备不能打开摄像头" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; 218 | [alertView show]; 219 | } 220 | } 221 | 222 | } 223 | 224 | /** 225 | * 视频的相关约束 226 | */ 227 | - (RTCMediaConstraints *)localVideoConstraints 228 | { 229 | RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{kRTCMediaConstraintsMaxWidth:@"640",kRTCMediaConstraintsMinWidth:@"640",kRTCMediaConstraintsMaxHeight:@"480",kRTCMediaConstraintsMinHeight:@"480",kRTCMediaConstraintsMinFrameRate:@"15"} optionalConstraints:nil]; 230 | return constraints; 231 | } 232 | 233 | /** 234 | * 为连接创建dataChannel 235 | */ 236 | - (void)createDataChannel 237 | { 238 | //给点对点连接,创建dataChannel 239 | 240 | RTCDataChannelConfiguration *dataChannelConfiguration = [[RTCDataChannelConfiguration alloc] init]; 241 | dataChannelConfiguration.isOrdered = YES; 242 | _localDataChannel = [_peerConnection dataChannelForLabel:@"testDataChannel" configuration:dataChannelConfiguration]; 243 | _localDataChannel.delegate = self; 244 | 245 | } 246 | 247 | /** 248 | * 为所有连接创建offer 249 | */ 250 | - (void)createOffer 251 | { 252 | //给每一个点对点连接,都去创建offer 253 | _role = RoleCaller; 254 | [_peerConnection offerForConstraints:[self creatAnswerOrOfferConstraint] completionHandler:^(RTCSessionDescription * _Nullable sdp, NSError * _Nullable error) { 255 | __weak RTCPeerConnection *peerConnection = _peerConnection; 256 | [peerConnection setLocalDescription:sdp completionHandler:^(NSError * _Nullable error) { 257 | [self setSessionDescriptionWithPeerConnection:peerConnection]; 258 | }]; 259 | }]; 260 | } 261 | 262 | /** 263 | * 设置offer/answer的约束 264 | */ 265 | - (RTCMediaConstraints *)creatAnswerOrOfferConstraint 266 | { 267 | RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{kRTCMediaConstraintsOfferToReceiveAudio:kRTCMediaConstraintsValueTrue,kRTCMediaConstraintsOfferToReceiveVideo:kRTCMediaConstraintsValueTrue} optionalConstraints:nil]; 268 | return constraints; 269 | } 270 | 271 | // Called when setting a local or remote description. 272 | //当一个远程或者本地的SDP被设置就会调用 273 | - (void)setSessionDescriptionWithPeerConnection:(RTCPeerConnection *)peerConnection 274 | { 275 | NSLog(@"%s",__func__); 276 | NSString *currentId = _connectId; 277 | 278 | //判断,当前连接状态为,收到了远程点发来的offer,这个是进入房间的时候,尚且没人,来人就调到这里 279 | if (peerConnection.signalingState == RTCSignalingStateHaveRemoteOffer) 280 | { 281 | //创建一个answer,会把自己的SDP信息返回出去 282 | [peerConnection answerForConstraints:[self creatAnswerOrOfferConstraint] completionHandler:^(RTCSessionDescription * _Nullable sdp, NSError * _Nullable error) { 283 | __weak RTCPeerConnection *obj = peerConnection; 284 | [peerConnection setLocalDescription:sdp completionHandler:^(NSError * _Nullable error) { 285 | [self setSessionDescriptionWithPeerConnection:obj]; 286 | }]; 287 | }]; 288 | } 289 | //判断连接状态为本地发送offer 290 | else if (peerConnection.signalingState == RTCSignalingStateHaveLocalOffer) 291 | { 292 | if (_role == RoleCallee) 293 | { 294 | NSDictionary *dic = @{@"eventName": @"__answer", @"data": @{@"sdp": @{@"type": @"answer", @"sdp": peerConnection.localDescription.sdp}, @"socketId": currentId}}; 295 | NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; 296 | [_socket send:data]; 297 | } 298 | //发送者,发送自己的offer 299 | else if(_role == RoleCaller) 300 | { 301 | NSDictionary *dic = @{@"eventName": @"__offer", @"data": @{@"sdp": @{@"type": @"offer", @"sdp": peerConnection.localDescription.sdp}, @"socketId": currentId}}; 302 | NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; 303 | [_socket send:data]; 304 | } 305 | } 306 | else if (peerConnection.signalingState == RTCSignalingStateStable) 307 | { 308 | if (_role == RoleCallee) 309 | { 310 | NSDictionary *dic = @{@"eventName": @"__answer", @"data": @{@"sdp": @{@"type": @"answer", @"sdp": peerConnection.localDescription.sdp}, @"socketId": currentId}}; 311 | NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; 312 | [_socket send:data]; 313 | } 314 | } 315 | 316 | } 317 | 318 | #pragma mark--RTCPeerConnectionDelegate 319 | 320 | /** Called when the SignalingState changed. */ 321 | - (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeSignalingState:(RTCSignalingState)stateChanged 322 | { 323 | NSLog(@"%s",__func__); 324 | NSLog(@"%ld", (long)stateChanged); 325 | } 326 | 327 | /** Called when media is received on a new stream from remote peer. */ 328 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 329 | didAddStream:(RTCMediaStream *)stream 330 | { 331 | NSLog(@"%s",__func__); 332 | 333 | _remoteStream = stream; 334 | dispatch_async(dispatch_get_main_queue(), ^{ 335 | if ([_chatdelegate respondsToSelector:@selector(webRTCHelper:setLocalStream:)]) 336 | { 337 | [_chatdelegate webRTCHelper:self setLocalStream:_localStream]; 338 | } 339 | if ([_chatdelegate respondsToSelector:@selector(webRTCHelper:setRemoteStream:)]) 340 | { 341 | [_chatdelegate webRTCHelper:self setRemoteStream:_remoteStream]; 342 | } 343 | }); 344 | } 345 | 346 | /** Called when a remote peer closes a stream. */ 347 | - (void)peerConnection:(RTCPeerConnection *)peerConnection 348 | didRemoveStream:(RTCMediaStream *)stream 349 | { 350 | NSLog(@"%s",__func__); 351 | } 352 | 353 | /** Called when negotiation is needed, for example ICE has restarted. */ 354 | - (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection 355 | { 356 | NSLog(@"%s",__func__); 357 | } 358 | 359 | /** Called any time the IceConnectionState changes. */ 360 | - (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeIceConnectionState:(RTCIceConnectionState)newState 361 | { 362 | NSLog(@"%s",__func__); 363 | NSLog(@"%ld", (long)newState); 364 | //断开peerconection 365 | if (newState == RTCIceConnectionStateDisconnected) { 366 | dispatch_async(dispatch_get_main_queue(), ^{ 367 | if ([_chatdelegate respondsToSelector:@selector(webRTCHelper:closeChatWithUserId:)]) { 368 | [_chatdelegate webRTCHelper:self closeChatWithUserId:_connectId]; 369 | } 370 | [self closePeerConnection]; 371 | }); 372 | } 373 | } 374 | 375 | /** Called any time the IceGatheringState changes. */ 376 | - (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeIceGatheringState:(RTCIceGatheringState)newState 377 | { 378 | NSLog(@"%s",__func__); 379 | NSLog(@"%ld", (long)newState); 380 | } 381 | 382 | //创建peerConnection之后,从server得到响应后调用,得到ICE 候选地址 383 | /** New ice candidate has been found. */ 384 | - (void)peerConnection:(RTCPeerConnection *)peerConnection didGenerateIceCandidate:(RTCIceCandidate *)candidate 385 | { 386 | NSLog(@"%s",__func__); 387 | 388 | NSString *currentId = _connectId; 389 | 390 | NSDictionary *dic = @{@"eventName": @"__ice_candidate", @"data": @{@"id":candidate.sdpMid,@"label": [NSNumber numberWithInteger:candidate.sdpMLineIndex], @"candidate": candidate.sdp, @"socketId": currentId}}; 391 | NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil]; 392 | [_socket send:data]; 393 | } 394 | 395 | /** Called when a group of local Ice candidates have been removed. */ 396 | - (void)peerConnection:(RTCPeerConnection *)peerConnection didRemoveIceCandidates:(NSArray *)candidates 397 | { 398 | NSLog(@"%s",__func__); 399 | } 400 | 401 | /** New data channel has been opened. */ 402 | - (void)peerConnection:(RTCPeerConnection*)peerConnection didOpenDataChannel:(RTCDataChannel*)dataChannel 403 | 404 | { 405 | NSLog(@"%s",__func__); 406 | NSLog(@"channel.state %ld",(long)dataChannel.readyState); 407 | _remoteDataChannel = dataChannel; 408 | _remoteDataChannel.delegate = self; 409 | 410 | } 411 | 412 | #pragma mark--RTCDataChannelDelegate 413 | 414 | /** The data channel state changed. */ 415 | - (void)dataChannelDidChangeState:(RTCDataChannel *)dataChannel 416 | { 417 | NSLog(@"%s",__func__); 418 | NSLog(@"channel.state %ld",(long)dataChannel.readyState); 419 | } 420 | 421 | /** The data channel successfully received a data buffer. */ 422 | - (void)dataChannel:(RTCDataChannel *)dataChannel didReceiveMessageWithBuffer:(RTCDataBuffer *)buffer 423 | { 424 | NSLog(@"%s",__func__); 425 | NSString *message = [[NSString alloc] initWithData:buffer.data encoding:NSUTF8StringEncoding]; 426 | NSLog(@"message:%@",message); 427 | dispatch_async(dispatch_get_main_queue(), ^{ 428 | if ([_chatdelegate respondsToSelector:@selector(webRTCHelper:receiveMessage:)]) 429 | { 430 | [_chatdelegate webRTCHelper:self receiveMessage:message]; 431 | } 432 | }); 433 | 434 | } 435 | 436 | //发送消息 437 | - (void)sendMessage:(NSString *)message 438 | { 439 | 440 | RTCDataBuffer *buffer = [[RTCDataBuffer alloc] initWithData:[message dataUsingEncoding:NSUTF8StringEncoding] isBinary:NO]; 441 | BOOL result = [_localDataChannel sendData:buffer]; 442 | if (result) { 443 | NSLog(@"success"); 444 | } 445 | else 446 | { 447 | NSLog(@"error"); 448 | } 449 | } 450 | 451 | 452 | #pragma mark--SRWebSocketDelegate 453 | - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message 454 | { 455 | NSLog(@"收到服务器消息:%@",message); 456 | NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:[message dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; 457 | NSString *eventName = dic[@"eventName"]; 458 | 459 | //1.发送加入房间后的反馈 460 | if ([eventName isEqualToString:@"_peers"]) 461 | { 462 | //得到data 463 | NSDictionary *dataDic = dic[@"data"]; 464 | //得到所有的连接 465 | NSArray *connections = dataDic[@"connections"]; 466 | if ([_friendListDelegate respondsToSelector:@selector(webRTCHelper:gotFriendList:)]) { 467 | [_friendListDelegate webRTCHelper:self gotFriendList:connections]; 468 | } 469 | } 470 | //4.接收到新加入的人发了ICE候选,(即经过ICEServer而获取到的地址) 471 | else if ([eventName isEqualToString:@"_ice_candidate"]) 472 | { 473 | NSDictionary *dataDic = dic[@"data"]; 474 | NSString *socketId = dataDic[@"socketId"]; 475 | NSString *sdpMid = dataDic[@"id"]; 476 | int sdpMLineIndex = [dataDic[@"label"] intValue]; 477 | NSString *sdp = dataDic[@"candidate"]; 478 | if ([_connectId isEqualToString:socketId]) { 479 | //生成远端网络地址对象 480 | RTCIceCandidate *candidate = [[RTCIceCandidate alloc] initWithSdp:sdp sdpMLineIndex:sdpMLineIndex sdpMid:sdpMid]; 481 | //添加到点对点连接中 482 | [_peerConnection addIceCandidate:candidate]; 483 | } 484 | 485 | } 486 | //2.其他新人加入房间的信息 487 | else if ([eventName isEqualToString:@"_new_peer"]) 488 | { 489 | NSDictionary *dataDic = dic[@"data"]; 490 | //拿到新人的ID 491 | NSString *socketId = dataDic[@"socketId"]; 492 | if ([_friendListDelegate respondsToSelector:@selector(webRTCHelper:gotNewFriend:)]) { 493 | [_friendListDelegate webRTCHelper:self gotNewFriend:socketId]; 494 | } 495 | } 496 | //有人离开房间的事件 497 | else if ([eventName isEqualToString:@"_remove_peer"]) 498 | { 499 | NSDictionary *dataDic = dic[@"data"]; 500 | NSString *socketId = dataDic[@"socketId"]; 501 | //得到socketId,并从用户列表中删除 502 | if ([_friendListDelegate respondsToSelector:@selector(webRTCHelper:removeFriend:)]) { 503 | [_friendListDelegate webRTCHelper:self removeFriend:socketId]; 504 | } 505 | //如果正与这个目标连接,关闭这个peerConnection 506 | if ([_connectId isEqualToString:socketId]) { 507 | if ([_chatdelegate respondsToSelector:@selector(webRTCHelper:closeChatWithUserId:)]) { 508 | [_chatdelegate webRTCHelper:self closeChatWithUserId:_connectId]; 509 | } 510 | [self closePeerConnection]; 511 | } 512 | } 513 | //这个新加入的人发了个offer 514 | else if ([eventName isEqualToString:@"_offer"]) 515 | { 516 | NSDictionary *dataDic = dic[@"data"]; 517 | NSDictionary *sdpDic = dataDic[@"sdp"]; 518 | //拿到SDP 519 | NSString *sdp = sdpDic[@"sdp"]; 520 | NSString *socketId = dataDic[@"socketId"]; 521 | if (_peerConnection) { 522 | //已经建立WebRTC连接,拒绝与建立新的连接,但是可以创建新的RTCPeerConnection,并与发起者建立连接,此处拒绝是为了在聊天界面,只与一个目标连接 523 | return; 524 | } 525 | 526 | _connectId = socketId; 527 | if ([_friendListDelegate respondsToSelector:@selector(requestConnectWithUserId:)]) { 528 | [_friendListDelegate requestConnectWithUserId:socketId]; 529 | } 530 | 531 | //设置当前角色状态为被呼叫,(被发offer) 532 | _role = RoleCallee; 533 | 534 | //根据类型和SDP 生成SDP描述对象 535 | RTCSessionDescription *remoteSdp = [[RTCSessionDescription alloc] initWithType:RTCSdpTypeOffer sdp:sdp]; 536 | //设置给这个点对点连接 537 | _peerConnection = [self createPeerConnection:socketId]; 538 | [self createDataChannel]; 539 | [self createLocalStream]; 540 | [_peerConnection addStream:_localStream]; 541 | __weak RTCPeerConnection *peerConnection = _peerConnection; 542 | __weak WebRTCHelper *weakSelf = self; 543 | [peerConnection setRemoteDescription:remoteSdp completionHandler:^(NSError * _Nullable error) { 544 | [weakSelf setSessionDescriptionWithPeerConnection:peerConnection]; 545 | }]; 546 | 547 | } 548 | //回应offer 549 | else if ([eventName isEqualToString:@"_answer"]) 550 | { 551 | NSDictionary *dataDic = dic[@"data"]; 552 | NSDictionary *sdpDic = dataDic[@"sdp"]; 553 | NSString *sdp = sdpDic[@"sdp"]; 554 | NSString *socketId = dataDic[@"socketId"]; 555 | if ([_connectId isEqualToString:socketId]) { 556 | RTCSessionDescription *remoteSdp = [[RTCSessionDescription alloc] initWithType:RTCSdpTypeAnswer sdp:sdp]; 557 | __weak RTCPeerConnection *peerConnection = _peerConnection; 558 | __weak WebRTCHelper *weakSelf = self; 559 | [peerConnection setRemoteDescription:remoteSdp completionHandler:^(NSError * _Nullable error) { 560 | [weakSelf setSessionDescriptionWithPeerConnection:peerConnection]; 561 | }]; 562 | } 563 | } 564 | } 565 | 566 | - (void)webSocketDidOpen:(SRWebSocket *)webSocket 567 | { 568 | NSLog(@"websocket建立成功"); 569 | //加入房间 570 | [self joinRoom:_room]; 571 | } 572 | 573 | - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error 574 | { 575 | NSLog(@"%s",__func__); 576 | NSLog(@"%ld:%@",(long)error.code, error.localizedDescription); 577 | } 578 | 579 | - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean 580 | { 581 | NSLog(@"%s",__func__); 582 | NSLog(@"%ld:%@",(long)code, reason); 583 | } 584 | 585 | @end 586 | --------------------------------------------------------------------------------