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 |
11 #import "ARDAppClient+Internal.h" | 11 #import "ARDAppClient+Internal.h" |
12 | 12 |
13 #import "WebRTC/RTCAVFoundationVideoSource.h" | 13 #import "WebRTC/RTCAVFoundationVideoSource.h" |
14 #import "WebRTC/RTCAudioTrack.h" | 14 #import "WebRTC/RTCAudioTrack.h" |
15 #import "WebRTC/RTCCameraVideoCapturer.h" | 15 #import "WebRTC/RTCCameraVideoCapturer.h" |
16 #import "WebRTC/RTCConfiguration.h" | 16 #import "WebRTC/RTCConfiguration.h" |
17 #import "WebRTC/RTCFileLogger.h" | 17 #import "WebRTC/RTCFileLogger.h" |
18 #import "WebRTC/RTCIceServer.h" | 18 #import "WebRTC/RTCIceServer.h" |
19 #import "WebRTC/RTCLogging.h" | 19 #import "WebRTC/RTCLogging.h" |
20 #import "WebRTC/RTCMediaConstraints.h" | 20 #import "WebRTC/RTCMediaConstraints.h" |
21 #import "WebRTC/RTCMediaStream.h" | 21 #import "WebRTC/RTCMediaStream.h" |
22 #import "WebRTC/RTCPeerConnectionFactory.h" | 22 #import "WebRTC/RTCPeerConnectionFactory.h" |
23 #import "WebRTC/RTCRtpSender.h" | 23 #import "WebRTC/RTCRtpSender.h" |
24 #import "WebRTC/RTCTracing.h" | 24 #import "WebRTC/RTCTracing.h" |
25 #import "WebRTC/RTCVideoTrack.h" | 25 #import "WebRTC/RTCVideoTrack.h" |
26 | 26 |
27 #import "ARDAppEngineClient.h" | 27 #import "ARDAppEngineClient.h" |
| 28 #import "ARDBitrateAllocationStrategy.h" |
28 #import "ARDJoinResponse.h" | 29 #import "ARDJoinResponse.h" |
29 #import "ARDMessageResponse.h" | 30 #import "ARDMessageResponse.h" |
30 #import "ARDSDPUtils.h" | 31 #import "ARDSDPUtils.h" |
31 #import "ARDSettingsModel.h" | 32 #import "ARDSettingsModel.h" |
32 #import "ARDSignalingMessage.h" | 33 #import "ARDSignalingMessage.h" |
33 #import "ARDTURNClient+Internal.h" | 34 #import "ARDTURNClient+Internal.h" |
34 #import "ARDUtilities.h" | 35 #import "ARDUtilities.h" |
35 #import "ARDWebSocketChannel.h" | 36 #import "ARDWebSocketChannel.h" |
36 #import "RTCIceCandidate+JSON.h" | 37 #import "RTCIceCandidate+JSON.h" |
37 #import "RTCSessionDescription+JSON.h" | 38 #import "RTCSessionDescription+JSON.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 525 } |
525 self.state = kARDAppClientStateConnected; | 526 self.state = kARDAppClientStateConnected; |
526 | 527 |
527 // Create peer connection. | 528 // Create peer connection. |
528 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; | 529 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; |
529 RTCConfiguration *config = [[RTCConfiguration alloc] init]; | 530 RTCConfiguration *config = [[RTCConfiguration alloc] init]; |
530 config.iceServers = _iceServers; | 531 config.iceServers = _iceServers; |
531 _peerConnection = [_factory peerConnectionWithConfiguration:config | 532 _peerConnection = [_factory peerConnectionWithConfiguration:config |
532 constraints:constraints | 533 constraints:constraints |
533 delegate:self]; | 534 delegate:self]; |
| 535 |
| 536 // Create bitrate allocation strategy |
| 537 [ARDBitrateAllocationStrategy setAudioPriorityStrategy:_peerConnection |
| 538 audioTrackId:kARDAudioTrackId]; |
| 539 |
534 // Create AV senders. | 540 // Create AV senders. |
535 [self createMediaSenders]; | 541 [self createMediaSenders]; |
| 542 |
536 if (_isInitiator) { | 543 if (_isInitiator) { |
537 // Send offer. | 544 // Send offer. |
538 __weak ARDAppClient *weakSelf = self; | 545 __weak ARDAppClient *weakSelf = self; |
539 [_peerConnection offerForConstraints:[self defaultOfferConstraints] | 546 [_peerConnection offerForConstraints:[self defaultOfferConstraints] |
540 completionHandler:^(RTCSessionDescription *sdp, | 547 completionHandler:^(RTCSessionDescription *sdp, |
541 NSError *error) { | 548 NSError *error) { |
542 ARDAppClient *strongSelf = weakSelf; | 549 ARDAppClient *strongSelf = weakSelf; |
543 [strongSelf peerConnection:strongSelf.peerConnection | 550 [strongSelf peerConnection:strongSelf.peerConnection |
544 didCreateSessionDescription:sdp | 551 didCreateSessionDescription:sdp |
545 error:error]; | 552 error:error]; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 686 } |
680 | 687 |
681 - (void)createMediaSenders { | 688 - (void)createMediaSenders { |
682 RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; | 689 RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; |
683 RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints]; | 690 RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints]; |
684 RTCAudioTrack *track = [_factory audioTrackWithSource:source | 691 RTCAudioTrack *track = [_factory audioTrackWithSource:source |
685 trackId:kARDAudioTrackId]; | 692 trackId:kARDAudioTrackId]; |
686 RTCMediaStream *stream = [_factory mediaStreamWithStreamId:kARDMediaStreamId]; | 693 RTCMediaStream *stream = [_factory mediaStreamWithStreamId:kARDMediaStreamId]; |
687 [stream addAudioTrack:track]; | 694 [stream addAudioTrack:track]; |
688 _localVideoTrack = [self createLocalVideoTrack]; | 695 _localVideoTrack = [self createLocalVideoTrack]; |
689 if(_localVideoTrack) { | 696 if (_localVideoTrack) { |
690 [stream addVideoTrack:_localVideoTrack]; | 697 [stream addVideoTrack:_localVideoTrack]; |
691 } | 698 } |
692 [_peerConnection addStream:stream]; | 699 [_peerConnection addStream:stream]; |
693 } | 700 } |
694 | 701 |
695 - (RTCVideoTrack *)createLocalVideoTrack { | 702 - (RTCVideoTrack *)createLocalVideoTrack { |
696 RTCVideoTrack* localVideoTrack = nil; | 703 RTCVideoTrack* localVideoTrack = nil; |
697 // The iOS simulator doesn't provide any sort of camera capture | 704 // The iOS simulator doesn't provide any sort of camera capture |
698 // support or emulation (http://goo.gl/rHAnC1) so don't bother | 705 // support or emulation (http://goo.gl/rHAnC1) so don't bother |
699 // trying to open a local stream. | 706 // trying to open a local stream. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 code:kARDAppClientErrorInvalidRoom | 834 code:kARDAppClientErrorInvalidRoom |
828 userInfo:@{ | 835 userInfo:@{ |
829 NSLocalizedDescriptionKey: @"Invalid room.", | 836 NSLocalizedDescriptionKey: @"Invalid room.", |
830 }]; | 837 }]; |
831 break; | 838 break; |
832 } | 839 } |
833 return error; | 840 return error; |
834 } | 841 } |
835 | 842 |
836 @end | 843 @end |
OLD | NEW |