Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions android/hello_sdl_android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ android {
targetSdkVersion 31
versionCode 1
versionName "1.0"
buildConfigField 'String', 'APP_TYPE', '"DEFAULT"'
buildConfigField 'String', 'REQUIRE_AUDIO_OUTPUT', '"FALSE"'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
Expand Down Expand Up @@ -42,6 +44,13 @@ android {
buildConfigField 'String', 'TRANSPORT', '"TCP"'
buildConfigField 'String', 'SECURITY', '"OFF"'
}
requiresAudioOutput {
buildConfigField 'String', 'TRANSPORT', '"MULTI"'
buildConfigField 'String', 'SECURITY', '"OFF"'
buildConfigField 'String', 'APP_TYPE', '"MEDIA"'
buildConfigField 'String', 'REQUIRE_AUDIO_OUTPUT', '"TRUE"'

}
}
lintOptions {
disable 'GoogleAppIndexingWarning'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ private void startProxy() {
securityLevel = MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF;
}
transport = new MultiplexTransportConfig(this, APP_ID, securityLevel);
if (BuildConfig.REQUIRE_AUDIO_OUTPUT.equals("TRUE") ) {
((MultiplexTransportConfig)transport).setRequiresAudioSupport(true);
}
} else if (BuildConfig.TRANSPORT.equals("TCP")) {
transport = new TCPTransportConfig(TCP_PORT, DEV_MACHINE_IP_ADDRESS, true);
} else if (BuildConfig.TRANSPORT.equals("MULTI_HB")) {
Expand All @@ -172,7 +175,8 @@ private void startProxy() {

// The app type to be used
Vector<AppHMIType> appType = new Vector<>();
appType.add(AppHMIType.DEFAULT);
appType.add(AppHMIType.valueForString(BuildConfig.APP_TYPE));


// The manager listener helps you know when certain events that pertain to the SDL Manager happen
// Here we will listen for ON_HMI_STATUS and ON_COMMAND notifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.smartdevicelink.transport.utl.TransportRecord;
import com.smartdevicelink.util.AndroidTools;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.MediaStreamingStatus;

import java.lang.ref.WeakReference;
import java.util.List;
Expand All @@ -80,7 +81,17 @@ void initialize() {

synchronized (SESSION_LOCK) {
if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig);
MultiplexTransportConfig multiplexTransportConfig = (MultiplexTransportConfig) _transportConfig;
this.session = new SdlSession(sdlSessionListener, multiplexTransportConfig);
if (multiplexTransportConfig.requiresAudioSupport()) {
this.session.setMediaStreamingStatusCallback(new MediaStreamingStatus.Callback() {
@Override
public void onAudioNoLongerAvailable() {
clean(true);
onClose("Audio output no longer available", null, SdlDisconnectedReason.DEFAULT);
}
});
}
} else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) {
this.session = new SdlSession(sdlSessionListener, (TCPTransportConfig) _transportConfig);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class SdlSession extends BaseSdlSession {
WeakReference<Context> contextWeakReference;
MediaStreamingStatus mediaStreamingStatus;
boolean requiresAudioSupport = false;
MediaStreamingStatus.Callback mediaStreamingStatusCallback;

public SdlSession(ISdlSessionListener listener, MultiplexTransportConfig config) {
super(listener, config);
Expand All @@ -79,6 +80,17 @@ public SdlSession(ISdlSessionListener listener, TCPTransportConfig config) {
this.sessionListener = listener;
}

/**
* Sets a callback that is triggered when there are no audio output methods available. If this
* is set then the caller of this method will be responsible for shutting the session down.
*
* @param mediaStreamingStatusCallback the callback that will be triggered when audio output is
* no longer available.
*/
public void setMediaStreamingStatusCallback(MediaStreamingStatus.Callback mediaStreamingStatusCallback) {
this.mediaStreamingStatusCallback = mediaStreamingStatusCallback;
}

protected SdlProtocolBase getSdlProtocolImplementation() {
if (transportConfig instanceof MultiplexTransportConfig) {
return new SdlProtocol(this, (MultiplexTransportConfig) transportConfig);
Expand All @@ -94,8 +106,12 @@ boolean isAudioRequirementMet() {
mediaStreamingStatus = new MediaStreamingStatus(contextWeakReference.get(), new MediaStreamingStatus.Callback() {
@Override
public void onAudioNoLongerAvailable() {
close();
shutdown("Audio output no longer available");
if (mediaStreamingStatusCallback != null) {
mediaStreamingStatusCallback.onAudioNoLongerAvailable();
} else {
close();
shutdown("Audio output no longer available");
}
}
});
}
Expand Down