summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkos Rapitis <mrapitis@ford.com>2015-04-29 10:54:32 -0400
committerMarkos Rapitis <mrapitis@ford.com>2015-04-29 10:54:32 -0400
commit453d028b7132e817502831e68d5da41257893e6a (patch)
tree9bee699d218ceee0ebc2d6bbb4fdc10d16c4d585
parentf8c8d4fddc393481fb0ac26d32fd27030f5e0aea (diff)
downloadsdl_android-453d028b7132e817502831e68d5da41257893e6a.tar.gz
Added basic javadocs and more error checking for video and audio services.
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java40
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java84
2 files changed, 90 insertions, 34 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
index 169db3f40..64020cf21 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
@@ -1,6 +1,7 @@
package com.smartdevicelink.SdlConnection;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
@@ -233,8 +234,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
public TransportType getCurrentTransportType() {
return _transport.getTransportType();
}
- public void startStream(InputStream is, SessionType sType, byte rpcSessionID) {
- try {
+ public void startStream(InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
if (sType.equals(SessionType.NAV))
{
mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
@@ -246,14 +246,10 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
mAudioPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
mAudioPacketizer.sdlConnection = this;
mAudioPacketizer.start();
- }
- } catch (Exception e) {
- Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
- }
+ }
}
- public OutputStream startStream(SessionType sType, byte rpcSessionID) {
- try {
+ public OutputStream startStream(SessionType sType, byte rpcSessionID) throws IOException {
OutputStream os = new PipedOutputStream();
InputStream is = new PipedInputStream((PipedOutputStream) os, BUFF_READ_SIZE);
@@ -276,10 +272,6 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
return null;
}
return os;
- } catch (Exception e) {
- Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
- }
- return null;
}
@@ -330,52 +322,64 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
}
- public void stopAudioStream()
+ public boolean stopAudioStream()
{
if (mAudioPacketizer != null)
{
mAudioPacketizer.stop();
+ return true;
}
+ return false;
}
- public void stopVideoStream()
+ public boolean stopVideoStream()
{
if (mVideoPacketizer != null)
{
mVideoPacketizer.stop();
+ return true;
}
+ return false;
}
- public void pauseAudioStream()
+ public boolean pauseAudioStream()
{
if (mAudioPacketizer != null)
{
mAudioPacketizer.pause();
+ return true;
}
+ return false;
}
- public void pauseVideoStream()
+ public boolean pauseVideoStream()
{
if (mVideoPacketizer != null)
{
mVideoPacketizer.pause();
+ return true;
}
+ return false;
}
- public void resumeAudioStream()
+ public boolean resumeAudioStream()
{
if (mAudioPacketizer != null)
{
mAudioPacketizer.resume();
+ return true;
}
+ return false;
}
- public void resumeVideoStream()
+ public boolean resumeVideoStream()
{
if (mVideoPacketizer != null)
{
mVideoPacketizer.resume();
+ return true;
}
+ return false;
}
@Override
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
index f771bcefa..f70bf4f43 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -2892,8 +2892,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
-
-
+ /**
+ *Opens the video service (serviceType 11) and subsequently streams raw H264 video from an InputStream provided by the app
+ *@return true if service is opened successfully and stream is started, return false otherwise
+ */
public boolean startH264(InputStream is) {
if (sdlSession == null) return false;
@@ -2914,13 +2916,21 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
fTask = null;
if (navServiceStartResponse) {
- sdlConn.startStream(is, SessionType.NAV, sdlSession.getSessionId());
- return true;
+ try {
+ sdlConn.startStream(is, SessionType.NAV, sdlSession.getSessionId());
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
} else {
return false;
}
}
+ /**
+ *Opens the video service (serviceType 11) and subsequently provides an OutputStream to the app to use for a raw H264 video stream
+ *@return OutputStream if service is opened successfully and stream is started, return null otherwise
+ */
public OutputStream startH264() {
if (sdlSession == null) return null;
@@ -2941,12 +2951,20 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
fTask = null;
if (navServiceStartResponse) {
- return sdlConn.startStream(SessionType.NAV, sdlSession.getSessionId());
+ try {
+ return sdlConn.startStream(SessionType.NAV, sdlSession.getSessionId());
+ } catch (Exception e) {
+ return null;
+ }
} else {
return null;
}
}
+ /**
+ *Closes the opened video service (serviceType 11)
+ *@return true if the video service is closed successfully, return false otherwise
+ */
public boolean endH264() {
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
@@ -2972,42 +2990,59 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
+ /**
+ *Pauses the stream for the opened audio service (serviceType 10)
+ *@return true if the audio service stream is paused successfully, return false otherwise
+ */
public boolean pausePCM()
{
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return false;
- sdlConn.pauseAudioStream();
- return true;
+ return sdlConn.pauseAudioStream();
}
+ /**
+ *Pauses the stream for the opened video service (serviceType 11)
+ *@return true if the video service stream is paused successfully, return false otherwise
+ */
public boolean pauseH264()
{
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return false;
- sdlConn.pauseVideoStream();
- return true;
+ return sdlConn.pauseVideoStream();
}
+ /**
+ *Resumes the stream for the opened audio service (serviceType 10)
+ *@return true if the audio service stream is resumed successfully, return false otherwise
+ */
public boolean resumePCM()
{
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return false;
- sdlConn.resumeAudioStream();
- return true;
+ return sdlConn.resumeAudioStream();
}
+ /**
+ *Resumes the stream for the opened video service (serviceType 11)
+ *@return true if the video service is resumed successfully, return false otherwise
+ */
public boolean resumeH264()
{
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return false;
- sdlConn.resumeVideoStream();
- return true;
+ return sdlConn.resumeVideoStream();
}
+
+ /**
+ *Opens the audio service (serviceType 10) and subsequently streams raw PCM audio from an InputStream provided by the app
+ *@return true if service is opened successfully and stream is started, return false otherwise
+ */
public boolean startPCM(InputStream is) {
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();
@@ -3028,13 +3063,21 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
fTask = null;
if (pcmServiceStartResponse) {
- sdlConn.startStream(is, SessionType.PCM, sdlSession.getSessionId());
- return true;
+ try {
+ sdlConn.startStream(is, SessionType.PCM, sdlSession.getSessionId());
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
} else {
return false;
}
}
+ /**
+ *Opens the audio service (serviceType 10) and subsequently provides an OutputStream to the app
+ *@return OutputStream if service is opened successfully and stream is started, return null otherwise
+ */
public OutputStream startPCM() {
if (sdlSession == null) return null;
SdlConnection sdlConn = sdlSession.getSdlConnection();
@@ -3053,11 +3096,20 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
fTask = null;
if (pcmServiceStartResponse) {
- return sdlConn.startStream(SessionType.PCM, sdlSession.getSessionId());
+ try {
+ return sdlConn.startStream(SessionType.PCM, sdlSession.getSessionId());
+ } catch (Exception e) {
+ return null;
+ }
} else {
return null;
}
}
+
+ /**
+ *Closes the opened audio service (serviceType 10)
+ *@return true if the audio service is closed successfully, return false otherwise
+ */
public boolean endPCM() {
if (sdlSession == null) return false;
SdlConnection sdlConn = sdlSession.getSdlConnection();