Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: webrtc/examples/objc/AppRTCDemo/ARDAppClient.m

Issue 1690313002: Update iOS AppRTCDemo to use the updated Objective-C API. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
diff --git a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
index 47252bef1dbc4a9483f6687ac894976910160249..47e717667853f6ad2a056f936bc2ae784e0380f8 100644
--- a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -12,16 +12,15 @@
#if defined(WEBRTC_IOS)
#import "webrtc/base/objc/RTCTracing.h"
-#import "RTCAVFoundationVideoSource.h"
+#import "webrtc/api/objc/RTCAVFoundationVideoSource.h"
#endif
#import "RTCFileLogger.h"
hjon_webrtc 2016/02/12 18:26:58 I seem to recall that we held off on this because
-#import "RTCICEServer.h"
-#import "RTCLogging.h"
-#import "RTCMediaConstraints.h"
-#import "RTCMediaStream.h"
-#import "RTCPair.h"
-#import "RTCPeerConnectionInterface.h"
-#import "RTCVideoCapturer.h"
+#import "webrtc/api/objc/RTCConfiguration.h"
+#import "webrtc/api/objc/RTCIceServer.h"
+#import "webrtc/api/objc/RTCMediaConstraints.h"
+#import "webrtc/api/objc/RTCMediaStream.h"
+#import "webrtc/api/objc/RTCVideoCapturer.h"
+#import "webrtc/base/objc/RTCLogging.h"
#import "ARDAppEngineClient.h"
#import "ARDCEODTURNClient.h"
@@ -31,7 +30,7 @@
#import "ARDSignalingMessage.h"
#import "ARDUtilities.h"
#import "ARDWebSocketChannel.h"
-#import "RTCICECandidate+JSON.h"
+#import "RTCIceCandidate+JSON.h"
#import "RTCSessionDescription+JSON.h"
static NSString * const kARDDefaultSTUNServerUrl =
@@ -188,9 +187,14 @@ static BOOL const kARDAppClientEnableTracing = NO;
repeats:YES
timerHandler:^{
ARDAppClient *strongSelf = weakSelf;
- [strongSelf.peerConnection getStatsWithDelegate:strongSelf
- mediaStreamTrack:nil
- statsOutputLevel:RTCStatsOutputLevelDebug];
+ [strongSelf.peerConnection statsForTrack:nil
+ statsOutputLevel:RTCStatsOutputLevelDebug
+ completionHandler:^(NSArray<RTCStatsReport *> *stats) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ ARDAppClient *strongSelf = weakSelf;
+ [strongSelf.delegate appClient:strongSelf didGetStats:stats];
+ });
+ }];
}];
} else {
[_statsTimer invalidate];
@@ -352,12 +356,12 @@ static BOOL const kARDAppClientEnableTracing = NO;
// dispatched back to main queue as needed.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- signalingStateChanged:(RTCSignalingState)stateChanged {
+ didChangeSignalingState:(RTCSignalingState)stateChanged {
RTCLog(@"Signaling state changed: %d", stateChanged);
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- addedStream:(RTCMediaStream *)stream {
+ didAddStream:(RTCMediaStream *)stream {
dispatch_async(dispatch_get_main_queue(), ^{
RTCLog(@"Received %lu video tracks and %lu audio tracks",
(unsigned long)stream.videoTracks.count,
@@ -370,17 +374,16 @@ static BOOL const kARDAppClientEnableTracing = NO;
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- removedStream:(RTCMediaStream *)stream {
+ didRemoveStream:(RTCMediaStream *)stream {
RTCLog(@"Stream was removed.");
}
-- (void)peerConnectionOnRenegotiationNeeded:
- (RTCPeerConnection *)peerConnection {
+- (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection {
RTCLog(@"WARNING: Renegotiation needed but unimplemented.");
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- iceConnectionChanged:(RTCICEConnectionState)newState {
+ didChangeIceConnectionState:(RTCIceConnectionState)newState {
RTCLog(@"ICE state changed: %d", newState);
dispatch_async(dispatch_get_main_queue(), ^{
[_delegate appClient:self didChangeConnectionState:newState];
@@ -388,12 +391,12 @@ static BOOL const kARDAppClientEnableTracing = NO;
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- iceGatheringChanged:(RTCICEGatheringState)newState {
+ didChangeIceGatheringState:(RTCIceGatheringState)newState {
RTCLog(@"ICE gathering state changed: %d", newState);
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
- gotICECandidate:(RTCICECandidate *)candidate {
+ didGenerateIceCandidate:(RTCIceCandidate *)candidate {
dispatch_async(dispatch_get_main_queue(), ^{
ARDICECandidateMessage *message =
[[ARDICECandidateMessage alloc] initWithCandidate:candidate];
@@ -405,15 +408,6 @@ static BOOL const kARDAppClientEnableTracing = NO;
didOpenDataChannel:(RTCDataChannel *)dataChannel {
}
-#pragma mark - RTCStatsDelegate
-
-- (void)peerConnection:(RTCPeerConnection *)peerConnection
- didGetStats:(NSArray *)stats {
- dispatch_async(dispatch_get_main_queue(), ^{
- [_delegate appClient:self didGetStats:stats];
- });
-}
-
#pragma mark - RTCSessionDescriptionDelegate
// Callbacks for this delegate occur on non-main thread and need to be
// dispatched back to main queue as needed.
@@ -496,9 +490,10 @@ static BOOL const kARDAppClientEnableTracing = NO;
RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints];
RTCConfiguration *config = [[RTCConfiguration alloc] init];
config.iceServers = _iceServers;
- _peerConnection = [_factory peerConnectionWithConfiguration:config
- constraints:constraints
- delegate:self];
+ _peerConnection = [[RTCPeerConnection alloc] initWithFactory:_factory
+ configuration:config
+ constraints:constraints
+ delegate:self];
// Create AV media stream and add it to the peer connection.
RTCMediaStream *localStream = [self createLocalMediaStream];
[_peerConnection addStream:localStream];
@@ -506,6 +501,11 @@ static BOOL const kARDAppClientEnableTracing = NO;
// Send offer.
[_peerConnection createOfferWithDelegate:self
constraints:[self defaultOfferConstraints]];
hjon_webrtc 2016/02/12 18:26:58 Did you have any thoughts on how you wanted to han
+ [_peerConnection offerForConstraints:[self defaultOfferConstraints]
+ completionHandler:^(RTCSessionDescription *sdp,
+ NSError *error) {
+
+ }];
} else {
// Check if we've received an offer.
[self drainMessageQueueIfReady];
@@ -548,7 +548,7 @@ static BOOL const kARDAppClientEnableTracing = NO;
case kARDSignalingMessageTypeCandidate: {
ARDICECandidateMessage *candidateMessage =
(ARDICECandidateMessage *)message;
- [_peerConnection addICECandidate:candidateMessage.candidate];
+ [_peerConnection addIceCandidate:candidateMessage.candidate];
break;
}
case kARDSignalingMessageTypeBye:
@@ -595,7 +595,10 @@ static BOOL const kARDAppClientEnableTracing = NO;
[localStream addVideoTrack:localVideoTrack];
[_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack];
}
- [localStream addAudioTrack:[_factory audioTrackWithID:@"ARDAMSa0"]];
+ RTCAudioTrack *localAudioTrack =
+ [[RTCAudioTrack alloc] initWithFactory:_factory
+ trackId:@"ARDAMSa0"];
+ [localStream addAudioTrack:localAudioTrack];
return localStream;
}
@@ -661,10 +664,10 @@ static BOOL const kARDAppClientEnableTracing = NO;
}
- (RTCMediaConstraints *)defaultOfferConstraints {
- NSArray *mandatoryConstraints = @[
- [[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"],
- [[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]
- ];
+ NSDictionary *mandatoryConstraints = @{
+ @"OfferToReceiveAudio" : @"true",
+ @"OfferToReceiveVideo" : @"true"
+ };
RTCMediaConstraints* constraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatoryConstraints
@@ -677,9 +680,7 @@ static BOOL const kARDAppClientEnableTracing = NO;
return _defaultPeerConnectionConstraints;
}
NSString *value = _isLoopback ? @"false" : @"true";
- NSArray *optionalConstraints = @[
- [[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:value]
- ];
+ NSDictionary *optionalConstraints = @{ @"DtlsSrtpKeyAgreement" : value };
RTCMediaConstraints* constraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:nil
@@ -688,10 +689,9 @@ static BOOL const kARDAppClientEnableTracing = NO;
}
- (RTCICEServer *)defaultSTUNServer {
- NSURL *defaultSTUNServerURL = [NSURL URLWithString:kARDDefaultSTUNServerUrl];
- return [[RTCICEServer alloc] initWithURI:defaultSTUNServerURL
- username:@""
- password:@""];
+ return [[RTCIceServer alloc] initWithURLStrings:@[kARDDefaultSTUNServerUrl]
+ username:@""
+ credential:@""];
}
#pragma mark - Errors

Powered by Google App Engine
This is Rietveld 408576698