diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c4de58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..0f59c5a --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +ZidoStreamer \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..1bbc21d --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1a3eaff --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..db2830f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ZidoStreamer.iml b/ZidoStreamer.iml new file mode 100644 index 0000000..52b2645 --- /dev/null +++ b/ZidoStreamer.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..a5c587f --- /dev/null +++ b/app/app.iml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..2ca0522 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "eu.danman.zidostreamer.zidostreamer" + minSdkVersion 19 + targetSdkVersion 19 + versionCode 1 + versionName "1.0" + + ndk { + moduleName "libjni_capture" + } + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.1.0' + compile files('libs/FlurryAnalytics-4.2.0.jar') + compile files('libs/classes.jar') + +} diff --git a/app/libs/FlurryAnalytics-4.2.0.jar b/app/libs/FlurryAnalytics-4.2.0.jar new file mode 100644 index 0000000..bab7b7f Binary files /dev/null and b/app/libs/FlurryAnalytics-4.2.0.jar differ diff --git a/app/libs/classes.jar b/app/libs/classes.jar new file mode 100644 index 0000000..cab3a87 Binary files /dev/null and b/app/libs/classes.jar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..ee5193e --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/dano/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/eu/danman/zidostreamer/zidostreamer/ApplicationTest.java b/app/src/androidTest/java/eu/danman/zidostreamer/zidostreamer/ApplicationTest.java new file mode 100644 index 0000000..302a1fd --- /dev/null +++ b/app/src/androidTest/java/eu/danman/zidostreamer/zidostreamer/ApplicationTest.java @@ -0,0 +1,13 @@ +package eu.danman.zidostreamer.zidostreamer; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4c60d6d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/mstar/hdmirecorder/HdmiRecorder.java b/app/src/main/java/com/mstar/hdmirecorder/HdmiRecorder.java new file mode 100755 index 0000000..4ca4ae2 --- /dev/null +++ b/app/src/main/java/com/mstar/hdmirecorder/HdmiRecorder.java @@ -0,0 +1,370 @@ + +package com.mstar.hdmirecorder; + +import java.lang.ref.WeakReference; +import java.io.IOException; +import android.util.Log; +import java.io.FileDescriptor; +import java.io.FileOutputStream; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; + + + +public class HdmiRecorder{ + private int mNativeContext; + private EventHandler mEventHandler; + private OnErrorListener mOnErrorListener; + private OnInfoListener mOnInfoListener; + private String mPath; + private static final String TAG = "java.HdmiRecorder"; + + static { + System.loadLibrary("jni_capture"); + native_init(); + } + + public HdmiRecorder() + { + Looper looper; + if ((looper = Looper.myLooper()) != null) { + mEventHandler = new EventHandler(this, looper); + } else if ((looper = Looper.getMainLooper()) != null) { + mEventHandler = new EventHandler(this, looper); + } else { + mEventHandler = null; + } + + mNativeContext = 0; + native_setup(new WeakReference(this)); + + //hello(); + //postEventFromNative(0,0,0,0); + } + + + public native boolean native_start(); + public native boolean native_stop(); + public native void native_set_video_encoder_bitrate(int bitrate); + //public native void native_set_video_cameraid(int cameraid); + + //("video-size-values","1920x1080,1280x720,720x576,720x480,640x480,320x240,720x400,640x368,320x176") + public native void native_set_video_wigth(int video_wight); + public native void native_set_video_high(int video_hight); + + public native void native_set_video_framerate(int video_framerate); + private native boolean native_set_outputFD(Object fd); + public native void native_set_video_travelingMode(int travelingMode); + public native void native_set_video_subSource(int sub); + private native void native_set_output_format(int format); + + private static native void native_init(); + private native final void native_setup(Object mediarecorder_this); + private native final void native_finalize(); + + @Override + protected void finalize() { native_finalize(); } + + public void set_output_file_path(String path){ + mPath = path; + } + + + public static final int FORMAT_MP4 = 0; + public static final int FORMAT_TS = 1; + + public void set_output_format(int format){ + native_set_output_format((FORMAT_MP4 == format) ? 2 : 8); + } + + public boolean start(){ + boolean ret = true; + if (mPath != null) { + Log.v(TAG, "mPath = " + mPath); + try{ + Log.v(TAG, "start 1"); + FileOutputStream fos = new FileOutputStream(mPath); + try { + Log.v(TAG, "start 2"); + ret = native_set_outputFD(fos.getFD()); + if(ret){ + //native_set_video_cameraid(5); + Log.v(TAG, "start 3"); + ret = native_start(); + Log.v(TAG, "start 4"); + } + else{ + Log.e(TAG, "native_set_outputFD failed"); + } + } finally { + Log.v(TAG, "start 5"); + fos.close(); + } + }catch(IOException e){ + Log.e(TAG, " handle " + mPath + " error"); + ret = false; + } + + } else { + Log.e(TAG, "open " + mPath + " failed"); + return false; + } + + return ret; + } + + + + + + + + + + + //contents below are copy from MediaRecorder.java + + + /* Do not change this value without updating its counterpart + * in include/media/mediarecorder.h or mediaplayer.h! + */ + /** Unspecified media recorder error. + * @see android.media.MediaRecorder.OnErrorListener + */ + public static final int MEDIA_RECORDER_ERROR_UNKNOWN = 1; + /** Media server died. In this case, the application must release the + * MediaRecorder object and instantiate a new one. + * @see android.media.MediaRecorder.OnErrorListener + */ + public static final int MEDIA_ERROR_SERVER_DIED = 100; + + /** + * Interface definition for a callback to be invoked when an error + * occurs while recording. + */ + public interface OnErrorListener + { + /** + * Called when an error occurs while recording. + * + * @param mr the MediaRecorder that encountered the error + * @param what the type of error that has occurred: + * + * @param extra an extra code, specific to the error type + */ + void onError(HdmiRecorder mr, int what, int extra); + } + + /** + * Register a callback to be invoked when an error occurs while + * recording. + * + * @param l the callback that will be run + */ + public void setOnErrorListener(OnErrorListener l) + { + mOnErrorListener = l; + } + + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + /** Unspecified media recorder error. + * @see android.media.MediaRecorder.OnInfoListener + */ + public static final int MEDIA_RECORDER_INFO_UNKNOWN = 1; + /** A maximum duration had been setup and has now been reached. + * @see android.media.MediaRecorder.OnInfoListener + */ + public static final int MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800; + /** A maximum filesize had been setup and has now been reached. + * @see android.media.MediaRecorder.OnInfoListener + */ + public static final int MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801; + + /** informational events for individual tracks, for testing purpose. + * The track informational event usually contains two parts in the ext1 + * arg of the onInfo() callback: bit 31-28 contains the track id; and + * the rest of the 28 bits contains the informational event defined here. + * For example, ext1 = (1 << 28 | MEDIA_RECORDER_TRACK_INFO_TYPE) if the + * track id is 1 for informational event MEDIA_RECORDER_TRACK_INFO_TYPE; + * while ext1 = (0 << 28 | MEDIA_RECORDER_TRACK_INFO_TYPE) if the track + * id is 0 for informational event MEDIA_RECORDER_TRACK_INFO_TYPE. The + * application should extract the track id and the type of informational + * event from ext1, accordingly. + * + * FIXME: + * Please update the comment for onInfo also when these + * events are unhidden so that application knows how to extract the track + * id and the informational event type from onInfo callback. + * + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_LIST_START = 1000; + /** Signal the completion of the track for the recording session. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS = 1000; + /** Indicate the recording progress in time (ms) during recording. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_PROGRESS_IN_TIME = 1001; + /** Indicate the track type: 0 for Audio and 1 for Video. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_TYPE = 1002; + /** Provide the track duration information. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_DURATION_MS = 1003; + /** Provide the max chunk duration in time (ms) for the given track. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_MAX_CHUNK_DUR_MS = 1004; + /** Provide the total number of recordd frames. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_ENCODED_FRAMES = 1005; + /** Provide the max spacing between neighboring chunks for the given track. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INTER_CHUNK_TIME_MS = 1006; + /** Provide the elapsed time measuring from the start of the recording + * till the first output frame of the given track is received, excluding + * any intentional start time offset of a recording session for the + * purpose of eliminating the recording sound in the recorded file. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_INITIAL_DELAY_MS = 1007; + /** Provide the start time difference (delay) betweeen this track and + * the start of the movie. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_START_OFFSET_MS = 1008; + /** Provide the total number of data (in kilo-bytes) encoded. + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_DATA_KBYTES = 1009; + /** + * {@hide} + */ + public static final int MEDIA_RECORDER_TRACK_INFO_LIST_END = 2000; + + + /** + * Interface definition for a callback to be invoked when an error + * occurs while recording. + */ + public interface OnInfoListener + { + /** + * Called when an error occurs while recording. + * + * @param mr the MediaRecorder that encountered the error + * @param what the type of error that has occurred: + * + * @param extra an extra code, specific to the error type + */ + void onInfo(HdmiRecorder mr, int what, int extra); + } + + /** + * Register a callback to be invoked when an informational event occurs while + * recording. + * + * @param listener the callback that will be run + */ + public void setOnInfoListener(OnInfoListener listener) + { + mOnInfoListener = listener; + } + + private class EventHandler extends Handler + { + private HdmiRecorder mMediaRecorder; + + public EventHandler(HdmiRecorder mr, Looper looper) { + super(looper); + mMediaRecorder = mr; + } + + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + private static final int MEDIA_RECORDER_EVENT_LIST_START = 1; + private static final int MEDIA_RECORDER_EVENT_ERROR = 1; + private static final int MEDIA_RECORDER_EVENT_INFO = 2; + private static final int MEDIA_RECORDER_EVENT_LIST_END = 99; + + /* Events related to individual tracks */ + private static final int MEDIA_RECORDER_TRACK_EVENT_LIST_START = 100; + private static final int MEDIA_RECORDER_TRACK_EVENT_ERROR = 100; + private static final int MEDIA_RECORDER_TRACK_EVENT_INFO = 101; + private static final int MEDIA_RECORDER_TRACK_EVENT_LIST_END = 1000; + + + @Override + public void handleMessage(Message msg) { + if (mMediaRecorder.mNativeContext == 0) { + Log.w(TAG, "mediarecorder went away with unhandled events"); + return; + } + switch(msg.what) { + case MEDIA_RECORDER_EVENT_ERROR: + case MEDIA_RECORDER_TRACK_EVENT_ERROR: + if (mOnErrorListener != null) + mOnErrorListener.onError(mMediaRecorder, msg.arg1, msg.arg2); + + return; + + case MEDIA_RECORDER_EVENT_INFO: + case MEDIA_RECORDER_TRACK_EVENT_INFO: + if (mOnInfoListener != null) + mOnInfoListener.onInfo(mMediaRecorder, msg.arg1, msg.arg2); + + return; + + default: + Log.e(TAG, "Unknown message type " + msg.what); + return; + } + } + } + + /** + * Called from native code when an interesting event happens. This method + * just uses the EventHandler system to post the event back to the main app thread. + * We use a weak reference to the original MediaRecorder object so that the native + * code is safe from the object disappearing from underneath it. (This is + * the cookie passed to native_setup().) + */ + private static void postEventFromNative(Object mediarecorder_ref, + int what, int arg1, int arg2, Object obj) + { + HdmiRecorder mr = (HdmiRecorder)((WeakReference)mediarecorder_ref).get(); + if (mr == null) { + return; + } + + if (mr.mEventHandler != null) { + Message m = mr.mEventHandler.obtainMessage(what, arg1, arg2, obj); + mr.mEventHandler.sendMessage(m); + } + } + + public void hello(){ + Log.i(TAG, "hello"); + } + +} + + + diff --git a/app/src/main/java/eu/danman/zidostreamer/zidostreamer/MainActivity.java b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/MainActivity.java new file mode 100644 index 0000000..c42e161 --- /dev/null +++ b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/MainActivity.java @@ -0,0 +1,59 @@ +package eu.danman.zidostreamer.zidostreamer; + +import android.content.Intent; +import android.os.StrictMode; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + + +public class MainActivity extends ActionBarActivity { + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); +// setContentView(R.layout.activity_main); + +// StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); + +// StrictMode.setThreadPolicy(policy); + + + + + Intent service = new Intent(this, StreamService.class); + startService(service); + + finish(); + +// while (true){ +// ut.dataSend("test".getBytes()); +// } + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/eu/danman/zidostreamer/zidostreamer/StreamService.java b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/StreamService.java new file mode 100644 index 0000000..443aa40 --- /dev/null +++ b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/StreamService.java @@ -0,0 +1,148 @@ +package eu.danman.zidostreamer.zidostreamer; + +import android.app.Service; +import android.content.Context; +import android.content.ContextWrapper; +import android.content.Intent; +import android.os.IBinder; +import android.system.ErrnoException; +import android.util.Log; + +import com.mstar.hdmirecorder.HdmiRecorder; + +import java.io.File; + +import static android.system.Os.mkfifo; + +public class StreamService extends Service { + + private HdmiRecorder mHdmiRecorder = null; + + String path; + + public StreamService() { + + //path=this.getApplicationContext().getFilesDir().getAbsolutePath() + "/stream"; + + path = "/data/data/eu.danman.zidostreamer.zidostreamer/stream.ts"; + path = "/mnt/sdcard/stream.ts"; + + + /* + int res = 0; + try { + mkfifo(path, 00007); + } catch (ErrnoException e) { + e.printStackTrace(); + } + if (res != 0) + { + Log.d("fifo", "Error while creating a pipe (return:%d, errno:%d)"); + return; + } + + */ + + /* + UdpThread ut; + + ut = new UdpThread(path); + + //ut.openFile("/mnt/usb/sda1/HdmiRecorder/video20151205210104.ts"); + + ut.start(); + + */ + Log.d("fifo", "Error while creating a pipe (return:%d, errno:%d)"); + + } + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + //TODO do something useful + + + + Log.d("Streamer", "instantiate Recorder"); + mHdmiRecorder = new HdmiRecorder(); + Log.d("Streamer", "set error listener"); + + mHdmiRecorder.setOnErrorListener(moErrorListener); + Log.d("Streamer", "set info listener"); + + mHdmiRecorder.setOnInfoListener(mOnInfoListener); + Log.d("Streamer", "set file path"); + + mHdmiRecorder.set_output_file_path(path); + Log.d("Streamer", "set format"); + + mHdmiRecorder.set_output_format(HdmiRecorder.FORMAT_TS); + Log.d("Streamer", "set W&H"); + + mHdmiRecorder.native_set_video_high(1080); + mHdmiRecorder.native_set_video_wigth(1920); + Log.d("Streamer", "set bitrate"); + + mHdmiRecorder.native_set_video_encoder_bitrate(5 * 1024 * 1024); + + Log.d("Streamer", "set framerate"); + + mHdmiRecorder.native_set_video_framerate(30); + + Log.d("Streamer", "set travel mode??"); + + mHdmiRecorder.native_set_video_travelingMode(4); + + Log.d("Streamer", "set sub source?"); + + mHdmiRecorder.native_set_video_subSource(23); + + Log.d("Streamer", "start recording"); + + boolean ret = mHdmiRecorder.start(); + + return Service.START_NOT_STICKY; + + } + + HdmiRecorder.OnInfoListener mOnInfoListener = new HdmiRecorder.OnInfoListener() { + + @Override + public void onInfo(com.mstar.hdmirecorder.HdmiRecorder mr, int what, int extra) { + System.out.println("bob--mOnInfoListener what-===" + what); + if (what == HdmiRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) { + mHdmiRecorder.native_stop(); + } else if (what == HdmiRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) { + } + + } + }; + + HdmiRecorder.OnErrorListener moErrorListener = new HdmiRecorder.OnErrorListener() { + + @Override + public void onError(com.mstar.hdmirecorder.HdmiRecorder mr, int what, int extra) { + System.out.println("bob--moErrorListener what-===" + what); + mHdmiRecorder.native_stop(); + // Toast.makeText(mContext, + // "error occur when recording what-=== " + // + what, + // Toast.LENGTH_LONG).show(); + if (what == HdmiRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) { + // We may have + // run out of + // space on the + // sdcard. + // Show the + // toast. + } + } + }; + + @Override + public IBinder onBind(Intent intent) { + // TODO: Return the communication channel to the service. + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/app/src/main/java/eu/danman/zidostreamer/zidostreamer/UdpThread.java b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/UdpThread.java new file mode 100644 index 0000000..3e0cf2e --- /dev/null +++ b/app/src/main/java/eu/danman/zidostreamer/zidostreamer/UdpThread.java @@ -0,0 +1,168 @@ +package eu.danman.zidostreamer.zidostreamer; + +/** + * Created by dano on 12/5/15. + */ + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.URL; +import java.net.URLConnection; +import java.util.Arrays; +import java.util.Comparator; + + +public class UdpThread extends Thread{ + + DatagramSocket ds = null; + DatagramPacket dp; + + InetAddress server = null; + + String path = null; + + int port = 1234; +// String serverName = "10.0.0.149"; + String serverName = "239.255.0.1"; +// String serverName = "danman.eu"; + +// byte [] addr = new byte[] {(byte)10,(byte)0,(byte)0,(byte)149}; + + public UdpThread(String m_path){ + + path = m_path; + +// File f = new File("/mnt/usb/sda1/HdmiRecorder"); +// File f = new File("/sdcard/HdmiRecorder"); + + /* + File [] files = f.listFiles(); + +Arrays.sort(files, new Comparator() { + public int compare(Object o1, Object o2) { + + if (((File) o1).lastModified() > ((File) o2).lastModified()) { + return -1; + } else if (((File) o1).lastModified() < ((File) o2).lastModified()) { + return +1; + } else { + return 0; + } + } + +}); + file = files[0]; + + Log.d("file",file.getAbsolutePath()); +*/ + } +/* + public void openFile(String filename){ + + file = new File(filename); + + } +*/ + + public void run() { + File file = new File(path); + + while (server == null){ + try { + server = InetAddress.getByName(serverName); +// server = InetAddress.getByAddress(addr); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + while (ds == null){ + + try { + ds = new DatagramSocket(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + String message; + byte[] lmessage = new byte[1500]; + DatagramPacket packet = new DatagramPacket(lmessage, lmessage.length); + + +// dataSend("".getBytes()); + + FileInputStream dis; + + try { + dis = new FileInputStream(file); + try { + + String tsdata; + byte[] tsdatab = new byte[1366]; + + while (true) { + + /* + tsdata = ""; + + while (tsdata.length() <1366) { + + + tsdata += dis.readByte(); + + } + */ + + if (dis.available() > 1365){ + dis.read(tsdatab, 0, 1366); + + dataSend(tsdatab); + + } + + } + } catch (IOException e) { + e.printStackTrace(); + } + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + + } + + public void dataSend(byte[] data) throws IOException { + dp = new DatagramPacket(data, data.length, server, port); + + ds.send(dp); + + } + + +} \ No newline at end of file diff --git a/app/src/main/jniLibs/armeabi-v7a/libjni_capture.so b/app/src/main/jniLibs/armeabi-v7a/libjni_capture.so new file mode 100644 index 0000000..ae5cb13 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libjni_capture.so differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f7158b8 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..b1cb908 --- /dev/null +++ b/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..a256e98 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ + + ZidoStreamer + + Hello world! + Settings + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..766ab99 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..d3ff69d --- /dev/null +++ b/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.1.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..1d3591c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c71e76 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/mstar_system_sign_tool/platform.pk8 b/mstar_system_sign_tool/platform.pk8 new file mode 100755 index 0000000..e27a393 Binary files /dev/null and b/mstar_system_sign_tool/platform.pk8 differ diff --git a/mstar_system_sign_tool/platform.x509.pem b/mstar_system_sign_tool/platform.x509.pem new file mode 100755 index 0000000..087f02e --- /dev/null +++ b/mstar_system_sign_tool/platform.x509.pem @@ -0,0 +1,27 @@ +-----BEGIN CERTIFICATE----- +MIIEqDCCA5CgAwIBAgIJALOZgIbQVs/6MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD +VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g +VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE +AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe +Fw0wODA0MTUyMjQwNTBaFw0zNTA5MDEyMjQwNTBaMIGUMQswCQYDVQQGEwJVUzET +MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G +A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p +ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI +hvcNAQEBBQADggENADCCAQgCggEBAJx4BZKsDV04HN6qZezIpgBuNkgMbXIHsSAR +vlCGOqvitV0Amt9xRtbyICKAx81Ne9smJDuKgGwms0sTdSOkkmgiSQTcAUk+fArP +GgXIdPabA3tgMJ2QdNJCgOFrrSqHNDYZUer3KkgtCbIEsYdeEqyYwap3PWgAuer9 +5W1Yvtjo2hb5o2AJnDeoNKbf7be2tEoEngeiafzPLFSW8s821k35CjuNjzSjuqtM +9TNxqydxmzulh1StDFP8FOHbRdUeI0+76TybpO35zlQmE1DsU1YHv2mi/0qgfbX3 +6iANCabBtJ4hQC+J7RGQiTqrWpGA8VLoL4WkV1PPX8GQccXuyCcCAQOjgfwwgfkw +HQYDVR0OBBYEFE/koLPdnLop9x1yh8Tnw48ghsKZMIHJBgNVHSMEgcEwgb6AFE/k +oLPdnLop9x1yh8Tnw48ghsKZoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE +CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH +QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG +CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJALOZgIbQVs/6MAwGA1Ud +EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBAFclUbjZOh9z3g9tRp+G2tZwFAAp +PIigzXzXeLc9r8wZf6t25iEuVsHHYc/EL9cz3lLFCuCIFM78CjtaGkNGBU2Cnx2C +tCsgSL+ItdFJKe+F9g7dEtctVWV+IuPoXQTIMdYT0Zk4u4mCJH+jISVroS0dao+S +6h2xw3Mxe6DAN/DRr/ZFrvIkl5+6bnoUvAJccbmBOM7z3fwFlhfPJIRc97QNY4L3 +J17XOElatuWTG5QhdlxJG3L7aOCA29tYwgKdNHyLMozkPvaosVUz7fvpib1qSN1L +IC7alMarjdW4OZID2q4u1EYjLk/pvZYTlMYwDlE448/Shebk5INTjLixs1c= +-----END CERTIFICATE----- diff --git a/mstar_system_sign_tool/signapk.jar b/mstar_system_sign_tool/signapk.jar new file mode 100755 index 0000000..9547adf Binary files /dev/null and b/mstar_system_sign_tool/signapk.jar differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/sign.sh b/sign.sh new file mode 100755 index 0000000..881f24a --- /dev/null +++ b/sign.sh @@ -0,0 +1,4 @@ +rm -f signed.apk +java -jar mstar_system_sign_tool/signapk.jar mstar_system_sign_tool/platform.x509.pem mstar_system_sign_tool/platform.pk8 app/build/outputs/apk/app-debug.apk signed.apk + +adb install -r signed.apk diff --git a/signed.apk b/signed.apk new file mode 100644 index 0000000..bddff65 Binary files /dev/null and b/signed.apk differ