Im przesyłam strumieniowo wideo do urządzenia z systemem Android przy użyciu Gstreamer i udpsrc. Problem, z jakim się spotykam, polega na tym, że strumień działa tylko przez kilka sekund, a następnie zatrzymuje się (wyświetlana jest trwale zatrzymana klatka). Najpierw tworzę serwer TCP na moim urządzeniu z Androidem, który jest używany przez urządzenie hostujące wideo do połączenia. Aby to zrobić, używam ServerSocket i wątków w MainActivity:

  class ServerThread implements Runnable {

        public void run() {
            Socket socket = null;
            Log.d(TAG, "running server thread");
            try {
                serverSocket = new ServerSocket(SERVERPORT);
            } catch (IOException e) {
                Log.d(TAG,e.getLocalizedMessage());
                e.printStackTrace();
            }
            while (!Thread.currentThread().isInterrupted()) {

                try {

                    socket = serverSocket.accept();

                    CommunicationThread commThread = new CommunicationThread(socket);
                    new Thread(commThread).start();

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    class CommunicationThread implements Runnable {

        private Socket clientSocket;

        private BufferedReader input;

        public CommunicationThread(Socket clientSocket) {

            this.clientSocket = clientSocket;

            try {
                this.input = new BufferedReader(new InputStreamReader(this.clientSocket.getInputStream()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        public void run() {
            while (!Thread.currentThread().isInterrupted()) {

                try {

                    String read = input.readLine();
                    PrintWriter out = new PrintWriter(new BufferedWriter(
                            new OutputStreamWriter(clientSocket.getOutputStream())),
                            true);
                    Log.d(TAG, "Received message: " + read);

                    String msg = "Stream\r";
                    Log.d(TAG, "Sending message: " + msg);
                    out.println(msg);

                    if (read != null && read.equals("Stream")) {
                        Log.d(TAG,"Starting stream");
                        updateConversationHandler.post(new updateUIThread("OK"));
                        nativePlay();
                    }
//                    if(read!=null) updateConversationHandler.post(new updateUIThread(read));

                } catch (IOException e) {
                    Log.d(TAG, e.getMessage());
                    Log.d(TAG, e.getLocalizedMessage());
                    e.printStackTrace();
                }
            }
        }

    }

Moja aplikacja to w zasadzie samouczek 3 Gstreamera (https: //gstreamer.freedesktop.org/documentation/tutorials/android/video.html?gi-language=c), z dodanym ServerSocket i gdzie zaktualizowałem potok w kodzie c, aby używać udpsrc

  gst_parse_launch ("udpsrc buffer-size=622080 port=8001 ! application/x-rtp, encoding-name=JPEG, payload=96 ! rtpjpegdepay ! jpegdec ! autovideosink sync=false",
      &error);

To, co się dzieje, to strumień wideo przez kilka sekund, a następnie po prostu się zatrzymuje. Podczas gdy otrzymuję strumień, wyjście dziennika gstreamera jest podobne

2019-11-20 13:33:57.149 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:40.650418010 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header

Ale kiedy wideo się zatrzymuje, również się zatrzymuje.

Czy możesz mi pomóc określić, gdzie może być potencjalny problem? Czy to możliwe, że coś jest nie tak ze sposobem, w jaki zarządzam połączeniem TCP? Strumień działa dobrze na innych urządzeniach.

Poniżej znajduje się pełne wyjście Logcat

2019-11-20 13:33:56.836 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/GStreamer+tutorial-3: 0:00:40.337306818 0x717b1f8c70 /Users/radek/dev/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial-3/jni/tutorial-3.c:286:gst_native_play Setting state to PLAYING
2019-11-20 13:33:56.998 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.498616587 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:1, Error:glBeginQueryEXT::failed to allocate CPU memory
2019-11-20 13:33:56.998 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.499609894 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:149, Error:glEndQueryEXT::query name is 0
2019-11-20 13:33:56.999 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.499794818 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:1, Error:glBeginQueryEXT::failed to allocate CPU memory
2019-11-20 13:33:56.999 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.500697125 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:149, Error:glEndQueryEXT::query name is 0
2019-11-20 13:33:57.001 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.502285471 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:1, Error:glBeginQueryEXT::failed to allocate CPU memory
2019-11-20 13:33:57.001 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.502463087 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:149, Error:glEndQueryEXT::query name is 0
2019-11-20 13:33:57.028 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
2019-11-20 13:33:57.057 22940-23059/org.freedesktop.gstreamer.tutorials.tutorial_3 D/GStreamer+tutorial-3: 0:00:40.558404894 0x717b055090 /Users/radek/dev/StudioProjects/gst-docs/examples/tutorials/android/android-tutorial-3/jni/tutorial-3.c:97:set_ui_message Setting message to: State changed to PLAYING
2019-11-20 13:33:57.093 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.594268125 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:151, Error:glGetQueryObjectui64vEXT::invalid query object
2019-11-20 13:33:57.096 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.596843356 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:151, Error:glGetQueryObjectui64vEXT::invalid query object
2019-11-20 13:33:57.099 22940-23082/org.freedesktop.gstreamer.tutorials.tutorial_3 E/GStreamer+gldebug: 0:00:40.600435779 0x717b1f9400 ../gst-libs/gst/gl/gstgldebug.c:307:_gst_gl_debug_callback:<glcontextegl1> high: GL error from API id:151, Error:glGetQueryObjectui64vEXT::invalid query object
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.959991772 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960143734 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960289465 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960433234 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960561618 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.459 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960688349 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.460 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960815503 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.460 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.960941618 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.460 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.961071618 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.460 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.961200888 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.460 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.961325657 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.461 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.962256080 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.461 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.962511811 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.461 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.962655965 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.962811465 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.962956503 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963086965 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963211542 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963336965 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963463426 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963592272 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.462 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963717811 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.963869234 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964007195 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964146118 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964283234 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964451157 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964586465 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.463 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964723388 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.464 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964858849 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.464 22940-23095/org.freedesktop.gstreamer.tutorials.tutorial_3 W/GStreamer+rtpjpegdepay: 0:00:49.964997195 0x717b0471e0 ../gst/rtp/gstrtpjpegdepay.c:759:gst_rtp_jpeg_depay_process:<rtpjpegdepay0> discarding data packets received when we have no header
2019-11-20 13:34:06.734 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.735 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.736 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.759 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 I/chatty: uid=11215(org.freedesktop.gstreamer.tutorials.tutorial_3) Thread-7 identical 6 lines
2019-11-20 13:34:06.761 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.763 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.764 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.765 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
2019-11-20 13:34:06.766 22940-23426/org.freedesktop.gstreamer.tutorials.tutorial_3 D/TCPServerDebug: Received message: null
1
shtas 20 listopad 2019, 16:44

1 odpowiedź

Najlepsza odpowiedź

Wygląda na to, że problem polega na utrzymaniu połączenia przy życiu, metoda keepAlive nic nie robi bez obrotu, ale zawsze, gdy wysyłam puste wiadomości do klienta, wideo nadal działa.

0
shtas 20 listopad 2019, 18:14