Hi,
I have a problem with streaming audio via bluetooth via avdtpsrc liblrary. In the below, my code. #include <gst/gst.h> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: g_print ("End of stream\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; } default: break; } return TRUE; } /* Main function for audio pipeline initialization and looping streaming process */ gint main (gint argc, gchar **argv) { GMainLoop *loop; GstElement *pipeline; GstElement *source; GstElement *depay; GstElement *parse; GstElement *decoder; GstElement *converter; GstElement *queues; GstElement *volume; GstElement *sink; GstElement *jitterbuffer; GstBus *bus; GstCaps *caps; gboolean ret; /* Initialisation */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* Create gstreamer elements: */ pipeline = gst_pipeline_new ("audio_stream"); gst_element_set_state (pipeline, GST_STATE_NULL); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); /* Add a message handler */ gst_bus_add_watch (bus, bus_call, loop); gst_object_unref (bus); source = gst_element_factory_make ("avdtpsrc", "audio_source"); g_return_val_if_fail (source, -1); jitterbuffer = gst_element_factory_make("rtpjitterbuffer", "jitterbuffer"); depay = gst_element_factory_make("rtpsbcdepay", "depayloader"); parse = gst_element_factory_make("sbcparse", "parser"); decoder = gst_element_factory_make("sbcdec", "decoder"); volume = gst_element_factory_make("volume", "volume"); converter = gst_element_factory_make("audioconvert", "converter"); queues = gst_element_factory_make ("queue", "queues"); g_return_val_if_fail (queues, -1); sink = gst_element_factory_make ("alsasink", "audio_sink"); g_return_val_if_fail (sink, -1); if (!pipeline) { g_printerr ("Audio: Pipeline couldn't be created\n"); return -1; } if (!source) { g_printerr ("Audio: alsasrc couldn't be created\n"); return -1; } if (!sink) { g_printerr ("Audio: Output file couldn't be created\n"); return -1; } // g_object_set (G_OBJECT (sink), "transport", "/org/bluez/hci0/dev_2C_BA_BA_6D_27_FA", NULL); /* Add elements to the bin before linking them. */ gst_bin_add (GST_BIN (pipeline), source); gst_bin_add (GST_BIN (pipeline), jitterbuffer); gst_bin_add (GST_BIN (pipeline), depay); gst_bin_add (GST_BIN (pipeline), parse); gst_bin_add (GST_BIN (pipeline), decoder); gst_bin_add (GST_BIN (pipeline), converter); gst_bin_add (GST_BIN (pipeline), queues); gst_bin_add (GST_BIN (pipeline), sink); g_object_set (G_OBJECT (jitterbuffer), "latency",0, NULL); g_object_set (G_OBJECT (jitterbuffer), "drop-on-latency", TRUE, NULL); g_object_set (G_OBJECT (source), "transport", "/org/bluez/hci0/dev_98_10_E8_34_04_BE/fd0", NULL); /* Link the pipeline */ caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S16LE", "layout", G_TYPE_STRING, "interleaved", "rate", G_TYPE_INT, (int)44100, "channels", G_TYPE_INT, (int)2, NULL); ret = gst_element_link_filtered (source, sink, caps); if (!ret) { g_print ("audio_source and sink couldn't be linked\n"); gst_caps_unref (caps); return FALSE; } gst_element_link_pads (queues, "src", sink, "sink"); /* Set the pipeline to "playing" state */ // g_print ("Playing: %s\n", argv[1]); gst_element_set_state (pipeline, GST_STATE_PLAYING); /* Iterate */ g_print ("Running...\n"); g_main_loop_run (loop); /* Out of the main loop, clean up nicely */ g_print ("Returned, stopping playback\n"); gst_element_set_state (pipeline, GST_STATE_NULL); g_print ("Deleting pipeline\n"); gst_object_unref (GST_OBJECT (pipeline)); return 0; } When run it. It error "Running... Error: Internal data stream error. Returned, stopping playback Deleting pipeline" When I using cmd gst-launch-1.0 avdtpsrc transport=/org/bluez/hci0/dev_98_10_E8_34_04_BE/fd0 ! rtpjitterbuffer ! rtpsbcdepay ! sbcparse ! sbcdec ! volume ! audioconvert ! alsasink It working. How to my code work? -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |