Я пытаюсь преобразовать следующее в c: приведенная ниже командная строка работает хорошо и генерирует выходной файл. Но предоставленный код c не генерирует никакого вывода.
gst-launch-1.0 dvbsr c частота = 147000000 модуляция = 5! расшифровка! очередь ! аудиосэмпл! аудиоконвертировать! voaacen c! Мультиплексор. mpegtsmux name = mux! filesink location = decode.ts
Ниже приведен пробный код, но выходной файл не создается.
#include <gst/gst.h>
GstElement *pipeline, *audio, *video, *sink;
static GMainLoop *loop;
static gboolean
my_bus_callback (GstBus
*bus,
GstMessage *message,
gpointer
data)
{
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR: {
GError *err;
gchar *debug;
gst_message_parse_error (message, &err, &debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_free (debug);
g_main_loop_quit (loop);
break;
}
case GST_MESSAGE_EOS:
/* end-of-stream */
g_main_loop_quit (loop);
break;
default:
/* unhandled message */
break;
}
return TRUE;
}
static void
cb_newpad (GstElement *decodebin,
GstPad *pad,
gpointer data)
{
GstCaps *caps;
GstStructure *str;
GstPad *audiopad;
// only link once
audiopad = gst_element_get_static_pad (audio, "sink");
if (GST_PAD_IS_LINKED (audiopad)) {
g_object_unref (audiopad);
return;
}
// check media type
caps = gst_pad_query_caps (pad, NULL);
str = gst_caps_get_structure (caps, 0);
if (!g_strrstr (gst_structure_get_name (str), "audio")) {
gst_caps_unref (caps);
gst_object_unref (audiopad);
return;
}
gst_caps_unref (caps);
// link'n'play
gst_pad_link (pad, audiopad);
g_object_unref (audiopad);
}
gint
main (gint argc,
gchar *argv[])
{
GstElement *src, *dec, *conv;
GstElement *audio_encode, *audio_resample, *muxer, *audio_queue;
GstElement *video_encode, *video_convert, *video_scale, *video_queue;
GstPad *audiopad;
GstBus *bus;
GstCaps *capsFilter;
gboolean link_ok;
/* init GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* setup */
pipeline = gst_pipeline_new ("pipeline");
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, (GstBusFunc)my_bus_callback, loop);
gst_object_unref (bus);
src = gst_element_factory_make ("dvbsrc", "source" );
g_object_set (src, "frequency", 147000000, NULL);
g_object_set (G_OBJECT (src), "modulation",5, NULL) ; //QAM 256
dec = gst_element_factory_make ("decodebin", "decoder");
g_signal_connect (dec, "pad-added", G_CALLBACK (cb_newpad), NULL);
gst_bin_add_many (GST_BIN (pipeline), src, dec, NULL);
gst_element_link (src, dec);
/* create audio output */
audio = gst_bin_new ("audiobin");
audio_queue = gst_element_factory_make ("queue","aqueue");
conv = gst_element_factory_make ("audioconvert", "aconv");
audio_resample = gst_element_factory_make ("audioresample","aresample");
audio_encode = gst_element_factory_make ("voaacenc", "aencode");
muxer = gst_element_factory_make ("mpegtxmux","muxer");
//audiopad = gst_element_get_static_pad (audio_queue, "sink");
audiopad = gst_element_get_static_pad (conv, "sink");
sink = gst_element_factory_make ("filesink", "sink");
g_object_set (G_OBJECT (sink), "location", "decode.ts", NULL);
gst_bin_add_many (GST_BIN (audio), audio_queue, conv, audio_resample, audio_encode, muxer, sink, NULL);
//output doesnt get generated gst_element_link (audio_queue, sink);
gst_element_link (conv, sink);
//gst_element_link_many (dec, conv, audio_resample, audio_encode, muxer, sink,NULL);
gst_element_add_pad (audio,
gst_ghost_pad_new ("sink", audiopad));
gst_object_unref (audiopad);
gst_bin_add (GST_BIN (pipeline), audio);
/* run */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
/* cleanup */
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
Любые предложения приветствуются, я пробовал много вариантов, но ни один еще не работал.