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}
diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h
index d906ec7..60ef700 100644
--- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h
+++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h
@@ -65,6 +65,9 @@
 // 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 4a073f3..cfcb356 100644
--- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
+++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
@@ -102,6 +102,7 @@
   RTCFileLogger *_fileLogger;
   ARDTimerProxy *_statsTimer;
   RTCMediaConstraints *_cameraConstraints;
+  NSNumber *_maxBitrate;
 }
 
 @synthesize shouldGetStats = _shouldGetStats;
@@ -328,6 +329,10 @@
   _cameraConstraints = mediaConstraints;
 }
 
+- (void)setMaxBitrate:(NSNumber *)maxBitrate {
+  _maxBitrate = maxBitrate;
+}
+
 #pragma mark - ARDSignalingChannelDelegate
 
 - (void)channel:(id<ARDSignalingChannel>)channel
@@ -675,6 +680,9 @@
   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 @@
   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];