gstreamer app stumbles with trace/bpt trap:5
aft
aftnix at gmail.com
Wed Feb 12 02:19:07 PST 2014
This seemingly innocent code fails to run on Max OSX 10.8
#include <string.h>
#include <math.h>
#include <gst/gst.h>
static void
print_source_stats (GObject *source)
{
GstStructure *stats;
gchar *str;
g_object_get(source, "stats", &stats, NULL);
str = gst_structure_to_string (stats);
g_print("source stat :%s\n", str);
gst_structure_free(stats);
g_free(str);
}
static gboolean
print_stats (GstElement *rtpbin)
{
GObject *session;
GValueArray *arr;
GValue *val;
guint i;
g_print("**********\n");
g_signal_emit_by_name(rtpbin, "get-internal-session",0, &session);
g_object_get(session, "sources", &arr, NULL);
for (i=0; i <arr->n_values; i++) {
GObject *sources;
val = g_value_array_get_nth(arr, i);
sources = g_value_get_object(val);
print_source_stats(sources);
}
g_value_array_free(arr);
g_object_unref(session);
return TRUE;
}
/*
Build a pipeline equivalent to :
gst-launch -v rtpbin name=rtpbin \
audiotestsrc ! audioconvert ! audioresample ! alawenc !
rtppcmapay ! rtpbin.send_rtp_src_0 !
rtpbin.send_rtp_sink_0 ! udpsink port=5002 host=127.0.0.1
*/
int main(int argc, char **argv) {
GstElement *audiosrc, *audioconv, *audiores, *audiopay, *audioenc;
GstElement *rtpbin, *rtpsink;
GstElement *pipeline;
GMainLoop *loop;
GstPad *srcpad, *sinkpad;
gst_init(&argc, &argv);
pipeline = gst_pipeline_new (NULL);
g_assert(pipeline);
audiosrc = gst_element_factory_make ("audiotestsrc", "audiosrc");
g_assert (audiosrc);
audioconv = gst_element_factory_make ("audioconvert", "audioconv");
g_assert (audioconv);
audiores = gst_element_factory_make ("audioresample", "audiores");
g_assert (audiores);
/* the encoding and payloading */
audioenc = gst_element_factory_make ("alawenc", "audioenc");
g_assert (audioenc);
audiopay = gst_element_factory_make ("rtppcmapay", "audiopay");
g_assert (audiopay);
/* add capture and payloading to the pipeline and link */
gst_bin_add_many (GST_BIN (pipeline), audiosrc, audioconv, audiores,
audioenc, audiopay, NULL);
if (!gst_element_link_many (audiosrc, audioconv, audiores, audioenc,
audiopay, NULL)) {
g_error ("Failed to link audiosrc, audioconv, audioresample, "
"audio encoder and audio payloader");
}
/* the rtpbin element */
rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
g_assert (rtpbin);
gst_bin_add (GST_BIN (pipeline), rtpbin);
rtpsink = gst_element_factory_make ("udpsink", "rtpsink");
g_assert (rtpsink);
g_object_set (rtpsink, "port", 5002, "host", "127.0.0.1", NULL);
sinkpad = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
srcpad = gst_element_get_static_pad (audiopay, "src");
if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
g_error ("Failed to link audio payloader to rtpbin");
gst_object_unref (srcpad);
/* get the RTP srcpad that was created when we requested the
sinkpad above and
* link it to the rtpsink sinkpad*/
srcpad = gst_element_get_static_pad (rtpbin, "send_rtp_src_0");
sinkpad = gst_element_get_static_pad (rtpsink, "sink");
if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
g_error ("Failed to link rtpbin to rtpsink");
gst_object_unref (srcpad);
gst_object_unref (sinkpad);
/* set the pipeline to playing */
g_print ("starting sender pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* print stats every second */
g_timeout_add_seconds (1, (GSourceFunc) print_stats, rtpbin);
/* we need to run a GLib main loop to get the messages */
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_print ("stopping sender pipeline\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
}
The error generated does not seems like a fault in code itself, it
seems to be a "dynamic library" related issue :
$./rtpSender --gst-debug-level=3
** (rtpSender:1360): ERROR **: Failed to link rtpbin to rtpsink
Trace/BPT trap: 5
The backtrace generated :
(lldb) bt
* thread #1: tid = 0x12d62, 0x000000010065dcb2
libglib-2.0.0.dylib`g_logv + 786, queue = 'com.apple.main-thread, stop
reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x000000010065dcb2 libglib-2.0.0.dylib`g_logv + 786
frame #1: 0x00000001000019a6
rtpSender`g_error(format=0x0000000100001e5d) + 358 at gmessages.h:196
frame #2: 0x0000000100001788 rtpSender`main(argc=1,
argv=0x00007fff5fbff8b8) + 1160 at main.c:106
frame #3: 0x00007fff87c097e1 libdyld.dylib`start + 1
(lldb)
--
-Cheers
-Arif
More information about the gstreamer-devel
mailing list