Skip to content

Commit

Permalink
Revert "Implementing SDL 0323: Align VideoStreamingParameters with Vi…
Browse files Browse the repository at this point in the history
…deoStreamingCapability."

This reverts commit 3adc0ea.
  • Loading branch information
shiniwat committed Dec 7, 2020
1 parent 3adc0ea commit 37427ef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,37 +294,38 @@ public void startRemoteDisplayStream(Context context, Class<? extends SdlRemoteD
stateMachine.transitionToState(StreamingStateMachine.ERROR);
return;
}
// regardless of VideoStreamingParameters are specified or not, we should refer to VideoStreamingCapability.
if (majorProtocolVersion >= 5) {
if (internalInterface.getSystemCapabilityManager() != null) {
final VideoStreamingParameters params = ( parameters == null) ? new VideoStreamingParameters() : new VideoStreamingParameters(parameters);
internalInterface.getSystemCapabilityManager().getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() {
@Override
public void onCapabilityRetrieved(Object capability) {
params.update((VideoStreamingCapability) capability, vehicleMake); //Streaming parameters are ready time to stream
startStreaming(params, encrypted);
}
if (parameters == null) {
if (majorProtocolVersion >= 5) {
if (internalInterface.getSystemCapabilityManager() != null) {
internalInterface.getSystemCapabilityManager().getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() {
@Override
public void onCapabilityRetrieved(Object capability) {
VideoStreamingParameters params = new VideoStreamingParameters();
params.update((VideoStreamingCapability) capability, vehicleMake); //Streaming parameters are ready time to stream
startStreaming(params, encrypted);
}

@Override
public void onError(String info) {
stateMachine.transitionToState(StreamingStateMachine.ERROR);
DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info);
}
}, false);
@Override
public void onError(String info) {
stateMachine.transitionToState(StreamingStateMachine.ERROR);
DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info);
}
}, false);
}
} else {
DebugTool.logError(TAG, "Cannot start video streaming because getSystemCapabilityManager is null.");
//We just use default video streaming params
VideoStreamingParameters params = new VideoStreamingParameters();
DisplayCapabilities dispCap = null;
if (internalInterface.getSystemCapabilityManager() != null) {
dispCap = (DisplayCapabilities) internalInterface.getSystemCapabilityManager().getCapability(SystemCapabilityType.DISPLAY, null, false);
}
if (dispCap != null) {
params.setResolution(dispCap.getScreenParams().getImageResolution());
}
startStreaming(params, encrypted);
}
} else {
//We just use default video streaming params
VideoStreamingParameters params = (parameters == null) ? new VideoStreamingParameters() : new VideoStreamingParameters(parameters);
DisplayCapabilities dispCap = null;
if (internalInterface.getSystemCapabilityManager() != null) {
dispCap = (DisplayCapabilities) internalInterface.getSystemCapabilityManager().getCapability(SystemCapabilityType.DISPLAY, null, false);
}
if (dispCap != null) {
params.setResolution(dispCap.getScreenParams().getImageResolution());
}
startStreaming(params, encrypted);
startStreaming(parameters, encrypted);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ public void update(VideoStreamingParameters params) {
if (params.interval > 0) {
this.interval = params.interval;
}
if (this.resolution == null) {
this.resolution = new ImageResolution();
}
if (params.resolution != null) {
if (params.resolution.getResolutionHeight() != null && params.resolution.getResolutionHeight() > 0) {
this.resolution.setResolutionHeight(params.resolution.getResolutionHeight());
Expand All @@ -171,7 +168,7 @@ public void update(VideoStreamingParameters params) {
*/
public void update(VideoStreamingCapability capability, String vehicleMake) {
if (capability.getMaxBitrate() != null) {
this.bitrate = Math.min(this.bitrate, capability.getMaxBitrate() * 1000);
this.bitrate = capability.getMaxBitrate() * 1000;
} // NOTE: the unit of maxBitrate in getSystemCapability is kbps.
double scale = DEFAULT_SCALE;
if (capability.getScale() != null) {
Expand All @@ -194,7 +191,7 @@ public void update(VideoStreamingCapability capability, String vehicleMake) {
}
}
if (capability.getPreferredFPS() != null) {
this.frameRate = Math.min(this.frameRate, capability.getPreferredFPS());
this.frameRate = capability.getPreferredFPS();
}

// This should be the last call as it will return out once a suitable format is found
Expand Down

0 comments on commit 37427ef

Please sign in to comment.