Coder Social home page Coder Social logo

gstreamer_audio_echo's Introduction

GStreamer Audio Echo (and more)

This project is a set of demo applications which show how to gain audio stream from input device and send it to output device using GStreamer framework.

Examples are written in C-language. They can be explored in such order:

  • direct_passthrough
  • udp_passthrough
  • G.726_rtp_passthrough
  • simple_P2P_phone

Each example is independent and has own readme file. That last contain short descriptions and command-line equivalents of C-code.

Tested on Arch Linux and Ubuntu.

gstreamer_audio_echo's People

Contributors

o3bvv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gstreamer_audio_echo's Issues

Need help for reading from dvbsrc

I am sorry to bother but my issue is not concerned with the source code you have written. I am only at wits end with the solution I need, and since you know more about gstreamer, am hoping you will be able to help.. Pls remove this issue if I overstepped.

I am trying to convert the following to c: The below command line works well and generates the output file. But the provided c code does not generate any output.
gst-launch-1.0 dvbsrc frequency=147000000 modulation=5 ! decodebin ! queue ! audioresample ! audioconvert ! voaacenc ! mux. 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;
}

'''

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.