BWE allocation strategy allows controlling of bitrate allocation with WEBRTC external logic.

This CL implements the main logic and IOS appRTC integration.

Unit tests and Android appRTC will be in separate CL.

Bug: webrtc:8243
Change-Id: If8e5195294046a47316e9fade1b0dfec211155e1
Reviewed-on: https://webrtc-review.googlesource.com/4860
Commit-Queue: Alex Narest <alexnarest@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20329}
This commit is contained in:
Alex Narest
2017-10-17 19:49:15 +02:00
committed by Commit Bot
parent 1b0eae3c81
commit 54d1da13a5
30 changed files with 534 additions and 18 deletions

View File

@ -25,6 +25,7 @@
#import "WebRTC/RTCVideoTrack.h"
#import "ARDAppEngineClient.h"
#import "ARDBitrateAllocationStrategy.h"
#import "ARDJoinResponse.h"
#import "ARDMessageResponse.h"
#import "ARDSettingsModel.h"
@ -50,6 +51,7 @@ static NSString * const kARDMediaStreamId = @"ARDAMS";
static NSString * const kARDAudioTrackId = @"ARDAMSa0";
static NSString * const kARDVideoTrackId = @"ARDAMSv0";
static NSString * const kARDVideoTrackKind = @"video";
static uint32_t const kSufficientAudioBitrate = 16000;
// TODO(tkchin): Add these as UI options.
static BOOL const kARDAppClientEnableTracing = NO;
@ -104,6 +106,7 @@ static int const kKbpsMultiplier = 1000;
ARDTimerProxy *_statsTimer;
ARDSettingsModel *_settings;
RTCVideoTrack *_localVideoTrack;
ARDBitrateAllocationStrategy *_bitrateAllocationStrategy;
}
@synthesize shouldGetStats = _shouldGetStats;
@ -306,12 +309,14 @@ static int const kKbpsMultiplier = 1000;
_hasReceivedSdp = NO;
_messageQueue = [NSMutableArray array];
_localVideoTrack = nil;
#if defined(WEBRTC_IOS)
[_factory stopAecDump];
[_peerConnection stopRtcEventLog];
#endif
[_peerConnection close];
_peerConnection = nil;
_bitrateAllocationStrategy = nil;
self.state = kARDAppClientStateDisconnected;
#if defined(WEBRTC_IOS)
if (kARDAppClientEnableTracing) {
@ -533,8 +538,14 @@ static int const kKbpsMultiplier = 1000;
_peerConnection = [_factory peerConnectionWithConfiguration:config
constraints:constraints
delegate:self];
_bitrateAllocationStrategy = [ARDBitrateAllocationStrategy
createAudioPriorityBitrateAllocationStrategyForPeerConnection:_peerConnection
withAudioTrack:kARDAudioTrackId
sufficientAudioBitrate:kSufficientAudioBitrate];
// Create AV senders.
[self createMediaSenders];
if (_isInitiator) {
// Send offer.
__weak ARDAppClient *weakSelf = self;

View File

@ -0,0 +1,23 @@
/*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#import "WebRTC/RTCPeerConnection.h"
@interface ARDBitrateAllocationStrategy : NSObject
+ (ARDBitrateAllocationStrategy*)
createAudioPriorityBitrateAllocationStrategyForPeerConnection:(RTCPeerConnection*)peerConnection
withAudioTrack:(NSString*)audioTrackID
sufficientAudioBitrate:(uint32_t)sufficientAudioBitrate;
- (instancetype)init NS_UNAVAILABLE;
@end

View File

@ -0,0 +1,40 @@
/*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import "ARDBitrateAllocationStrategy.h"
#import "WebRTC/RTCBitrateAllocationStrategy.h"
#include "rtc_base/bitrateallocationstrategy.h"
@implementation ARDBitrateAllocationStrategy
+ (ARDBitrateAllocationStrategy*)
createAudioPriorityBitrateAllocationStrategyForPeerConnection:(RTCPeerConnection*)peerConnection
withAudioTrack:(NSString*)audioTrackID
sufficientAudioBitrate:(uint32_t)sufficientAudioBitrate {
return [[ARDBitrateAllocationStrategy alloc] initWithPeerCoonnection:peerConnection
withAudioTrack:audioTrackID
sufficientAudioBitrate:sufficientAudioBitrate];
}
- (instancetype)initWithPeerCoonnection:(RTCPeerConnection*)peerConnection
withAudioTrack:(NSString*)audioTrackID
sufficientAudioBitrate:(uint32_t)sufficientAudioBitrate {
if (self = [super init]) {
[peerConnection
setBitrateAllocationStrategy:[[RTCBitrateAllocationStrategy alloc]
initWith:new rtc::AudioPriorityBitrateAllocationStrategy(
std::string(audioTrackID.UTF8String),
sufficientAudioBitrate)]];
}
return self;
}
@end

View File

@ -26,7 +26,8 @@
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *fieldTrials = @{
kRTCFieldTrialH264HighProfileKey: kRTCFieldTrialEnabledValue,
kRTCFieldTrialH264HighProfileKey : kRTCFieldTrialEnabledValue,
kRTCFieldTrialAudioSendSideBweKey : kRTCFieldTrialEnabledValue
};
RTCInitFieldTrialDictionary(fieldTrials);
RTCInitializeSSL();