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

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/ARDAppClient.m

Issue 2735303004: Add video codec setting to AppRTCMobile on iOS. (Closed)
Patch Set: Replace if statements with switches. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 @synthesize isInitiator = _isInitiator; 119 @synthesize isInitiator = _isInitiator;
120 @synthesize iceServers = _iceServers; 120 @synthesize iceServers = _iceServers;
121 @synthesize webSocketURL = _websocketURL; 121 @synthesize webSocketURL = _websocketURL;
122 @synthesize webSocketRestURL = _websocketRestURL; 122 @synthesize webSocketRestURL = _websocketRestURL;
123 @synthesize defaultPeerConnectionConstraints = 123 @synthesize defaultPeerConnectionConstraints =
124 _defaultPeerConnectionConstraints; 124 _defaultPeerConnectionConstraints;
125 @synthesize isLoopback = _isLoopback; 125 @synthesize isLoopback = _isLoopback;
126 @synthesize isAudioOnly = _isAudioOnly; 126 @synthesize isAudioOnly = _isAudioOnly;
127 @synthesize shouldMakeAecDump = _shouldMakeAecDump; 127 @synthesize shouldMakeAecDump = _shouldMakeAecDump;
128 @synthesize shouldUseLevelControl = _shouldUseLevelControl; 128 @synthesize shouldUseLevelControl = _shouldUseLevelControl;
129 @synthesize videoCodec = _videoCodec;
129 130
130 - (instancetype)init { 131 - (instancetype)init {
131 return [self initWithDelegate:nil]; 132 return [self initWithDelegate:nil];
132 } 133 }
133 134
134 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate { 135 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate {
135 if (self = [super init]) { 136 if (self = [super init]) {
136 _roomServerClient = [[ARDAppEngineClient alloc] init]; 137 _roomServerClient = [[ARDAppEngineClient alloc] init];
137 _delegate = delegate; 138 _delegate = delegate;
138 NSURL *turnRequestURL = [NSURL URLWithString:kARDIceServerRequestUrl]; 139 NSURL *turnRequestURL = [NSURL URLWithString:kARDIceServerRequestUrl];
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 NSDictionary *userInfo = @{ 446 NSDictionary *userInfo = @{
446 NSLocalizedDescriptionKey: @"Failed to create session description.", 447 NSLocalizedDescriptionKey: @"Failed to create session description.",
447 }; 448 };
448 NSError *sdpError = 449 NSError *sdpError =
449 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain 450 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
450 code:kARDAppClientErrorCreateSDP 451 code:kARDAppClientErrorCreateSDP
451 userInfo:userInfo]; 452 userInfo:userInfo];
452 [_delegate appClient:self didError:sdpError]; 453 [_delegate appClient:self didError:sdpError];
453 return; 454 return;
454 } 455 }
455 // Prefer H264 if available. 456 // Prefer codec from settings if available.
456 RTCSessionDescription *sdpPreferringH264 = 457 RTCSessionDescription *sdpPreferringCodec =
457 [ARDSDPUtils descriptionForDescription:sdp 458 [ARDSDPUtils descriptionForDescription:sdp
458 preferredVideoCodec:@"H264"]; 459 preferredVideoCodec:_videoCodec];
459 __weak ARDAppClient *weakSelf = self; 460 __weak ARDAppClient *weakSelf = self;
460 [_peerConnection setLocalDescription:sdpPreferringH264 461 [_peerConnection setLocalDescription:sdpPreferringCodec
461 completionHandler:^(NSError *error) { 462 completionHandler:^(NSError *error) {
462 ARDAppClient *strongSelf = weakSelf; 463 ARDAppClient *strongSelf = weakSelf;
463 [strongSelf peerConnection:strongSelf.peerConnection 464 [strongSelf peerConnection:strongSelf.peerConnection
464 didSetSessionDescriptionWithError:error]; 465 didSetSessionDescriptionWithError:error];
465 }]; 466 }];
466 ARDSessionDescriptionMessage *message = 467 ARDSessionDescriptionMessage *message =
467 [[ARDSessionDescriptionMessage alloc] 468 [[ARDSessionDescriptionMessage alloc]
468 initWithDescription:sdpPreferringH264]; 469 initWithDescription:sdpPreferringCodec];
469 [self sendSignalingMessage:message]; 470 [self sendSignalingMessage:message];
470 [self setMaxBitrateForPeerConnectionVideoSender]; 471 [self setMaxBitrateForPeerConnectionVideoSender];
471 }); 472 });
472 } 473 }
473 474
474 - (void)peerConnection:(RTCPeerConnection *)peerConnection 475 - (void)peerConnection:(RTCPeerConnection *)peerConnection
475 didSetSessionDescriptionWithError:(NSError *)error { 476 didSetSessionDescriptionWithError:(NSError *)error {
476 dispatch_async(dispatch_get_main_queue(), ^{ 477 dispatch_async(dispatch_get_main_queue(), ^{
477 if (error) { 478 if (error) {
478 RTCLogError(@"Failed to set session description. Error: %@", error); 479 RTCLogError(@"Failed to set session description. Error: %@", error);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Processes the given signaling message based on its type. 600 // Processes the given signaling message based on its type.
600 - (void)processSignalingMessage:(ARDSignalingMessage *)message { 601 - (void)processSignalingMessage:(ARDSignalingMessage *)message {
601 NSParameterAssert(_peerConnection || 602 NSParameterAssert(_peerConnection ||
602 message.type == kARDSignalingMessageTypeBye); 603 message.type == kARDSignalingMessageTypeBye);
603 switch (message.type) { 604 switch (message.type) {
604 case kARDSignalingMessageTypeOffer: 605 case kARDSignalingMessageTypeOffer:
605 case kARDSignalingMessageTypeAnswer: { 606 case kARDSignalingMessageTypeAnswer: {
606 ARDSessionDescriptionMessage *sdpMessage = 607 ARDSessionDescriptionMessage *sdpMessage =
607 (ARDSessionDescriptionMessage *)message; 608 (ARDSessionDescriptionMessage *)message;
608 RTCSessionDescription *description = sdpMessage.sessionDescription; 609 RTCSessionDescription *description = sdpMessage.sessionDescription;
609 // Prefer H264 if available. 610 // Prefer codec from settings if available.
610 RTCSessionDescription *sdpPreferringH264 = 611 RTCSessionDescription *sdpPreferringCodec =
611 [ARDSDPUtils descriptionForDescription:description 612 [ARDSDPUtils descriptionForDescription:description
612 preferredVideoCodec:@"H264"]; 613 preferredVideoCodec:_videoCodec];
613 __weak ARDAppClient *weakSelf = self; 614 __weak ARDAppClient *weakSelf = self;
614 [_peerConnection setRemoteDescription:sdpPreferringH264 615 [_peerConnection setRemoteDescription:sdpPreferringCodec
615 completionHandler:^(NSError *error) { 616 completionHandler:^(NSError *error) {
616 ARDAppClient *strongSelf = weakSelf; 617 ARDAppClient *strongSelf = weakSelf;
617 [strongSelf peerConnection:strongSelf.peerConnection 618 [strongSelf peerConnection:strongSelf.peerConnection
618 didSetSessionDescriptionWithError:error]; 619 didSetSessionDescriptionWithError:error];
619 }]; 620 }];
620 break; 621 break;
621 } 622 }
622 case kARDSignalingMessageTypeCandidate: { 623 case kARDSignalingMessageTypeCandidate: {
623 ARDICECandidateMessage *candidateMessage = 624 ARDICECandidateMessage *candidateMessage =
624 (ARDICECandidateMessage *)message; 625 (ARDICECandidateMessage *)message;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 code:kARDAppClientErrorInvalidRoom 855 code:kARDAppClientErrorInvalidRoom
855 userInfo:@{ 856 userInfo:@{
856 NSLocalizedDescriptionKey: @"Invalid room.", 857 NSLocalizedDescriptionKey: @"Invalid room.",
857 }]; 858 }];
858 break; 859 break;
859 } 860 }
860 return error; 861 return error;
861 } 862 }
862 863
863 @end 864 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698