summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java50
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java31
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java71
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java11
4 files changed, 157 insertions, 6 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
index 1a9d051a6..be96d7c62 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -5,11 +5,13 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.CopyOnWriteArrayList;
import android.annotation.SuppressLint;
+import android.app.Service;
import android.os.Build;
import android.util.Log;
import android.view.Surface;
@@ -22,6 +24,10 @@ import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitor;
import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitorListener;
import com.smartdevicelink.proxy.LockScreenManager;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.security.ISecurityInitializedListener;
import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.streaming.IStreamListener;
@@ -51,6 +57,11 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
SdlEncoder mSdlEncoder = null;
private final static int BUFF_READ_SIZE = 1024;
private int sessionHashId = 0;
+ private HashMap<SessionType, ISdlServiceListener> serviceListeners;
+ private ImageResolution desiredResolution = null;
+ private VideoStreamingFormat desiredFormat = null;
+ private ImageResolution acceptedResolution = null;
+ private VideoStreamingFormat acceptedFormat = null;
public static SdlSession createSession(byte wiproVersion, ISdlConnectionListener listener, BaseTransportConfig btConfig) {
@@ -596,4 +607,43 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public static boolean removeConnection(SdlConnection connection){
return shareConnections.remove(connection);
}
+
+ public void setServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceListeners == null){
+ serviceListeners = new HashMap<>();
+ }
+ if(serviceType != null && sdlServiceListener != null){
+ serviceListeners.put(serviceType, sdlServiceListener);
+ }
+ }
+
+ public HashMap<SessionType, ISdlServiceListener> getServiceListeners(){
+ return serviceListeners;
+ }
+
+ public void setDesiredVideoConfig(ImageResolution desiredResolution, VideoStreamingFormat desiredFormat){
+ this.desiredResolution = desiredResolution;
+ this.desiredFormat = desiredFormat;
+ }
+
+ public VideoStreamingFormat getDesiredVideoFormat(){
+ return desiredFormat;
+ }
+
+ public ImageResolution getDesiredVideoResolution(){
+ return desiredResolution;
+ }
+
+ public void setAcceptedVideoConfig(ImageResolution acceptedResolution, VideoStreamingFormat acceptedFormat){
+ this.acceptedResolution = acceptedResolution;
+ this.acceptedFormat = acceptedFormat;
+ }
+
+ public VideoStreamingFormat getAcceptedVideoFormat(){
+ return acceptedFormat;
+ }
+
+ public ImageResolution getAcceptedVideoResolution(){
+ return acceptedResolution;
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
index 37ed19aae..347d6d58e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
@@ -9,6 +9,10 @@ import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
import com.smartdevicelink.protocol.enums.FrameType;
import com.smartdevicelink.protocol.enums.MessageType;
import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.util.BitConverter;
import com.smartdevicelink.util.DebugTool;
@@ -468,6 +472,17 @@ public class WiProProtocol extends AbstractProtocol {
//At this point we have confirmed the negotiated version between the module and the proxy
protocolVersion = new Version((String)version);
}
+ }else if(serviceType.equals(SessionType.NAV)){
+ SdlSession session = sdlconn.findSessionById((byte) packet.sessionId);
+ ImageResolution acceptedResolution = new ImageResolution();
+ VideoStreamingFormat acceptedFormat = new VideoStreamingFormat();
+ acceptedResolution.setResolutionHeight((Integer) packet.getTag(ControlFrameTags.Video.StartServiceACK.HEIGHT));
+ acceptedResolution.setResolutionWidth((Integer) packet.getTag(ControlFrameTags.Video.StartServiceACK.WIDTH));
+ acceptedFormat.setCodec((VideoStreamingCodec) packet.getTag(ControlFrameTags.Video.StartServiceACK.VIDEO_CODEC));
+ acceptedFormat.setProtocol((VideoStreamingProtocol) packet.getTag(ControlFrameTags.Video.StartServiceACK.VIDEO_PROTOCOL));
+ if(session != null) {
+ session.setAcceptedVideoConfig(acceptedResolution, acceptedFormat);
+ }
}
}else{
if (protocolVersion.getMajor() > 1){
@@ -575,7 +590,21 @@ public class WiProProtocol extends AbstractProtocol {
public void StartProtocolService(SessionType sessionType, byte sessionID, boolean isEncrypted) {
SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, getMajorVersionByte(), sessionID, isEncrypted);
if(sessionType.equals(SessionType.NAV)){
- // TODO: Add bson tags for video service
+ SdlSession videoSession = sdlconn.findSessionById(sessionID);
+ ImageResolution desiredResolution = null;
+ VideoStreamingFormat desiredFormat = null;
+ if(videoSession != null){
+ desiredResolution = videoSession.getDesiredVideoResolution();
+ desiredFormat = videoSession.getDesiredVideoFormat();
+ if(desiredResolution != null){
+ header.putTag(ControlFrameTags.Video.StartService.WIDTH, desiredResolution.getResolutionWidth());
+ header.putTag(ControlFrameTags.Video.StartService.HEIGHT, desiredResolution.getResolutionHeight());
+ }
+ if(desiredFormat != null){
+ header.putTag(ControlFrameTags.Video.StartService.VIDEO_CODEC, desiredFormat.getCodec().toString());
+ header.putTag(ControlFrameTags.Video.StartService.VIDEO_PROTOCOL, desiredFormat.getProtocol().toString());
+ }
+ }
}
handlePacketToSend(header);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 08a3fba58..efaff9496 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -58,6 +58,7 @@ import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
import com.smartdevicelink.proxy.rpc.*;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
@@ -83,6 +84,8 @@ import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.SystemContext;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
@@ -333,9 +336,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
RPCProtectedServiceStarted();
}
} else if (sessionType.eq(SessionType.NAV)) {
- NavServiceStarted();
+ NavServiceStarted(isEncrypted);
} else if (sessionType.eq(SessionType.PCM)) {
- AudioServiceStarted();
+ AudioServiceStarted(isEncrypted);
} else if (sessionType.eq(SessionType.RPC)){
cycleProxy(SdlDisconnectedReason.RPC_SESSION_ENDED);
}
@@ -3509,7 +3512,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
public ScheduledExecutorService createScheduler(){
return Executors.newSingleThreadScheduledExecutor();
- }
+ }
+
+ public void startService(SessionType serviceType, boolean isEncrypted){
+ sdlSession.startService(serviceType, sdlSession.getSessionId(), isEncrypted);
+ }
+
+ public void endService(SessionType serviceType){
+ sdlSession.endService(serviceType, sdlSession.getSessionId());
+ }
+
+ public void setVideoConfig(ImageResolution desiredResolution, VideoStreamingFormat desiredFormat){
+ sdlSession.setVideoConfig(desiredResolution, desiredFormat);
+ }
/**
*Opens the video service (serviceType 11) and subsequently streams raw H264 video from an InputStream provided by the app
@@ -3806,19 +3821,31 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sdlSession.drainEncoder(endOfStream);
}
- private void NavServiceStarted() {
+ private void NavServiceStarted(boolean isEncrypted) {
navServiceStartResponseReceived = true;
navServiceStartResponse = true;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.NAV)){
+ sdlSession.getServiceListeners().get(SessionType.NAV).onServiceStarted(sdlSession, SessionType.NAV, isEncrypted);
+ }
}
private void NavServiceStartedNACK() {
navServiceStartResponseReceived = true;
navServiceStartResponse = false;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.NAV)){
+ sdlSession.getServiceListeners().get(SessionType.NAV).onServiceError(sdlSession, SessionType.NAV, "Start NAV Service NACK'ed");
+ }
}
- private void AudioServiceStarted() {
+ private void AudioServiceStarted(boolean isEncrypted) {
pcmServiceStartResponseReceived = true;
pcmServiceStartResponse = true;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.PCM)){
+ sdlSession.getServiceListeners().get(SessionType.PCM).onServiceStarted(sdlSession, SessionType.PCM, isEncrypted);
+ }
}
private void RPCProtectedServiceStarted() {
@@ -3828,26 +3855,46 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private void AudioServiceStartedNACK() {
pcmServiceStartResponseReceived = true;
pcmServiceStartResponse = false;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.PCM)){
+ sdlSession.getServiceListeners().get(SessionType.PCM).onServiceError(sdlSession, SessionType.PCM, "Start PCM Service NACK'ed");
+ }
}
private void NavServiceEnded() {
navServiceEndResponseReceived = true;
navServiceEndResponse = true;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.NAV)){
+ sdlSession.getServiceListeners().get(SessionType.NAV).onServiceEnded(sdlSession, SessionType.NAV);
+ }
}
private void NavServiceEndedNACK() {
navServiceEndResponseReceived = true;
navServiceEndResponse = false;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.NAV)){
+ sdlSession.getServiceListeners().get(SessionType.NAV).onServiceError(sdlSession, SessionType.NAV, "End NAV Service NACK'ed");
+ }
}
private void AudioServiceEnded() {
pcmServiceEndResponseReceived = true;
pcmServiceEndResponse = true;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.PCM)){
+ sdlSession.getServiceListeners().get(SessionType.PCM).onServiceEnded(sdlSession, SessionType.PCM);
+ }
}
private void AudioServiceEndedNACK() {
pcmServiceEndResponseReceived = true;
pcmServiceEndResponse = false;
+
+ if(sdlSession.getServiceListeners().containsKey(SessionType.PCM)){
+ sdlSession.getServiceListeners().get(SessionType.PCM).onServiceError(sdlSession, SessionType.PCM, "End PCM Service NACK'ed");
+ }
}
public void setAppService(Service mService)
@@ -5563,6 +5610,20 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
return sdlSession.isServiceProtected(sType);
}
+
+ public void setServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceType != null && sdlSession != null && sdlServiceListener != null){
+ sdlSession.setServiceListener(serviceType, sdlServiceListener);
+ }
+ }
+
+ public ImageResolution getAcceptedVideoResolution(){
+ return sdlSession.getAcceptedVideoResolution();
+ }
+
+ public VideoStreamingFormat getAcceptedVideoFormat(){
+ return sdlSession.getAcceptedVideoFormat();
+ }
public IProxyListenerBase getProxyListener()
{
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java
new file mode 100644
index 000000000..db5179a73
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java
@@ -0,0 +1,11 @@
+package com.smartdevicelink.proxy.interfaces;
+
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.enums.SessionType;
+
+public interface ISdlServiceListener {
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted);
+ public void onServiceEnded(SdlSession session, SessionType type);
+ public void onServiceError(SdlSession session, SessionType type, String reason);
+}