summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergii Kurylo <x0156751@ti.com>2013-04-02 11:50:17 +0000
committerSergii Kurylo <x0156751@ti.com>2013-04-04 11:34:45 +0000
commit24d301cee05dd48c157e1a49ddd103ef408f7e5f (patch)
tree3d9fa1fa8489cdbf98dbc0ee917c71f0556719e7
parent7c3c3a252517b94e97bd461477bc19121187831b (diff)
downloadcommon-open-24d301cee05dd48c157e1a49ddd103ef408f7e5f.tar.gz
WFD: WfdSinkLib conversion to dynamic java library
This patch converts WfdSinkLib to dynamic java library. WfdSinkActivity class removed from library to move application functionality to application itself. Unnecessary native functions removed. Unnecessary constants removed. All remaining classes were moved to com.ti.omap.android.wfd.sink namespace. RtspSink class was renamed to WfdSink. RtspStateListener was renamed to WfdStateListener. WfdSinkException added WFD role check moved from application to WfdSink class. Change-Id: I9d081d034ec0b13728a15e3aa01a509be3b8af6f Signed-off-by: Sergii Kurylo <x0156751@ti.com>
-rw-r--r--wfd/WfdSinkLib/Android.mk4
-rw-r--r--wfd/WfdSinkLib/jni/Android.mk4
-rw-r--r--wfd/WfdSinkLib/jni/wfdsink_jni.cpp (renamed from wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp)49
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSink.java (renamed from wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspSink.java)32
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkRoleException.java23
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkSurfaceView.java (renamed from wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkSurfaceView.java)2
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkTools.java (renamed from wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkTools.java)28
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdStateListener.java5
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java412
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspStateListener.java5
-rw-r--r--wfd/configs/com.ti.wfd.xml5
-rw-r--r--wfd/wfd-products.mk3
12 files changed, 94 insertions, 478 deletions
diff --git a/wfd/WfdSinkLib/Android.mk b/wfd/WfdSinkLib/Android.mk
index cbd9f35..3ef2c72 100644
--- a/wfd/WfdSinkLib/Android.mk
+++ b/wfd/WfdSinkLib/Android.mk
@@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := WfdSinkLib
+LOCAL_MODULE := com.ti.wfd
LOCAL_MODULE_TAGS := optional
@@ -10,6 +10,6 @@ LOCAL_REQUIRED_MODULES := librtspsink_jni
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-include $(BUILD_STATIC_JAVA_LIBRARY)
+include $(BUILD_JAVA_LIBRARY)
include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/wfd/WfdSinkLib/jni/Android.mk b/wfd/WfdSinkLib/jni/Android.mk
index 8a72e8c..fce1d26 100644
--- a/wfd/WfdSinkLib/jni/Android.mk
+++ b/wfd/WfdSinkLib/jni/Android.mk
@@ -11,7 +11,7 @@ LOCAL_C_INCLUDES := . \
$(TOP)/frameworks/av/include/media/stagefright/foundation \
$(TOP)/frameworks/av/media/libstagefright/wifi-display
-LOCAL_SRC_FILES := rtsp_sink_jni.cpp \
+LOCAL_SRC_FILES := wfdsink_jni.cpp \
LOCAL_SHARED_LIBRARIES := libcutils \
libutils \
@@ -21,6 +21,6 @@ LOCAL_SHARED_LIBRARIES := libcutils \
libstagefright_foundation \
libstagefright_wfd
-LOCAL_MODULE := librtspsink_jni
+LOCAL_MODULE := libwfdsink_jni
include $(BUILD_SHARED_LIBRARY)
diff --git a/wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp b/wfd/WfdSinkLib/jni/wfdsink_jni.cpp
index 22712ed..1c2a18b 100644
--- a/wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp
+++ b/wfd/WfdSinkLib/jni/wfdsink_jni.cpp
@@ -33,7 +33,7 @@
#include <sink/WifiDisplaySink.h>
-#define LOG_TAG "rtspsink_jni"
+#define LOG_TAG "wfdsink_jni"
using namespace android;
@@ -75,7 +75,7 @@ NativeRtspStateListener::NativeRtspStateListener(JavaVM *jvm, jobject listener)
return;
}
mListener = e->NewGlobalRef(listener);
- jclass listenerClass = e->FindClass("com/ti/omap/android/wfd/sink/rtsp/RtspStateListener");
+ jclass listenerClass = e->FindClass("com/ti/omap/android/wfd/sink/WfdStateListener");
mOnStateChangedId = e->GetMethodID(listenerClass, "onStateChanged", "(I)V");
}
@@ -158,7 +158,7 @@ static sp<ISurfaceTexture> getSurface(JNIEnv *e, jobject thisObj,
return new_st;
}
-jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_connect(JNIEnv *e,
+jboolean Java_com_ti_omap_android_wfd_sink_WfdSink_connect(JNIEnv *e,
jobject thisObj, jobject jSurface, jstring url) {
char *utfUrl = (char*) e->GetStringUTFChars(url, JNI_FALSE);
@@ -202,7 +202,7 @@ jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_connect(JNIEnv *e,
return JNI_TRUE;
}
-jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_disconnect(JNIEnv *e,
+jboolean Java_com_ti_omap_android_wfd_sink_WfdSink_disconnect(JNIEnv *e,
jobject thisObj) {
// TODO implement rtsp disconnect
jboolean result = JNI_TRUE;
@@ -210,7 +210,7 @@ jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_disconnect(JNIEnv *e,
return result;
}
-jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_play(JNIEnv *e,
+jboolean Java_com_ti_omap_android_wfd_sink_WfdSink_play(JNIEnv *e,
jobject thisObj) {
jboolean result = JNI_TRUE;
ALOGI("Sink. play");
@@ -220,7 +220,7 @@ jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_play(JNIEnv *e,
return result;
}
-jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_pause(JNIEnv *e,
+jboolean Java_com_ti_omap_android_wfd_sink_WfdSink_pause(JNIEnv *e,
jobject thisObj) {
jboolean result = JNI_TRUE;
ALOGI("Sink. pause");
@@ -230,7 +230,7 @@ jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_pause(JNIEnv *e,
return result;
}
-jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_teardown(JNIEnv *e,
+jboolean Java_com_ti_omap_android_wfd_sink_WfdSink_teardown(JNIEnv *e,
jobject thisObj) {
jboolean result = JNI_TRUE;
ALOGI("Sink. teardown");
@@ -240,14 +240,7 @@ jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_teardown(JNIEnv *e,
return result;
}
-jstring Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_getMediaInfo(JNIEnv *e,
- jobject thisObj) {
- AString mediaInfo("dummy media info");
- jstring result = e->NewStringUTF(mediaInfo.c_str());
- return result;
-}
-
-void Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_setStateListener(JNIEnv *e,
+void Java_com_ti_omap_android_wfd_sink_WfdSink_setStateListener(JNIEnv *e,
jobject thisObj,
jobject listenerObj) {
ALOGV("Setting java listener");
@@ -262,7 +255,7 @@ void Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_setStateListener(JNIEnv *e,
}
}
-void Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_removeStateListener(JNIEnv *e,
+void Java_com_ti_omap_android_wfd_sink_WfdSink_removeStateListener(JNIEnv *e,
jobject thisObj) {
ALOGV("Removing java listener");
if (sink != NULL) {
@@ -270,23 +263,21 @@ void Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_removeStateListener(JNIEnv
}
}
-static JNINativeMethod rtspSinkMethods[] = { { "connect",
+static JNINativeMethod wfdSinkMethods[] = { { "connect",
"(Landroid/view/Surface;Ljava/lang/String;)Z",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_connect }, {
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_connect }, {
"disconnect", "()Z",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_disconnect }, {
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_disconnect }, {
"play", "()Z",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_play }, {
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_play }, {
"pause", "()Z",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_pause }, {
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_pause }, {
"teardown", "()Z",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_teardown }, {
- "getMediaInfo", "()Ljava/lang/String;",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_getMediaInfo }, {
- "setStateListener", "(Lcom/ti/omap/android/wfd/sink/rtsp/RtspStateListener;)V",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_setStateListener }, {
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_teardown }, {
+ "setStateListener", "(Lcom/ti/omap/android/wfd/sink/WfdStateListener;)V",
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_setStateListener }, {
"removeStateListener", "()V",
- (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_setStateListener }
+ (void*) Java_com_ti_omap_android_wfd_sink_WfdSink_removeStateListener }
};
extern "C" jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
@@ -297,8 +288,8 @@ extern "C" jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
return JNI_ERR;
}
- jniRegisterNativeMethods(e, "com/ti/omap/android/wfd/sink/rtsp/RtspSink",
- rtspSinkMethods, NELEM(rtspSinkMethods));
+ jniRegisterNativeMethods(e, "com/ti/omap/android/wfd/sink/WfdSink",
+ wfdSinkMethods, NELEM(wfdSinkMethods));
return JNI_VERSION_1_4;
}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspSink.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSink.java
index 6073600..041d997 100644
--- a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspSink.java
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSink.java
@@ -13,23 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ti.omap.android.wfd.sink.rtsp;
+package com.ti.omap.android.wfd.sink;
+import android.os.SystemProperties;
import android.view.Surface;
-public class RtspSink {
+public class WfdSink {
- boolean mSigmaActivate;
+ private String mIpAddress;
+ private int mPort;
- public RtspSink(boolean sigmaActivate) {
- mSigmaActivate = sigmaActivate;
+ public WfdSink(String ipAddress, int port) throws WfdSinkRoleException {
+ String wfdRole = SystemProperties.get("persist.wfd.role", "source");
+
+ if (!wfdRole.equalsIgnoreCase("sink")) {
+ throw (new WfdSinkRoleException());
+ }
+
+ mIpAddress = ipAddress;
+ mPort = port;
}
static {
- System.loadLibrary("rtspsink_jni");
+ System.loadLibrary("wfdsink_jni");
}
- public native boolean connect(Surface surface, String url);
+ boolean connect(Surface surface) {
+ String url = mIpAddress + ":" + mPort;
+ return connect(surface, url);
+ }
+
+ private native boolean connect(Surface surface, String url);
public native boolean disconnect();
@@ -39,9 +53,7 @@ public class RtspSink {
public native boolean teardown();
- public native String getMediaInfo();
-
- public native void setStateListener(RtspStateListener listener);
+ public native void setStateListener(WfdStateListener listener);
public native void removeStateListener();
}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkRoleException.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkRoleException.java
new file mode 100644
index 0000000..47994c0
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkRoleException.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ti.omap.android.wfd.sink;
+
+public class WfdSinkRoleException extends Exception {
+ public WfdSinkRoleException() {
+ super("The device is not properly configured to be WFD sink.");
+ }
+}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkSurfaceView.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkSurfaceView.java
index 5500267..322f22c 100644
--- a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkSurfaceView.java
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkSurfaceView.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ti.omap.android.wfd.sink.manager;
+package com.ti.omap.android.wfd.sink;
import android.content.Context;
import android.view.KeyEvent;
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkTools.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkTools.java
index cba6ef0..bb42295 100644
--- a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkTools.java
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdSinkTools.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ti.omap.android.wfd.sink.manager;
+package com.ti.omap.android.wfd.sink;
public class WfdSinkTools {
public static final int STATE_UNDEFINED = -1;
@@ -24,23 +24,19 @@ public class WfdSinkTools {
public static final int STATE_PAUSED = 4;
public static final int STATE_DISCONNECTING = 5;
- public static final int RTSP_COMMAND_PLAY = 6;
- public static final int RTSP_COMMAND_PAUSE = 7;
- public static final int RTSP_COMMAND_CONNECT = 8;
- public static final int RTSP_COMMAND_DISCONNECT = 9;
+ public static final int DEFAULT_RTSP_PORT = 7236;
- public static final int COMMAND_REGISTER = 10;
- public static final int COMMAND_UNREGISTER = 11;
+ public static final String START_SINK_ACTION = "com.ti.wfd.sink.start";
- public static final int COMMAND_PLAY = 12;
- public static final int COMMAND_PAUSE = 13;
- public static final int COMMAND_CONNECT = 14;
- public static final int COMMAND_DISCONNECT = 15;
- public static final int COMMAND_INVOKE_SINK = 16;
-
- public static final int COMMAND_FIND = 17;
-
- public static final String EXTRA_AUTOSTART = "EXTRA_AUTOSTART";
public static final String EXTRA_ADDRESS = "EXTRA_ADDRESS";
public static final String EXTRA_PORT = "EXTRA_PORT";
+
+ public static final String DHCP_ACTION = "com.ti.wfd.dhcp.action";
+
+ public static final String EXTRA_MAC_ADDRESS = "MACAddress";
+ public static final String EXTRA_ACTION = "Action";
+ public static final String EXTRA_IP_ADDRESS = "IPAddress";
+
+ public static final String LEASES_ACTION_OLD = "old";
+ public static final String LEASES_ACTION_ADD = "add";
}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdStateListener.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdStateListener.java
new file mode 100644
index 0000000..608dd7c
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/WfdStateListener.java
@@ -0,0 +1,5 @@
+package com.ti.omap.android.wfd.sink;
+
+public interface WfdStateListener {
+ public void onStateChanged(int newState);
+}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java
deleted file mode 100644
index 2da034e..0000000
--- a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ti.omap.android.wfd.sink.manager;
-
-import com.ti.omap.android.wfd.sink.rtsp.RtspSink;
-import com.ti.omap.android.wfd.sink.rtsp.RtspStateListener;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.os.SystemProperties;
-import android.util.Log;
-import android.view.SurfaceHolder;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-public class WfdSinkActivity extends Activity {
-
- private static final String LOG_TAG = "WfdSinkActivity";
-
- // Messenger for communicating with the service.
- private Messenger mService = null;
-
- // Messenger for receiving responses from service.
- private Messenger mMessenger;
-
- // Flag indicating whether we have called bind on the service.
- private boolean mBound;
-
- private int mState;
- private int mRtspPort;
- private String mUrl;
- private String mIpAddress;
-
- private boolean mIsSigmaActive;
- private boolean mIsAutoStart = true;
- private boolean mIsSink = false;
-
- private WfdSinkSurfaceView mSinkSurfaceView;
- private RtspSink mRtspSink;
- private RtspStateListener mStateListener;
-
- private static final Boolean D = true;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- String wfdRole = SystemProperties.get("persist.wfd.role", "source");
- mIsSink = wfdRole.equalsIgnoreCase("sink");
- if (!mIsSink) {
- AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
- WfdSinkActivity.this);
-
- alertDialogBuilder.setTitle("Wrong WFD role");
- alertDialogBuilder
- .setMessage("This device is not a WFD sink. " +
- "Can't start player now.")
- .setCancelable(false)
- .setPositiveButton("Close",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,int id){
- // Finish player activity
- WfdSinkActivity.this.finish();
- }
- });
- // Create and show warning
- alertDialogBuilder.create().show();
- }
-
- mMessenger = new Messenger(new IncomingHandler());
-
- mSinkSurfaceView = new WfdSinkSurfaceView(getApplicationContext());
-
- mRtspSink = new RtspSink(false);
-
- mState = WfdSinkTools.STATE_IDLE;
- setStateListener(new WfdRtspStateListener());
-
- mBound = false;
- }
-
- @Override
- public void onStart() {
- super.onStart();
- connectService();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- // Unbind from the service
- if (mBound) {
- Message msg = Message.obtain(null, WfdSinkTools.COMMAND_UNREGISTER,
- 0, 0, null);
- try {
- mService.send(msg);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- unbindService(mConnection);
- mBound = false;
- }
-
- removeStateListener();
- }
-
- @Override
- public void onRestart() {
- super.onRestart();
- if ((mRtspSink != null) && (mStateListener != null)) {
- mRtspSink.setStateListener(mStateListener);
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- pause();
- }
-
- public boolean placeView(int resouceId) {
- if (mSinkSurfaceView == null) {
- Log.e(LOG_TAG, "Cannot place null surface view");
- return false;
- }
- try {
- ViewGroup parent = (ViewGroup) findViewById(resouceId);
- parent.addView(mSinkSurfaceView);
- } catch (ClassCastException ex) {
- Log.e(LOG_TAG, "Cannot cast provided view to viewgroup");
- return false;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
-
- private void connectService() {
- if (D) Log.v(LOG_TAG, "connectService() called");
-
- if (!mIsSink) {
- Log.e(LOG_TAG, "Device is not a WFD SINK. Won't start service");
- return;
- }
-
- // Bind to the service
- Intent startIntent = new Intent();
- startIntent.setClassName("com.ti.omap.android.wfd.sink.service",
- "com.ti.omap.android.wfd.sink.service.WfdSinkService");
- startService(startIntent);
-
- boolean bindResult = bindService(startIntent, mConnection, 0);
- if (D) Log.v(LOG_TAG, "bind to service result : " + bindResult);
- }
-
- // Currently not needed. For future use.
- private void stopService() {
- if (D) Log.v(LOG_TAG, "disconnectService() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound");
- return;
- }
-
- Message msg = Message.obtain(null, WfdSinkTools.COMMAND_UNREGISTER, 0,
- 0, null);
- msg.replyTo = mMessenger;
- try {
- mService.send(msg);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
- mRtspSink.disconnect();
-
- Intent stopIntent = new Intent();
- stopIntent.setClassName("com.ti.omap.android.wfd.sink.service",
- "com.ti.omap.android.wfd.sink.service.WfdSinkService");
- stopService(stopIntent);
- }
-
- private boolean isServiceBound() {
- return mBound;
- }
-
- private void setAutoStart(boolean autoStart) {
- mIsAutoStart = autoStart;
- }
-
- private void autoConnect() {
- if (D) Log.v(LOG_TAG, "autoConnnect() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound.");
- return;
- }
- if (!mIsAutoStart) {
- Log.e(LOG_TAG, "autoStart is not set.");
- return;
- }
-
- connect();
- }
-
- public void find() {
- if (D) Log.v(LOG_TAG, "find() called");
- if (!isServiceBound()) {
- connectService();
- } else {
- Message msg = Message.obtain(null, WfdSinkTools.COMMAND_FIND, 0, 0,
- null);
- msg.replyTo = mMessenger;
- try {
- mService.send(msg);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void connect() {
- if (D) Log.v(LOG_TAG, "connect() called");
- if (mUrl == null || mUrl.isEmpty()) {
- Log.e(LOG_TAG, "Service has not provided URL to connect");
- return;
- }
- if (mSinkSurfaceView == null || mSinkSurfaceView.getSurface() == null) {
- Log.e(LOG_TAG, "Surface is not available.");
- return;
- }
-
- if (mState == WfdSinkTools.STATE_IDLE) {
- mRtspSink.connect(mSinkSurfaceView.getSurface(), mUrl);
-
- if ((mStateListener != null) && (mRtspSink != null)) {
- mRtspSink.setStateListener(mStateListener);
- }
- } else {
- Log.e(LOG_TAG, "Already connected.");
- }
- }
-
- public void disconnect() {
- if (D) Log.v(LOG_TAG, "disconnect() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound. Continue anyway.");
- }
-
- if (mState != WfdSinkTools.STATE_IDLE && mState != WfdSinkTools.STATE_DISCONNECTING) {
- mRtspSink.disconnect();
- } else {
- Log.e(LOG_TAG, "Already disconnected");
- }
- }
-
- public void play() {
- if (D) Log.v(LOG_TAG, "play() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound. Continue anyway.");
- }
-
- if (mState == WfdSinkTools.STATE_PAUSED
- || mState == WfdSinkTools.STATE_CONNECTED) {
- mRtspSink.play();
- } else {
- Log.e(LOG_TAG, "Not connected now so can't play");
- }
- }
-
- public void pause() {
- if (D) Log.v(LOG_TAG, "pause() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound. Continue anyway.");
- }
-
- if (mState == WfdSinkTools.STATE_PLAYING) {
- mRtspSink.pause();
- } else {
- Log.e(LOG_TAG, "Not playing now so can't pause");
- }
- }
-
- public void tearDown() {
- if (D) Log.v(LOG_TAG, "tearDown() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound. Continue anyway.");
- }
-
- if (mState != WfdSinkTools.STATE_CONNECTED
- && mState != WfdSinkTools.STATE_PLAYING
- && mState != WfdSinkTools.STATE_PAUSED) {
- Log.e(LOG_TAG, "Not connected now so can't teardown");
- } else {
- mRtspSink.teardown();
- }
- }
-
- public String getMediaInfo() {
- if (D) Log.v(LOG_TAG, "getMediaInfo() called");
- if (!isServiceBound()) {
- Log.e(LOG_TAG, "Service not bound. Continue anyway.");
- }
-
- if (mState != WfdSinkTools.STATE_PLAYING) {
- return "Not playing any media now";
- }
-
- return mRtspSink.getMediaInfo();
- }
-
- public void setStateListener(RtspStateListener stateListener) {
- if (D) Log.v(LOG_TAG, "setStateListener() called");
-
- if (stateListener != null) {
- mStateListener = stateListener;
- } else {
- Log.e(LOG_TAG, "Attempt to set null listener");
- }
- }
-
- public void removeStateListener() {
- if (D) Log.v(LOG_TAG, "removeStateListener() called");
- if (mRtspSink == null) {
- Log.e(LOG_TAG, "Rtsp sink is null.");
- return;
- }
-
- mRtspSink.removeStateListener();
- }
-
- public class WfdRtspStateListener implements RtspStateListener {
- public void onStateChanged(int newState) {
- mState = newState;
- }
- }
-
- private class IncomingHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case WfdSinkTools.COMMAND_INVOKE_SINK:
- mIpAddress = msg.getData()
- .getString(WfdSinkTools.EXTRA_ADDRESS);
- if (mIpAddress == null || mIpAddress.isEmpty()) {
- if (D) Log.v(LOG_TAG, "No ip address received");
- mIpAddress = "127.0.0.1";
- }
- mRtspPort = msg.getData().getInt(WfdSinkTools.EXTRA_PORT);
- mUrl = mIpAddress + ":" + mRtspPort;
- autoConnect();
- break;
- default:
- super.handleMessage(msg);
- }
- }
- }
-
- // Class for interacting with the main interface of the service.
- private ServiceConnection mConnection = new ServiceConnection() {
- public void onServiceConnected(ComponentName className, IBinder service) {
- Log.d(LOG_TAG, "Connected to service");
- mService = new Messenger(service);
- mBound = true;
-
- Message msg = Message.obtain(null, WfdSinkTools.COMMAND_REGISTER,
- 0, 0, null);
- msg.replyTo = mMessenger;
- try {
- mService.send(msg);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- msg = Message.obtain(null, WfdSinkTools.COMMAND_FIND, 0, 0, null);
- try {
- mService.send(msg);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
-
- public void onServiceDisconnected(ComponentName className) {
- Log.d(LOG_TAG, "Disconnected from service");
- mService = null;
- mBound = false;
- }
- };
-
-}
diff --git a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspStateListener.java b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspStateListener.java
deleted file mode 100644
index 7f4d23d..0000000
--- a/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspStateListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.ti.omap.android.wfd.sink.rtsp;
-
-public interface RtspStateListener {
- public void onStateChanged(int newState);
-}
diff --git a/wfd/configs/com.ti.wfd.xml b/wfd/configs/com.ti.wfd.xml
new file mode 100644
index 0000000..06179ee
--- /dev/null
+++ b/wfd/configs/com.ti.wfd.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<permissions>
+ <library name="com.ti.wfd"
+ file="/system/framework/com.ti.wfd.jar"/>
+</permissions> \ No newline at end of file
diff --git a/wfd/wfd-products.mk b/wfd/wfd-products.mk
index dcc47cb..721fdc1 100644
--- a/wfd/wfd-products.mk
+++ b/wfd/wfd-products.mk
@@ -3,7 +3,8 @@
PRODUCT_COPY_FILES += \
device/ti/common-open/wfd/configs/wfd_source_cfg.xml:system/etc/wfd/wfd_source_cfg.xml \
device/ti/common-open/wfd/configs/wfd_sink_cfg.xml:system/etc/wfd/wfd_sink_cfg.xml \
- device/ti/common-open/wfd/scripts/dhcp_script.sh:system/etc/dhcp_script.sh
+ device/ti/common-open/wfd/scripts/dhcp_script.sh:system/etc/dhcp_script.sh \
+ device/ti/common-open/wfd/configs/com.ti.wfd.xml:system/etc/permissions/com.ti.wfd.xml
PRODUCT_PACKAGES += \
librtspsink_jni \