Skip to content

Commit

Permalink
Merge pull request #1953 from smartdevicelink/bugfix/issue_1950_overr…
Browse files Browse the repository at this point in the history
…iding_default_custom_encoder_settings

Let developer override the default custom video encoder settings when not set by the video streaming capability
  • Loading branch information
joeljfischer authored Apr 9, 2021
2 parents b22f509 + 6527912 commit 047d827
Show file tree
Hide file tree
Showing 2 changed files with 274 additions and 171 deletions.
19 changes: 13 additions & 6 deletions SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,13 @@ - (void)sdl_applyVideoCapabilityWhileStarting:(nullable SDLVideoStreamingCapabil
if (!matchedVideoCapability.supportedFormats) {
matchedVideoCapability.supportedFormats = videoCapabilityUpdated.supportedFormats;
}
if (matchedVideoCapability.maxBitrate == nil) {
matchedVideoCapability.maxBitrate = videoCapabilityUpdated.maxBitrate;
}
if (matchedVideoCapability.preferredFPS == nil) {
matchedVideoCapability.preferredFPS = videoCapabilityUpdated.preferredFPS;
}

[self sdl_applyVideoCapability:matchedVideoCapability];
self.shouldUpdateDelegateOnSizeChange = YES;

Expand Down Expand Up @@ -1109,7 +1116,7 @@ - (void)sdl_applyVideoCapability:(SDLVideoStreamingCapability *)capability {
assert(capability != nil);

self.videoStreamingCapability = capability;
self.focusableItemManager.enableHapticDataRequests = capability.hapticSpatialDataSupported.boolValue; // nil capability makes NO
self.focusableItemManager.enableHapticDataRequests = capability.hapticSpatialDataSupported.boolValue;
self.videoScaleManager.scale = capability.scale.floatValue;
self.videoScaleManager.displayViewportResolution = capability.preferredResolution.makeSize;

Expand All @@ -1124,12 +1131,12 @@ - (void)sdl_applyVideoCapability:(SDLVideoStreamingCapability *)capability {
// Apply customEncoderSettings here. Note that value from HMI (such as maxBitrate) will be overwritten by custom settings
// (Exception: ExpectedFrameRate, AverageBitRate)
for (id key in self.customEncoderSettings.keyEnumerator) {
// do NOT override framerate or average bitreate if custom setting is higher than current setting.
// Do *not* override framerate or average bitrate if custom setting is higher than current setting.
// See SDL 0323 (https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0323-align-VideoStreamingParameter-with-capability.md) for details.
if ([(NSString *)key isEqualToString:(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate] ||
[(NSString *)key isEqualToString:(__bridge NSString *)kVTCompressionPropertyKey_AverageBitRate]) {
NSNumber *customEncoderSettings = (NSNumber *)[self.customEncoderSettings valueForKey:key];
NSNumber *videoEncoderSettings = (NSNumber *)[self.videoEncoderSettings valueForKey:key];
if (([(NSString *)key isEqualToString:(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate] && capability.preferredFPS != nil) ||
([(NSString *)key isEqualToString:(__bridge NSString *)kVTCompressionPropertyKey_AverageBitRate] && capability.maxBitrate != nil)) {
NSNumber *customEncoderSettings = (NSNumber *)self.customEncoderSettings[key];
NSNumber *videoEncoderSettings = (NSNumber *)self.videoEncoderSettings[key];
if (customEncoderSettings.doubleValue < videoEncoderSettings.doubleValue) {
self.videoEncoderSettings[key] = customEncoderSettings;
}
Expand Down
Loading

0 comments on commit 047d827

Please sign in to comment.