Insert data to pipe with UDPSRC
yxxone
xuchangxue365812 at 126.com
Wed Nov 27 04:57:19 PST 2013
I record video with ANDROID "MediaRecorder" and send it to my pipeline which
will send it via RTP .
My plan : use UDP to send data come from "MediaRecorder" to the pipeline
which get the data with UDPsrc.
some of my java code:
nativeInit();
try {
mSender = new DatagramSocket(7000);
} catch (SocketException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
mSender.connect(InetAddress.getLocalHost(), 8000);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mParcelFileDescriptor = ParcelFileDescriptor.fromDatagramSocket(mSender);
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
mMediaRecorder.setVideoSize(mylist.get(0).width, mylist.get(0).height);
mMediaRecorder.setOutputFile(mParcelFileDescriptor.getFileDescriptor());
in JNI the "nativeInit()" :
videosrc = gst_element_factory_make("udpsrc", "videosrc");
g_assert(videosrc);
g_object_set(videosrc, "port", 8000, NULL);
but code "mSender.connect(InetAddress.getLocalHost(), 8000);" always end up
with error:
11-27 20:53:28.510: W/System.err(13001):
android.os.NetworkOnMainThreadException
11-27 20:53:28.510: W/System.err(13001): at
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1133)
11-27 20:53:28.517: W/System.err(13001): at
java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-27 20:53:28.517: W/System.err(13001): at
java.net.InetAddress.getLocalHost(InetAddress.java:365)
11-27 20:53:28.525: W/System.err(13001): at
cn.android.test.Test.start(Test.java:219)
11-27 20:53:28.525: W/System.err(13001): at
cn.android.test.Test$2.onClick(Test.java:105)
11-27 20:53:28.525: W/System.err(13001): at
android.view.View.performClick(View.java:4240)
11-27 20:53:28.525: W/System.err(13001): at
android.view.View$PerformClick.run(View.java:17721)
11-27 20:53:28.533: W/System.err(13001): at
android.os.Handler.handleCallback(Handler.java:730)
11-27 20:53:28.533: W/System.err(13001): at
android.os.Handler.dispatchMessage(Handler.java:92)
11-27 20:53:28.533: W/System.err(13001): at
android.os.Looper.loop(Looper.java:137)
11-27 20:53:28.533: W/System.err(13001): at
android.app.ActivityThread.main(ActivityThread.java:5103)
11-27 20:53:28.533: W/System.err(13001): at
java.lang.reflect.Method.invokeNative(Native Method)
11-27 20:53:28.541: W/System.err(13001): at
java.lang.reflect.Method.invoke(Method.java:525)
11-27 20:53:28.541: W/System.err(13001): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-27 20:53:28.541: W/System.err(13001): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-27 20:53:28.541: W/System.err(13001): at
dalvik.system.NativeStart.main(Native Method)
I have to questions:
1. Is my plan reasonable?
2. can any one give me some other ways to manage the task? (let the
pipeline get data from "MediaRecorder" with no delay)
thanks in advance.
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Insert-data-to-pipe-with-UDPSRC-tp4663649.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list