fyhertz / libstreaming-examples

Some examples of how to use libstreaming
283 stars 231 forks source link

Example 1 not working properly #10

Open dannyboyukliev opened 10 years ago

dannyboyukliev commented 10 years ago

I've run Example 1 on my device and now I'm trying to connect it to my computer through VLC. The problem is that it connects for 1 or several seconds and then disconnects, so that there is no video in the VLC. Here's the log I've received. Do you know any solution?

05-12 16:20:12.027: D/dalvikvm(15825): GC_CONCURRENT freed 379K, 5% free 8161K/8583K, paused 13ms+2ms, total 40ms 05-12 16:20:12.027: D/dalvikvm(15825): WAIT_FOR_CONCURRENT_GC blocked 20ms 05-12 16:20:12.037: I/First(15825): IP: rtsp://192.168.1.8:1234 05-12 16:20:29.043: I/RtspServer(15825): Connection from 192.168.1.7 05-12 16:20:29.043: E/RtspServer(15825): OPTIONS rtsp://192.168.1.8:1234/ 05-12 16:20:29.043: D/RtspServer(15825): RTSP/1.0 200 OK 05-12 16:20:29.043: D/RtspServer(15825): Server: MajorKernelPanic RTSP Server 05-12 16:20:29.043: D/RtspServer(15825): Cseq: 2 05-12 16:20:29.043: D/RtspServer(15825): Content-Length: 0 05-12 16:20:29.043: D/RtspServer(15825): Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE 05-12 16:20:29.053: E/RtspServer(15825): DESCRIBE rtsp://192.168.1.8:1234/ 05-12 16:20:29.083: I/dalvikvm(15825): Could not find method android.media.MediaCodec.createInputSurface, referenced from method net.majorkernelpanic.streaming.video.VideoStream.encodeWithMediaCodecMethod2 05-12 16:20:29.083: W/dalvikvm(15825): VFY: unable to resolve virtual method 361: Landroid/media/MediaCodec;.createInputSurface ()Landroid/view/Surface; 05-12 16:20:29.083: D/dalvikvm(15825): VFY: replacing opcode 0x6e at 0x005e 05-12 16:20:29.093: I/MediaStream(15825): Phone supports the MediaCoded API 05-12 16:20:29.154: D/dalvikvm(15825): GC_CONCURRENT freed 211K, 3% free 8464K/8711K, paused 5ms+5ms, total 43ms 05-12 16:20:29.164: D/dalvikvm(15825): WAIT_FOR_CONCURRENT_GC blocked 25ms 05-12 16:20:29.334: V/VideoQuality(15825): Supported resolutions: 960x540, 720x540, 720x480, 640x480, 480x320, 352x288, 320x240, 176x144 05-12 16:20:29.334: V/VideoQuality(15825): Supported frame rates: 1-15fps, 1-30fps 05-12 16:20:29.634: I/OMXClient(15825): Using client-side OMX mux. 05-12 16:20:29.674: I/OMXClient(15825): Using client-side OMX mux. 05-12 16:20:29.684: I/ENSLoader(15825): Scanning directory /system/lib/ste_omxcomponents/ for STE ENS based components 05-12 16:20:29.954: E/libals-utils(15825): verify_interface: can't access '/sys/bus/i2c/devices/2-0037/als' 05-12 16:20:29.954: E/libals-noa3402(15825): noa3402_init: unable to access 'als' 05-12 16:20:29.954: I/libals-tsl2772(15825): tsl2772_init: device '/sys/devices/virtual/input/input10/', input event '/dev/input/event10' ok 05-12 16:20:30.054: E/BellagioCore(15825): ST Static Component Loader : Cannot open OpenMAX registry file /tmp/.omxregister 05-12 16:20:30.054: E/BellagioCore(15825): Component loader 1 constructor fails. Error= 0x80001000 05-12 16:20:30.054: E/OMXMaster(15825): A component of name 'OMX.ST.AFM.decoder.wmapro_v10' already exists, ignoring this one. 05-12 16:20:30.064: I/OMXClient(15825): Using client-side OMX mux. 05-12 16:20:30.074: E/EncoderDebugger(15825): No usable encoder were found on the phone for resolution 176x144 05-12 16:20:30.074: E/H264Stream(15825): Resolution not supported with the MediaCodec API, we fallback on the old streamign method. 05-12 16:20:30.074: I/H264Stream(15825): Testing H264 support... Test file saved at: /storage/sdcard0/spydroid-test.mp4 05-12 16:20:30.185: D/VideoStream(15825): Unlocking camera 05-12 16:20:30.195: I/MediaRecorderJNI(15825): prepare: surface=0x57254008 (identity=295) 05-12 16:20:30.205: E/MediaRecorder(15825): start failed: -19 05-12 16:20:30.205: E/MediaRecorder(15825): stop called in an invalid state: 0 05-12 16:20:30.215: D/VideoStream(15825): Locking camera 05-12 16:20:30.215: E/RtspServer(15825): start failed. 05-12 16:20:30.215: W/System.err(15825): net.majorkernelpanic.streaming.exceptions.ConfNotSupportedException: start failed. 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.video.H264Stream.testMediaRecorderAPI(H264Stream.java:239) 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.video.H264Stream.testH264(H264Stream.java:120) 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.video.H264Stream.testMediaCodecAPI(H264Stream.java:138) 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.video.H264Stream.testH264(H264Stream.java:119) 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.video.H264Stream.configure(H264Stream.java:111) 05-12 16:20:30.215: W/System.err(15825): at net.majorkernelpanic.streaming.Session.syncConfigure(Session.java:408) 05-12 16:20:30.225: W/System.err(15825): at net.majorkernelpanic.streaming.rtsp.RtspServer$WorkerThread.processRequest(RtspServer.java:439) 05-12 16:20:30.225: W/System.err(15825): at net.majorkernelpanic.streaming.rtsp.RtspServer$WorkerThread.run(RtspServer.java:390) 05-12 16:20:30.225: D/RtspServer(15825): RTSP/1.0 500 Internal Server Error 05-12 16:20:30.225: D/RtspServer(15825): Server: MajorKernelPanic RTSP Server 05-12 16:20:30.225: D/RtspServer(15825): Cseq: 3 05-12 16:20:30.225: D/RtspServer(15825): Content-Length: 0 05-12 16:20:30.365: I/RtspServer(15825): Client disconnected 05-12 16:20:35.269: I/RtspServer(15825): Connection from 192.168.1.7 05-12 16:20:35.279: E/RtspServer(15825): OPTIONS rtsp://192.168.1.8:1234 05-12 16:20:35.279: D/RtspServer(15825): RTSP/1.0 200 OK 05-12 16:20:35.279: D/RtspServer(15825): Server: MajorKernelPanic RTSP Server 05-12 16:20:35.279: D/RtspServer(15825): Cseq: 1 05-12 16:20:35.279: D/RtspServer(15825): Content-Length: 0 05-12 16:20:35.279: D/RtspServer(15825): Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE 05-12 16:20:35.289: I/RtspServer(15825): Client disconnected

fyhertz commented 10 years ago

Hi,

The ConfNotSupportedException means that streaming is not possible on your particular device, with the settings you have provided...

You need to try a different combination of (resolution, frame rate, bitrate)

Btw, you can see from the stack trace that libstreaming failed to use an encoder with the resolution 176x144 on your device through the MediaCodec API.

Regards

dannyboyukliev commented 10 years ago

Thank you for the fast answer,

You've been right. It seems like the problem is coming from the createInputSurface() method the example is using by default. It's been introduced in Android 4.3 while my device (Xperia P) is with Android 4.1.2.

Hopefully I've been helpful to others.

Best luck!

rsruthi commented 10 years ago

can the rtsp streaming be started before requesting from VLC player? when client does not view the stream, stream can be stored in sdcard. Can this example be used in live streaming scenario? why do we have to send a request to start streaming? can we see this stream remotely? Example 1 is not working on my phone that has android 4.1. but when my mediacodecAPI does not support, mediarecorderAPI is getting called anyway. then, why is it not working. what basic resoultion and bitrates do you suggest?

Rajiv083 commented 8 years ago

hey i am working on Vuzix M100 smart Glass. and i have set all the parameters to its lowest value. still getting errors, same described above. Please let m eknow the solution.

jason4007 commented 8 years ago

I'm having trouble when connecting to the rtsp server. Any advice?

04-06 13:55:55.095 29826-29826/? I/art: Late-enabling -Xcheck:jni
04-06 13:55:55.131 29826-29826/? W/ResourceType: Found multiple library tables, ignoring...
04-06 13:55:55.136 29826-29836/? I/art: Debugger is no longer active
04-06 13:55:55.215 29826-29846/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-06 13:55:55.221 29826-29826/? D/Atlas: Validating map...
04-06 13:55:55.227 29826-29847/? I/RtspServer: RTSP server listening on port 9000
04-06 13:55:55.248 29826-29846/? I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030_msm8974_LA.BF.1.1.1_RB1__release_AU ()
                                               OpenGL ES Shader Compiler Version: E031.25.03.06
                                               Build Date: 07/13/15 Mon
                                               Local Branch: mybranch11906725
                                               Remote Branch: quic/LA.BF.1.1.1_rb1.26
                                               Local Patches: NONE
                                               Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030 + 6151be1 + a1e0343 + 002d7d6 + 7d0e3f7 +  NOTHING
04-06 13:55:55.249 29826-29846/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-06 13:55:55.264 29826-29846/? D/OpenGLRenderer: Enabling debug mode 0
04-06 13:55:55.323 29826-29826/? I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@25e5e750 time:1688390
04-06 13:56:02.427 29826-29950/com.example.user.streamingserverexample I/RtspServer: Connection from 192.168.1.41
04-06 13:56:02.431 29826-29950/com.example.user.streamingserverexample E/RtspServer: OPTIONS rtsp://192.168.1.94:9000
04-06 13:56:02.431 29826-29950/com.example.user.streamingserverexample D/RtspServer: RTSP/1.0 200 OK
                                                                                     Server: MajorKernelPanic RTSP Server
                                                                                     Cseq: 2
                                                                                     Content-Length: 0
                                                                                     Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE
04-06 13:56:02.436 29826-29950/com.example.user.streamingserverexample E/RtspServer: DESCRIBE rtsp://192.168.1.94:9000
04-06 13:56:02.437 29826-29950/com.example.user.streamingserverexample E/RtspServer: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
04-06 13:56:02.437 29826-29950/com.example.user.streamingserverexample W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
04-06 13:56:02.438 29826-29950/com.example.user.streamingserverexample W/System.err:     at net.majorkernelpanic.streaming.rtsp.UriParser.parse(UriParser.java:69)
04-06 13:56:02.439 29826-29950/com.example.user.streamingserverexample W/System.err:     at net.majorkernelpanic.streaming.rtsp.RtspServer.handleRequest(RtspServer.java:314)
04-06 13:56:02.439 29826-29950/com.example.user.streamingserverexample W/System.err:     at net.majorkernelpanic.streaming.rtsp.RtspServer$WorkerThread.processRequest(RtspServer.java:461)
04-06 13:56:02.439 29826-29950/com.example.user.streamingserverexample W/System.err:     at net.majorkernelpanic.streaming.rtsp.RtspServer$WorkerThread.run(RtspServer.java:406)
04-06 13:56:02.439 29826-29950/com.example.user.streamingserverexample D/RtspServer: RTSP/1.0 500 Internal Server Error
                                                                                     Server: MajorKernelPanic RTSP Server
                                                                                     Cseq: 3
                                                                                     Content-Length: 0
04-06 13:56:02.445 29826-29950/com.example.user.streamingserverexample I/RtspServer: Client disconnected
04-06 13:56:04.738 29826-29986/com.example.user.streamingserverexample I/RtspServer: Connection from 192.168.1.41
04-06 13:56:04.744 29826-29986/com.example.user.streamingserverexample E/RtspServer: OPTIONS rtsp://192.168.1.94:9000
04-06 13:56:04.744 29826-29986/com.example.user.streamingserverexample D/RtspServer: RTSP/1.0 200 OK
                                                                                     Server: MajorKernelPanic RTSP Server
                                                                                     Cseq: 1
                                                                                     Content-Length: 0
                                                                                     Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE
04-06 13:56:04.749 29826-29986/com.example.user.streamingserverexample I/RtspServer: Client disconnected
chenshaoze commented 8 years ago

hi @jason4007, your uri have no queryParams, so "URI.create(uri).getQuery()" return null in net.majorkernelpanic.streaming.rtsp.UriParser.parse. You can do like this `public static Session parse(String uri) throws IllegalStateException, IOException {

    SessionBuilder builder = SessionBuilder.getInstance().clone();
    byte audioApi = 0, videoApi = 0;
    String queryStr = URI.create(uri).getQuery();
    if (queryStr != null) {
        String[] queryParams = queryStr.split("&");
        ContentValues params = new ContentValues();
        for (String param : queryParams) {
            String[] keyValue = param.split("=");
            String value = "";
            try {
                value = keyValue[1];
            } catch (ArrayIndexOutOfBoundsException e) {
            }

            params.put(
                    URLEncoder.encode(keyValue[0], "UTF-8"), // Name
                    URLEncoder.encode(value, "UTF-8")  // Value
            );

        } ...`

It will be work fine!

jason4007 commented 8 years ago

You are right @chenshaoze - it w0rks. I needed to add the following to the uri to make streaming possible: ?videoapi=mr&camera=back&h264=2000-15-1280-720 I was also able to stream audio and video with default video settings but at the moment I don't get any audio with hd video - I guess I need to play around with the parameters a little more.