Skip to content

Commit 6a1ea10

Browse files
author
fyhertz
committed
Updated spydroid to libstreaming 4.0
1 parent 9405ef5 commit 6a1ea10

36 files changed

+2230
-1157
lines changed

.classpath

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="src" path="gen"/>
53
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
64
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
75
<classpathentry kind="lib" path="libs/GoogleAdMobAdsSdk-6.1.0.jar"/>
8-
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
6+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
7+
<classpathentry kind="src" path="src"/>
8+
<classpathentry kind="src" path="gen"/>
99
<classpathentry kind="output" path="bin/classes"/>
1010
</classpath>

AndroidManifest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="net.majorkernelpanic.spydroid"
4-
android:versionCode="910"
5-
android:versionName="9.1" >
4+
android:versionCode="1000"
5+
android:versionName="10" >
66

77
<uses-sdk
8-
android:minSdkVersion="9"
9-
android:targetSdkVersion="18" />
8+
android:minSdkVersion="14"
9+
android:targetSdkVersion="19" />
1010

1111
<uses-feature android:name="android.hardware.camera" />
1212
<uses-feature android:name="android.hardware.camera.autofocus" />

lint.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<lint>
3+
<issue id="InlinedApi">
4+
<ignore path="src/net/majorkernelpanic/streaming/video/ColorFormatConvertor.java" />
5+
</issue>
36
<issue id="MissingTranslation">
47
<ignore path="res/values/arrays.xml" />
58
</issue>

project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
# project structure.
99

1010
# Project target.
11-
target=android-18
11+
target=android-19
1212
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

res/layout/spydroid.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content" >
55

6-
<SurfaceView
6+
<net.majorkernelpanic.streaming.gl.SurfaceView
77
android:id="@+id/handset_camera_view"
88
android:layout_width="match_parent"
99
android:layout_height="match_parent"
@@ -42,8 +42,6 @@
4242
</android.support.v4.view.ViewPager>
4343

4444
<LinearLayout
45-
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
46-
xmlns:android="http://schemas.android.com/apk/res/android"
4745
android:id="@+id/adcontainer"
4846
android:layout_width="match_parent"
4947
android:layout_height="wrap_content"
@@ -52,6 +50,7 @@
5250
android:orientation="vertical" >
5351

5452
<com.google.ads.AdView
53+
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
5554
android:layout_width="match_parent"
5655
android:layout_height="wrap_content"
5756
ads:adSize="SMART_BANNER"

src/net/majorkernelpanic/spydroid/SpydroidApplication.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public class SpydroidApplication extends android.app.Application {
5050
public final static String TAG = "SpydroidApplication";
5151

5252
/** Default quality of video streams. */
53-
public VideoQuality videoQuality = new VideoQuality(640,480,15,500000);
53+
public VideoQuality videoQuality = new VideoQuality(320,240,20,500000);
5454

5555
/** By default AMR is the audio encoder. */
56-
public int audioEncoder = SessionBuilder.AUDIO_AMRNB;
56+
public int audioEncoder = SessionBuilder.AUDIO_AAC;
5757

5858
/** By default H.263 is the video encoder. */
59-
public int videoEncoder = SessionBuilder.VIDEO_H263;
59+
public int videoEncoder = SessionBuilder.VIDEO_H264;
6060

6161
/** Set this flag to true to disable the ads. */
6262
public final boolean DONATE_VERSION = false;
@@ -94,13 +94,11 @@ public void onCreate() {
9494
videoEncoder = Integer.parseInt(settings.getString("video_encoder", String.valueOf(videoEncoder)));
9595

9696
// Read video quality settings from the preferences
97-
videoQuality = VideoQuality.merge(
98-
new VideoQuality(
99-
settings.getInt("video_resX", 0),
100-
settings.getInt("video_resY", 0),
101-
Integer.parseInt(settings.getString("video_framerate", "0")),
102-
Integer.parseInt(settings.getString("video_bitrate", "0"))*1000),
103-
videoQuality);
97+
videoQuality = new VideoQuality(
98+
settings.getInt("video_resX", videoQuality.resX),
99+
settings.getInt("video_resY", videoQuality.resY),
100+
Integer.parseInt(settings.getString("video_framerate", String.valueOf(videoQuality.framerate))),
101+
Integer.parseInt(settings.getString("video_bitrate", String.valueOf(videoQuality.bitrate/1000)))*1000);
104102

105103
SessionBuilder.getInstance()
106104
.setContext(getApplicationContext())

src/net/majorkernelpanic/spydroid/api/CustomHttpServer.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.IOException;
2727
import java.io.OutputStream;
2828
import java.io.OutputStreamWriter;
29+
import java.net.InetAddress;
2930
import java.net.Socket;
3031
import java.net.URI;
3132
import java.nio.charset.Charset;
@@ -129,7 +130,7 @@ public void stop() {
129130
if (streaming && !isStreaming()) {
130131
postMessage(MESSAGE_STREAMING_STOPPED);
131132
}
132-
mDescriptionRequestHandler.mSessionList[i].session.flush();
133+
mDescriptionRequestHandler.mSessionList[i].session.release();
133134
mDescriptionRequestHandler.mSessionList[i].session = null;
134135
}
135136
}
@@ -242,37 +243,44 @@ else if (param.getName().equalsIgnoreCase("stop")) {
242243
// Stops all streams if a Session already exists
243244
if (mSessionList[id].session != null) {
244245
boolean streaming = isStreaming();
245-
mSessionList[id].session.stop();
246+
mSessionList[id].session.syncStop();
246247
if (streaming && !isStreaming()) {
247248
postMessage(MESSAGE_STREAMING_STOPPED);
248249
}
249-
mSessionList[id].session.flush();
250+
mSessionList[id].session.release();
250251
mSessionList[id].session = null;
251252
}
252253

253254
if (!stop) {
254-
if (mSessionList[id].session == null ||
255-
(mSessionList[id].session != null && !mSessionList[id].session.getDestination().isMulticastAddress()))
256-
{
255+
256+
boolean b = false;
257+
if (mSessionList[id].session != null) {
258+
InetAddress dest = InetAddress.getByName(mSessionList[id].session.getDestination());
259+
if (!dest.isMulticastAddress()) {
260+
b = true;
261+
}
262+
}
263+
if (mSessionList[id].session == null || b) {
257264
// Parses URI and creates the Session
258265
mSessionList[id].session = UriParser.parse(uri);
259266
mSessions.put(mSessionList[id].session, null);
260267
}
261268

262269
// Sets proper origin & dest
263-
mSessionList[id].session.setOrigin(socket.getLocalAddress());
270+
mSessionList[id].session.setOrigin(socket.getLocalAddress().getHostAddress());
264271
if (mSessionList[id].session.getDestination()==null) {
265-
mSessionList[id].session.setDestination(socket.getInetAddress());
272+
mSessionList[id].session.setDestination(socket.getInetAddress().getHostAddress());
266273
}
267-
268-
mSessionList[id].description = mSessionList[id].session.getSessionDescription().replace("Unnamed", "Stream-"+id);
269274

270275
// Starts all streams associated to the Session
271276
boolean streaming = isStreaming();
272-
mSessionList[id].session.start();
277+
mSessionList[id].session.syncStart();
273278
if (!streaming && isStreaming()) {
274279
postMessage(MESSAGE_STREAMING_STARTED);
275280
}
281+
282+
mSessionList[id].description = mSessionList[id].session.getSessionDescription().replace("Unnamed", "Stream-"+id);
283+
Log.v(TAG, mSessionList[id].description);
276284

277285
}
278286
}

src/net/majorkernelpanic/spydroid/ui/PreviewFragment.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import net.majorkernelpanic.spydroid.api.CustomHttpServer;
2626
import net.majorkernelpanic.spydroid.api.CustomRtspServer;
2727
import net.majorkernelpanic.streaming.SessionBuilder;
28+
import net.majorkernelpanic.streaming.gl.SurfaceView;
2829
import net.majorkernelpanic.streaming.rtsp.RtspServer;
2930
import android.content.ComponentName;
3031
import android.content.Context;
@@ -35,7 +36,6 @@
3536
import android.support.v4.app.Fragment;
3637
import android.view.LayoutInflater;
3738
import android.view.SurfaceHolder;
38-
import android.view.SurfaceView;
3939
import android.view.View;
4040
import android.view.ViewGroup;
4141
import android.widget.TextView;
@@ -45,7 +45,6 @@ public class PreviewFragment extends Fragment {
4545
public final static String TAG = "PreviewFragment";
4646

4747
private SurfaceView mSurfaceView;
48-
private SurfaceHolder mSurfaceHolder;
4948
private TextView mTextView;
5049
private CustomHttpServer mHttpServer;
5150
private RtspServer mRtspServer;
@@ -78,12 +77,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
7877
if (((SpydroidActivity)getActivity()).device == ((SpydroidActivity)getActivity()).TABLET) {
7978

8079
mSurfaceView = (SurfaceView)rootView.findViewById(R.id.tablet_camera_view);
81-
mSurfaceHolder = mSurfaceView.getHolder();
82-
83-
// We still need this line for backward compatibility reasons with android 2
84-
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
85-
86-
SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);
80+
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
8781

8882
}
8983

src/net/majorkernelpanic/spydroid/ui/SpydroidActivity.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.majorkernelpanic.spydroid.api.CustomHttpServer;
2727
import net.majorkernelpanic.spydroid.api.CustomRtspServer;
2828
import net.majorkernelpanic.streaming.SessionBuilder;
29+
import net.majorkernelpanic.streaming.gl.SurfaceView;
2930
import net.majorkernelpanic.streaming.rtsp.RtspServer;
3031
import android.app.AlertDialog;
3132
import android.app.Notification;
@@ -52,7 +53,6 @@
5253
import android.view.MenuInflater;
5354
import android.view.MenuItem;
5455
import android.view.SurfaceHolder;
55-
import android.view.SurfaceView;
5656
import android.widget.LinearLayout;
5757
import android.widget.Toast;
5858

@@ -74,7 +74,6 @@ public class SpydroidActivity extends FragmentActivity {
7474
private PowerManager.WakeLock mWakeLock;
7575
private SectionsPagerAdapter mAdapter;
7676
private SurfaceView mSurfaceView;
77-
private SurfaceHolder mSurfaceHolder;
7877
private SpydroidApplication mApplication;
7978
private CustomHttpServer mHttpServer;
8079
private RtspServer mRtspServer;
@@ -89,26 +88,22 @@ public void onCreate(Bundle savedInstanceState) {
8988
if (findViewById(R.id.handset_pager) != null) {
9089

9190
// Handset detected !
92-
9391
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
9492
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
9593
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
9694
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
97-
mSurfaceHolder = mSurfaceView.getHolder();
98-
// We still need this line for backward compatibility reasons with android 2
99-
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
100-
SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);
101-
95+
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
96+
SessionBuilder.getInstance().setPreviewOrientation(90);
97+
10298
} else {
10399

104100
// Tablet detected !
105-
106101
device = TABLET;
107102
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
108103
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
109104
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
110-
mApplication.videoQuality.orientation = 0;
111-
105+
SessionBuilder.getInstance().setPreviewOrientation(0);
106+
112107
}
113108

114109
mViewPager.setAdapter(mAdapter);

0 commit comments

Comments
 (0)