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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 - (void)timerDidFire:(NSTimer *)timer { | 95 - (void)timerDidFire:(NSTimer *)timer { |
96 _timerHandler(); | 96 _timerHandler(); |
97 } | 97 } |
98 | 98 |
99 @end | 99 @end |
100 | 100 |
101 @implementation ARDAppClient { | 101 @implementation ARDAppClient { |
102 RTCFileLogger *_fileLogger; | 102 RTCFileLogger *_fileLogger; |
103 ARDTimerProxy *_statsTimer; | 103 ARDTimerProxy *_statsTimer; |
104 RTCMediaConstraints *_cameraConstraints; | 104 RTCMediaConstraints *_cameraConstraints; |
105 NSNumber *_maxBitrate; | |
105 } | 106 } |
106 | 107 |
107 @synthesize shouldGetStats = _shouldGetStats; | 108 @synthesize shouldGetStats = _shouldGetStats; |
108 @synthesize state = _state; | 109 @synthesize state = _state; |
109 @synthesize delegate = _delegate; | 110 @synthesize delegate = _delegate; |
110 @synthesize roomServerClient = _roomServerClient; | 111 @synthesize roomServerClient = _roomServerClient; |
111 @synthesize channel = _channel; | 112 @synthesize channel = _channel; |
112 @synthesize loopbackChannel = _loopbackChannel; | 113 @synthesize loopbackChannel = _loopbackChannel; |
113 @synthesize turnClient = _turnClient; | 114 @synthesize turnClient = _turnClient; |
114 @synthesize peerConnection = _peerConnection; | 115 @synthesize peerConnection = _peerConnection; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 self.state = kARDAppClientStateDisconnected; | 320 self.state = kARDAppClientStateDisconnected; |
320 #if defined(WEBRTC_IOS) | 321 #if defined(WEBRTC_IOS) |
321 RTCStopInternalCapture(); | 322 RTCStopInternalCapture(); |
322 #endif | 323 #endif |
323 } | 324 } |
324 | 325 |
325 - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints { | 326 - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints { |
326 _cameraConstraints = mediaConstraints; | 327 _cameraConstraints = mediaConstraints; |
327 } | 328 } |
328 | 329 |
330 - (void)setMaxBitrate:(NSNumber *)maxBitrate { | |
331 _maxBitrate = maxBitrate; | |
332 } | |
333 | |
329 #pragma mark - ARDSignalingChannelDelegate | 334 #pragma mark - ARDSignalingChannelDelegate |
330 | 335 |
331 - (void)channel:(id<ARDSignalingChannel>)channel | 336 - (void)channel:(id<ARDSignalingChannel>)channel |
332 didReceiveMessage:(ARDSignalingMessage *)message { | 337 didReceiveMessage:(ARDSignalingMessage *)message { |
333 switch (message.type) { | 338 switch (message.type) { |
334 case kARDSignalingMessageTypeOffer: | 339 case kARDSignalingMessageTypeOffer: |
335 case kARDSignalingMessageTypeAnswer: | 340 case kARDSignalingMessageTypeAnswer: |
336 // Offers and answers must be processed before any other message, so we | 341 // Offers and answers must be processed before any other message, so we |
337 // place them at the front of the queue. | 342 // place them at the front of the queue. |
338 _hasReceivedSdp = YES; | 343 _hasReceivedSdp = YES; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 }]; | 671 }]; |
667 } else { | 672 } else { |
668 [_channel sendMessage:message]; | 673 [_channel sendMessage:message]; |
669 } | 674 } |
670 } | 675 } |
671 | 676 |
672 - (RTCRtpSender *)createVideoSender { | 677 - (RTCRtpSender *)createVideoSender { |
673 RTCRtpSender *sender = | 678 RTCRtpSender *sender = |
674 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo | 679 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo |
675 streamId:kARDMediaStreamId]; | 680 streamId:kARDMediaStreamId]; |
681 | |
682 [self setMaxBitrate:_maxBitrate forVideoSender:sender]; | |
683 | |
676 RTCVideoTrack *track = [self createLocalVideoTrack]; | 684 RTCVideoTrack *track = [self createLocalVideoTrack]; |
677 if (track) { | 685 if (track) { |
678 sender.track = track; | 686 sender.track = track; |
679 [_delegate appClient:self didReceiveLocalVideoTrack:track]; | 687 [_delegate appClient:self didReceiveLocalVideoTrack:track]; |
680 } | 688 } |
681 return sender; | 689 return sender; |
682 } | 690 } |
683 | 691 |
692 - (void)setMaxBitrate:(NSNumber *)maxBitrate forVideoSender:(RTCRtpSender *)send er { | |
693 RTCRtpParameters *parameters = sender.parameters; | |
694 for (RTCRtpEncodingParameters *encoding in parameters.encodings) { | |
magjed_webrtc
2016/11/08 12:52:46
nit: Can we just inline sender.parameters.encoding
daniela-webrtc
2016/11/08 13:28:35
Done.
| |
695 encoding.maxBitrateBps = maxBitrate; | |
696 } | |
697 } | |
698 | |
684 - (RTCRtpSender *)createAudioSender { | 699 - (RTCRtpSender *)createAudioSender { |
685 RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; | 700 RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; |
686 RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints]; | 701 RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints]; |
687 RTCAudioTrack *track = [_factory audioTrackWithSource:source | 702 RTCAudioTrack *track = [_factory audioTrackWithSource:source |
688 trackId:kARDAudioTrackId]; | 703 trackId:kARDAudioTrackId]; |
689 RTCRtpSender *sender = | 704 RTCRtpSender *sender = |
690 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindAudio | 705 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindAudio |
691 streamId:kARDMediaStreamId]; | 706 streamId:kARDMediaStreamId]; |
692 sender.track = track; | 707 sender.track = track; |
693 return sender; | 708 return sender; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 code:kARDAppClientErrorInvalidRoom | 853 code:kARDAppClientErrorInvalidRoom |
839 userInfo:@{ | 854 userInfo:@{ |
840 NSLocalizedDescriptionKey: @"Invalid room.", | 855 NSLocalizedDescriptionKey: @"Invalid room.", |
841 }]; | 856 }]; |
842 break; | 857 break; |
843 } | 858 } |
844 return error; | 859 return error; |
845 } | 860 } |
846 | 861 |
847 @end | 862 @end |
OLD | NEW |