Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflect bitrate returned from HMI in video encoder settings #1393

Merged
merged 5 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions SmartDeviceLink/SDLStreamingMediaConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@ typedef NS_ENUM(NSUInteger, SDLCarWindowRenderingType) {
* Properties to use for applications that utilize the video encoder for streaming. See VTCompressionProperties.h for more details. For example, you can set kVTCompressionPropertyKey_ExpectedFrameRate to set your framerate. Setting the framerate this way will also set the framerate if you use CarWindow automatic streaming.
*
* Other properties you may want to try adjusting include kVTCompressionPropertyKey_AverageBitRate and kVTCompressionPropertyKey_DataRateLimits.
@note Setting values can be overridden by StreamingMediaManager when `allowOverrideEncoderSettings` property is YES.
*/
@property (copy, nonatomic, nullable) NSDictionary<NSString *, id> *customVideoEncoderSettings;

/**
When YES, the StreamingMediaManager will override encoder settings by the capability values returned from HMI. If you wish not to allow overriding encoder settings, set it to NO. Defaults to YES.
*/
@property (assign, nonatomic) BOOL allowOverrideEncoderSettings;

/**
Usable to change run time video stream setup behavior. Only use this and modify the results if you *really* know what you're doing. The head unit defaults are generally good.
*/
Expand Down
2 changes: 2 additions & 0 deletions SmartDeviceLink/SDLStreamingMediaConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (instancetype)initWithSecurityManagers:(nullable NSArray<Class<SDLSecurityType
_carWindowRenderingType = SDLCarWindowRenderingTypeLayer;
_enableForcedFramerateSync = YES;
_allowMultipleViewControllerOrientations = NO;
_allowOverrideEncoderSettings = YES;

return self;
}
Expand Down Expand Up @@ -68,6 +69,7 @@ - (id)copyWithZone:(nullable NSZone *)zone {
newConfig.carWindowRenderingType = self.carWindowRenderingType;
newConfig.enableForcedFramerateSync = self.enableForcedFramerateSync;
newConfig.allowMultipleViewControllerOrientations = self.allowMultipleViewControllerOrientations;
newConfig.allowOverrideEncoderSettings = self.allowOverrideEncoderSettings;

return newConfig;
}
Expand Down
6 changes: 6 additions & 0 deletions SmartDeviceLink/SDLStreamingVideoLifecycleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL showVideoBackgroundDisplay;


/**
When YES, the StreamingMediaManager will override encoder settings by the capability values returned from HMI. Defaults to YES.
*/
@property (assign, nonatomic) BOOL allowOverrideEncoderSettings;


- (instancetype)init NS_UNAVAILABLE;

/**
Expand Down
9 changes: 9 additions & 0 deletions SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ - (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connecti
_screenSize = SDLDefaultScreenSize;
_backgroundingPixelBuffer = NULL;
_showVideoBackgroundDisplay = YES;
_allowOverrideEncoderSettings = configuration.streamingMediaConfig.allowOverrideEncoderSettings;
_preferredFormatIndex = 0;
_preferredResolutionIndex = 0;

Expand Down Expand Up @@ -344,6 +345,14 @@ - (void)didEnterStateVideoStreamStarting {
weakSelf.preferredFormats = capability.supportedFormats;
weakSelf.preferredResolutions = @[capability.preferredResolution];

if (weakSelf.allowOverrideEncoderSettings && capability.maxBitrate != nil) {
NSNumber *bitrate = [[NSNumber alloc] initWithUnsignedLongLong:(capability.maxBitrate.unsignedLongLongValue * 1000)];
NSMutableDictionary *settings = [[NSMutableDictionary alloc] init];
[settings addEntriesFromDictionary: self.videoEncoderSettings];
[settings setObject:bitrate forKey:(__bridge NSString *)kVTCompressionPropertyKey_AverageBitRate];
weakSelf.videoEncoderSettings = settings;
t-yoshii marked this conversation as resolved.
Show resolved Hide resolved
}

if (weakSelf.dataSource != nil) {
SDLLogV(@"Calling data source for modified preferred formats");
weakSelf.preferredFormats = [weakSelf.dataSource preferredVideoFormatOrderFromHeadUnitPreferredOrder:weakSelf.preferredFormats];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel, SDLVideoStream
expect(@(streamingLifecycleManager.pixelBufferPool == NULL)).to(equal(@YES));
expect(@(streamingLifecycleManager.requestedEncryptionType)).to(equal(@(SDLStreamingEncryptionFlagNone)));
expect(@(streamingLifecycleManager.showVideoBackgroundDisplay)).to(equal(@YES));
expect(@(streamingLifecycleManager.allowOverrideEncoderSettings)).to(equal(@YES));
expect(streamingLifecycleManager.currentAppState).to(equal(SDLAppStateActive));
expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStopped));
expect(streamingLifecycleManager.videoFormat).to(beNil());
Expand Down