element send EOS event not returning

Anjo John anjo.john at vvdntech.in
Tue Mar 6 13:35:07 UTC 2018


Hi Stephenwei,

i can get PID of the display pipeline, besides i use the killall -2
gst-launch-1.0 which will send the SIGINT to the pipeline. The pipeline is
receiving the interrupt. But it is not exiting. Pipeline will exit if
running in foreground and giving Ctrl+c. Below is the c application i use.
Here /tmp/test is a fifo.(fifo made with mkfifo )

/*
 * program for decoding h264 data from baresip
 * and display using imxg2dvideosink plugin
*/

#include<stdio.h>
#include<gst/gst.h>
#include<signal.h>
#include<stdlib.h>

typedef struct {

GstElement *pipeline;
GstElement *source;
GstElement *h264parser;
GstElement *decoder;
GstElement *display;
GstBus *bus;
GMainLoop *loop;

} DisplayData;

DisplayData Data; /*structure containing all elements*/
static gboolean bus_msg_hndler(GstBus *bus, GstMessage *msg, void
*user_data);
static int signal_handle_int(int data) {
g_printf("Display pipeline-end\n");
gst_element_send_event(Data.pipeline, gst_event_new_eos());
return 0;
}

int main(int argc, char *argv[])
{
FILE *fd;
char buf[30];
char model[10];
char cmd[50];

guint bus_watch_id;


/*gstreamer initialisation*/
gst_init(&argc, &argv);
//signal(SIGINT, signal_handle_int);
/*main loop*/
Data.loop = g_main_loop_new(NULL, FALSE);
/*main pipeline*/
Data.pipeline = gst_pipeline_new("display_pipeline");
/*GstBus for video_main_pipeline*/
Data.bus = gst_pipeline_get_bus(Data.pipeline);
bus_watch_id = gst_bus_add_watch(Data.bus, bus_msg_hndler, NULL);
gst_object_unref(Data.bus);

/*Create all elements*/
Data.source = gst_element_factory_make("filesrc", "file_source");
Data.h264parser = gst_element_factory_make("h264parse", "h264_parser");
Data.decoder = gst_element_factory_make("imxvpudec", "imxvpu_decoder");
Data.display = gst_element_factory_make("imxg2dvideosink",
"g2d_videodisplay");
if (!Data.source || !Data.h264parser || !Data.decoder || !Data.display) {
g_critical("gst_element_factory_make error");
gst_object_unref(Data.pipeline);
g_main_loop_unref(Data.loop);
return -1;
}
gst_bin_add_many(GST_BIN(Data.pipeline), Data.source, Data.h264parser,
Data.decoder, Data.display, NULL);
if (!gst_element_link_many(Data.source, Data.h264parser, Data.decoder,
Data.display, NULL)) {
g_critical("Unable to link elements\n");
return -1;
}
g_object_set(Data.source, "location", "/tmp/test", NULL);

GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(Data.pipeline), GST_DEBUG_GRAPH_SHOW_ALL,
"display-pipeline");
gst_element_set_state(GST_ELEMENT(Data.pipeline), GST_STATE_PLAYING);
g_main_loop_run(Data.loop);
}
static gboolean bus_msg_hndler(GstBus *bus, GstMessage *msg, void
*user_data)
{
switch (GST_MESSAGE_TYPE(msg))
{
case GST_MESSAGE_EOS:
{
g_main_loop_quit(Data.loop);
gst_element_set_state(GST_ELEMENT(Data.pipeline), GST_STATE_NULL);
gst_object_unref(GST_OBJECT(Data.pipeline));
g_main_loop_unref (Data.loop);
break;
}
case GST_MESSAGE_ERROR:
{
GError *err;
gst_message_parse_error(msg, &err, NULL);
//report error
g_print ("ERROR: %s", err->message);
g_error_free(err);
g_main_loop_quit(Data.loop);
break;
}
case GST_MESSAGE_APPLICATION:
{
const GstStructure *str;
str = gst_message_get_structure (msg);
if (gst_structure_has_name(str,"turn_off"))
{
g_main_loop_quit(Data.loop);
}
break;
}
case GST_MESSAGE_STATE_CHANGED:
{
GstState old_state, pending_state, new_state;
gst_message_parse_state_changed(msg, &old_state, &new_state,
&pending_state);
if(GST_OBJECT_NAME(msg->src) == GST_OBJECT_NAME(Data.pipeline)){
//show  pipeline messages
g_print("'%s' state changed from %s to %s. \n", GST_OBJECT_NAME(msg->src),
gst_element_state_get_name(old_state),
gst_element_state_get_name(new_state));
}
break;
}
default:
break;
}
return TRUE;
}


On Tue, Mar 6, 2018 at 3:45 PM, Stephenwei <lofy.stephen at gmail.com> wrote:

> Hi,
> I suggest you store the pid when send system common.
> Besides please upload your c code.
>
> Regards,
> Stephen
>
>
>
> --
> 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
>



-- 

*With Best Regards*


*Anjo John*

VVDN Technologies Pvt Ltd

*Cell : *+91 9539931442 | Skype :anjojohn051
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180306/dd9eeac7/attachment.html>


More information about the gstreamer-devel mailing list