Skip to content

Commit

Permalink
Updated spydroid to libstreaming 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fyhertz committed Feb 18, 2014
1 parent 9405ef5 commit 6a1ea10
Show file tree
Hide file tree
Showing 36 changed files with 2,230 additions and 1,157 deletions.
6 changes: 3 additions & 3 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/GoogleAdMobAdsSdk-6.1.0.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
8 changes: 4 additions & 4 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.majorkernelpanic.spydroid"
android:versionCode="910"
android:versionName="9.1" >
android:versionCode="1000"
android:versionName="10" >

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

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Expand Down
3 changes: 3 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="InlinedApi">
<ignore path="src/net/majorkernelpanic/streaming/video/ColorFormatConvertor.java" />
</issue>
<issue id="MissingTranslation">
<ignore path="res/values/arrays.xml" />
</issue>
Expand Down
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-18
target=android-19
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
5 changes: 2 additions & 3 deletions res/layout/spydroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<SurfaceView
<net.majorkernelpanic.streaming.gl.SurfaceView
android:id="@+id/handset_camera_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -42,8 +42,6 @@
</android.support.v4.view.ViewPager>

<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/adcontainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -52,6 +50,7 @@
android:orientation="vertical" >

<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
Expand Down
18 changes: 8 additions & 10 deletions src/net/majorkernelpanic/spydroid/SpydroidApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class SpydroidApplication extends android.app.Application {
public final static String TAG = "SpydroidApplication";

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

/** By default AMR is the audio encoder. */
public int audioEncoder = SessionBuilder.AUDIO_AMRNB;
public int audioEncoder = SessionBuilder.AUDIO_AAC;

/** By default H.263 is the video encoder. */
public int videoEncoder = SessionBuilder.VIDEO_H263;
public int videoEncoder = SessionBuilder.VIDEO_H264;

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

// Read video quality settings from the preferences
videoQuality = VideoQuality.merge(
new VideoQuality(
settings.getInt("video_resX", 0),
settings.getInt("video_resY", 0),
Integer.parseInt(settings.getString("video_framerate", "0")),
Integer.parseInt(settings.getString("video_bitrate", "0"))*1000),
videoQuality);
videoQuality = new VideoQuality(
settings.getInt("video_resX", videoQuality.resX),
settings.getInt("video_resY", videoQuality.resY),
Integer.parseInt(settings.getString("video_framerate", String.valueOf(videoQuality.framerate))),
Integer.parseInt(settings.getString("video_bitrate", String.valueOf(videoQuality.bitrate/1000)))*1000);

SessionBuilder.getInstance()
.setContext(getApplicationContext())
Expand Down
30 changes: 19 additions & 11 deletions src/net/majorkernelpanic/spydroid/api/CustomHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URI;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -129,7 +130,7 @@ public void stop() {
if (streaming && !isStreaming()) {
postMessage(MESSAGE_STREAMING_STOPPED);
}
mDescriptionRequestHandler.mSessionList[i].session.flush();
mDescriptionRequestHandler.mSessionList[i].session.release();
mDescriptionRequestHandler.mSessionList[i].session = null;
}
}
Expand Down Expand Up @@ -242,37 +243,44 @@ else if (param.getName().equalsIgnoreCase("stop")) {
// Stops all streams if a Session already exists
if (mSessionList[id].session != null) {
boolean streaming = isStreaming();
mSessionList[id].session.stop();
mSessionList[id].session.syncStop();
if (streaming && !isStreaming()) {
postMessage(MESSAGE_STREAMING_STOPPED);
}
mSessionList[id].session.flush();
mSessionList[id].session.release();
mSessionList[id].session = null;
}

if (!stop) {
if (mSessionList[id].session == null ||
(mSessionList[id].session != null && !mSessionList[id].session.getDestination().isMulticastAddress()))
{

boolean b = false;
if (mSessionList[id].session != null) {
InetAddress dest = InetAddress.getByName(mSessionList[id].session.getDestination());
if (!dest.isMulticastAddress()) {
b = true;
}
}
if (mSessionList[id].session == null || b) {
// Parses URI and creates the Session
mSessionList[id].session = UriParser.parse(uri);
mSessions.put(mSessionList[id].session, null);
}

// Sets proper origin & dest
mSessionList[id].session.setOrigin(socket.getLocalAddress());
mSessionList[id].session.setOrigin(socket.getLocalAddress().getHostAddress());
if (mSessionList[id].session.getDestination()==null) {
mSessionList[id].session.setDestination(socket.getInetAddress());
mSessionList[id].session.setDestination(socket.getInetAddress().getHostAddress());
}

mSessionList[id].description = mSessionList[id].session.getSessionDescription().replace("Unnamed", "Stream-"+id);

// Starts all streams associated to the Session
boolean streaming = isStreaming();
mSessionList[id].session.start();
mSessionList[id].session.syncStart();
if (!streaming && isStreaming()) {
postMessage(MESSAGE_STREAMING_STARTED);
}

mSessionList[id].description = mSessionList[id].session.getSessionDescription().replace("Unnamed", "Stream-"+id);
Log.v(TAG, mSessionList[id].description);

}
}
Expand Down
10 changes: 2 additions & 8 deletions src/net/majorkernelpanic/spydroid/ui/PreviewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.majorkernelpanic.spydroid.api.CustomHttpServer;
import net.majorkernelpanic.spydroid.api.CustomRtspServer;
import net.majorkernelpanic.streaming.SessionBuilder;
import net.majorkernelpanic.streaming.gl.SurfaceView;
import net.majorkernelpanic.streaming.rtsp.RtspServer;
import android.content.ComponentName;
import android.content.Context;
Expand All @@ -35,7 +36,6 @@
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
Expand All @@ -45,7 +45,6 @@ public class PreviewFragment extends Fragment {
public final static String TAG = "PreviewFragment";

private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
private TextView mTextView;
private CustomHttpServer mHttpServer;
private RtspServer mRtspServer;
Expand Down Expand Up @@ -78,12 +77,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (((SpydroidActivity)getActivity()).device == ((SpydroidActivity)getActivity()).TABLET) {

mSurfaceView = (SurfaceView)rootView.findViewById(R.id.tablet_camera_view);
mSurfaceHolder = mSurfaceView.getHolder();

// We still need this line for backward compatibility reasons with android 2
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);

}

Expand Down
17 changes: 6 additions & 11 deletions src/net/majorkernelpanic/spydroid/ui/SpydroidActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.majorkernelpanic.spydroid.api.CustomHttpServer;
import net.majorkernelpanic.spydroid.api.CustomRtspServer;
import net.majorkernelpanic.streaming.SessionBuilder;
import net.majorkernelpanic.streaming.gl.SurfaceView;
import net.majorkernelpanic.streaming.rtsp.RtspServer;
import android.app.AlertDialog;
import android.app.Notification;
Expand All @@ -52,7 +53,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.LinearLayout;
import android.widget.Toast;

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

// Handset detected !

mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
mSurfaceHolder = mSurfaceView.getHolder();
// We still need this line for backward compatibility reasons with android 2
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);

SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
SessionBuilder.getInstance().setPreviewOrientation(90);

} else {

// Tablet detected !

device = TABLET;
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mApplication.videoQuality.orientation = 0;

SessionBuilder.getInstance().setPreviewOrientation(0);
}

mViewPager.setAdapter(mAdapter);
Expand Down
Loading

0 comments on commit 6a1ea10

Please sign in to comment.