Reputation: 61
sorry for the previous post. I'll try to be more precise.
Using Gstreamer I created a pipeline, which contains an element of video.ts, I can see and hear the video without problems, but I would like to get some information packages video.ts.
The information is to be interested get me PTS, DTS, OFFSET and PID. To view these values I used the property of "emit-stats" of Tsdemux.
g_object_set(G_OBJECT(v1_demux),"emit-stats",1,NULL);
Now, I want to see the values of PTS, DTS, OFFSET and PID. To do this use "gst_bus_add_watch" and create several cases for messages
case GST_MESSAGE_EOS:
g_print (" \n");
g_print (" End of video\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR: {
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}/*end case error*/
case GST_MESSAGE_ELEMENT:{
if(strcmp(GST_MESSAGE_SRC_NAME (msg),"mux")==0){
msg_struct=gst_message_get_structure(msg);
i=i+1;
g_print ("Element nº: %d \n", i);
/* get PID,PTS,DTS,OFFSET value */
pts =gst_structure_get_value (msg_struct,"pts");
dts =gst_structure_get_value (msg_struct,"dts");
offset =gst_structure_get_value (msg_struct,"offset");
pid =gst_structure_get_value (msg_struct,"pid");
/*display information PTS, DTS, OFFSET*/
if(pts!=0){
g_print(" *PID= % " G_GUINT64_FORMAT" *PTS= % " G_GUINT64_FORMAT " *Offset: % " G_GUINT64_FORMAT "\n",g_value_get_uint64(pid), g_value_get_uint64(pts),g_value_get_uint64(offset));
}else if (dts!=0){
g_print(" *DTS= % " G_GUINT64_FORMAT " *Offset: % " G_GUINT64_FORMAT "\n",g_value_get_uint64(dts),g_value_get_uint64(offset));
}else if (pts==0 && dts==0){
g_print(" *Paquete nulo: PTS=0 DTS=0 \n" );
}
}
Now I can see the values of PTS, DTS and OFFSET. This part could be solve whit lot of patience, test and correct errors. But the PID is not displayed correctly and I do not really know how to solve this.
show a snapshot of messages
estoy imprimiendo estados n?: 490 *DTS= 4672782274 *Offset: 12554828 Element n?: 491
(test:3385): GLib-GObject-CRITICAL **: g_value_get_uint64: assertion `G_VALUE_HOLDS_UINT64 (value)' failed *PID= 0 *PTS= 4672793074 *Offset: 12554828 Element n?: 492
(test:3385): GLib-GObject-CRITICAL **: g_value_get_uint64: assertion `G_VALUE_HOLDS_UINT64 (value)' failed *PID= 0 *PTS= 4672746274 *Offset: 12556520 Element n?: 493
(test:3385): GLib-GObject-CRITICAL **: g_value_get_uint64: assertion `G_VALUE_HOLDS_UINT64 (value)' failed *PID= 0 *PTS= 4672748074 *Offset: 12605024 Element n?: 494
What I can do, to show me the PID correctly?
Upvotes: 2
Views: 1088
Reputation: 173
A GstStructure is a collection of key/value pairs. You can use
gchar * gst_structure_to_string (const GstStructure *structure);
to display all fields. In you case
g_print("%s\n", gst_structure_to_string(gst_message_get_structure(msg)));
Upvotes: 1