summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrii Kulian2013-02-20 09:38:11 -0600
committerAndrii Kulian2013-02-21 08:49:25 -0600
commit1391c83b457b388793783cfcc2911746be81e8d5 (patch)
tree5d92b58db34eef63f6f43f61a0ff31dea288951d
parent373c5fe88072e8923035bc96a8084ab0deee890b (diff)
downloaddevice-ti-common-open-1391c83b457b388793783cfcc2911746be81e8d5.tar.gz
device-ti-common-open-1391c83b457b388793783cfcc2911746be81e8d5.tar.xz
device-ti-common-open-1391c83b457b388793783cfcc2911746be81e8d5.zip
WFD: WfdSinkLib initial commit
This library provides high-level API for WfdSinkPlayer application. Also it is used by WfdSinkService. Change-Id: I9391e91301f8a519394e7579d3aa4ed205d5aae4 Signed-off-by: Andrii Kulian <andrii.kulian@ti.com>
-rw-r--r--wfd/Android.mk1
-rw-r--r--wfd/WfdSinkLib/Android.mk15
-rw-r--r--wfd/WfdSinkLib/AndroidManifest.xml31
-rw-r--r--wfd/WfdSinkLib/jni/Android.mk26
-rw-r--r--wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp197
-rw-r--r--wfd/WfdSinkLib/res/values/strings.xml21
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java308
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkSurfaceView.java83
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkTools.java45
-rw-r--r--wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspSink.java43
-rw-r--r--wfd/wfd-products.mk4
11 files changed, 774 insertions, 0 deletions
diff --git a/wfd/Android.mk b/wfd/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/wfd/Android.mk
@@ -0,0 +1 @@
include $(call all-subdir-makefiles)
diff --git a/wfd/WfdSinkLib/Android.mk b/wfd/WfdSinkLib/Android.mk
new file mode 100644
index 0000000..cbd9f35
--- /dev/null
+++ b/wfd/WfdSinkLib/Android.mk
@@ -0,0 +1,15 @@
1LOCAL_PATH:= $(call my-dir)
2
3include $(CLEAR_VARS)
4
5LOCAL_MODULE := WfdSinkLib
6
7LOCAL_MODULE_TAGS := optional
8
9LOCAL_REQUIRED_MODULES := librtspsink_jni
10
11LOCAL_SRC_FILES := $(call all-subdir-java-files)
12
13include $(BUILD_STATIC_JAVA_LIBRARY)
14
15include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/wfd/WfdSinkLib/AndroidManifest.xml b/wfd/WfdSinkLib/AndroidManifest.xml
new file mode 100644
index 0000000..f02a264
--- /dev/null
+++ b/wfd/WfdSinkLib/AndroidManifest.xml
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 Copyright (C) Texas Instruments - http://www.ti.com/
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18 package="com.ti.omap.android.wfd.sink.manager"
19 android:versionCode="1"
20 android:versionName="1.0" >
21
22 <uses-sdk
23 android:minSdkVersion="17"
24 android:targetSdkVersion="17" />
25
26 <application
27 android:allowBackup="true"
28 android:label="@string/app_name" >
29 </application>
30
31</manifest>
diff --git a/wfd/WfdSinkLib/jni/Android.mk b/wfd/WfdSinkLib/jni/Android.mk
new file mode 100644
index 0000000..8a72e8c
--- /dev/null
+++ b/wfd/WfdSinkLib/jni/Android.mk
@@ -0,0 +1,26 @@
1LOCAL_PATH := $(call my-dir)
2include $(CLEAR_VARS)
3
4LOCAL_MODULE_TAGS := optional
5
6LOCAL_C_INCLUDES := . \
7 $(JNI_H_INCLUDE) \
8 $(TOP)/frameworks/native/include \
9 $(TOP)/frameworks/native/include/media/openmax \
10 $(TOP)/frameworks/base/include \
11 $(TOP)/frameworks/av/include/media/stagefright/foundation \
12 $(TOP)/frameworks/av/media/libstagefright/wifi-display
13
14LOCAL_SRC_FILES := rtsp_sink_jni.cpp \
15
16LOCAL_SHARED_LIBRARIES := libcutils \
17 libutils \
18 libnativehelper \
19 libgui \
20 libstagefright \
21 libstagefright_foundation \
22 libstagefright_wfd
23
24LOCAL_MODULE := librtspsink_jni
25
26include $(BUILD_SHARED_LIBRARY)
diff --git a/wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp b/wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp
new file mode 100644
index 0000000..15bf69d
--- /dev/null
+++ b/wfd/WfdSinkLib/jni/rtsp_sink_jni.cpp
@@ -0,0 +1,197 @@
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <jni.h>
17#include <JNIHelp.h>
18
19#include <utils/StrongPointer.h>
20#include <utils/Log.h>
21
22#include <gui/ISurfaceTexture.h>
23#include <gui/Surface.h>
24
25#include <pthread.h>
26#include <unistd.h>
27#include <arpa/inet.h>
28#include <netinet/in.h>
29#include <sys/socket.h>
30#include <sys/types.h>
31
32#include <unistd.h>
33
34#include <sink/WifiDisplaySink.h>
35
36#define LOG_TAG "rtsp_sink_jni"
37
38using namespace android;
39
40static sp<ALooper> looper = NULL;
41static sp<WifiDisplaySink> sink = NULL;
42
43static sp<ISurfaceTexture> getSurface(JNIEnv *e, jobject thisObj,
44 jobject jSurface) {
45 sp<ISurfaceTexture> new_st = NULL;
46
47 if (!jSurface) {
48 ALOGE("NULL Surface got as argument");
49 return new_st;
50 }
51
52 jclass surfaceClass = e->FindClass("android/view/Surface");
53
54 if (surfaceClass == NULL) {
55 ALOGE("Error getting Surface class");
56 return new_st;
57 }
58
59 jfieldID surfaceId = e->GetFieldID(surfaceClass, "mNativeSurface", "I");
60
61 if (surfaceId == NULL) {
62 ALOGE("Error getting Surface field");
63 return new_st;
64 }
65
66 jint surfaceValue = e->GetIntField(jSurface, surfaceId);
67
68 sp<Surface> surface((Surface*) surfaceValue);
69 if (surface != NULL) {
70 new_st = surface->getSurfaceTexture();
71 new_st->incStrong(thisObj);
72 } else {
73 jniThrowException(e, "java/lang/IllegalArgumentException",
74 "The surface has been released");
75 return new_st;
76 }
77
78 return new_st;
79}
80
81jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_connect(JNIEnv *e,
82 jobject thisObj, jobject jSurface, jstring url) {
83 char *utfUrl = (char*) e->GetStringUTFChars(url, JNI_FALSE);
84
85 int port;
86 char * ip = new char[strlen(utfUrl) + 1];
87 strcpy(ip, utfUrl);
88 char *colonPos = strchr(ip, ':');
89 if (colonPos != NULL) {
90 char *end;
91 unsigned long x = strtoul(colonPos + 1, &end, 10);
92
93 if (end == colonPos + 1 || *end != '\0' || x >= 65536) {
94 return JNI_FALSE;
95 }
96
97 *colonPos = '\0';
98 port = x;
99 } else {
100 port = 7236;
101 }
102 ALOGI("Sink. Connecting ... URL: %s:%d", ip, port);
103 if (sink == NULL) {
104 sp<ANetworkSession> netSession = new ANetworkSession();
105 netSession->start();
106
107 looper = new ALooper();
108
109 sink = new WifiDisplaySink(netSession,
110 getSurface(e, thisObj, jSurface));
111 looper->setName("wfd_sink_looper");
112 looper->registerHandler(sink);
113 looper->start();
114
115 sink->start(ip, port);
116 } else {
117 sink->start(ip, port);
118 }
119 delete[] ip;
120 e->ReleaseStringUTFChars(url, utfUrl);
121
122 return JNI_TRUE;
123}
124
125jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_disconnect(JNIEnv *e,
126 jobject thisObj) {
127 // TODO implement rtsp disconnect
128 jboolean result = JNI_TRUE;
129 ALOGI("Sink. Disconnecting ...");
130 return result;
131}
132
133jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_play(JNIEnv *e,
134 jobject thisObj) {
135 jboolean result = JNI_TRUE;
136 ALOGI("Sink. play");
137 if (sink != NULL) {
138 sink->play();
139 }
140 return result;
141}
142
143jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_pause(JNIEnv *e,
144 jobject thisObj) {
145 jboolean result = JNI_TRUE;
146 ALOGI("Sink. pause");
147 if (sink != NULL) {
148 sink->pause();
149 }
150 return result;
151}
152
153jboolean Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_teardown(JNIEnv *e,
154 jobject thisObj) {
155 jboolean result = JNI_TRUE;
156 ALOGI("Sink. teardown");
157 if (sink != NULL) {
158 sink->teardown();
159 }
160 return result;
161}
162
163jstring Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_getMediaInfo(JNIEnv *e,
164 jobject thisObj) {
165 AString mediaInfo("dummy media info");
166 jstring result = e->NewStringUTF(mediaInfo.c_str());
167 return result;
168}
169
170static JNINativeMethod rtspSinkMethods[] = { { "connect",
171 "(Landroid/view/Surface;Ljava/lang/String;)Z",
172 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_connect }, {
173 "disconnect", "()Z",
174 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_disconnect }, {
175 "play", "()Z",
176 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_play }, {
177 "pause", "()Z",
178 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_pause }, {
179 "teardown", "()Z",
180 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_teardown }, {
181 "getMediaInfo", "()Ljava/lang/String;",
182 (void*) Java_com_ti_omap_android_wfd_sink_rtsp_RtspSink_getMediaInfo }
183 };
184
185extern "C" jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
186 JNIEnv *e;
187
188 if (jvm->GetEnv((void**) &e, JNI_VERSION_1_4) != JNI_OK) {
189 ALOGE("Error getting Env var");
190 return JNI_ERR;
191 }
192
193 jniRegisterNativeMethods(e, "com/ti/omap/android/wfd/sink/rtsp/RtspSink",
194 rtspSinkMethods, NELEM(rtspSinkMethods));
195
196 return JNI_VERSION_1_4;
197}
diff --git a/wfd/WfdSinkLib/res/values/strings.xml b/wfd/WfdSinkLib/res/values/strings.xml
new file mode 100644
index 0000000..5c94036
--- /dev/null
+++ b/wfd/WfdSinkLib/res/values/strings.xml
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 Copyright (C) Texas Instruments - http://www.ti.com/
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<resources>
18
19 <string name="app_name">WfdSinkLib</string>
20
21</resources>
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
new file mode 100644
index 0000000..7b97e5f
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkActivity.java
@@ -0,0 +1,308 @@
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.ti.omap.android.wfd.sink.manager;
17
18import com.ti.omap.android.wfd.sink.rtsp.RtspSink;
19
20import android.app.Activity;
21import android.content.ComponentName;
22import android.content.Context;
23import android.content.Intent;
24import android.content.ServiceConnection;
25import android.os.Bundle;
26import android.os.Handler;
27import android.os.IBinder;
28import android.os.Message;
29import android.os.Messenger;
30import android.os.RemoteException;
31import android.util.Log;
32import android.view.SurfaceHolder;
33import android.view.ViewGroup;
34import android.widget.TextView;
35
36public class WfdSinkActivity extends Activity {
37
38 private static final String LOG_TAG = "WfdSinkActivity";
39
40 // Messenger for communicating with the service.
41 private Messenger mService = null;
42
43 // Messenger for receiving responses from service.
44 private Messenger mMessenger;
45
46 // Flag indicating whether we have called bind on the service.
47 private boolean mBound;
48
49 private int mRtspPort;
50 private String mUrl;
51 private String mIpAddress;
52
53 private boolean mIsSigmaActive;
54 private boolean mIsAutoStart = true;
55
56 private WfdSinkSurfaceView mSinkSurfaceView;
57 private RtspSink mRtspSink;
58
59 private static final Boolean D = true;
60
61 @Override
62 public void onCreate(Bundle savedInstanceState) {
63 super.onCreate(savedInstanceState);
64
65 mMessenger = new Messenger(new IncomingHandler());
66
67 mSinkSurfaceView = new WfdSinkSurfaceView(getApplicationContext());
68
69 mRtspSink = new RtspSink(false);
70
71 mBound = false;
72 }
73
74 @Override
75 public void onStart() {
76 super.onStart();
77 connectService();
78 }
79
80 @Override
81 protected void onStop() {
82 super.onStop();
83 // Unbind from the service
84 if (mBound) {
85 Message msg = Message.obtain(null, WfdSinkTools.COMMAND_UNREGISTER,
86 0, 0, null);
87 try {
88 mService.send(msg);
89 } catch (RemoteException e) {
90 e.printStackTrace();
91 }
92 unbindService(mConnection);
93 mBound = false;
94 }
95 }
96
97 @Override
98 public void onPause() {
99 super.onPause();
100 pause();
101 }
102
103 public boolean placeView(int resouceId) {
104 if (mSinkSurfaceView == null) {
105 Log.e(LOG_TAG, "Cannot place null surface view");
106 return false;
107 }
108 try {
109 ViewGroup parent = (ViewGroup) findViewById(resouceId);
110 parent.addView(mSinkSurfaceView);
111 } catch (ClassCastException ex) {
112 Log.e(LOG_TAG, "Cannot cast provided view to viewgroup");
113 return false;
114 } catch (Exception e) {
115 e.printStackTrace();
116 return false;
117 }
118
119 return true;
120 }
121
122 private void connectService() {
123 if (D) Log.v(LOG_TAG, "connectService() called");
124
125 // Bind to the service
126 Intent startIntent = new Intent();
127 startIntent.setClassName("com.ti.omap.android.wfd.sink.service",
128 "com.ti.omap.android.wfd.sink.service.WfdSinkService");
129 startService(startIntent);
130
131 boolean bindResult = bindService(startIntent, mConnection, 0);
132 if (D) Log.v(LOG_TAG, "bind to service result : " + bindResult);
133 }
134
135 // Currently not needed. For future use.
136 private void stopService() {
137 if (D) Log.v(LOG_TAG, "disconnectService() called");
138 if (!isServiceBound()) {
139 Log.e(LOG_TAG, "Service not bound");
140 return;
141 }
142
143 Message msg = Message.obtain(null, WfdSinkTools.COMMAND_UNREGISTER, 0,
144 0, null);
145 msg.replyTo = mMessenger;
146 try {
147 mService.send(msg);
148 } catch (RemoteException e) {
149 e.printStackTrace();
150 }
151
152 mRtspSink.disconnect();
153
154 Intent stopIntent = new Intent();
155 stopIntent.setClassName("com.ti.omap.android.wfd.sink.service",
156 "com.ti.omap.android.wfd.sink.service.WfdSinkService");
157 stopService(stopIntent);
158 }
159
160 private boolean isServiceBound() {
161 return mBound;
162 }
163
164 private void setAutoStart(boolean autoStart) {
165 mIsAutoStart = autoStart;
166 }
167
168 private void autoConnect() {
169 if (D) Log.v(LOG_TAG, "autoConnnect() called");
170 if (!isServiceBound()) {
171 Log.e(LOG_TAG, "Service not bound.");
172 return;
173 }
174 if (!mIsAutoStart) {
175 Log.e(LOG_TAG, "autoStart is not set.");
176 return;
177 }
178
179 connect();
180 }
181
182 public void find() {
183 if (D) Log.v(LOG_TAG, "find() called");
184 if (!isServiceBound()) {
185 connectService();
186 } else {
187 Message msg = Message.obtain(null, WfdSinkTools.COMMAND_FIND, 0, 0,
188 null);
189 msg.replyTo = mMessenger;
190 try {
191 mService.send(msg);
192 } catch (RemoteException e) {
193 e.printStackTrace();
194 }
195 }
196 }
197
198 public void connect() {
199 if (D) Log.v(LOG_TAG, "connect() called");
200 if (mUrl == null || mUrl.isEmpty()) {
201 Log.e(LOG_TAG, "Service has not provided URL to connect");
202 return;
203 }
204 if (mSinkSurfaceView == null || mSinkSurfaceView.getSurface() == null) {
205 Log.e(LOG_TAG, "Surface is not available.");
206 return;
207 }
208
209 mRtspSink.connect(mSinkSurfaceView.getSurface(), mUrl);
210 }
211
212 public void disconnect() {
213 if (D) Log.v(LOG_TAG, "disconnect() called");
214 if (!isServiceBound()) {
215 Log.e(LOG_TAG, "Service not bound. Continue anyway.");
216 }
217
218 mRtspSink.disconnect();
219 }
220
221 public void play() {
222 if (D) Log.v(LOG_TAG, "play() called");
223 if (!isServiceBound()) {
224 Log.e(LOG_TAG, "Service not bound. Continue anyway.");
225 }
226
227 mRtspSink.play();
228 }
229
230 public void pause() {
231 if (D) Log.v(LOG_TAG, "pause() called");
232 if (!isServiceBound()) {
233 Log.e(LOG_TAG, "Service not bound. Continue anyway.");
234 }
235
236 mRtspSink.pause();
237 }
238
239 public void tearDown() {
240 if (D) Log.v(LOG_TAG, "tearDown() called");
241 if (!isServiceBound()) {
242 Log.e(LOG_TAG, "Service not bound. Continue anyway.");
243 }
244
245 mRtspSink.teardown();
246 }
247
248 public String getMediaInfo() {
249 if (D) Log.v(LOG_TAG, "getMediaInfo() called");
250 if (!isServiceBound()) {
251 Log.e(LOG_TAG, "Service not bound. Continue anyway.");
252 }
253
254 return mRtspSink.getMediaInfo();
255 }
256
257 private class IncomingHandler extends Handler {
258 @Override
259 public void handleMessage(Message msg) {
260 switch (msg.what) {
261 case WfdSinkTools.COMMAND_INVOKE_SINK:
262 mIpAddress = msg.getData()
263 .getString(WfdSinkTools.EXTRA_ADDRESS);
264 if (mIpAddress == null || mIpAddress.isEmpty()) {
265 if (D) Log.v(LOG_TAG, "No ip address received");
266 mIpAddress = "127.0.0.1";
267 }
268 mRtspPort = msg.getData().getInt(WfdSinkTools.EXTRA_PORT);
269 mUrl = mIpAddress + ":" + mRtspPort;
270 autoConnect();
271 break;
272 default:
273 super.handleMessage(msg);
274 }
275 }
276 }
277
278 // Class for interacting with the main interface of the service.
279 private ServiceConnection mConnection = new ServiceConnection() {
280 public void onServiceConnected(ComponentName className, IBinder service) {
281 Log.d(LOG_TAG, "Connected to service");
282 mService = new Messenger(service);
283 mBound = true;
284
285 Message msg = Message.obtain(null, WfdSinkTools.COMMAND_REGISTER,
286 0, 0, null);
287 msg.replyTo = mMessenger;
288 try {
289 mService.send(msg);
290 } catch (RemoteException e) {
291 e.printStackTrace();
292 }
293 msg = Message.obtain(null, WfdSinkTools.COMMAND_FIND, 0, 0, null);
294 try {
295 mService.send(msg);
296 } catch (RemoteException e) {
297 e.printStackTrace();
298 }
299 }
300
301 public void onServiceDisconnected(ComponentName className) {
302 Log.d(LOG_TAG, "Disconnected from service");
303 mService = null;
304 mBound = false;
305 }
306 };
307
308}
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/manager/WfdSinkSurfaceView.java
new file mode 100644
index 0000000..5500267
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkSurfaceView.java
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.ti.omap.android.wfd.sink.manager;
17
18import android.content.Context;
19import android.view.KeyEvent;
20import android.view.MotionEvent;
21import android.view.Surface;
22import android.view.SurfaceView;
23
24public class WfdSinkSurfaceView extends SurfaceView {
25 private Surface mSurface;
26 private boolean mPreserveSurface;
27
28 public WfdSinkSurfaceView(Context context) {
29 super(context);
30 mSurface = getHolder().getSurface();
31 }
32
33 @Override
34 public boolean onKeyDown(int keyCode, KeyEvent ke) {
35 return true;
36 }
37
38 @Override
39 public boolean onKeyUp(int keyCode, KeyEvent ke) {
40 return true;
41 }
42
43 @Override
44 public boolean onTouchEvent(MotionEvent me) {
45 return true;
46 }
47
48 @Override
49 public boolean onTrackballEvent(MotionEvent me) {
50 return true;
51 }
52
53 @Override
54 public boolean onGenericMotionEvent(MotionEvent me) {
55 return true;
56 }
57
58 public Surface getSurface() {
59 if (mSurface == null) {
60 mSurface = getHolder().getSurface();
61 }
62 return mSurface;
63 }
64
65 @Override
66 protected void onWindowVisibilityChanged(int visibility) {
67 if (mPreserveSurface) {
68 super.onWindowVisibilityChanged(VISIBLE);
69 } else {
70 super.onWindowVisibilityChanged(visibility);
71 }
72 }
73
74 @Override
75 public void setVisibility(int visibility) {
76 if (mPreserveSurface) {
77 super.setVisibility(VISIBLE);
78 } else {
79 super.setVisibility(visibility);
80 }
81 }
82
83}
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/manager/WfdSinkTools.java
new file mode 100644
index 0000000..7ff16fc
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/manager/WfdSinkTools.java
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.ti.omap.android.wfd.sink.manager;
17
18public class WfdSinkTools {
19 public static final int STATE_IDLE = 0;
20 public static final int STATE_CONNECTING = 1;
21 public static final int STATE_CONNECTED = 2;
22 public static final int STATE_PLAYING = 3;
23 public static final int STATE_PAUSED = 4;
24 public static final int STATE_DISCONNECTING = 5;
25
26 public static final int RTSP_COMMAND_PLAY = 6;
27 public static final int RTSP_COMMAND_PAUSE = 7;
28 public static final int RTSP_COMMAND_CONNECT = 8;
29 public static final int RTSP_COMMAND_DISCONNECT = 9;
30
31 public static final int COMMAND_REGISTER = 10;
32 public static final int COMMAND_UNREGISTER = 11;
33
34 public static final int COMMAND_PLAY = 12;
35 public static final int COMMAND_PAUSE = 13;
36 public static final int COMMAND_CONNECT = 14;
37 public static final int COMMAND_DISCONNECT = 15;
38 public static final int COMMAND_INVOKE_SINK = 16;
39
40 public static final int COMMAND_FIND = 17;
41
42 public static final String EXTRA_AUTOSTART = "EXTRA_AUTOSTART";
43 public static final String EXTRA_ADDRESS = "EXTRA_ADDRESS";
44 public static final String EXTRA_PORT = "EXTRA_PORT";
45}
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/rtsp/RtspSink.java
new file mode 100644
index 0000000..f8763ab
--- /dev/null
+++ b/wfd/WfdSinkLib/src/com/ti/omap/android/wfd/sink/rtsp/RtspSink.java
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.ti.omap.android.wfd.sink.rtsp;
17
18import android.view.Surface;
19
20public class RtspSink {
21
22 boolean mSigmaActivate;
23
24 public RtspSink(boolean sigmaActivate) {
25 mSigmaActivate = sigmaActivate;
26 }
27
28 static {
29 System.loadLibrary("rtspsink_jni");
30 }
31
32 public native boolean connect(Surface surface, String url);
33
34 public native boolean disconnect();
35
36 public native boolean play();
37
38 public native boolean pause();
39
40 public native boolean teardown();
41
42 public native String getMediaInfo();
43}
diff --git a/wfd/wfd-products.mk b/wfd/wfd-products.mk
index e4281c5..9047e29 100644
--- a/wfd/wfd-products.mk
+++ b/wfd/wfd-products.mk
@@ -3,3 +3,7 @@
3PRODUCT_COPY_FILES += \ 3PRODUCT_COPY_FILES += \
4 device/ti/common-open/wfd/configs/wfd_source_cfg.xml:system/etc/wfd/wfd_source_cfg.xml \ 4 device/ti/common-open/wfd/configs/wfd_source_cfg.xml:system/etc/wfd/wfd_source_cfg.xml \
5 device/ti/common-open/wfd/configs/wfd_sink_cfg.xml:system/etc/wfd/wfd_sink_cfg.xml 5 device/ti/common-open/wfd/configs/wfd_sink_cfg.xml:system/etc/wfd/wfd_sink_cfg.xml
6
7PRODUCT_PACKAGES += \
8 librtspsink_jni \
9 WfdSinkLib