OLD | NEW |
---|---|
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 - (void)timerDidFire:(NSTimer *)timer { | 92 - (void)timerDidFire:(NSTimer *)timer { |
93 _timerHandler(); | 93 _timerHandler(); |
94 } | 94 } |
95 | 95 |
96 @end | 96 @end |
97 | 97 |
98 @implementation ARDAppClient { | 98 @implementation ARDAppClient { |
99 RTCFileLogger *_fileLogger; | 99 RTCFileLogger *_fileLogger; |
100 ARDTimerProxy *_statsTimer; | 100 ARDTimerProxy *_statsTimer; |
101 RTCMediaConstraints *_cameraConstraints; | 101 RTCMediaConstraints *_cameraConstraints; |
102 NSString *_videoCodec; | |
kthelgason
2017/03/09 13:39:43
Maybe make this a property and @synthesize it. The
sakal
2017/03/10 10:25:27
Done.
| |
102 NSNumber *_maxBitrate; | 103 NSNumber *_maxBitrate; |
103 } | 104 } |
104 | 105 |
105 @synthesize shouldGetStats = _shouldGetStats; | 106 @synthesize shouldGetStats = _shouldGetStats; |
106 @synthesize state = _state; | 107 @synthesize state = _state; |
107 @synthesize delegate = _delegate; | 108 @synthesize delegate = _delegate; |
108 @synthesize roomServerClient = _roomServerClient; | 109 @synthesize roomServerClient = _roomServerClient; |
109 @synthesize channel = _channel; | 110 @synthesize channel = _channel; |
110 @synthesize loopbackChannel = _loopbackChannel; | 111 @synthesize loopbackChannel = _loopbackChannel; |
111 @synthesize turnClient = _turnClient; | 112 @synthesize turnClient = _turnClient; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 if (kARDAppClientEnableTracing) { | 314 if (kARDAppClientEnableTracing) { |
314 RTCStopInternalCapture(); | 315 RTCStopInternalCapture(); |
315 } | 316 } |
316 #endif | 317 #endif |
317 } | 318 } |
318 | 319 |
319 - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints { | 320 - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints { |
320 _cameraConstraints = mediaConstraints; | 321 _cameraConstraints = mediaConstraints; |
321 } | 322 } |
322 | 323 |
324 - (void)setVideoCodec:(NSString *)videoCodec { | |
325 _videoCodec = videoCodec; | |
326 } | |
327 | |
323 - (void)setMaxBitrate:(NSNumber *)maxBitrate { | 328 - (void)setMaxBitrate:(NSNumber *)maxBitrate { |
324 _maxBitrate = maxBitrate; | 329 _maxBitrate = maxBitrate; |
325 } | 330 } |
326 | 331 |
327 #pragma mark - ARDSignalingChannelDelegate | 332 #pragma mark - ARDSignalingChannelDelegate |
328 | 333 |
329 - (void)channel:(id<ARDSignalingChannel>)channel | 334 - (void)channel:(id<ARDSignalingChannel>)channel |
330 didReceiveMessage:(ARDSignalingMessage *)message { | 335 didReceiveMessage:(ARDSignalingMessage *)message { |
331 switch (message.type) { | 336 switch (message.type) { |
332 case kARDSignalingMessageTypeOffer: | 337 case kARDSignalingMessageTypeOffer: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 NSDictionary *userInfo = @{ | 450 NSDictionary *userInfo = @{ |
446 NSLocalizedDescriptionKey: @"Failed to create session description.", | 451 NSLocalizedDescriptionKey: @"Failed to create session description.", |
447 }; | 452 }; |
448 NSError *sdpError = | 453 NSError *sdpError = |
449 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain | 454 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain |
450 code:kARDAppClientErrorCreateSDP | 455 code:kARDAppClientErrorCreateSDP |
451 userInfo:userInfo]; | 456 userInfo:userInfo]; |
452 [_delegate appClient:self didError:sdpError]; | 457 [_delegate appClient:self didError:sdpError]; |
453 return; | 458 return; |
454 } | 459 } |
455 // Prefer H264 if available. | 460 // Prefer codec from settings if available. |
456 RTCSessionDescription *sdpPreferringH264 = | 461 RTCSessionDescription *sdpPreferringCodec = |
457 [ARDSDPUtils descriptionForDescription:sdp | 462 [ARDSDPUtils descriptionForDescription:sdp |
458 preferredVideoCodec:@"H264"]; | 463 preferredVideoCodec:_videoCodec]; |
459 __weak ARDAppClient *weakSelf = self; | 464 __weak ARDAppClient *weakSelf = self; |
460 [_peerConnection setLocalDescription:sdpPreferringH264 | 465 [_peerConnection setLocalDescription:sdpPreferringCodec |
461 completionHandler:^(NSError *error) { | 466 completionHandler:^(NSError *error) { |
462 ARDAppClient *strongSelf = weakSelf; | 467 ARDAppClient *strongSelf = weakSelf; |
463 [strongSelf peerConnection:strongSelf.peerConnection | 468 [strongSelf peerConnection:strongSelf.peerConnection |
464 didSetSessionDescriptionWithError:error]; | 469 didSetSessionDescriptionWithError:error]; |
465 }]; | 470 }]; |
466 ARDSessionDescriptionMessage *message = | 471 ARDSessionDescriptionMessage *message = |
467 [[ARDSessionDescriptionMessage alloc] | 472 [[ARDSessionDescriptionMessage alloc] |
468 initWithDescription:sdpPreferringH264]; | 473 initWithDescription:sdpPreferringCodec]; |
469 [self sendSignalingMessage:message]; | 474 [self sendSignalingMessage:message]; |
470 [self setMaxBitrateForPeerConnectionVideoSender]; | 475 [self setMaxBitrateForPeerConnectionVideoSender]; |
471 }); | 476 }); |
472 } | 477 } |
473 | 478 |
474 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 479 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
475 didSetSessionDescriptionWithError:(NSError *)error { | 480 didSetSessionDescriptionWithError:(NSError *)error { |
476 dispatch_async(dispatch_get_main_queue(), ^{ | 481 dispatch_async(dispatch_get_main_queue(), ^{ |
477 if (error) { | 482 if (error) { |
478 RTCLogError(@"Failed to set session description. Error: %@", error); | 483 RTCLogError(@"Failed to set session description. Error: %@", error); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 // Processes the given signaling message based on its type. | 604 // Processes the given signaling message based on its type. |
600 - (void)processSignalingMessage:(ARDSignalingMessage *)message { | 605 - (void)processSignalingMessage:(ARDSignalingMessage *)message { |
601 NSParameterAssert(_peerConnection || | 606 NSParameterAssert(_peerConnection || |
602 message.type == kARDSignalingMessageTypeBye); | 607 message.type == kARDSignalingMessageTypeBye); |
603 switch (message.type) { | 608 switch (message.type) { |
604 case kARDSignalingMessageTypeOffer: | 609 case kARDSignalingMessageTypeOffer: |
605 case kARDSignalingMessageTypeAnswer: { | 610 case kARDSignalingMessageTypeAnswer: { |
606 ARDSessionDescriptionMessage *sdpMessage = | 611 ARDSessionDescriptionMessage *sdpMessage = |
607 (ARDSessionDescriptionMessage *)message; | 612 (ARDSessionDescriptionMessage *)message; |
608 RTCSessionDescription *description = sdpMessage.sessionDescription; | 613 RTCSessionDescription *description = sdpMessage.sessionDescription; |
609 // Prefer H264 if available. | 614 // Prefer codec set in settings if available. |
610 RTCSessionDescription *sdpPreferringH264 = | 615 RTCSessionDescription *sdpPreferringCodec = |
611 [ARDSDPUtils descriptionForDescription:description | 616 [ARDSDPUtils descriptionForDescription:description |
612 preferredVideoCodec:@"H264"]; | 617 preferredVideoCodec:_videoCodec]; |
613 __weak ARDAppClient *weakSelf = self; | 618 __weak ARDAppClient *weakSelf = self; |
614 [_peerConnection setRemoteDescription:sdpPreferringH264 | 619 [_peerConnection setRemoteDescription:sdpPreferringCodec |
615 completionHandler:^(NSError *error) { | 620 completionHandler:^(NSError *error) { |
616 ARDAppClient *strongSelf = weakSelf; | 621 ARDAppClient *strongSelf = weakSelf; |
617 [strongSelf peerConnection:strongSelf.peerConnection | 622 [strongSelf peerConnection:strongSelf.peerConnection |
618 didSetSessionDescriptionWithError:error]; | 623 didSetSessionDescriptionWithError:error]; |
619 }]; | 624 }]; |
620 break; | 625 break; |
621 } | 626 } |
622 case kARDSignalingMessageTypeCandidate: { | 627 case kARDSignalingMessageTypeCandidate: { |
623 ARDICECandidateMessage *candidateMessage = | 628 ARDICECandidateMessage *candidateMessage = |
624 (ARDICECandidateMessage *)message; | 629 (ARDICECandidateMessage *)message; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 code:kARDAppClientErrorInvalidRoom | 859 code:kARDAppClientErrorInvalidRoom |
855 userInfo:@{ | 860 userInfo:@{ |
856 NSLocalizedDescriptionKey: @"Invalid room.", | 861 NSLocalizedDescriptionKey: @"Invalid room.", |
857 }]; | 862 }]; |
858 break; | 863 break; |
859 } | 864 } |
860 return error; | 865 return error; |
861 } | 866 } |
862 | 867 |
863 @end | 868 @end |
OLD | NEW |