From 8c375dedb2d1a6b9b93a330ea225fcf6ef43dc73 Mon Sep 17 00:00:00 2001 From: denicija Date: Tue, 8 Nov 2016 06:28:17 -0800 Subject: [PATCH] Expose bit rate property in ARDAppClient and set max bitrate for video RTCRtcSender. BUG=webrtc:6654 Review-Url: https://codereview.webrtc.org/2484733002 Cr-Commit-Position: refs/heads/master@{#14977} --- webrtc/examples/objc/AppRTCMobile/ARDAppClient.h | 3 +++ webrtc/examples/objc/AppRTCMobile/ARDAppClient.m | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h index d906ec726f..60ef70071c 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h @@ -65,6 +65,9 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) { // Sets camera constraints. - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints; +// Sets maximum bitrate the rtp sender should use. +- (void)setMaxBitrate:(NSNumber *)maxBitrate; + // Establishes a connection with the AppRTC servers for the given room id. // If |isLoopback| is true, the call will connect to itself. // If |isAudioOnly| is true, video will be disabled for the call. diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m index 4a073f3f1c..cfcb356548 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m @@ -102,6 +102,7 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. RTCFileLogger *_fileLogger; ARDTimerProxy *_statsTimer; RTCMediaConstraints *_cameraConstraints; + NSNumber *_maxBitrate; } @synthesize shouldGetStats = _shouldGetStats; @@ -328,6 +329,10 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. _cameraConstraints = mediaConstraints; } +- (void)setMaxBitrate:(NSNumber *)maxBitrate { + _maxBitrate = maxBitrate; +} + #pragma mark - ARDSignalingChannelDelegate - (void)channel:(id)channel @@ -675,6 +680,9 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. RTCRtpSender *sender = [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo streamId:kARDMediaStreamId]; + + [self setMaxBitrate:_maxBitrate forVideoSender:sender]; + RTCVideoTrack *track = [self createLocalVideoTrack]; if (track) { sender.track = track; @@ -683,6 +691,12 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. return sender; } +- (void)setMaxBitrate:(NSNumber *)maxBitrate forVideoSender:(RTCRtpSender *)sender { + for (RTCRtpEncodingParameters *encoding in sender.parameters.encodings) { + encoding.maxBitrateBps = maxBitrate; + } +} + - (RTCRtpSender *)createAudioSender { RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints];