Skip to content

Commit 98d80bb

Browse files
committed
Fix #1110
1 parent 89f5c6f commit 98d80bb

4 files changed

Lines changed: 61 additions & 25 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,18 @@ public void removeServiceListener(SessionType serviceType, ISdlServiceListener s
737737
@Override
738738
public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) {
739739
if(proxy.getIsConnected()){
740-
proxy.startVideoStream(encrypted,parameters);
740+
proxy.startVideoService(encrypted,parameters);
741741
}
742742
}
743743

744744
@Override
745745
public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters){
746-
return proxy.startVideoStream(isEncrypted, parameters);
746+
if(proxy.getIsConnected()){
747+
return proxy.startVideoStream(isEncrypted, parameters);
748+
}else{
749+
DebugTool.logError("Unable to start video stream, proxy not connected");
750+
return null;
751+
}
747752
}
748753

749754
@Override

android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import com.smartdevicelink.streaming.video.SdlRemoteDisplay;
7070
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
7171
import com.smartdevicelink.transport.utl.TransportRecord;
72+
import com.smartdevicelink.util.DebugTool;
7273
import com.smartdevicelink.util.Version;
7374

7475
import java.lang.ref.WeakReference;
@@ -101,12 +102,13 @@ public class VideoStreamManager extends BaseVideoStreamManager {
101102
@Override
102103
public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
103104
if(SessionType.NAV.equals(type)){
104-
if(session != null && session.getAcceptedVideoParams() != null){
105+
if (session != null && session.getAcceptedVideoParams() != null) {
105106
parameters = session.getAcceptedVideoParams();
107+
VideoStreamManager.this.streamListener = session.startVideoStream();
106108
}
107-
VideoStreamManager.this.streamListener = internalInterface.startVideoStream(isEncrypted, parameters);
108-
if(streamListener == null){
109-
Log.e(TAG, "Error starting video service");
109+
110+
if (VideoStreamManager.this.streamListener == null) {
111+
Log.e(TAG, "Error starting video stream");
110112
stateMachine.transitionToState(StreamingStateMachine.ERROR);
111113
return;
112114
}
@@ -132,6 +134,7 @@ public void onServiceEnded(SdlSession session, SessionType type) {
132134

133135
@Override
134136
public void onServiceError(SdlSession session, SessionType type, String reason) {
137+
DebugTool.logError("Unable to start video service: " + reason);
135138
stateMachine.transitionToState(StreamingStateMachine.ERROR);
136139
transitionToState(BaseSubManager.ERROR);
137140
}
@@ -302,7 +305,6 @@ protected void startStreaming(VideoStreamingParameters parameters, boolean encry
302305
//Start the video service
303306
this.internalInterface.startVideoService(parameters, encrypted);
304307

305-
306308
}
307309

308310
/**
@@ -477,10 +479,14 @@ public void run() {
477479
}
478480
} ));
479481
Thread showPresentation = new Thread(fTask);
482+
showPresentation.setName("RmtDispThread");
480483

481484
showPresentation.start();
482485
} catch (Exception ex) {
483486
Log.e(TAG, "Unable to create Virtual Display.");
487+
if(DebugTool.isDebugEnabled()){
488+
ex.printStackTrace();
489+
}
484490
}
485491
}
486492

android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5296,6 +5296,27 @@ public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreaming
52965296
}
52975297
}
52985298

5299+
/**
5300+
* This method will try to start the video service with the requested parameters.
5301+
* When it returns it will attempt to store the accepted parameters if available.
5302+
* @param isEncrypted if the service should be encrypted
5303+
* @param parameters the desiered video streaming parameters
5304+
*/
5305+
public void startVideoService(boolean isEncrypted, VideoStreamingParameters parameters) {
5306+
if (sdlSession == null) {
5307+
DebugTool.logWarning("SdlSession is not created yet.");
5308+
return;
5309+
}
5310+
if (!sdlSession.getIsConnected()) {
5311+
DebugTool.logWarning("Connection is not available.");
5312+
return;
5313+
}
5314+
5315+
sdlSession.setDesiredVideoParams(parameters);
5316+
5317+
tryStartVideoStream(isEncrypted, parameters);
5318+
}
5319+
52995320
/**
53005321
*Closes the opened video service (serviceType 11)
53015322
*@return true if the video service is closed successfully, return false otherwise

base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,27 +1046,31 @@ protected void handleProtocolSessionStarted(SdlPacket packet, SessionType servic
10461046
}
10471047
}
10481048
} else {
1049-
TransportRecord transportRecord = packet.getTransportRecord();
1050-
if(transportRecord == null || (requiresHighBandwidth
1051-
&& TransportType.BLUETOOTH.equals(transportRecord.getType()))){
1052-
//transport can't support high bandwidth
1053-
onTransportNotAccepted((transportRecord != null ? transportRecord.getType().toString() : "Transport") + "can't support high bandwidth requirement, and secondary transport not supported in this protocol version");
1054-
return;
1055-
}
1056-
//If version < 5 and transport is acceptable we need to just add these
1057-
activeTransports.put(SessionType.RPC, transportRecord);
1058-
activeTransports.put(SessionType.BULK_DATA, transportRecord);
1059-
activeTransports.put(SessionType.CONTROL, transportRecord);
1060-
activeTransports.put(SessionType.NAV, transportRecord);
1061-
activeTransports.put(SessionType.PCM, transportRecord);
1062-
1063-
if (protocolVersion.getMajor() > 1){
1064-
if (packet.payload!= null && packet.dataSize == 4){ //hashid will be 4 bytes in length
1065-
hashID = BitConverter.intFromByteArray(packet.payload, 0);
1049+
if(serviceType.equals(SessionType.RPC)) {
1050+
TransportRecord transportRecord = packet.getTransportRecord();
1051+
if (transportRecord == null || (requiresHighBandwidth
1052+
&& TransportType.BLUETOOTH.equals(transportRecord.getType()))) {
1053+
//transport can't support high bandwidth
1054+
onTransportNotAccepted((transportRecord != null ? transportRecord.getType().toString() : "Transport ") + "can't support high bandwidth requirement, and secondary transport not supported in this protocol version");
1055+
return;
10661056
}
1057+
//If version < 5 and transport is acceptable we need to just add these
1058+
activeTransports.put(SessionType.RPC, transportRecord);
1059+
activeTransports.put(SessionType.BULK_DATA, transportRecord);
1060+
activeTransports.put(SessionType.CONTROL, transportRecord);
1061+
activeTransports.put(SessionType.NAV, transportRecord);
1062+
activeTransports.put(SessionType.PCM, transportRecord);
1063+
1064+
if (protocolVersion.getMajor() > 1) {
1065+
if (packet.payload != null && packet.dataSize == 4) { //hashid will be 4 bytes in length
1066+
hashID = BitConverter.intFromByteArray(packet.payload, 0);
1067+
}
1068+
}
1069+
}else if(serviceType.equals(SessionType.NAV)) {
1070+
//Protocol versions <5 don't support param negotiation
1071+
iSdlProtocol.setAcceptedVideoParams(iSdlProtocol.getDesiredVideoParams());
10671072
}
10681073
}
1069-
10701074
iSdlProtocol.onProtocolSessionStarted(serviceType, (byte) packet.getSessionId(), (byte)protocolVersion.getMajor(), "", hashID, packet.isEncrypted());
10711075
}
10721076

0 commit comments

Comments
 (0)