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

Implement SDL 0323: Align video streaming parameters with VideoStreamingCapability #1576

Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,26 @@ public VideoStreamingParameters getStreamingParams() {
return this.streamingParams;
}

/**
* This method is deprecated; setStreamingParams with having stableFrameRate should be used.
*/
@Deprecated
public void setStreamingParams(int displayDensity, ImageResolution resolution, int frameRate, int bitrate, int interval, VideoStreamingFormat format) {
this.streamingParams = new VideoStreamingParameters(displayDensity, frameRate, bitrate, interval, resolution, format);
}

@SuppressWarnings("unused")
public void setStreamingParams(int displayDensity, ImageResolution resolution, int frameRate, int bitrate, int interval, VideoStreamingFormat format, boolean stableFrameRate) {
this.streamingParams = new VideoStreamingParameters(displayDensity, frameRate, bitrate, interval, resolution, format, stableFrameRate);
/**
* setter of every parameter in streamingParams.
* @param displayDensity
* @param resolution
* @param frameRate
* @param bitrate
* @param interval
* @param format
* @param stableFramerate
*/
public void setStreamingParams(int displayDensity, ImageResolution resolution, int frameRate, int bitrate, int interval, VideoStreamingFormat format, boolean stableFramerate) {
this.streamingParams = new VideoStreamingParameters(displayDensity, frameRate, bitrate, interval, resolution, format, stableFramerate);
}

shiniwat marked this conversation as resolved.
Show resolved Hide resolved
@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,38 +294,35 @@ public void startRemoteDisplayStream(Context context, Class<? extends SdlRemoteD
stateMachine.transitionToState(StreamingStateMachine.ERROR);
return;
}
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);
}
// 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);
}

@Override
public void onError(String info) {
stateMachine.transitionToState(StreamingStateMachine.ERROR);
DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info);
}
}, false);
}
} else {
//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);
@Override
public void onError(String info) {
stateMachine.transitionToState(StreamingStateMachine.ERROR);
DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info);
}
}, false);
}
} else {
startStreaming(parameters, encrypted);
//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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,28 @@ public VideoStreamingParameters() {
format = new VideoStreamingFormat();
format.setProtocol(DEFAULT_PROTOCOL);
format.setCodec(DEFAULT_CODEC);
stableFrameRate = true;
}

/**
* deprecated constructor of VideoStreamingParameters. This constructor will be removed in the future version.
* @param displayDensity
* @param frameRate
* @param bitrate
* @param interval
* @param resolution
* @param format
*/
@Deprecated
public VideoStreamingParameters(int displayDensity, int frameRate, int bitrate, int interval,
ImageResolution resolution, VideoStreamingFormat format) {
this.displayDensity = displayDensity;
this.frameRate = frameRate;
this.bitrate = bitrate;
this.interval = interval;
this.resolution = resolution;
this.format = format;
this.stableFrameRate = true;
this.displayDensity = displayDensity;
this.frameRate = frameRate;
this.bitrate = bitrate;
this.interval = interval;
this.resolution = resolution;
this.format = format;
this.stableFrameRate = true;
shiniwat marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -104,14 +114,14 @@ public VideoStreamingParameters(int displayDensity, int frameRate, int bitrate,
* @param stableFrameRate
*/
public VideoStreamingParameters(int displayDensity, int frameRate, int bitrate, int interval,
ImageResolution resolution, VideoStreamingFormat format, boolean stableFrameRate){
this.displayDensity = displayDensity;
this.frameRate = frameRate;
this.bitrate = bitrate;
this.interval = interval;
this.resolution = resolution;
this.format = format;
this.stableFrameRate = stableFrameRate;
ImageResolution resolution, VideoStreamingFormat format, boolean stableFrameRate) {
this.displayDensity = displayDensity;
this.frameRate = frameRate;
this.bitrate = bitrate;
this.interval = interval;
this.resolution = resolution;
this.format = format;
this.stableFrameRate = stableFrameRate;
}

/**
Expand Down Expand Up @@ -171,6 +181,7 @@ public void update(VideoStreamingCapability capability, String vehicleMake) {
this.bitrate = capability.getMaxBitrate() * 1000;
} // NOTE: the unit of maxBitrate in getSystemCapability is kbps.
double scale = DEFAULT_SCALE;
// For resolution and scale, the capability values should be taken rather than parameters specified by developers.
if (capability.getScale() != null) {
scale = capability.getScale();
}
Expand All @@ -197,6 +208,9 @@ public void update(VideoStreamingCapability capability, String vehicleMake) {
// This should be the last call as it will return out once a suitable format is found
final List<VideoStreamingFormat> formats = capability.getSupportedFormats();
if (formats != null && formats.size() > 0) {
if (this.format != null && formats.contains(this.format)) {
return; // given format is supported, so no need to change.
}
for (VideoStreamingFormat format : formats) {
for (VideoStreamingFormat currentlySupportedFormat : currentlySupportedFormats) {
if (currentlySupportedFormat.equals(format)) {
Expand Down