Multichannel audio working pipeline

diegoavila diego_javila at hotmail.com
Mon Oct 7 17:34:21 UTC 2019


Thanks actually im trying to write all the pipeline elements by miself , i
cant use gst_parse_launch () function (work ) , my current code is :
#include <gst/gst.h>
#include <iostream>
#include <thread>
#include <chrono>
typedef struct _CustomData {
    GstElement *pipeline;
    GstElement *source;
    GstElement *audio_queue;
    GstElement *audio_convert;
    GstElement *audio_sink;
    GstElement *decodebin;
    GstElement *deinterleave;
    GstElement *interleave;
} CustomData;
static void cb_new_pad (GstElement *element, GstPad *pad, CustomData data);
// GOAL
// gst-launch-1.0 -v filesrc location=/home/atr/Downloads/test.mp3 name=src
//! decodebin ! audioconvert ! "audio/x-raw,channels=6"  ! deinterleave
keep-positions=true name=d interleave name=i
// ! autoaudiosink d.src_0 ! queue ! volume volume=0 ! i.sink_1 d.src_1 !
queue ! volume volume=1
// ! i.sink_2 d.src_2 ! volume volume = 0 ! queue ! i.sink_3 d.src_3 !
volume volume=0 ! queue ! i.sink_4 d.src_4
// ! volume volume=0 ! queue ! i.sink_5 d.src_5 ! volume volume=0 ! queue !
i.sink_6
static void cb_new_pad (GstElement *element, GstPad *pad, CustomData data)
{
  g_print("Inside the pad_added_handler method \n");
  //GstPad *sink_pad_audio = gst_element_get_static_pad (data->audio_queue,
"sink");

}


int main(int argc, char *argv[])
{
  CustomData data;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  data.pipeline = gst_pipeline_new ("test-pipeline");
  data.source = gst_element_factory_make ("filesrc", "src");
  data.audio_queue = gst_element_factory_make("queue","audio_queue");
  data.audio_convert = gst_element_factory_make ("audioconvert",
"audio_convert");
  data.audio_sink = gst_element_factory_make ("autoaudiosink",
"audio_sink");
  data.decodebin = gst_element_factory_make ("decodebin", "decodebin");
  data.deinterleave = gst_element_factory_make ("deinterleave", "d");
  data.interleave = gst_element_factory_make ("interleave", "i");

  if(!data.pipeline || !data.source || !data.audio_queue ||
!data.audio_convert || !data.audio_sink ||
     !data.deinterleave || !data.interleave || !data.decodebin)
  {
    g_printerr ("Not all elements could be created.\n");
    return -1;
  }

  gst_bin_add_many (GST_BIN (data.pipeline),
data.source,data.audio_queue,data.audio_convert,data.audio_sink,
    data.deinterleave,data.interleave,data.decodebin ,NULL);

  if(!gst_element_link (data.source, data.decodebin))
  {
    g_printerr ("Decodebin and source could not be linked.\n");
    gst_object_unref (data.pipeline);
    return -1;
  }
  if (!gst_element_link_many
(data.audio_queue,data.audio_convert,data.audio_sink,NULL))
  {
    g_printerr (" audio Elements could not be linked.\n");
    gst_object_unref (data.pipeline);
    return -1;
  }

  g_object_set (data.source, "location", "/home/diego/Downloads/test.mp3",
NULL);
  g_signal_connect (data.decodebin, "pad-added", G_CALLBACK (cb_new_pad),
&data);

  return 0;
}
but the signal is not working i dont know why



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list