[Android] [Appsink] [Appsrc] Strange behavior when displaying the receiving raw data via appsrc
Nicolas Dufresne
nicolas at ndufresne.ca
Tue Mar 3 14:15:49 UTC 2020
Le mar. 3 mars 2020 05 h 30, sofien rahmouni <sofien.rahmouni at gmail.com> a
écrit :
> Hello,
> i have an issue of strange behavior when display the received raw data h264
> is half of the screen is grey.
>
> The issue only reproduce on internet network (in local network is work
> perfectely)
>
> On my code i have two pipeline:
>
> 1 - Pipeline: Appsink which take the ahcsrc as a source video and send
> it
> as a raw by a UdpSocket on java
>
> / Sample Send data APPSINK
> data->pipeline = gst_parse_launch(
> "ahcsrc device=1 ! video/x-raw,format=(string)NV21 ! tee name=t t.
> ! queue ! autovideosink sync=false t. ! queue ! video/x-raw, width=320,
> height=240 ! videoconvert ! x264enc bitrate=500 speed-preset=superfast
> tune=zerolatency ! rtph264pay mtu=1024 ! appsink
> name=callback_read_buffer_sink emit-signals=true",
> &error);
> 1.1 - Callback de l'appsink :
>
> GstElement *testsink = NULL;
> /* we use appsink in push mode, it sends us a signal when data is
> available
> * and we pull out the data in the signal callback. */
> testsink = gst_bin_get_by_name(GST_BIN(data->pipeline),
> "callback_read_buffer_sink");
>
> if (testsink == NULL) {
> g_print("appsink is NULL\n");
> }
> g_signal_connect(testsink, "new-sample", G_CALLBACK(cb_new_sample), NULL);
> gst_object_unref(testsink);
>
> if (error) {
> gchar *message =
> g_strdup_printf("Unable to build pipeline: %s",
> error->message);
> g_clear_error(&error);
> set_ui_message(message, data);
> g_free(message);
> return NULL;
> }
>
> 2- Pipeline: Appsrc which receive a data raw video h264 and display it via
> autovideosink
>
> // Sample Receive data APPSRC
> data->pipeline = gst_parse_launch(
> "appsrc name=video_app_source is-live=true !
>
> application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96
> ! rtpjitterbuffer latency=10 ! rtph264depay ! h264parse ! avdec_h264 !
> videoconvert ! autovideosink",
> &error);
> 2.1 - Callback de l'appsrc :
> static void gst_native_receive_video_data(JNIEnv *env, jobject thiz,
> jbyteArray array) {
>
> jbyte *temp = (*env)->GetByteArrayElements(env, array, NULL);
> jsize size = (*env)->GetArrayLength(env, array);
>
> GstBuffer *buffer = gst_buffer_new_allocate(NULL, size, NULL);
> gst_buffer_fill(buffer, 0, temp, size);
>
> GstElement *element =
> gst_bin_get_by_name(GST_BIN(pCustomData->pipeline), "video_app_source");
>
> if (basetimestamp == 0) {
>
> if (appsrc) {
> element = gst_object_ref(appsrc);
> } else {
> fprintf(stdout, "%s:%d %s\n", __func__, __LINE__, "manually
> setting time: exit");
> element = NULL;
> return;
> }
>
> GST_OBJECT_LOCK (element);
>
> if (GST_ELEMENT_CLOCK (element)) {
> GstClockTime now;
> GstClockTime base_time;
> now = gst_clock_get_time (GST_ELEMENT_CLOCK (element));
> base_time = GST_ELEMENT_CAST (element)->base_time;
>
> basetimestamp = now - base_time;
> GST_BUFFER_TIMESTAMP (buffer) = basetimestamp;
> }
>
> GST_OBJECT_UNLOCK (element);
> gst_object_unref (element);
>
> gst_app_src_push_buffer (GST_APP_SRC(element), buffer);
> } else {
> gst_app_src_push_buffer(appsrc, buffer);
> }
>
> (*env)->ReleaseByteArrayElements(env, array, temp, JNI_ABORT);
> }
>
> P.S:
> Here is attached screenshot of the strange behavior of the streaming
>
> <
> http://gstreamer-devel.966125.n4.nabble.com/file/t379283/Screenshot_20200302-165235%5B1%5D.png>
>
>
Looks like a key frame was lost or never seen. Consider configuring a key
frame interval on your encoder. Property key-int-max iirc.
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200303/687393cb/attachment.htm>
More information about the gstreamer-devel
mailing list