├── .gitignore
├── AppRTCMobile
├── .gitignore
├── AppRTCMobile.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── AppRTCMobile.xcworkspace
│ └── contents.xcworkspacedata
├── Default-568h@2x.png
├── Podfile
├── Podfile.lock
└── webrtc
│ ├── ARDAppClient+Internal.h
│ ├── ARDAppClient.h
│ ├── ARDAppClient.m
│ ├── ARDAppEngineClient.h
│ ├── ARDAppEngineClient.m
│ ├── ARDBitrateTracker.h
│ ├── ARDBitrateTracker.m
│ ├── ARDCaptureController.h
│ ├── ARDCaptureController.m
│ ├── ARDJoinResponse+Internal.h
│ ├── ARDJoinResponse.h
│ ├── ARDJoinResponse.m
│ ├── ARDMessageResponse+Internal.h
│ ├── ARDMessageResponse.h
│ ├── ARDMessageResponse.m
│ ├── ARDRoomServerClient.h
│ ├── ARDSDPUtils.h
│ ├── ARDSDPUtils.m
│ ├── ARDSettingsModel+Private.h
│ ├── ARDSettingsModel.h
│ ├── ARDSettingsModel.m
│ ├── ARDSettingsStore.h
│ ├── ARDSettingsStore.m
│ ├── ARDSignalingChannel.h
│ ├── ARDSignalingMessage.h
│ ├── ARDSignalingMessage.m
│ ├── ARDStatsBuilder.h
│ ├── ARDStatsBuilder.m
│ ├── ARDTURNClient+Internal.h
│ ├── ARDTURNClient.h
│ ├── ARDTURNClient.m
│ ├── ARDVideoDecoderFactory.h
│ ├── ARDVideoDecoderFactory.m
│ ├── ARDVideoEncoderFactory.h
│ ├── ARDVideoEncoderFactory.m
│ ├── ARDWebSocketChannel.h
│ ├── ARDWebSocketChannel.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Icon-120.png
│ ├── Icon-180.png
│ ├── RTCIceCandidate+JSON.h
│ ├── RTCIceCandidate+JSON.m
│ ├── RTCIceServer+JSON.h
│ ├── RTCIceServer+JSON.m
│ ├── RTCMediaConstraints+JSON.h
│ ├── RTCMediaConstraints+JSON.m
│ ├── RTCSessionDescription+JSON.h
│ ├── RTCSessionDescription+JSON.m
│ ├── ios
│ └── Info.plist
│ ├── mac
│ ├── APPRTCAppDelegate.h
│ ├── APPRTCAppDelegate.m
│ ├── APPRTCViewController.h
│ ├── APPRTCViewController.m
│ ├── Info.plist
│ └── main.m
│ └── tests
│ ├── ARDAppClient_xctest.mm
│ ├── ARDSDPUtils_xctest.mm
│ └── ARDSettingsModel_xctest.mm
├── LICENSE
├── README.md
├── WebRTC.framework
├── Headers
│ ├── RTCAVFoundationVideoSource.h
│ ├── RTCAudioSession.h
│ ├── RTCAudioSessionConfiguration.h
│ ├── RTCAudioSource.h
│ ├── RTCAudioTrack.h
│ ├── RTCCameraPreviewView.h
│ ├── RTCCameraVideoCapturer.h
│ ├── RTCConfiguration.h
│ ├── RTCDataChannel.h
│ ├── RTCDataChannelConfiguration.h
│ ├── RTCDispatcher.h
│ ├── RTCEAGLVideoView.h
│ ├── RTCFieldTrials.h
│ ├── RTCFileLogger.h
│ ├── RTCIceCandidate.h
│ ├── RTCIceServer.h
│ ├── RTCIntervalRange.h
│ ├── RTCLegacyStatsReport.h
│ ├── RTCLogging.h
│ ├── RTCMTLVideoView.h
│ ├── RTCMacros.h
│ ├── RTCMediaConstraints.h
│ ├── RTCMediaSource.h
│ ├── RTCMediaStream.h
│ ├── RTCMediaStreamTrack.h
│ ├── RTCMetrics.h
│ ├── RTCMetricsSampleInfo.h
│ ├── RTCPeerConnection.h
│ ├── RTCPeerConnectionFactory.h
│ ├── RTCRtpCodecParameters.h
│ ├── RTCRtpEncodingParameters.h
│ ├── RTCRtpParameters.h
│ ├── RTCRtpReceiver.h
│ ├── RTCRtpSender.h
│ ├── RTCSSLAdapter.h
│ ├── RTCSessionDescription.h
│ ├── RTCTracing.h
│ ├── RTCVideoCapturer.h
│ ├── RTCVideoCodec.h
│ ├── RTCVideoCodecFactory.h
│ ├── RTCVideoCodecH264.h
│ ├── RTCVideoDecoderVP8.h
│ ├── RTCVideoDecoderVP9.h
│ ├── RTCVideoEncoderVP8.h
│ ├── RTCVideoEncoderVP9.h
│ ├── RTCVideoFrame.h
│ ├── RTCVideoFrameBuffer.h
│ ├── RTCVideoRenderer.h
│ ├── RTCVideoSource.h
│ ├── RTCVideoTrack.h
│ ├── RTCVideoViewShading.h
│ ├── UIDevice+RTCDevice.h
│ └── WebRTC.h
├── Info.plist
├── LICENSE.md
├── Modules
│ └── module.modulemap
└── WebRTC
└── WebRTC.podspec
/.gitignore:
--------------------------------------------------------------------------------
1 | test-app
2 | *.zip
3 | *.dSYM
4 |
--------------------------------------------------------------------------------
/AppRTCMobile/.gitignore:
--------------------------------------------------------------------------------
1 | ## Build generated
2 | build/
3 | DerivedData/
4 |
5 | ## Various settings
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata/
15 |
16 | ## Other
17 | *.moved-aside
18 | *.xccheckout
19 | *.xcscmblueprint
20 |
21 | ## Obj-C/Swift specific
22 | *.hmap
23 | *.ipa
24 | *.dSYM.zip
25 | *.dSYM
26 |
27 | Pods
28 |
--------------------------------------------------------------------------------
/AppRTCMobile/AppRTCMobile.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AppRTCMobile/AppRTCMobile.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AppRTCMobile/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlexKMDev/WebRTC/abf728ea9718a3dd407030c209bfb564fb7ee5ec/AppRTCMobile/Default-568h@2x.png
--------------------------------------------------------------------------------
/AppRTCMobile/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | platform :ios, '8.0'
3 |
4 | target 'AppRTCMobile' do
5 | # Comment this line if you're not using Swift and don't want to use dynamic frameworks
6 | use_frameworks!
7 |
8 | pod "WebRTC", path: "../"
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/AppRTCMobile/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - WebRTC (63.11.20455)
3 |
4 | DEPENDENCIES:
5 | - WebRTC (from `../`)
6 |
7 | EXTERNAL SOURCES:
8 | WebRTC:
9 | :path: ../
10 |
11 | SPEC CHECKSUMS:
12 | WebRTC: f2a6203584745fe53532633397557876b5d71640
13 |
14 | PODFILE CHECKSUM: 32dd69aee34d5019b9a3aed136069c1e3c8de858
15 |
16 | COCOAPODS: 1.3.1
17 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDAppClient+Internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDAppClient.h"
12 |
13 | #import "WebRTC/RTCPeerConnection.h"
14 |
15 | #import "ARDRoomServerClient.h"
16 | #import "ARDSignalingChannel.h"
17 | #import "ARDTURNClient.h"
18 |
19 | @class RTCPeerConnectionFactory;
20 |
21 | @interface ARDAppClient ()
23 |
24 | // All properties should only be mutated from the main queue.
25 | @property(nonatomic, strong) id roomServerClient;
26 | @property(nonatomic, strong) id channel;
27 | @property(nonatomic, strong) id loopbackChannel;
28 | @property(nonatomic, strong) id turnClient;
29 |
30 | @property(nonatomic, strong) RTCPeerConnection *peerConnection;
31 | @property(nonatomic, strong) RTCPeerConnectionFactory *factory;
32 | @property(nonatomic, strong) NSMutableArray *messageQueue;
33 |
34 | @property(nonatomic, assign) BOOL isTurnComplete;
35 | @property(nonatomic, assign) BOOL hasReceivedSdp;
36 | @property(nonatomic, readonly) BOOL hasJoinedRoomServerRoom;
37 |
38 | @property(nonatomic, strong) NSString *roomId;
39 | @property(nonatomic, strong) NSString *clientId;
40 | @property(nonatomic, assign) BOOL isInitiator;
41 | @property(nonatomic, strong) NSMutableArray *iceServers;
42 | @property(nonatomic, strong) NSURL *webSocketURL;
43 | @property(nonatomic, strong) NSURL *webSocketRestURL;
44 | @property(nonatomic, readonly) BOOL isLoopback;
45 |
46 | @property(nonatomic, strong)
47 | RTCMediaConstraints *defaultPeerConnectionConstraints;
48 |
49 | - (instancetype)initWithRoomServerClient:(id)rsClient
50 | signalingChannel:(id)channel
51 | turnClient:(id)turnClient
52 | delegate:(id)delegate;
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDAppClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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/RTCCameraVideoCapturer.h"
14 | #import "WebRTC/RTCPeerConnection.h"
15 | #import "WebRTC/RTCVideoTrack.h"
16 |
17 | typedef NS_ENUM(NSInteger, ARDAppClientState) {
18 | // Disconnected from servers.
19 | kARDAppClientStateDisconnected,
20 | // Connecting to servers.
21 | kARDAppClientStateConnecting,
22 | // Connected to servers.
23 | kARDAppClientStateConnected,
24 | };
25 |
26 | @class ARDAppClient;
27 | @class ARDSettingsModel;
28 | @class RTCMediaConstraints;
29 |
30 | // The delegate is informed of pertinent events and will be called on the
31 | // main queue.
32 | @protocol ARDAppClientDelegate
33 |
34 | - (void)appClient:(ARDAppClient *)client
35 | didChangeState:(ARDAppClientState)state;
36 |
37 | - (void)appClient:(ARDAppClient *)client
38 | didChangeConnectionState:(RTCIceConnectionState)state;
39 |
40 | - (void)appClient:(ARDAppClient *)client
41 | didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer;
42 |
43 | - (void)appClient:(ARDAppClient *)client
44 | didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack;
45 |
46 | - (void)appClient:(ARDAppClient *)client
47 | didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack;
48 |
49 | - (void)appClient:(ARDAppClient *)client
50 | didError:(NSError *)error;
51 |
52 | - (void)appClient:(ARDAppClient *)client
53 | didGetStats:(NSArray *)stats;
54 |
55 | @end
56 |
57 | // Handles connections to the AppRTC server for a given room. Methods on this
58 | // class should only be called from the main queue.
59 | @interface ARDAppClient : NSObject
60 |
61 | // If |shouldGetStats| is true, stats will be reported in 1s intervals through
62 | // the delegate.
63 | @property(nonatomic, assign) BOOL shouldGetStats;
64 | @property(nonatomic, readonly) ARDAppClientState state;
65 | @property(nonatomic, weak) id delegate;
66 | // Convenience constructor since all expected use cases will need a delegate
67 | // in order to receive remote tracks.
68 | - (instancetype)initWithDelegate:(id)delegate;
69 |
70 | // Establishes a connection with the AppRTC servers for the given room id.
71 | // |settings| is an object containing settings such as video codec for the call.
72 | // If |isLoopback| is true, the call will connect to itself.
73 | - (void)connectToRoomWithId:(NSString *)roomId
74 | settings:(ARDSettingsModel *)settings
75 | isLoopback:(BOOL)isLoopback;
76 |
77 | // Disconnects from the AppRTC servers and any connected clients.
78 | - (void)disconnect;
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDAppEngineClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDRoomServerClient.h"
12 |
13 | @interface ARDAppEngineClient : NSObject
14 | @end
15 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDAppEngineClient.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDAppEngineClient.h"
12 |
13 | #import "WebRTC/RTCLogging.h"
14 |
15 | #import "ARDJoinResponse.h"
16 | #import "ARDMessageResponse.h"
17 | #import "ARDSignalingMessage.h"
18 | #import "ARDUtilities.h"
19 |
20 | // TODO(tkchin): move these to a configuration object.
21 | static NSString * const kARDRoomServerHostUrl =
22 | @"https://appr.tc";
23 | static NSString * const kARDRoomServerJoinFormat =
24 | @"https://appr.tc/join/%@";
25 | static NSString * const kARDRoomServerJoinFormatLoopback =
26 | @"https://appr.tc/join/%@?debug=loopback";
27 | static NSString * const kARDRoomServerMessageFormat =
28 | @"https://appr.tc/message/%@/%@";
29 | static NSString * const kARDRoomServerLeaveFormat =
30 | @"https://appr.tc/leave/%@/%@";
31 |
32 | static NSString * const kARDAppEngineClientErrorDomain = @"ARDAppEngineClient";
33 | static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
34 |
35 | @implementation ARDAppEngineClient
36 |
37 | #pragma mark - ARDRoomServerClient
38 |
39 | - (void)joinRoomWithRoomId:(NSString *)roomId
40 | isLoopback:(BOOL)isLoopback
41 | completionHandler:(void (^)(ARDJoinResponse *response,
42 | NSError *error))completionHandler {
43 | NSParameterAssert(roomId.length);
44 |
45 | NSString *urlString = nil;
46 | if (isLoopback) {
47 | urlString =
48 | [NSString stringWithFormat:kARDRoomServerJoinFormatLoopback, roomId];
49 | } else {
50 | urlString =
51 | [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
52 | }
53 |
54 | NSURL *roomURL = [NSURL URLWithString:urlString];
55 | RTCLog(@"Joining room:%@ on room server.", roomId);
56 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
57 | request.HTTPMethod = @"POST";
58 | __weak ARDAppEngineClient *weakSelf = self;
59 | [NSURLConnection sendAsyncRequest:request
60 | completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
61 | ARDAppEngineClient *strongSelf = weakSelf;
62 | if (error) {
63 | if (completionHandler) {
64 | completionHandler(nil, error);
65 | }
66 | return;
67 | }
68 | ARDJoinResponse *joinResponse = [ARDJoinResponse responseFromJSONData:data];
69 | if (!joinResponse) {
70 | if (completionHandler) {
71 | NSError *error = [[self class] badResponseError];
72 | completionHandler(nil, error);
73 | }
74 | return;
75 | }
76 | if (completionHandler) {
77 | completionHandler(joinResponse, nil);
78 | }
79 | }];
80 | }
81 |
82 | - (void)sendMessage:(ARDSignalingMessage *)message
83 | forRoomId:(NSString *)roomId
84 | clientId:(NSString *)clientId
85 | completionHandler:(void (^)(ARDMessageResponse *response,
86 | NSError *error))completionHandler {
87 | NSParameterAssert(message);
88 | NSParameterAssert(roomId.length);
89 | NSParameterAssert(clientId.length);
90 |
91 | NSData *data = [message JSONData];
92 | NSString *urlString =
93 | [NSString stringWithFormat:
94 | kARDRoomServerMessageFormat, roomId, clientId];
95 | NSURL *url = [NSURL URLWithString:urlString];
96 | RTCLog(@"C->RS POST: %@", message);
97 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
98 | request.HTTPMethod = @"POST";
99 | request.HTTPBody = data;
100 | __weak ARDAppEngineClient *weakSelf = self;
101 | [NSURLConnection sendAsyncRequest:request
102 | completionHandler:^(NSURLResponse *response,
103 | NSData *data,
104 | NSError *error) {
105 | ARDAppEngineClient *strongSelf = weakSelf;
106 | if (error) {
107 | if (completionHandler) {
108 | completionHandler(nil, error);
109 | }
110 | return;
111 | }
112 | ARDMessageResponse *messageResponse =
113 | [ARDMessageResponse responseFromJSONData:data];
114 | if (!messageResponse) {
115 | if (completionHandler) {
116 | NSError *error = [[self class] badResponseError];
117 | completionHandler(nil, error);
118 | }
119 | return;
120 | }
121 | if (completionHandler) {
122 | completionHandler(messageResponse, nil);
123 | }
124 | }];
125 | }
126 |
127 | - (void)leaveRoomWithRoomId:(NSString *)roomId
128 | clientId:(NSString *)clientId
129 | completionHandler:(void (^)(NSError *error))completionHandler {
130 | NSParameterAssert(roomId.length);
131 | NSParameterAssert(clientId.length);
132 |
133 | NSString *urlString =
134 | [NSString stringWithFormat:kARDRoomServerLeaveFormat, roomId, clientId];
135 | NSURL *url = [NSURL URLWithString:urlString];
136 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
137 | request.HTTPMethod = @"POST";
138 |
139 | RTCLog(@"C->RS: BYE");
140 | __block NSError *error = nil;
141 |
142 | // We want a synchronous request so that we know that we've left the room on
143 | // room server before we do any further work.
144 | dispatch_semaphore_t sem = dispatch_semaphore_create(0);
145 | [NSURLConnection sendAsyncRequest:request
146 | completionHandler:^(NSURLResponse *response, NSData *data, NSError *e) {
147 | if (e) {
148 | error = e;
149 | }
150 | dispatch_semaphore_signal(sem);
151 | }];
152 |
153 | dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
154 | if (error) {
155 | RTCLogError(@"Error leaving room %@ on room server: %@", roomId, error.localizedDescription);
156 | if (completionHandler) {
157 | completionHandler(error);
158 | }
159 | return;
160 | }
161 | RTCLog(@"Left room:%@ on room server.", roomId);
162 | if (completionHandler) {
163 | completionHandler(nil);
164 | }
165 | }
166 |
167 | #pragma mark - Private
168 |
169 | + (NSError *)badResponseError {
170 | NSError *error =
171 | [[NSError alloc] initWithDomain:kARDAppEngineClientErrorDomain
172 | code:kARDAppEngineClientErrorBadResponse
173 | userInfo:@{
174 | NSLocalizedDescriptionKey: @"Error parsing response.",
175 | }];
176 | return error;
177 | }
178 |
179 | @end
180 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDBitrateTracker.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 | /** Class used to estimate bitrate based on byte count. It is expected that
14 | * byte count is monotonocially increasing. This class tracks the times that
15 | * byte count is updated, and measures the bitrate based on the byte difference
16 | * over the interval between updates.
17 | */
18 | @interface ARDBitrateTracker : NSObject
19 |
20 | /** The bitrate in bits per second. */
21 | @property(nonatomic, readonly) double bitrate;
22 | /** The bitrate as a formatted string in bps, Kbps or Mbps. */
23 | @property(nonatomic, readonly) NSString *bitrateString;
24 |
25 | /** Converts the bitrate to a readable format in bps, Kbps or Mbps. */
26 | + (NSString *)bitrateStringForBitrate:(double)bitrate;
27 | /** Updates the tracked bitrate with the new byte count. */
28 | - (void)updateBitrateWithCurrentByteCount:(NSInteger)byteCount;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDBitrateTracker.m:
--------------------------------------------------------------------------------
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 "ARDBitrateTracker.h"
12 |
13 | #import
14 |
15 | @implementation ARDBitrateTracker {
16 | CFTimeInterval _prevTime;
17 | NSInteger _prevByteCount;
18 | }
19 |
20 | @synthesize bitrate = _bitrate;
21 |
22 | + (NSString *)bitrateStringForBitrate:(double)bitrate {
23 | if (bitrate > 1e6) {
24 | return [NSString stringWithFormat:@"%.2fMbps", bitrate * 1e-6];
25 | } else if (bitrate > 1e3) {
26 | return [NSString stringWithFormat:@"%.0fKbps", bitrate * 1e-3];
27 | } else {
28 | return [NSString stringWithFormat:@"%.0fbps", bitrate];
29 | }
30 | }
31 |
32 | - (NSString *)bitrateString {
33 | return [[self class] bitrateStringForBitrate:_bitrate];
34 | }
35 |
36 | - (void)updateBitrateWithCurrentByteCount:(NSInteger)byteCount {
37 | CFTimeInterval currentTime = CACurrentMediaTime();
38 | if (_prevTime && (byteCount > _prevByteCount)) {
39 | _bitrate = (byteCount - _prevByteCount) * 8 / (currentTime - _prevTime);
40 | }
41 | _prevByteCount = byteCount;
42 | _prevTime = currentTime;
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDCaptureController.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 | #include
12 |
13 | @class ARDSettingsModel;
14 |
15 | // Controls the camera. Handles starting the capture, switching cameras etc.
16 | @interface ARDCaptureController : NSObject
17 |
18 | - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
19 | settings:(ARDSettingsModel *)settings;
20 | - (void)startCapture;
21 | - (void)stopCapture;
22 | - (void)switchCamera;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDCaptureController.m:
--------------------------------------------------------------------------------
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 "ARDCaptureController.h"
12 |
13 | #import "ARDSettingsModel.h"
14 |
15 | @implementation ARDCaptureController {
16 | RTCCameraVideoCapturer *_capturer;
17 | ARDSettingsModel *_settings;
18 | BOOL _usingFrontCamera;
19 | }
20 |
21 | - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
22 | settings:(ARDSettingsModel *)settings {
23 | if ([super init]) {
24 | _capturer = capturer;
25 | _settings = settings;
26 | _usingFrontCamera = YES;
27 | }
28 |
29 | return self;
30 | }
31 |
32 | - (void)startCapture {
33 | AVCaptureDevicePosition position =
34 | _usingFrontCamera ? AVCaptureDevicePositionFront : AVCaptureDevicePositionBack;
35 | AVCaptureDevice *device = [self findDeviceForPosition:position];
36 | AVCaptureDeviceFormat *format = [self selectFormatForDevice:device];
37 | NSInteger fps = [self selectFpsForFormat:format];
38 |
39 | [_capturer startCaptureWithDevice:device format:format fps:fps];
40 | }
41 |
42 | - (void)stopCapture {
43 | [_capturer stopCapture];
44 | }
45 |
46 | - (void)switchCamera {
47 | _usingFrontCamera = !_usingFrontCamera;
48 | [self startCapture];
49 | }
50 |
51 | #pragma mark - Private
52 |
53 | - (AVCaptureDevice *)findDeviceForPosition:(AVCaptureDevicePosition)position {
54 | NSArray *captureDevices = [RTCCameraVideoCapturer captureDevices];
55 | for (AVCaptureDevice *device in captureDevices) {
56 | if (device.position == position) {
57 | return device;
58 | }
59 | }
60 | return captureDevices[0];
61 | }
62 |
63 | - (AVCaptureDeviceFormat *)selectFormatForDevice:(AVCaptureDevice *)device {
64 | NSArray *formats =
65 | [RTCCameraVideoCapturer supportedFormatsForDevice:device];
66 | int targetWidth = [_settings currentVideoResolutionWidthFromStore];
67 | int targetHeight = [_settings currentVideoResolutionHeightFromStore];
68 | AVCaptureDeviceFormat *selectedFormat = nil;
69 | int currentDiff = INT_MAX;
70 |
71 | for (AVCaptureDeviceFormat *format in formats) {
72 | CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
73 | int diff = abs(targetWidth - dimension.width) + abs(targetHeight - dimension.height);
74 | if (diff < currentDiff) {
75 | selectedFormat = format;
76 | currentDiff = diff;
77 | }
78 | }
79 |
80 | NSAssert(selectedFormat != nil, @"No suitable capture format found.");
81 | return selectedFormat;
82 | }
83 |
84 | - (NSInteger)selectFpsForFormat:(AVCaptureDeviceFormat *)format {
85 | Float64 maxFramerate = 0;
86 | for (AVFrameRateRange *fpsRange in format.videoSupportedFrameRateRanges) {
87 | maxFramerate = fmax(maxFramerate, fpsRange.maxFrameRate);
88 | }
89 | return maxFramerate;
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDJoinResponse+Internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDJoinResponse.h"
12 |
13 | @interface ARDJoinResponse ()
14 |
15 | @property(nonatomic, assign) ARDJoinResultType result;
16 | @property(nonatomic, assign) BOOL isInitiator;
17 | @property(nonatomic, strong) NSString *roomId;
18 | @property(nonatomic, strong) NSString *clientId;
19 | @property(nonatomic, strong) NSArray *messages;
20 | @property(nonatomic, strong) NSURL *webSocketURL;
21 | @property(nonatomic, strong) NSURL *webSocketRestURL;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDJoinResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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, ARDJoinResultType) {
14 | kARDJoinResultTypeUnknown,
15 | kARDJoinResultTypeSuccess,
16 | kARDJoinResultTypeFull
17 | };
18 |
19 | // Result of joining a room on the room server.
20 | @interface ARDJoinResponse : NSObject
21 |
22 | @property(nonatomic, readonly) ARDJoinResultType result;
23 | @property(nonatomic, readonly) BOOL isInitiator;
24 | @property(nonatomic, readonly) NSString *roomId;
25 | @property(nonatomic, readonly) NSString *clientId;
26 | @property(nonatomic, readonly) NSArray *messages;
27 | @property(nonatomic, readonly) NSURL *webSocketURL;
28 | @property(nonatomic, readonly) NSURL *webSocketRestURL;
29 |
30 | + (ARDJoinResponse *)responseFromJSONData:(NSData *)data;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDJoinResponse.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDJoinResponse+Internal.h"
12 |
13 | #import "ARDSignalingMessage.h"
14 | #import "ARDUtilities.h"
15 | #import "RTCIceServer+JSON.h"
16 |
17 | static NSString const *kARDJoinResultKey = @"result";
18 | static NSString const *kARDJoinResultParamsKey = @"params";
19 | static NSString const *kARDJoinInitiatorKey = @"is_initiator";
20 | static NSString const *kARDJoinRoomIdKey = @"room_id";
21 | static NSString const *kARDJoinClientIdKey = @"client_id";
22 | static NSString const *kARDJoinMessagesKey = @"messages";
23 | static NSString const *kARDJoinWebSocketURLKey = @"wss_url";
24 | static NSString const *kARDJoinWebSocketRestURLKey = @"wss_post_url";
25 |
26 | @implementation ARDJoinResponse
27 |
28 | @synthesize result = _result;
29 | @synthesize isInitiator = _isInitiator;
30 | @synthesize roomId = _roomId;
31 | @synthesize clientId = _clientId;
32 | @synthesize messages = _messages;
33 | @synthesize webSocketURL = _webSocketURL;
34 | @synthesize webSocketRestURL = _webSocketRestURL;
35 |
36 | + (ARDJoinResponse *)responseFromJSONData:(NSData *)data {
37 | NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
38 | if (!responseJSON) {
39 | return nil;
40 | }
41 | ARDJoinResponse *response = [[ARDJoinResponse alloc] init];
42 | NSString *resultString = responseJSON[kARDJoinResultKey];
43 | response.result = [[self class] resultTypeFromString:resultString];
44 | NSDictionary *params = responseJSON[kARDJoinResultParamsKey];
45 |
46 | response.isInitiator = [params[kARDJoinInitiatorKey] boolValue];
47 | response.roomId = params[kARDJoinRoomIdKey];
48 | response.clientId = params[kARDJoinClientIdKey];
49 |
50 | // Parse messages.
51 | NSArray *messages = params[kARDJoinMessagesKey];
52 | NSMutableArray *signalingMessages =
53 | [NSMutableArray arrayWithCapacity:messages.count];
54 | for (NSString *message in messages) {
55 | ARDSignalingMessage *signalingMessage =
56 | [ARDSignalingMessage messageFromJSONString:message];
57 | [signalingMessages addObject:signalingMessage];
58 | }
59 | response.messages = signalingMessages;
60 |
61 | // Parse websocket urls.
62 | NSString *webSocketURLString = params[kARDJoinWebSocketURLKey];
63 | response.webSocketURL = [NSURL URLWithString:webSocketURLString];
64 | NSString *webSocketRestURLString = params[kARDJoinWebSocketRestURLKey];
65 | response.webSocketRestURL = [NSURL URLWithString:webSocketRestURLString];
66 |
67 | return response;
68 | }
69 |
70 | #pragma mark - Private
71 |
72 | + (ARDJoinResultType)resultTypeFromString:(NSString *)resultString {
73 | ARDJoinResultType result = kARDJoinResultTypeUnknown;
74 | if ([resultString isEqualToString:@"SUCCESS"]) {
75 | result = kARDJoinResultTypeSuccess;
76 | } else if ([resultString isEqualToString:@"FULL"]) {
77 | result = kARDJoinResultTypeFull;
78 | }
79 | return result;
80 | }
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDMessageResponse+Internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDMessageResponse.h"
12 |
13 | @interface ARDMessageResponse ()
14 |
15 | @property(nonatomic, assign) ARDMessageResultType result;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDMessageResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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, ARDMessageResultType) {
14 | kARDMessageResultTypeUnknown,
15 | kARDMessageResultTypeSuccess,
16 | kARDMessageResultTypeInvalidRoom,
17 | kARDMessageResultTypeInvalidClient
18 | };
19 |
20 | @interface ARDMessageResponse : NSObject
21 |
22 | @property(nonatomic, readonly) ARDMessageResultType result;
23 |
24 | + (ARDMessageResponse *)responseFromJSONData:(NSData *)data;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDMessageResponse.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDMessageResponse+Internal.h"
12 |
13 | #import "ARDUtilities.h"
14 |
15 | static NSString const *kARDMessageResultKey = @"result";
16 |
17 | @implementation ARDMessageResponse
18 |
19 | @synthesize result = _result;
20 |
21 | + (ARDMessageResponse *)responseFromJSONData:(NSData *)data {
22 | NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
23 | if (!responseJSON) {
24 | return nil;
25 | }
26 | ARDMessageResponse *response = [[ARDMessageResponse alloc] init];
27 | response.result =
28 | [[self class] resultTypeFromString:responseJSON[kARDMessageResultKey]];
29 | return response;
30 | }
31 |
32 | #pragma mark - Private
33 |
34 | + (ARDMessageResultType)resultTypeFromString:(NSString *)resultString {
35 | ARDMessageResultType result = kARDMessageResultTypeUnknown;
36 | if ([resultString isEqualToString:@"SUCCESS"]) {
37 | result = kARDMessageResultTypeSuccess;
38 | } else if ([resultString isEqualToString:@"INVALID_CLIENT"]) {
39 | result = kARDMessageResultTypeInvalidClient;
40 | } else if ([resultString isEqualToString:@"INVALID_ROOM"]) {
41 | result = kARDMessageResultTypeInvalidRoom;
42 | }
43 | return result;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDRoomServerClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 | @class ARDJoinResponse;
14 | @class ARDMessageResponse;
15 | @class ARDSignalingMessage;
16 |
17 | @protocol ARDRoomServerClient
18 |
19 | - (void)joinRoomWithRoomId:(NSString *)roomId
20 | isLoopback:(BOOL)isLoopback
21 | completionHandler:(void (^)(ARDJoinResponse *response,
22 | NSError *error))completionHandler;
23 |
24 | - (void)sendMessage:(ARDSignalingMessage *)message
25 | forRoomId:(NSString *)roomId
26 | clientId:(NSString *)clientId
27 | completionHandler:(void (^)(ARDMessageResponse *response,
28 | NSError *error))completionHandler;
29 |
30 | - (void)leaveRoomWithRoomId:(NSString *)roomId
31 | clientId:(NSString *)clientId
32 | completionHandler:(void (^)(NSError *error))completionHandler;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSDPUtils.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 | @class RTCSessionDescription;
14 |
15 | @interface ARDSDPUtils : NSObject
16 |
17 | // Updates the original SDP description to instead prefer the specified video
18 | // codec. We do this by placing the specified codec at the beginning of the
19 | // codec list if it exists in the sdp.
20 | + (RTCSessionDescription *)
21 | descriptionForDescription:(RTCSessionDescription *)description
22 | preferredVideoCodec:(NSString *)codec;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSDPUtils.m:
--------------------------------------------------------------------------------
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 "ARDSDPUtils.h"
12 |
13 | #import "WebRTC/RTCLogging.h"
14 | #import "WebRTC/RTCSessionDescription.h"
15 |
16 | @implementation ARDSDPUtils
17 |
18 | + (RTCSessionDescription *)
19 | descriptionForDescription:(RTCSessionDescription *)description
20 | preferredVideoCodec:(NSString *)codec {
21 | NSString *sdpString = description.sdp;
22 | NSString *lineSeparator = @"\r\n";
23 | NSString *mLineSeparator = @" ";
24 | // Copied from PeerConnectionClient.java.
25 | // TODO(tkchin): Move this to a shared C++ file.
26 | NSMutableArray *lines =
27 | [NSMutableArray arrayWithArray:
28 | [sdpString componentsSeparatedByString:lineSeparator]];
29 | // Find the line starting with "m=video".
30 | NSInteger mLineIndex = -1;
31 | for (NSInteger i = 0; i < lines.count; ++i) {
32 | if ([lines[i] hasPrefix:@"m=video"]) {
33 | mLineIndex = i;
34 | break;
35 | }
36 | }
37 | if (mLineIndex == -1) {
38 | RTCLog(@"No m=video line, so can't prefer %@", codec);
39 | return description;
40 | }
41 | // An array with all payload types with name |codec|. The payload types are
42 | // integers in the range 96-127, but they are stored as strings here.
43 | NSMutableArray *codecPayloadTypes = [[NSMutableArray alloc] init];
44 | // a=rtpmap: /
45 | // [/]
46 | NSString *pattern =
47 | [NSString stringWithFormat:@"^a=rtpmap:(\\d+) %@(/\\d+)+[\r]?$", codec];
48 | NSRegularExpression *regex =
49 | [NSRegularExpression regularExpressionWithPattern:pattern
50 | options:0
51 | error:nil];
52 | for (NSString *line in lines) {
53 | NSTextCheckingResult *codecMatches =
54 | [regex firstMatchInString:line
55 | options:0
56 | range:NSMakeRange(0, line.length)];
57 | if (codecMatches) {
58 | [codecPayloadTypes
59 | addObject:[line substringWithRange:[codecMatches rangeAtIndex:1]]];
60 | }
61 | }
62 | if ([codecPayloadTypes count] == 0) {
63 | RTCLog(@"No payload types with name %@", codec);
64 | return description;
65 | }
66 | NSArray *origMLineParts =
67 | [lines[mLineIndex] componentsSeparatedByString:mLineSeparator];
68 | // The format of ML should be: m= ...
69 | const int kHeaderLength = 3;
70 | if (origMLineParts.count <= kHeaderLength) {
71 | RTCLogWarning(@"Wrong SDP media description format: %@", lines[mLineIndex]);
72 | return description;
73 | }
74 | // Split the line into header and payloadTypes.
75 | NSRange headerRange = NSMakeRange(0, kHeaderLength);
76 | NSRange payloadRange =
77 | NSMakeRange(kHeaderLength, origMLineParts.count - kHeaderLength);
78 | NSArray *header = [origMLineParts subarrayWithRange:headerRange];
79 | NSMutableArray *payloadTypes = [NSMutableArray
80 | arrayWithArray:[origMLineParts subarrayWithRange:payloadRange]];
81 | // Reconstruct the line with |codecPayloadTypes| moved to the beginning of the
82 | // payload types.
83 | NSMutableArray *newMLineParts = [NSMutableArray arrayWithCapacity:origMLineParts.count];
84 | [newMLineParts addObjectsFromArray:header];
85 | [newMLineParts addObjectsFromArray:codecPayloadTypes];
86 | [payloadTypes removeObjectsInArray:codecPayloadTypes];
87 | [newMLineParts addObjectsFromArray:payloadTypes];
88 |
89 | NSString *newMLine = [newMLineParts componentsJoinedByString:mLineSeparator];
90 | [lines replaceObjectAtIndex:mLineIndex
91 | withObject:newMLine];
92 |
93 | NSString *mangledSdpString = [lines componentsJoinedByString:lineSeparator];
94 | return [[RTCSessionDescription alloc] initWithType:description.type
95 | sdp:mangledSdpString];
96 | }
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSettingsModel+Private.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 "ARDSettingsModel.h"
13 |
14 | @class ARDSettingsStore;
15 |
16 | NS_ASSUME_NONNULL_BEGIN
17 | @interface ARDSettingsModel ()
18 | - (ARDSettingsStore *)settingsStore;
19 | @end
20 | NS_ASSUME_NONNULL_END
21 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSettingsModel.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 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | /**
16 | * Model class for user defined settings.
17 | *
18 | * Handles storing the settings and provides default values if setting is not
19 | * set. Also provides list of available options for different settings. Stores
20 | * for example video codec, video resolution and maximum bitrate.
21 | */
22 | @interface ARDSettingsModel : NSObject
23 |
24 | /**
25 | * Returns array of available capture resoultions.
26 | *
27 | * The capture resolutions are represented as strings in the following format
28 | * [width]x[height]
29 | */
30 | - (NSArray *)availableVideoResolutions;
31 |
32 | /**
33 | * Returns current video resolution string.
34 | * If no resolution is in store, default value of 640x480 is returned.
35 | * When defaulting to value, the default is saved in store for consistency reasons.
36 | */
37 | - (NSString *)currentVideoResolutionSettingFromStore;
38 | - (int)currentVideoResolutionWidthFromStore;
39 | - (int)currentVideoResolutionHeightFromStore;
40 |
41 | /**
42 | * Stores the provided video resolution string into the store.
43 | *
44 | * If the provided resolution is no part of the available video resolutions
45 | * the store operation will not be executed and NO will be returned.
46 | * @param resolution the string to be stored.
47 | * @return YES/NO depending on success.
48 | */
49 | - (BOOL)storeVideoResolutionSetting:(NSString *)resolution;
50 |
51 | /**
52 | * Returns array of available video codecs.
53 | */
54 | - (NSArray *)availableVideoCodecs;
55 |
56 | /**
57 | * Returns current video codec setting from store if present or default (H264) otherwise.
58 | */
59 | - (NSString *)currentVideoCodecSettingFromStore;
60 |
61 | /**
62 | * Stores the provided video codec setting into the store.
63 | *
64 | * If the provided video codec is not part of the available video codecs
65 | * the store operation will not be executed and NO will be returned.
66 | * @param video codec settings the string to be stored.
67 | * @return YES/NO depending on success.
68 | */
69 | - (BOOL)storeVideoCodecSetting:(NSString *)videoCodec;
70 |
71 | /**
72 | * Returns current max bitrate setting from store if present.
73 | */
74 | - (nullable NSNumber *)currentMaxBitrateSettingFromStore;
75 |
76 | /**
77 | * Stores the provided bitrate value into the store.
78 | *
79 | * @param bitrate NSNumber representation of the max bitrate value.
80 | */
81 | - (void)storeMaxBitrateSetting:(nullable NSNumber *)bitrate;
82 |
83 | /**
84 | * Returns current audio only setting from store if present or default (NO) otherwise.
85 | */
86 | - (BOOL)currentAudioOnlySettingFromStore;
87 |
88 | /**
89 | * Stores the provided audio only setting into the store.
90 | *
91 | * @param setting the boolean value to be stored.
92 | */
93 | - (void)storeAudioOnlySetting:(BOOL)audioOnly;
94 |
95 | /**
96 | * Returns current create AecDump setting from store if present or default (NO) otherwise.
97 | */
98 | - (BOOL)currentCreateAecDumpSettingFromStore;
99 |
100 | /**
101 | * Stores the provided create AecDump setting into the store.
102 | *
103 | * @param setting the boolean value to be stored.
104 | */
105 | - (void)storeCreateAecDumpSetting:(BOOL)createAecDump;
106 |
107 | /**
108 | * Returns current setting whether to use level controller from store if present or default (NO)
109 | * otherwise.
110 | */
111 | - (BOOL)currentUseLevelControllerSettingFromStore;
112 |
113 | /**
114 | * Stores the provided use level controller setting into the store.
115 | *
116 | * @param setting the boolean value to be stored.
117 | */
118 | - (void)storeUseLevelControllerSetting:(BOOL)useLevelController;
119 |
120 | /**
121 | * Returns current setting whether to use manual audio config from store if present or default (YES)
122 | * otherwise.
123 | */
124 | - (BOOL)currentUseManualAudioConfigSettingFromStore;
125 |
126 | /**
127 | * Stores the provided use manual audio config setting into the store.
128 | *
129 | * @param setting the boolean value to be stored.
130 | */
131 | - (void)storeUseManualAudioConfigSetting:(BOOL)useManualAudioConfig;
132 |
133 | @end
134 | NS_ASSUME_NONNULL_END
135 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSettingsModel.m:
--------------------------------------------------------------------------------
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 "ARDSettingsModel+Private.h"
12 | #import "ARDSettingsStore.h"
13 | #import "WebRTC/RTCCameraVideoCapturer.h"
14 | #import "WebRTC/RTCMediaConstraints.h"
15 |
16 | NS_ASSUME_NONNULL_BEGIN
17 |
18 | static NSArray *videoCodecsStaticValues() {
19 | return @[ @"H264", @"VP8", @"VP9" ];
20 | }
21 |
22 | @interface ARDSettingsModel () {
23 | ARDSettingsStore *_settingsStore;
24 | }
25 | @end
26 |
27 | @implementation ARDSettingsModel
28 |
29 | - (NSArray *)availableVideoResolutions {
30 | NSMutableSet *> *resolutions =
31 | [[NSMutableSet *> alloc] init];
32 | for (AVCaptureDevice *device in [RTCCameraVideoCapturer captureDevices]) {
33 | for (AVCaptureDeviceFormat *format in
34 | [RTCCameraVideoCapturer supportedFormatsForDevice:device]) {
35 | CMVideoDimensions resolution =
36 | CMVideoFormatDescriptionGetDimensions(format.formatDescription);
37 | NSArray *resolutionObject = @[ @(resolution.width), @(resolution.height) ];
38 | [resolutions addObject:resolutionObject];
39 | }
40 | }
41 |
42 | NSArray *> *sortedResolutions =
43 | [[resolutions allObjects] sortedArrayUsingComparator:^NSComparisonResult(
44 | NSArray *obj1, NSArray *obj2) {
45 | return obj1.firstObject > obj2.firstObject;
46 | }];
47 |
48 | NSMutableArray *resolutionStrings = [[NSMutableArray alloc] init];
49 | for (NSArray *resolution in sortedResolutions) {
50 | NSString *resolutionString =
51 | [NSString stringWithFormat:@"%@x%@", resolution.firstObject, resolution.lastObject];
52 | [resolutionStrings addObject:resolutionString];
53 | }
54 |
55 | return [resolutionStrings copy];
56 | }
57 |
58 | - (NSString *)currentVideoResolutionSettingFromStore {
59 | [self registerStoreDefaults];
60 | return [[self settingsStore] videoResolution];
61 | }
62 |
63 | - (BOOL)storeVideoResolutionSetting:(NSString *)resolution {
64 | if (![[self availableVideoResolutions] containsObject:resolution]) {
65 | return NO;
66 | }
67 | [[self settingsStore] setVideoResolution:resolution];
68 | return YES;
69 | }
70 |
71 | - (NSArray *)availableVideoCodecs {
72 | return videoCodecsStaticValues();
73 | }
74 |
75 | - (NSString *)currentVideoCodecSettingFromStore {
76 | [self registerStoreDefaults];
77 | return [[self settingsStore] videoCodec];
78 | }
79 |
80 | - (BOOL)storeVideoCodecSetting:(NSString *)videoCodec {
81 | if (![[self availableVideoCodecs] containsObject:videoCodec]) {
82 | return NO;
83 | }
84 | [[self settingsStore] setVideoCodec:videoCodec];
85 | return YES;
86 | }
87 |
88 | - (nullable NSNumber *)currentMaxBitrateSettingFromStore {
89 | [self registerStoreDefaults];
90 | return [[self settingsStore] maxBitrate];
91 | }
92 |
93 | - (void)storeMaxBitrateSetting:(nullable NSNumber *)bitrate {
94 | [[self settingsStore] setMaxBitrate:bitrate];
95 | }
96 |
97 | - (BOOL)currentAudioOnlySettingFromStore {
98 | return [[self settingsStore] audioOnly];
99 | }
100 |
101 | - (void)storeAudioOnlySetting:(BOOL)audioOnly {
102 | [[self settingsStore] setAudioOnly:audioOnly];
103 | }
104 |
105 | - (BOOL)currentCreateAecDumpSettingFromStore {
106 | return [[self settingsStore] createAecDump];
107 | }
108 |
109 | - (void)storeCreateAecDumpSetting:(BOOL)createAecDump {
110 | [[self settingsStore] setCreateAecDump:createAecDump];
111 | }
112 |
113 | - (BOOL)currentUseLevelControllerSettingFromStore {
114 | return [[self settingsStore] useLevelController];
115 | }
116 |
117 | - (void)storeUseLevelControllerSetting:(BOOL)useLevelController {
118 | [[self settingsStore] setUseLevelController:useLevelController];
119 | }
120 |
121 | - (BOOL)currentUseManualAudioConfigSettingFromStore {
122 | return [[self settingsStore] useManualAudioConfig];
123 | }
124 |
125 | - (void)storeUseManualAudioConfigSetting:(BOOL)useManualAudioConfig {
126 | [[self settingsStore] setUseManualAudioConfig:useManualAudioConfig];
127 | }
128 |
129 | #pragma mark - Testable
130 |
131 | - (ARDSettingsStore *)settingsStore {
132 | if (!_settingsStore) {
133 | _settingsStore = [[ARDSettingsStore alloc] init];
134 | [self registerStoreDefaults];
135 | }
136 | return _settingsStore;
137 | }
138 |
139 | - (int)currentVideoResolutionWidthFromStore {
140 | NSString *resolution = [self currentVideoResolutionSettingFromStore];
141 |
142 | return [self videoResolutionComponentAtIndex:0 inString:resolution];
143 | }
144 |
145 | - (int)currentVideoResolutionHeightFromStore {
146 | NSString *resolution = [self currentVideoResolutionSettingFromStore];
147 | return [self videoResolutionComponentAtIndex:1 inString:resolution];
148 | }
149 |
150 | #pragma mark -
151 |
152 | - (NSString *)defaultVideoResolutionSetting {
153 | return [self availableVideoResolutions][0];
154 | }
155 |
156 | - (NSString *)defaultVideoCodecSetting {
157 | return videoCodecsStaticValues()[0];
158 | }
159 |
160 | - (int)videoResolutionComponentAtIndex:(int)index inString:(NSString *)resolution {
161 | if (index != 0 && index != 1) {
162 | return 0;
163 | }
164 | NSArray *components = [resolution componentsSeparatedByString:@"x"];
165 | if (components.count != 2) {
166 | return 0;
167 | }
168 | return components[index].intValue;
169 | }
170 |
171 | - (void)registerStoreDefaults {
172 | [ARDSettingsStore setDefaultsForVideoResolution:[self defaultVideoResolutionSetting]
173 | videoCodec:[self defaultVideoCodecSetting]
174 | bitrate:nil
175 | audioOnly:NO
176 | createAecDump:NO
177 | useLevelController:NO
178 | useManualAudioConfig:YES];
179 | }
180 |
181 | @end
182 | NS_ASSUME_NONNULL_END
183 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSettingsStore.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 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | /**
16 | * Light-weight persistent store for user settings.
17 | *
18 | * It will persist between application launches and application updates.
19 | */
20 | @interface ARDSettingsStore : NSObject
21 |
22 | /**
23 | * Set fallback values in case the setting has not been written by the user.
24 | * @param dictionary of values to store
25 | */
26 | + (void)setDefaultsForVideoResolution:(NSString *)videoResolution
27 | videoCodec:(NSString *)videoCodec
28 | bitrate:(nullable NSNumber *)bitrate
29 | audioOnly:(BOOL)audioOnly
30 | createAecDump:(BOOL)createAecDump
31 | useLevelController:(BOOL)useLevelController
32 | useManualAudioConfig:(BOOL)useManualAudioConfig;
33 |
34 | @property(nonatomic) NSString *videoResolution;
35 | @property(nonatomic) NSString *videoCodec;
36 |
37 | /**
38 | * Returns current max bitrate number stored in the store.
39 | */
40 | - (nullable NSNumber *)maxBitrate;
41 |
42 | /**
43 | * Stores the provided value as maximum bitrate setting.
44 | * @param value the number to be stored
45 | */
46 | - (void)setMaxBitrate:(nullable NSNumber *)value;
47 |
48 | @property(nonatomic) BOOL audioOnly;
49 | @property(nonatomic) BOOL createAecDump;
50 | @property(nonatomic) BOOL useLevelController;
51 | @property(nonatomic) BOOL useManualAudioConfig;
52 |
53 | @end
54 | NS_ASSUME_NONNULL_END
55 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSettingsStore.m:
--------------------------------------------------------------------------------
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 "ARDSettingsStore.h"
12 |
13 | static NSString *const kVideoResolutionKey = @"rtc_video_resolution_key";
14 | static NSString *const kVideoCodecKey = @"rtc_video_codec_key";
15 | static NSString *const kBitrateKey = @"rtc_max_bitrate_key";
16 | static NSString *const kAudioOnlyKey = @"rtc_audio_only_key";
17 | static NSString *const kCreateAecDumpKey = @"rtc_create_aec_dump_key";
18 | static NSString *const kUseLevelControllerKey = @"rtc_use_level_controller_key";
19 | static NSString *const kUseManualAudioConfigKey = @"rtc_use_manual_audio_config_key";
20 |
21 | NS_ASSUME_NONNULL_BEGIN
22 | @interface ARDSettingsStore () {
23 | NSUserDefaults *_storage;
24 | }
25 | @property(nonatomic, strong, readonly) NSUserDefaults *storage;
26 | @end
27 |
28 | @implementation ARDSettingsStore
29 |
30 | + (void)setDefaultsForVideoResolution:(NSString *)videoResolution
31 | videoCodec:(NSString *)videoCodec
32 | bitrate:(nullable NSNumber *)bitrate
33 | audioOnly:(BOOL)audioOnly
34 | createAecDump:(BOOL)createAecDump
35 | useLevelController:(BOOL)useLevelController
36 | useManualAudioConfig:(BOOL)useManualAudioConfig {
37 | NSMutableDictionary *defaultsDictionary = [@{
38 | kVideoResolutionKey : videoResolution,
39 | kVideoCodecKey : videoCodec,
40 | kAudioOnlyKey : @(audioOnly),
41 | kCreateAecDumpKey : @(createAecDump),
42 | kUseLevelControllerKey : @(useLevelController),
43 | kUseManualAudioConfigKey : @(useManualAudioConfig)
44 | } mutableCopy];
45 | if (bitrate) {
46 | [defaultsDictionary setObject:bitrate forKey:kBitrateKey];
47 | }
48 | [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
49 | }
50 |
51 | - (NSUserDefaults *)storage {
52 | if (!_storage) {
53 | _storage = [NSUserDefaults standardUserDefaults];
54 | }
55 | return _storage;
56 | }
57 |
58 | - (NSString *)videoResolution {
59 | return [self.storage objectForKey:kVideoResolutionKey];
60 | }
61 |
62 | - (void)setVideoResolution:(NSString *)resolution {
63 | [self.storage setObject:resolution forKey:kVideoResolutionKey];
64 | [self.storage synchronize];
65 | }
66 |
67 | - (NSString *)videoCodec {
68 | return [self.storage objectForKey:kVideoCodecKey];
69 | }
70 |
71 | - (void)setVideoCodec:(NSString *)videoCodec {
72 | [self.storage setObject:videoCodec forKey:kVideoCodecKey];
73 | [self.storage synchronize];
74 | }
75 |
76 | - (nullable NSNumber *)maxBitrate {
77 | return [self.storage objectForKey:kBitrateKey];
78 | }
79 |
80 | - (void)setMaxBitrate:(nullable NSNumber *)value {
81 | [self.storage setObject:value forKey:kBitrateKey];
82 | [self.storage synchronize];
83 | }
84 |
85 | - (BOOL)audioOnly {
86 | return [self.storage boolForKey:kAudioOnlyKey];
87 | }
88 |
89 | - (void)setAudioOnly:(BOOL)audioOnly {
90 | [self.storage setBool:audioOnly forKey:kAudioOnlyKey];
91 | [self.storage synchronize];
92 | }
93 |
94 | - (BOOL)createAecDump {
95 | return [self.storage boolForKey:kCreateAecDumpKey];
96 | }
97 |
98 | - (void)setCreateAecDump:(BOOL)createAecDump {
99 | [self.storage setBool:createAecDump forKey:kCreateAecDumpKey];
100 | [self.storage synchronize];
101 | }
102 |
103 | - (BOOL)useLevelController {
104 | return [self.storage boolForKey:kUseLevelControllerKey];
105 | }
106 |
107 | - (void)setUseLevelController:(BOOL)useLevelController {
108 | [self.storage setBool:useLevelController forKey:kUseLevelControllerKey];
109 | [self.storage synchronize];
110 | }
111 |
112 | - (BOOL)useManualAudioConfig {
113 | return [self.storage boolForKey:kUseManualAudioConfigKey];
114 | }
115 |
116 | - (void)setUseManualAudioConfig:(BOOL)useManualAudioConfig {
117 | [self.storage setBool:useManualAudioConfig forKey:kUseManualAudioConfigKey];
118 | [self.storage synchronize];
119 | }
120 |
121 | @end
122 | NS_ASSUME_NONNULL_END
123 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSignalingChannel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDSignalingMessage.h"
14 |
15 | typedef NS_ENUM(NSInteger, ARDSignalingChannelState) {
16 | // State when disconnected.
17 | kARDSignalingChannelStateClosed,
18 | // State when connection is established but not ready for use.
19 | kARDSignalingChannelStateOpen,
20 | // State when connection is established and registered.
21 | kARDSignalingChannelStateRegistered,
22 | // State when connection encounters a fatal error.
23 | kARDSignalingChannelStateError
24 | };
25 |
26 | @protocol ARDSignalingChannel;
27 | @protocol ARDSignalingChannelDelegate
28 |
29 | - (void)channel:(id)channel
30 | didChangeState:(ARDSignalingChannelState)state;
31 |
32 | - (void)channel:(id)channel
33 | didReceiveMessage:(ARDSignalingMessage *)message;
34 |
35 | @end
36 |
37 | @protocol ARDSignalingChannel
38 |
39 | @property(nonatomic, readonly) NSString *roomId;
40 | @property(nonatomic, readonly) NSString *clientId;
41 | @property(nonatomic, readonly) ARDSignalingChannelState state;
42 | @property(nonatomic, weak) id delegate;
43 |
44 | // Registers the channel for the given room and client id.
45 | - (void)registerForRoomId:(NSString *)roomId
46 | clientId:(NSString *)clientId;
47 |
48 | // Sends signaling message over the channel.
49 | - (void)sendMessage:(ARDSignalingMessage *)message;
50 |
51 | @end
52 |
53 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSignalingMessage.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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/RTCIceCandidate.h"
14 | #import "WebRTC/RTCSessionDescription.h"
15 |
16 | typedef enum {
17 | kARDSignalingMessageTypeCandidate,
18 | kARDSignalingMessageTypeCandidateRemoval,
19 | kARDSignalingMessageTypeOffer,
20 | kARDSignalingMessageTypeAnswer,
21 | kARDSignalingMessageTypeBye,
22 | } ARDSignalingMessageType;
23 |
24 | @interface ARDSignalingMessage : NSObject
25 |
26 | @property(nonatomic, readonly) ARDSignalingMessageType type;
27 |
28 | + (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString;
29 | - (NSData *)JSONData;
30 |
31 | @end
32 |
33 | @interface ARDICECandidateMessage : ARDSignalingMessage
34 |
35 | @property(nonatomic, readonly) RTCIceCandidate *candidate;
36 |
37 | - (instancetype)initWithCandidate:(RTCIceCandidate *)candidate;
38 |
39 | @end
40 |
41 | @interface ARDICECandidateRemovalMessage : ARDSignalingMessage
42 |
43 | @property(nonatomic, readonly) NSArray *candidates;
44 |
45 | - (instancetype)initWithRemovedCandidates:
46 | (NSArray *)candidates;
47 |
48 | @end
49 |
50 | @interface ARDSessionDescriptionMessage : ARDSignalingMessage
51 |
52 | @property(nonatomic, readonly) RTCSessionDescription *sessionDescription;
53 |
54 | - (instancetype)initWithDescription:(RTCSessionDescription *)description;
55 |
56 | @end
57 |
58 | @interface ARDByeMessage : ARDSignalingMessage
59 | @end
60 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDSignalingMessage.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDSignalingMessage.h"
12 |
13 | #import "WebRTC/RTCLogging.h"
14 |
15 | #import "ARDUtilities.h"
16 | #import "RTCIceCandidate+JSON.h"
17 | #import "RTCSessionDescription+JSON.h"
18 |
19 | static NSString * const kARDSignalingMessageTypeKey = @"type";
20 | static NSString * const kARDTypeValueRemoveCandidates = @"remove-candidates";
21 |
22 | @implementation ARDSignalingMessage
23 |
24 | @synthesize type = _type;
25 |
26 | - (instancetype)initWithType:(ARDSignalingMessageType)type {
27 | if (self = [super init]) {
28 | _type = type;
29 | }
30 | return self;
31 | }
32 |
33 | - (NSString *)description {
34 | return [[NSString alloc] initWithData:[self JSONData]
35 | encoding:NSUTF8StringEncoding];
36 | }
37 |
38 | + (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString {
39 | NSDictionary *values = [NSDictionary dictionaryWithJSONString:jsonString];
40 | if (!values) {
41 | RTCLogError(@"Error parsing signaling message JSON.");
42 | return nil;
43 | }
44 |
45 | NSString *typeString = values[kARDSignalingMessageTypeKey];
46 | ARDSignalingMessage *message = nil;
47 | if ([typeString isEqualToString:@"candidate"]) {
48 | RTCIceCandidate *candidate =
49 | [RTCIceCandidate candidateFromJSONDictionary:values];
50 | message = [[ARDICECandidateMessage alloc] initWithCandidate:candidate];
51 | } else if ([typeString isEqualToString:kARDTypeValueRemoveCandidates]) {
52 | RTCLogInfo(@"Received remove-candidates message");
53 | NSArray *candidates =
54 | [RTCIceCandidate candidatesFromJSONDictionary:values];
55 | message = [[ARDICECandidateRemovalMessage alloc]
56 | initWithRemovedCandidates:candidates];
57 | } else if ([typeString isEqualToString:@"offer"] ||
58 | [typeString isEqualToString:@"answer"]) {
59 | RTCSessionDescription *description =
60 | [RTCSessionDescription descriptionFromJSONDictionary:values];
61 | message =
62 | [[ARDSessionDescriptionMessage alloc] initWithDescription:description];
63 | } else if ([typeString isEqualToString:@"bye"]) {
64 | message = [[ARDByeMessage alloc] init];
65 | } else {
66 | RTCLogError(@"Unexpected type: %@", typeString);
67 | }
68 | return message;
69 | }
70 |
71 | - (NSData *)JSONData {
72 | return nil;
73 | }
74 |
75 | @end
76 |
77 | @implementation ARDICECandidateMessage
78 |
79 | @synthesize candidate = _candidate;
80 |
81 | - (instancetype)initWithCandidate:(RTCIceCandidate *)candidate {
82 | if (self = [super initWithType:kARDSignalingMessageTypeCandidate]) {
83 | _candidate = candidate;
84 | }
85 | return self;
86 | }
87 |
88 | - (NSData *)JSONData {
89 | return [_candidate JSONData];
90 | }
91 |
92 | @end
93 |
94 | @implementation ARDICECandidateRemovalMessage
95 |
96 | @synthesize candidates = _candidates;
97 |
98 | - (instancetype)initWithRemovedCandidates:(
99 | NSArray *)candidates {
100 | NSParameterAssert(candidates.count);
101 | if (self = [super initWithType:kARDSignalingMessageTypeCandidateRemoval]) {
102 | _candidates = candidates;
103 | }
104 | return self;
105 | }
106 |
107 | - (NSData *)JSONData {
108 | return
109 | [RTCIceCandidate JSONDataForIceCandidates:_candidates
110 | withType:kARDTypeValueRemoveCandidates];
111 | }
112 |
113 | @end
114 |
115 | @implementation ARDSessionDescriptionMessage
116 |
117 | @synthesize sessionDescription = _sessionDescription;
118 |
119 | - (instancetype)initWithDescription:(RTCSessionDescription *)description {
120 | ARDSignalingMessageType messageType = kARDSignalingMessageTypeOffer;
121 | RTCSdpType sdpType = description.type;
122 | switch (sdpType) {
123 | case RTCSdpTypeOffer:
124 | messageType = kARDSignalingMessageTypeOffer;
125 | break;
126 | case RTCSdpTypeAnswer:
127 | messageType = kARDSignalingMessageTypeAnswer;
128 | break;
129 | case RTCSdpTypePrAnswer:
130 | NSAssert(NO, @"Unexpected type: %@",
131 | [RTCSessionDescription stringForType:sdpType]);
132 | break;
133 | }
134 | if (self = [super initWithType:messageType]) {
135 | _sessionDescription = description;
136 | }
137 | return self;
138 | }
139 |
140 | - (NSData *)JSONData {
141 | return [_sessionDescription JSONData];
142 | }
143 |
144 | @end
145 |
146 | @implementation ARDByeMessage
147 |
148 | - (instancetype)init {
149 | return [super initWithType:kARDSignalingMessageTypeBye];
150 | }
151 |
152 | - (NSData *)JSONData {
153 | NSDictionary *message = @{
154 | @"type": @"bye"
155 | };
156 | return [NSJSONSerialization dataWithJSONObject:message
157 | options:NSJSONWritingPrettyPrinted
158 | error:NULL];
159 | }
160 |
161 | @end
162 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDStatsBuilder.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 | @class RTCLegacyStatsReport;
14 |
15 | /** Class used to accumulate stats information into a single displayable string.
16 | */
17 | @interface ARDStatsBuilder : NSObject
18 |
19 | /** String that represents the accumulated stats reports passed into this
20 | * class.
21 | */
22 | @property(nonatomic, readonly) NSString *statsString;
23 |
24 | /** Parses the information in the stats report into an appropriate internal
25 | * format used to generate the stats string.
26 | */
27 | - (void)parseStatsReport:(RTCLegacyStatsReport *)statsReport;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDTURNClient+Internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDTURNClient.h"
12 |
13 | @interface ARDTURNClient : NSObject
14 |
15 | - (instancetype)initWithURL:(NSURL *)url;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDTURNClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 | @class RTCIceServer;
14 |
15 | @protocol ARDTURNClient
16 |
17 | // Returns TURN server urls if successful.
18 | - (void)requestServersWithCompletionHandler:
19 | (void (^)(NSArray *turnServers,
20 | NSError *error))completionHandler;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDTURNClient.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDTURNClient+Internal.h"
12 |
13 | #import "ARDUtilities.h"
14 | #import "RTCIceServer+JSON.h"
15 |
16 | // TODO(tkchin): move this to a configuration object.
17 | static NSString *kTURNRefererURLString = @"https://appr.tc";
18 | static NSString *kARDTURNClientErrorDomain = @"ARDTURNClient";
19 | static NSInteger kARDTURNClientErrorBadResponse = -1;
20 |
21 | @implementation ARDTURNClient {
22 | NSURL *_url;
23 | }
24 |
25 | - (instancetype)initWithURL:(NSURL *)url {
26 | NSParameterAssert([url absoluteString].length);
27 | if (self = [super init]) {
28 | _url = url;
29 | }
30 | return self;
31 | }
32 |
33 | - (void)requestServersWithCompletionHandler:
34 | (void (^)(NSArray *turnServers, NSError *error))completionHandler {
35 |
36 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:_url];
37 | [NSURLConnection sendAsyncRequest:request
38 | completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
39 | if (error) {
40 | completionHandler(nil, error);
41 | return;
42 | }
43 | NSDictionary *responseDict = [NSDictionary dictionaryWithJSONData:data];
44 | NSString *iceServerUrl = responseDict[@"ice_server_url"];
45 | [self makeTurnServerRequestToURL:[NSURL URLWithString:iceServerUrl]
46 | WithCompletionHandler:completionHandler];
47 | }];
48 | }
49 |
50 | #pragma mark - Private
51 |
52 | - (void)makeTurnServerRequestToURL:(NSURL *)url
53 | WithCompletionHandler:(void (^)(NSArray *turnServers,
54 | NSError *error))completionHandler {
55 | NSMutableURLRequest *iceServerRequest = [NSMutableURLRequest requestWithURL:url];
56 | iceServerRequest.HTTPMethod = @"POST";
57 | [iceServerRequest addValue:kTURNRefererURLString forHTTPHeaderField:@"referer"];
58 | [NSURLConnection sendAsyncRequest:iceServerRequest
59 | completionHandler:^(NSURLResponse *response,
60 | NSData *data,
61 | NSError *error) {
62 | if (error) {
63 | completionHandler(nil, error);
64 | return;
65 | }
66 | NSDictionary *turnResponseDict = [NSDictionary dictionaryWithJSONData:data];
67 | NSMutableArray *turnServers = [NSMutableArray array];
68 | [turnResponseDict[@"iceServers"] enumerateObjectsUsingBlock:
69 | ^(NSDictionary *obj, NSUInteger idx, BOOL *stop){
70 | [turnServers addObject:[RTCIceServer serverFromJSONDictionary:obj]];
71 | }];
72 | if (!turnServers) {
73 | NSError *responseError =
74 | [[NSError alloc] initWithDomain:kARDTURNClientErrorDomain
75 | code:kARDTURNClientErrorBadResponse
76 | userInfo:@{
77 | NSLocalizedDescriptionKey: @"Bad TURN response.",
78 | }];
79 | completionHandler(nil, responseError);
80 | return;
81 | }
82 | completionHandler(turnServers, nil);
83 | }];
84 | }
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDVideoDecoderFactory.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 "WebRTC/RTCVideoCodecFactory.h"
13 |
14 | @interface ARDVideoDecoderFactory : NSObject
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDVideoDecoderFactory.m:
--------------------------------------------------------------------------------
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 "ARDVideoDecoderFactory.h"
12 |
13 | #import "WebRTC/RTCVideoCodecH264.h"
14 | #import "WebRTC/RTCVideoDecoderVP8.h"
15 | #import "WebRTC/RTCVideoDecoderVP9.h"
16 |
17 | @implementation ARDVideoDecoderFactory
18 |
19 | - (id)createDecoder:(RTCVideoCodecInfo *)info {
20 | if ([info.name isEqualToString:@"H264"]) {
21 | return [[RTCVideoDecoderH264 alloc] init];
22 | } else if ([info.name isEqualToString:@"VP8"]) {
23 | return [RTCVideoDecoderVP8 vp8Decoder];
24 | } else if ([info.name isEqualToString:@"VP9"]) {
25 | return [RTCVideoDecoderVP9 vp9Decoder];
26 | }
27 |
28 | return nil;
29 | }
30 |
31 | - (NSArray *)supportedCodecs {
32 | return @[
33 | [[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:nil],
34 | [[RTCVideoCodecInfo alloc] initWithName:@"VP8" parameters:nil],
35 | [[RTCVideoCodecInfo alloc] initWithName:@"VP9" parameters:nil]
36 | ];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDVideoEncoderFactory.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 "WebRTC/RTCVideoCodecFactory.h"
13 |
14 | @interface ARDVideoEncoderFactory : NSObject
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDVideoEncoderFactory.m:
--------------------------------------------------------------------------------
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 "ARDVideoEncoderFactory.h"
12 |
13 | #import "WebRTC/RTCVideoCodecH264.h"
14 | #import "WebRTC/RTCVideoEncoderVP8.h"
15 | #import "WebRTC/RTCVideoEncoderVP9.h"
16 |
17 | static NSString *kLevel31ConstrainedHigh = @"640c1f";
18 | static NSString *kLevel31ConstrainedBaseline = @"42e01f";
19 |
20 | @implementation ARDVideoEncoderFactory
21 |
22 | - (id)createEncoder:(RTCVideoCodecInfo *)info {
23 | if ([info.name isEqualToString:@"H264"]) {
24 | return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
25 | } else if ([info.name isEqualToString:@"VP8"]) {
26 | return [RTCVideoEncoderVP8 vp8Encoder];
27 | } else if ([info.name isEqualToString:@"VP9"]) {
28 | return [RTCVideoEncoderVP9 vp9Encoder];
29 | }
30 |
31 | return nil;
32 | }
33 |
34 | - (NSArray *)supportedCodecs {
35 | NSMutableArray *codecs = [NSMutableArray array];
36 |
37 | NSDictionary *constrainedHighParams = @{
38 | @"profile-level-id" : kLevel31ConstrainedHigh,
39 | @"level-asymmetry-allowed" : @"1",
40 | @"packetization-mode" : @"1",
41 | };
42 | RTCVideoCodecInfo *constrainedHighInfo =
43 | [[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedHighParams];
44 | [codecs addObject:constrainedHighInfo];
45 |
46 | NSDictionary *constrainedBaselineParams = @{
47 | @"profile-level-id" : kLevel31ConstrainedBaseline,
48 | @"level-asymmetry-allowed" : @"1",
49 | @"packetization-mode" : @"1",
50 | };
51 | RTCVideoCodecInfo *constrainedBaselineInfo =
52 | [[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedBaselineParams];
53 | [codecs addObject:constrainedBaselineInfo];
54 |
55 | RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP8" parameters:nil];
56 | [codecs addObject:vp8Info];
57 |
58 | RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP9" parameters:nil];
59 | [codecs addObject:vp9Info];
60 |
61 | return [codecs copy];
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ARDWebSocketChannel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "ARDSignalingChannel.h"
14 |
15 | // Wraps a WebSocket connection to the AppRTC WebSocket server.
16 | @interface ARDWebSocketChannel : NSObject
17 |
18 | - (instancetype)initWithURL:(NSURL *)url
19 | restURL:(NSURL *)restURL
20 | delegate:(id)delegate;
21 |
22 | // Registers with the WebSocket server for the given room and client id once
23 | // the web socket connection is open.
24 | - (void)registerForRoomId:(NSString *)roomId
25 | clientId:(NSString *)clientId;
26 |
27 | // Sends message over the WebSocket connection if registered, otherwise POSTs to
28 | // the web socket server instead.
29 | - (void)sendMessage:(ARDSignalingMessage *)message;
30 |
31 | @end
32 |
33 | // Loopback mode is used to cause the client to connect to itself for testing.
34 | // A second web socket connection is established simulating the other client.
35 | // Any messages received are sent back to the WebSocket server after modifying
36 | // them as appropriate.
37 | @interface ARDLoopbackWebSocketChannel : ARDWebSocketChannel
38 |
39 | - (instancetype)initWithURL:(NSURL *)url restURL:(NSURL *)restURL;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/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 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/Icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlexKMDev/WebRTC/abf728ea9718a3dd407030c209bfb564fb7ee5ec/AppRTCMobile/webrtc/Icon-120.png
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/Icon-180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlexKMDev/WebRTC/abf728ea9718a3dd407030c209bfb564fb7ee5ec/AppRTCMobile/webrtc/Icon-180.png
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCIceCandidate+JSON.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "WebRTC/RTCIceCandidate.h"
12 |
13 | @interface RTCIceCandidate (JSON)
14 |
15 | + (RTCIceCandidate *)candidateFromJSONDictionary:(NSDictionary *)dictionary;
16 | + (NSArray *)candidatesFromJSONDictionary:
17 | (NSDictionary *)dictionary;
18 | + (NSData *)JSONDataForIceCandidates:(NSArray *)candidates
19 | withType:(NSString *)typeValue;
20 | - (NSData *)JSONData;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCIceCandidate+JSON.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "RTCIceCandidate+JSON.h"
12 |
13 | #import "WebRTC/RTCLogging.h"
14 |
15 | static NSString const *kRTCICECandidateTypeKey = @"type";
16 | static NSString const *kRTCICECandidateTypeValue = @"candidate";
17 | static NSString const *kRTCICECandidateMidKey = @"id";
18 | static NSString const *kRTCICECandidateMLineIndexKey = @"label";
19 | static NSString const *kRTCICECandidateSdpKey = @"candidate";
20 | static NSString const *kRTCICECandidatesTypeKey = @"candidates";
21 |
22 |
23 | @implementation RTCIceCandidate (JSON)
24 |
25 | + (RTCIceCandidate *)candidateFromJSONDictionary:(NSDictionary *)dictionary {
26 | NSString *mid = dictionary[kRTCICECandidateMidKey];
27 | NSString *sdp = dictionary[kRTCICECandidateSdpKey];
28 | NSNumber *num = dictionary[kRTCICECandidateMLineIndexKey];
29 | NSInteger mLineIndex = [num integerValue];
30 | return [[RTCIceCandidate alloc] initWithSdp:sdp
31 | sdpMLineIndex:mLineIndex
32 | sdpMid:mid];
33 | }
34 |
35 | + (NSData *)JSONDataForIceCandidates:(NSArray *)candidates
36 | withType:(NSString *)typeValue {
37 | NSMutableArray *jsonCandidates =
38 | [NSMutableArray arrayWithCapacity:candidates.count];
39 | for (RTCIceCandidate *candidate in candidates) {
40 | NSDictionary *jsonCandidate = [candidate JSONDictionary];
41 | [jsonCandidates addObject:jsonCandidate];
42 | }
43 | NSDictionary *json = @{
44 | kRTCICECandidateTypeKey : typeValue,
45 | kRTCICECandidatesTypeKey : jsonCandidates
46 | };
47 | NSError *error = nil;
48 | NSData *data =
49 | [NSJSONSerialization dataWithJSONObject:json
50 | options:NSJSONWritingPrettyPrinted
51 | error:&error];
52 | if (error) {
53 | RTCLogError(@"Error serializing JSON: %@", error);
54 | return nil;
55 | }
56 | return data;
57 | }
58 |
59 | + (NSArray *)candidatesFromJSONDictionary:
60 | (NSDictionary *)dictionary {
61 | NSArray *jsonCandidates = dictionary[kRTCICECandidatesTypeKey];
62 | NSMutableArray *candidates =
63 | [NSMutableArray arrayWithCapacity:jsonCandidates.count];
64 | for (NSDictionary *jsonCandidate in jsonCandidates) {
65 | RTCIceCandidate *candidate =
66 | [RTCIceCandidate candidateFromJSONDictionary:jsonCandidate];
67 | [candidates addObject:candidate];
68 | }
69 | return candidates;
70 | }
71 |
72 | - (NSData *)JSONData {
73 | NSDictionary *json = @{
74 | kRTCICECandidateTypeKey : kRTCICECandidateTypeValue,
75 | kRTCICECandidateMLineIndexKey : @(self.sdpMLineIndex),
76 | kRTCICECandidateMidKey : self.sdpMid,
77 | kRTCICECandidateSdpKey : self.sdp
78 | };
79 | NSError *error = nil;
80 | NSData *data =
81 | [NSJSONSerialization dataWithJSONObject:json
82 | options:NSJSONWritingPrettyPrinted
83 | error:&error];
84 | if (error) {
85 | RTCLogError(@"Error serializing JSON: %@", error);
86 | return nil;
87 | }
88 | return data;
89 | }
90 |
91 | - (NSDictionary *)JSONDictionary{
92 | NSDictionary *json = @{
93 | kRTCICECandidateMLineIndexKey : @(self.sdpMLineIndex),
94 | kRTCICECandidateMidKey : self.sdpMid,
95 | kRTCICECandidateSdpKey : self.sdp
96 | };
97 | return json;
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCIceServer+JSON.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "WebRTC/RTCIceServer.h"
12 |
13 | @interface RTCIceServer (JSON)
14 |
15 | + (RTCIceServer *)serverFromJSONDictionary:(NSDictionary *)dictionary;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCIceServer+JSON.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "RTCIceServer+JSON.h"
12 |
13 | @implementation RTCIceServer (JSON)
14 |
15 | + (RTCIceServer *)serverFromJSONDictionary:(NSDictionary *)dictionary {
16 | NSArray *turnUrls = dictionary[@"urls"];
17 | NSString *username = dictionary[@"username"] ?: @"";
18 | NSString *credential = dictionary[@"credential"] ?: @"";
19 | return [[RTCIceServer alloc] initWithURLStrings:turnUrls
20 | username:username
21 | credential:credential];
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCMediaConstraints+JSON.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "WebRTC/RTCMediaConstraints.h"
12 |
13 | @interface RTCMediaConstraints (JSON)
14 |
15 | + (RTCMediaConstraints *)constraintsFromJSONDictionary:
16 | (NSDictionary *)dictionary;
17 |
18 | @end
19 |
20 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCMediaConstraints+JSON.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "RTCMediaConstraints+JSON.h"
12 |
13 | static NSString const *kRTCMediaConstraintsMandatoryKey = @"mandatory";
14 |
15 | @implementation RTCMediaConstraints (JSON)
16 |
17 | + (RTCMediaConstraints *)constraintsFromJSONDictionary:
18 | (NSDictionary *)dictionary {
19 | NSDictionary *mandatory = dictionary[kRTCMediaConstraintsMandatoryKey];
20 | NSMutableDictionary *mandatoryContraints =
21 | [NSMutableDictionary dictionaryWithCapacity:[mandatory count]];
22 | [mandatory enumerateKeysAndObjectsUsingBlock:^(
23 | id key, id obj, BOOL *stop) {
24 | mandatoryContraints[key] = obj;
25 | }];
26 | // TODO(tkchin): figure out json formats for optional constraints.
27 | RTCMediaConstraints *constraints =
28 | [[RTCMediaConstraints alloc]
29 | initWithMandatoryConstraints:mandatoryContraints
30 | optionalConstraints:nil];
31 | return constraints;
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCSessionDescription+JSON.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "WebRTC/RTCSessionDescription.h"
12 |
13 | @interface RTCSessionDescription (JSON)
14 |
15 | + (RTCSessionDescription *)descriptionFromJSONDictionary:
16 | (NSDictionary *)dictionary;
17 | - (NSData *)JSONData;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/RTCSessionDescription+JSON.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "RTCSessionDescription+JSON.h"
12 |
13 | static NSString const *kRTCSessionDescriptionTypeKey = @"type";
14 | static NSString const *kRTCSessionDescriptionSdpKey = @"sdp";
15 |
16 | @implementation RTCSessionDescription (JSON)
17 |
18 | + (RTCSessionDescription *)descriptionFromJSONDictionary:
19 | (NSDictionary *)dictionary {
20 | NSString *typeString = dictionary[kRTCSessionDescriptionTypeKey];
21 | RTCSdpType type = [[self class] typeForString:typeString];
22 | NSString *sdp = dictionary[kRTCSessionDescriptionSdpKey];
23 | return [[RTCSessionDescription alloc] initWithType:type sdp:sdp];
24 | }
25 |
26 | - (NSData *)JSONData {
27 | NSString *type = [[self class] stringForType:self.type];
28 | NSDictionary *json = @{
29 | kRTCSessionDescriptionTypeKey : type,
30 | kRTCSessionDescriptionSdpKey : self.sdp
31 | };
32 | return [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/ios/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 12E55
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleDisplayName
10 | AppRTCMobile
11 | CFBundleExecutable
12 | ${EXECUTABLE_NAME}
13 | CFBundleIcons
14 |
15 | CFBundlePrimaryIcon
16 |
17 | CFBundleIconFiles
18 |
19 | Icon.png
20 | Icon-120.png
21 | Icon-180.png
22 |
23 |
24 |
25 | CFBundleIdentifier
26 | com.google.AppRTCMobile
27 | CFBundleInfoDictionaryVersion
28 | 6.0
29 | CFBundleName
30 | ${EXECUTABLE_NAME}
31 | CFBundlePackageType
32 | APPL
33 | CFBundleShortVersionString
34 | 1.0
35 | CFBundleSignature
36 | ????
37 | CFBundleSupportedPlatforms
38 |
39 | iPhoneOS
40 |
41 | CFBundleVersion
42 | 1.0
43 | UIStatusBarTintParameters
44 |
45 | UINavigationBar
46 |
47 | Style
48 | UIBarStyleDefault
49 | Translucent
50 |
51 |
52 |
53 | UISupportedInterfaceOrientations
54 |
55 | UIInterfaceOrientationPortrait
56 |
57 | UIAppFonts
58 |
59 | Roboto-Regular.ttf
60 |
61 | UIBackgroundModes
62 |
63 | audio
64 | voip
65 |
66 | NSCameraUsageDescription
67 | Camera access needed for video calling
68 | NSMicrophoneUsageDescription
69 | Microphone access needed for video calling
70 | UIFileSharingEnabled
71 |
72 | UILaunchImages
73 |
74 |
75 | UILaunchImageMinimumOSVersion
76 | 7.0
77 | UILaunchImageName
78 | iPhone5
79 | UILaunchImageOrientation
80 | Portrait
81 | UILaunchImageSize
82 | {320, 568}
83 |
84 |
85 | UILaunchImageMinimumOSVersion
86 | 8.0
87 | UILaunchImageName
88 | iPhone6
89 | UILaunchImageOrientation
90 | Portrait
91 | UILaunchImageSize
92 | {375, 667}
93 |
94 |
95 | UILaunchImageMinimumOSVersion
96 | 8.0
97 | UILaunchImageName
98 | iPhone6p
99 | UILaunchImageOrientation
100 | Portrait
101 | UILaunchImageSize
102 | {414, 736}
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/mac/APPRTCAppDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 | @interface APPRTCAppDelegate : NSObject
14 | @end
15 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/mac/APPRTCAppDelegate.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "APPRTCAppDelegate.h"
12 | #import "APPRTCViewController.h"
13 | #import "WebRTC/RTCSSLAdapter.h"
14 |
15 | @interface APPRTCAppDelegate ()
16 | @end
17 |
18 | @implementation APPRTCAppDelegate {
19 | APPRTCViewController* _viewController;
20 | NSWindow* _window;
21 | }
22 |
23 | #pragma mark - NSApplicationDelegate
24 |
25 | - (void)applicationDidFinishLaunching:(NSNotification*)notification {
26 | RTCInitializeSSL();
27 | NSScreen* screen = [NSScreen mainScreen];
28 | NSRect visibleRect = [screen visibleFrame];
29 | NSRect windowRect = NSMakeRect(NSMidX(visibleRect),
30 | NSMidY(visibleRect),
31 | 1320,
32 | 1140);
33 | NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask;
34 | _window = [[NSWindow alloc] initWithContentRect:windowRect
35 | styleMask:styleMask
36 | backing:NSBackingStoreBuffered
37 | defer:NO];
38 | _window.delegate = self;
39 | [_window makeKeyAndOrderFront:self];
40 | [_window makeMainWindow];
41 | _viewController = [[APPRTCViewController alloc] initWithNibName:nil
42 | bundle:nil];
43 | [_window setContentView:[_viewController view]];
44 | }
45 |
46 | #pragma mark - NSWindow
47 |
48 | - (void)windowWillClose:(NSNotification*)notification {
49 | [_viewController windowWillClose:notification];
50 | RTCCleanupSSL();
51 | [NSApp terminate:self];
52 | }
53 |
54 | @end
55 |
56 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/mac/APPRTCViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 | @interface APPRTCViewController : NSViewController
14 |
15 | - (void)windowWillClose:(NSNotification*)notification;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CFBundleDevelopmentRegion
7 | en
8 | CFBundleDisplayName
9 | ${PRODUCT_NAME}
10 | CFBundleExecutable
11 | ${EXECUTABLE_NAME}
12 | CFBundleIdentifier
13 | com.Google.${PRODUCT_NAME:rfc1034identifier}
14 | CFBundleInfoDictionaryVersion
15 | 6.0
16 | CFBundleName
17 | ${PRODUCT_NAME}
18 | CFBundlePackageType
19 | APPL
20 | CFBundleShortVersionString
21 | 1.0
22 | CFBundleVersion
23 | 1.0
24 | LSMinimumSystemVersion
25 | ${MACOSX_DEPLOYMENT_TARGET}
26 | NSPrincipalClass
27 | NSApplication
28 |
29 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/mac/main.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 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 "APPRTCAppDelegate.h"
14 |
15 | int main(int argc, char* argv[]) {
16 | @autoreleasepool {
17 | [NSApplication sharedApplication];
18 | APPRTCAppDelegate* delegate = [[APPRTCAppDelegate alloc] init];
19 | [NSApp setDelegate:delegate];
20 | [NSApp run];
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/tests/ARDSDPUtils_xctest.mm:
--------------------------------------------------------------------------------
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 "WebRTC/RTCSessionDescription.h"
15 |
16 | #import "ARDSDPUtils.h"
17 |
18 | @interface ARDSDPUtilsTest : XCTestCase
19 | @end
20 |
21 | @implementation ARDSDPUtilsTest
22 |
23 | - (void)testPreferVideoCodecH264 {
24 | NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n"
25 | "a=rtpmap:120 H264/90000\r\n"
26 | "a=rtpmap:97 H264/90000\r\n");
27 | NSString *expectedSdp = @("m=video 9 RTP/SAVPF 120 97 100 116 117 96\r\n"
28 | "a=rtpmap:120 H264/90000\r\n"
29 | "a=rtpmap:97 H264/90000\r\n");
30 | [self preferVideoCodec:@"H264" sdp:sdp expected:expectedSdp];
31 | }
32 |
33 | - (void)testPreferVideoCodecVP8 {
34 | NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n"
35 | "a=rtpmap:116 VP8/90000\r\n");
36 | NSString *expectedSdp = @("m=video 9 RTP/SAVPF 116 100 117 96 120 97\r\n"
37 | "a=rtpmap:116 VP8/90000\r\n");
38 | [self preferVideoCodec:@"VP8" sdp:sdp expected:expectedSdp];
39 | }
40 |
41 | - (void)testNoMLine {
42 | NSString *sdp = @("a=rtpmap:116 VP8/90000\r\n");
43 | [self preferVideoCodec:@"VP8" sdp:sdp expected:sdp];
44 | }
45 |
46 | - (void)testMissingCodec {
47 | NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n"
48 | "a=rtpmap:116 VP8/90000\r\n");
49 | [self preferVideoCodec:@"foo" sdp:sdp expected:sdp];
50 | }
51 |
52 | #pragma mark - Helpers
53 |
54 | - (void)preferVideoCodec:(NSString *)codec
55 | sdp:(NSString *)sdp
56 | expected:(NSString *)expectedSdp{
57 | RTCSessionDescription* desc =
58 | [[RTCSessionDescription alloc] initWithType:RTCSdpTypeOffer sdp:sdp];
59 | RTCSessionDescription *outputDesc =
60 | [ARDSDPUtils descriptionForDescription:desc
61 | preferredVideoCodec:codec];
62 | XCTAssertTrue([outputDesc.description rangeOfString:expectedSdp].location != NSNotFound);
63 | }
64 | @end
65 |
--------------------------------------------------------------------------------
/AppRTCMobile/webrtc/tests/ARDSettingsModel_xctest.mm:
--------------------------------------------------------------------------------
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 |
15 | #import "WebRTC/RTCMediaConstraints.h"
16 |
17 | #import "ARDSettingsModel+Private.h"
18 | #import "ARDSettingsStore.h"
19 |
20 |
21 | @interface ARDSettingsModelTests : XCTestCase {
22 | ARDSettingsModel *_model;
23 | }
24 | @end
25 |
26 | @implementation ARDSettingsModelTests
27 |
28 | - (id)setupMockStore {
29 | id storeMock = [OCMockObject mockForClass:[ARDSettingsStore class]];
30 |
31 | id partialMock = [OCMockObject partialMockForObject:_model];
32 | [[[partialMock stub] andReturn:storeMock] settingsStore];
33 | [[[partialMock stub] andReturn:@[ @"640x480", @"960x540", @"1280x720" ]]
34 | availableVideoResolutions];
35 |
36 | return storeMock;
37 | }
38 |
39 | - (void)setUp {
40 | _model = [[ARDSettingsModel alloc] init];
41 | }
42 |
43 | - (void)testRetrievingSetting {
44 | id storeMock = [self setupMockStore];
45 | [[[storeMock expect] andReturn:@"640x480"] videoResolution];
46 | NSString *string = [_model currentVideoResolutionSettingFromStore];
47 |
48 | XCTAssertEqualObjects(string, @"640x480");
49 | }
50 |
51 | - (void)testStoringInvalidConstraintReturnsNo {
52 | id storeMock = [self setupMockStore];
53 | [([[storeMock stub] andReturn:@"960x480"])videoResolution];
54 | XCTAssertFalse([_model storeVideoResolutionSetting:@"960x480"]);
55 | }
56 |
57 | - (void)testWidthConstraintFromStore {
58 | id storeMock = [self setupMockStore];
59 | [([[storeMock stub] andReturn:@"1270x480"])videoResolution];
60 | int width = [_model currentVideoResolutionWidthFromStore];
61 |
62 | XCTAssertEqual(width, 1270);
63 | }
64 |
65 | - (void)testHeightConstraintFromStore {
66 | id storeMock = [self setupMockStore];
67 | [([[storeMock stub] andReturn:@"960x540"])videoResolution];
68 | int height = [_model currentVideoResolutionHeightFromStore];
69 |
70 | XCTAssertEqual(height, 540);
71 | }
72 |
73 | - (void)testConstraintComponentIsNilWhenInvalidConstraintString {
74 | id storeMock = [self setupMockStore];
75 | [([[storeMock stub] andReturn:@"invalid"])videoResolution];
76 | int width = [_model currentVideoResolutionWidthFromStore];
77 |
78 | XCTAssertEqual(width, 0);
79 | }
80 |
81 | - (void)testStoringAudioSetting {
82 | id storeMock = [self setupMockStore];
83 | [[storeMock expect] setAudioOnly:YES];
84 |
85 | [_model storeAudioOnlySetting:YES];
86 | [storeMock verify];
87 | }
88 |
89 | - (void)testReturningDefaultCallOption {
90 | id storeMock = [self setupMockStore];
91 | [[[storeMock stub] andReturnValue:@YES] useManualAudioConfig];
92 |
93 | XCTAssertTrue([_model currentUseManualAudioConfigSettingFromStore]);
94 | }
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | WebRTC.framework/LICENSE.md
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Deprecated!
2 |
3 | Google now provides the official builds:
4 | * https://cocoapods.org/pods/GoogleWebRTC
5 | * https://webrtc.org/native-code/ios/
6 |
7 | # WebRTC iOS framework
8 |
9 |  
10 | 
11 |
12 | [__!__] Please report all WebRTC related (not specific to this binary build) bugs and questions to [discussion group](https://groups.google.com/forum/#!forum/discuss-webrtc) or [official bug tracker](https://bugs.chromium.org/p/webrtc/issues/list). You more likely to find professional help there.
13 |
14 | # Contents
15 |
16 | - [Installation](#installation)
17 | - [Usage](#usage)
18 | - [Information](#information)
19 | - [Links](#links)
20 |
21 | # Installation
22 |
23 | [__!__] Bitcode is supported by the upstream, but Google source code builder (GN) produces ~700Mb binary with enabled bitcode, so it's hardly possible to distribute as a framework via CocoaPods/Carthage and that's why bitcode is __disabled__ in my build. Follow corresponding issue there: https://bugs.chromium.org/p/webrtc/issues/detail?id=5085
24 |
25 | Make sure to disable bitcode for your project: Go to your project's settings and find the *Build settings* tab, check *All* and search for *bitcode*, then set it to __No__.
26 |
27 | If you encounter linker errors, try to add the framework to [embedded binaries section](https://github.com/Anakros/WebRTC/issues/18#issuecomment-271535794).
28 |
29 | __CocoaPods__ (add to Podfile):
30 |
31 | ```ruby
32 | pod "WebRTC"
33 | ```
34 |
35 | __Carthage__ (add to Cartfile):
36 |
37 | ```
38 | github "Anakros/WebRTC"
39 | ```
40 |
41 | __Manual__: just download framework from [the latest release](https://github.com/Anakros/WebRTC/releases/latest) and copy it to your project
42 |
43 | >You can only use the binary release, because the whole WebRTC repository takes ~12Gb of disk space
44 |
45 | # Usage
46 |
47 | ## Swift
48 | ```swift
49 | import WebRTC
50 |
51 | let device = UIDevice.string(for: UIDevice.deviceType())
52 |
53 | print(device)
54 | print(RTCInitializeSSL())
55 | ```
56 |
57 | ## Objective-C
58 | ```objc
59 | @import WebRTC;
60 |
61 | NSString *device = [UIDevice stringForDeviceType:[UIDevice deviceType]];
62 |
63 | NSLog(@"%@", device);
64 | NSLog(@"%d", RTCInitializeSSL());
65 | ```
66 |
67 | >Check out [Official Example App](https://webrtc.googlesource.com/src/+/master/examples/objc/AppRTCMobile/)!
68 |
69 | # Information
70 |
71 | Built from `https://chromium.googlesource.com/external/webrtc/` using `tools_webrtc/ios/build_ios_libs.py` script with following modifications (to enable x86 architecture):
72 |
73 | ```diff
74 | diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py
75 | index 734f3e216..e6f250c97 100755
76 | --- a/tools_webrtc/ios/build_ios_libs.py
77 | +++ b/tools_webrtc/ios/build_ios_libs.py
78 | @@ -165,8 +165,6 @@ def main():
79 |
80 | # Ignoring x86 except for static libraries for now because of a GN build issue
81 | # where the generated dynamic framework has the wrong architectures.
82 | - if 'x86' in architectures and args.build_type != 'static_only':
83 | - architectures.remove('x86')
84 |
85 | # Build all architectures.
86 | for arch in architectures:
87 | ```
88 |
89 | # Links
90 |
91 | [Official Example App](https://webrtc.googlesource.com/src/+/master/examples/objc/AppRTCMobile/)
92 |
93 | [Official WebRTC Source Code Repository](https://webrtc.googlesource.com/src/)
94 |
95 | [WebRTC Homepage](https://webrtc.org/)
96 |
97 | [WebRTC Discussion Group](https://groups.google.com/forum/#!forum/discuss-webrtc)
98 |
99 | [WebRTC Bug Tracker](https://bugs.chromium.org/p/webrtc/issues/list)
100 |
101 | [CocoaDocs](http://cocoadocs.org/docsets/WebRTC/)
102 |
103 | [CocoaPods Page](https://cocoapods.org/pods/WebRTC)
104 |
--------------------------------------------------------------------------------
/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.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.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.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.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.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.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.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.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.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.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.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.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.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.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 | /** List of protocols to be used in the TLS ALPN extension. */
47 | @property(nonatomic, readonly) NSArray *tlsAlpnProtocols;
48 |
49 | /**
50 | List elliptic curves to be used in the TLS elliptic curves extension.
51 | Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
52 | */
53 | @property(nonatomic, readonly) NSArray *tlsEllipticCurves;
54 |
55 | - (nonnull instancetype)init NS_UNAVAILABLE;
56 |
57 | /** Convenience initializer for a server with no authentication (e.g. STUN). */
58 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings;
59 |
60 | /**
61 | * Initialize an RTCIceServer with its associated URLs, optional username,
62 | * optional credential, and credentialType.
63 | */
64 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings
65 | username:(nullable NSString *)username
66 | credential:(nullable NSString *)credential;
67 |
68 | /**
69 | * Initialize an RTCIceServer with its associated URLs, optional username,
70 | * optional credential, and TLS cert policy.
71 | */
72 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings
73 | username:(nullable NSString *)username
74 | credential:(nullable NSString *)credential
75 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy;
76 |
77 | /**
78 | * Initialize an RTCIceServer with its associated URLs, optional username,
79 | * optional credential, TLS cert policy and hostname.
80 | */
81 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings
82 | username:(nullable NSString *)username
83 | credential:(nullable NSString *)credential
84 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
85 | hostname:(nullable NSString *)hostname;
86 |
87 | /**
88 | * Initialize an RTCIceServer with its associated URLs, optional username,
89 | * optional credential, TLS cert policy, hostname and ALPN protocols.
90 | */
91 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings
92 | username:(nullable NSString *)username
93 | credential:(nullable NSString *)credential
94 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
95 | hostname:(nullable NSString *)hostname
96 | tlsAlpnProtocols:(NSArray *)tlsAlpnProtocols;
97 |
98 | /**
99 | * Initialize an RTCIceServer with its associated URLs, optional username,
100 | * optional credential, TLS cert policy, hostname, ALPN protocols and
101 | * elliptic curves.
102 | */
103 | - (instancetype)initWithURLStrings:(NSArray *)urlStrings
104 | username:(nullable NSString *)username
105 | credential:(nullable NSString *)credential
106 | tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
107 | hostname:(nullable NSString *)hostname
108 | tlsAlpnProtocols:(nullable NSArray *)tlsAlpnProtocols
109 | tlsEllipticCurves:(nullable NSArray *)tlsEllipticCurves
110 | NS_DESIGNATED_INITIALIZER;
111 |
112 | @end
113 |
114 | NS_ASSUME_NONNULL_END
115 |
--------------------------------------------------------------------------------
/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.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.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.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.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 SDK_OBJC_FRAMEWORK_HEADERS_WEBRTC_RTCMACROS_H_
12 | #define 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 // SDK_OBJC_FRAMEWORK_HEADERS_WEBRTC_RTCMACROS_H_
29 |
--------------------------------------------------------------------------------
/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.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.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.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.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.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.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 |
40 | /** Initialize an RTCAudioSource with constraints. */
41 | - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints;
42 |
43 | /** Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio source with no
44 | * constraints.
45 | */
46 | - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId;
47 |
48 | /** Initialize an RTCAudioTrack with a source and an id. */
49 | - (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source
50 | trackId:(NSString *)trackId;
51 |
52 | /** Initialize an RTCAVFoundationVideoSource with constraints. */
53 | - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
54 | (nullable RTCMediaConstraints *)constraints;
55 |
56 | /** Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer
57 | * implementation, e.g. RTCCameraVideoCapturer, in order to produce frames.
58 | */
59 | - (RTCVideoSource *)videoSource;
60 |
61 | /** Initialize an RTCVideoTrack with a source and an id. */
62 | - (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
63 | trackId:(NSString *)trackId;
64 |
65 | /** Initialize an RTCMediaStream with an id. */
66 | - (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId;
67 |
68 | /** Initialize an RTCPeerConnection with a configuration, constraints, and
69 | * delegate.
70 | */
71 | - (RTCPeerConnection *)peerConnectionWithConfiguration:
72 | (RTCConfiguration *)configuration
73 | constraints:
74 | (RTCMediaConstraints *)constraints
75 | delegate:
76 | (nullable id)delegate;
77 |
78 | /** Start an AecDump recording. This API call will likely change in the future. */
79 | - (BOOL)startAecDumpWithFilePath:(NSString *)filePath
80 | maxSizeInBytes:(int64_t)maxSizeInBytes;
81 |
82 | /* Stop an active AecDump recording */
83 | - (void)stopAecDump;
84 |
85 | @end
86 |
87 | NS_ASSUME_NONNULL_END
88 |
--------------------------------------------------------------------------------
/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.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.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.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.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.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.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 |
--------------------------------------------------------------------------------
/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.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.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 | #import
15 |
16 | NS_ASSUME_NONNULL_BEGIN
17 |
18 | /** Represents an encoded frame's type. */
19 | typedef NS_ENUM(NSUInteger, RTCFrameType) {
20 | RTCFrameTypeEmptyFrame = 0,
21 | RTCFrameTypeAudioFrameSpeech = 1,
22 | RTCFrameTypeAudioFrameCN = 2,
23 | RTCFrameTypeVideoFrameKey = 3,
24 | RTCFrameTypeVideoFrameDelta = 4,
25 | };
26 |
27 | typedef NS_ENUM(NSUInteger, RTCVideoContentType) {
28 | RTCVideoContentTypeUnspecified,
29 | RTCVideoContentTypeScreenshare,
30 | };
31 |
32 | /** Represents an encoded frame. Corresponds to webrtc::EncodedImage. */
33 | RTC_EXPORT
34 | @interface RTCEncodedImage : NSObject
35 |
36 | @property(nonatomic, strong) NSData *buffer;
37 | @property(nonatomic, assign) int32_t encodedWidth;
38 | @property(nonatomic, assign) int32_t encodedHeight;
39 | @property(nonatomic, assign) uint32_t timeStamp;
40 | @property(nonatomic, assign) int64_t captureTimeMs;
41 | @property(nonatomic, assign) int64_t ntpTimeMs;
42 | @property(nonatomic, assign) uint8_t flags;
43 | @property(nonatomic, assign) int64_t encodeStartMs;
44 | @property(nonatomic, assign) int64_t encodeFinishMs;
45 | @property(nonatomic, assign) RTCFrameType frameType;
46 | @property(nonatomic, assign) RTCVideoRotation rotation;
47 | @property(nonatomic, assign) BOOL completeFrame;
48 | @property(nonatomic, strong) NSNumber *qp;
49 | @property(nonatomic, assign) RTCVideoContentType contentType;
50 |
51 | @end
52 |
53 | /** Information for header. Corresponds to webrtc::RTPFragmentationHeader. */
54 | RTC_EXPORT
55 | @interface RTCRtpFragmentationHeader : NSObject
56 |
57 | @property(nonatomic, strong) NSArray *fragmentationOffset;
58 | @property(nonatomic, strong) NSArray *fragmentationLength;
59 | @property(nonatomic, strong) NSArray *fragmentationTimeDiff;
60 | @property(nonatomic, strong) NSArray *fragmentationPlType;
61 |
62 | @end
63 |
64 | /** Implement this protocol to pass codec specific info from the encoder.
65 | * Corresponds to webrtc::CodecSpecificInfo.
66 | */
67 | RTC_EXPORT
68 | @protocol RTCCodecSpecificInfo
69 |
70 | @end
71 |
72 | /** Callback block for encoder. */
73 | typedef BOOL (^RTCVideoEncoderCallback)(RTCEncodedImage *frame,
74 | id info,
75 | RTCRtpFragmentationHeader *header);
76 |
77 | /** Callback block for decoder. */
78 | typedef void (^RTCVideoDecoderCallback)(RTCVideoFrame *frame);
79 |
80 | typedef NS_ENUM(NSUInteger, RTCVideoCodecMode) {
81 | RTCVideoCodecModeRealtimeVideo,
82 | RTCVideoCodecModeScreensharing,
83 | };
84 |
85 | /** Holds information to identify a codec. Corresponds to cricket::VideoCodec. */
86 | RTC_EXPORT
87 | @interface RTCVideoCodecInfo : NSObject
88 |
89 | - (instancetype)init NS_UNAVAILABLE;
90 |
91 | - (instancetype)initWithName:(NSString *)name;
92 |
93 | - (instancetype)initWithName:(NSString *)name
94 | parameters:(nullable NSDictionary *)parameters
95 | NS_DESIGNATED_INITIALIZER;
96 |
97 | - (BOOL)isEqualToCodecInfo:(RTCVideoCodecInfo *)info;
98 |
99 | @property(nonatomic, readonly) NSString *name;
100 | @property(nonatomic, readonly) NSDictionary *parameters;
101 |
102 | @end
103 |
104 | /** Settings for encoder. Corresponds to webrtc::VideoCodec. */
105 | RTC_EXPORT
106 | @interface RTCVideoEncoderSettings : NSObject
107 |
108 | @property(nonatomic, strong) NSString *name;
109 |
110 | @property(nonatomic, assign) unsigned short width;
111 | @property(nonatomic, assign) unsigned short height;
112 |
113 | @property(nonatomic, assign) unsigned int startBitrate; // kilobits/sec.
114 | @property(nonatomic, assign) unsigned int maxBitrate;
115 | @property(nonatomic, assign) unsigned int minBitrate;
116 | @property(nonatomic, assign) unsigned int targetBitrate;
117 |
118 | @property(nonatomic, assign) uint32_t maxFramerate;
119 |
120 | @property(nonatomic, assign) unsigned int qpMax;
121 | @property(nonatomic, assign) RTCVideoCodecMode mode;
122 |
123 | @end
124 |
125 | /** QP thresholds for encoder. Corresponds to webrtc::VideoEncoder::QpThresholds. */
126 | RTC_EXPORT
127 | @interface RTCVideoEncoderQpThresholds : NSObject
128 |
129 | - (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high;
130 |
131 | @property(nonatomic, readonly) NSInteger low;
132 | @property(nonatomic, readonly) NSInteger high;
133 |
134 | @end
135 |
136 | /** Protocol for encoder implementations. */
137 | RTC_EXPORT
138 | @protocol RTCVideoEncoder
139 |
140 | - (void)setCallback:(RTCVideoEncoderCallback)callback;
141 | - (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
142 | numberOfCores:(int)numberOfCores;
143 | - (NSInteger)releaseEncoder;
144 | - (NSInteger)encode:(RTCVideoFrame *)frame
145 | codecSpecificInfo:(id)info
146 | frameTypes:(NSArray *)frameTypes;
147 | - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate;
148 | - (NSString *)implementationName;
149 |
150 | /** Returns QP scaling settings for encoder. The quality scaler adjusts the resolution in order to
151 | * keep the QP from the encoded images within the given range. Returning nil from this function
152 | * disables quality scaling. */
153 | - (RTCVideoEncoderQpThresholds *)scalingSettings;
154 |
155 | @end
156 |
157 | /** Protocol for decoder implementations. */
158 | RTC_EXPORT
159 | @protocol RTCVideoDecoder
160 |
161 | - (void)setCallback:(RTCVideoDecoderCallback)callback;
162 | - (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings
163 | numberOfCores:(int)numberOfCores;
164 | - (NSInteger)releaseDecoder;
165 | - (NSInteger)decode:(RTCEncodedImage *)encodedImage
166 | missingFrames:(BOOL)missingFrames
167 | fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader
168 | codecSpecificInfo:(__nullable id)info
169 | renderTimeMs:(int64_t)renderTimeMs;
170 | - (NSString *)implementationName;
171 |
172 | @end
173 |
174 | NS_ASSUME_NONNULL_END
175 |
--------------------------------------------------------------------------------
/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 webrtc::VideoEncoderFactory. */
19 | RTC_EXPORT
20 | @protocol RTCVideoEncoderFactory
21 |
22 | - (id)createEncoder:(RTCVideoCodecInfo *)info;
23 | - (NSArray *)supportedCodecs; // TODO(andersc): "supportedFormats" instead?
24 |
25 | @end
26 |
27 | /** RTCVideoDecoderFactory is an Objective-C version of webrtc::VideoDecoderFactory. */
28 | RTC_EXPORT
29 | @protocol RTCVideoDecoderFactory
30 |
31 | - (id)createDecoder:(RTCVideoCodecInfo *)info;
32 | - (NSArray *)supportedCodecs; // TODO(andersc): "supportedFormats" instead?
33 |
34 | @end
35 |
36 | NS_ASSUME_NONNULL_END
37 |
--------------------------------------------------------------------------------
/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 | /** Class for H264 specific config. */
17 | typedef NS_ENUM(NSUInteger, RTCH264PacketizationMode) {
18 | RTCH264PacketizationModeNonInterleaved = 0, // Mode 1 - STAP-A, FU-A is allowed
19 | RTCH264PacketizationModeSingleNalUnit // Mode 0 - only single NALU allowed
20 | };
21 |
22 | RTC_EXPORT
23 | @interface RTCCodecSpecificInfoH264 : NSObject
24 |
25 | @property(nonatomic, assign) RTCH264PacketizationMode packetizationMode;
26 |
27 | @end
28 |
29 | /** Encoder. */
30 | RTC_EXPORT
31 | @interface RTCVideoEncoderH264 : NSObject
32 |
33 | - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo;
34 |
35 | @end
36 |
37 | /** Decoder. */
38 | RTC_EXPORT
39 | @interface RTCVideoDecoderH264 : NSObject