2001-04-18 14:04:08 +00:00
|
|
|
/*
|
|
|
|
* mixer.c - stereo audio mixer - thomas@apestaart.org
|
2001-04-18 16:08:59 +00:00
|
|
|
* example based on helloworld
|
2001-04-18 14:04:08 +00:00
|
|
|
* demonstrates the adder plugin and the volume envelope plugin
|
|
|
|
* work in progress but do try it out
|
|
|
|
*
|
2001-08-29 09:00:49 +00:00
|
|
|
* Latest change : 28/08/2001
|
2001-05-25 21:00:07 +00:00
|
|
|
* trying to adapt to incsched
|
|
|
|
* delayed start for channels > 1
|
|
|
|
* now works by quickhacking the
|
|
|
|
* adder plugin to set
|
|
|
|
* GST_ELEMENT_COTHREAD_STOPPING
|
2001-08-29 09:00:49 +00:00
|
|
|
* Version : 0.5.1
|
2001-04-18 14:04:08 +00:00
|
|
|
*/
|
|
|
|
|
2001-04-16 16:34:16 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <gst/gst.h>
|
2001-04-17 17:47:45 +00:00
|
|
|
#include "mixer.h"
|
2001-04-18 14:04:08 +00:00
|
|
|
#include <unistd.h>
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/*#define WITH_BUG */
|
|
|
|
/*#define WITH_BUG2 */
|
|
|
|
/*#define DEBUG */
|
|
|
|
/*#define AUTOPLUG * define if you want autoplugging of input channels * */
|
2001-04-17 17:47:45 +00:00
|
|
|
/* function prototypes */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
input_channel_t *create_input_channel (int id, char *location);
|
|
|
|
void destroy_input_channel (input_channel_t * pipe);
|
|
|
|
void env_register_cp (GstElement * volenv, double cp_time, double cp_level);
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-16 16:34:16 +00:00
|
|
|
|
|
|
|
gboolean playing;
|
|
|
|
|
|
|
|
|
|
|
|
/* eos will be called when the src element has an end of stream */
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
eos (GstElement * element)
|
2001-04-16 16:34:16 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("have eos, quitting ?\n");
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* playing = FALSE; */
|
2001-04-16 16:34:16 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
G_GNUC_UNUSED static GstCaps *
|
|
|
|
gst_play_type_find (GstBin * bin, GstElement * element)
|
2001-04-17 21:17:55 +00:00
|
|
|
{
|
|
|
|
GstElement *typefind;
|
2001-05-25 21:00:07 +00:00
|
|
|
GstElement *pipeline;
|
2001-04-17 21:17:55 +00:00
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("GstPipeline: typefind for element \"%s\"",
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_ELEMENT_NAME (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("autoplug_pipeline");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
typefind = gst_element_factory_make ("typefind", "typefind");
|
2001-04-17 21:17:55 +00:00
|
|
|
g_return_val_if_fail (typefind != NULL, FALSE);
|
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_pad_link (gst_element_get_pad (element, "src"),
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_get_pad (typefind, "sink"));
|
2001-04-17 21:17:55 +00:00
|
|
|
gst_bin_add (bin, typefind);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (bin));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* push a buffer... the have_type signal handler will set the found flag */
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_iterate (GST_BIN (pipeline));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
2001-04-17 21:17:55 +00:00
|
|
|
|
|
|
|
caps = gst_pad_get_caps (gst_element_get_pad (element, "src"));
|
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_pad_unlink (gst_element_get_pad (element, "src"),
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_get_pad (typefind, "sink"));
|
2001-04-17 21:17:55 +00:00
|
|
|
gst_bin_remove (bin, typefind);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin));
|
2001-04-17 21:17:55 +00:00
|
|
|
gst_object_unref (GST_OBJECT (typefind));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (pipeline));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2001-04-16 16:34:16 +00:00
|
|
|
{
|
2001-05-25 21:00:07 +00:00
|
|
|
int i, j;
|
2001-04-18 16:08:59 +00:00
|
|
|
int num_channels;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
char buffer[20];
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
GList *input_channels; /* structure holding all the input channels */
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
input_channel_t *channel_in;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
GstElement *main_bin;
|
2001-04-16 16:34:16 +00:00
|
|
|
GstElement *adder;
|
|
|
|
GstElement *audiosink;
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
GstPad *pad; /* to request pads for the adder */
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_init (&argc, &argv);
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
if (argc == 1) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("usage: %s <filename1> <filename2> <...>\n", argv[0]);
|
|
|
|
exit (-1);
|
2001-04-16 16:34:16 +00:00
|
|
|
}
|
2001-04-18 16:08:59 +00:00
|
|
|
num_channels = argc - 1;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
/* set up output channel and main bin */
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-16 16:34:16 +00:00
|
|
|
/* create adder */
|
2002-04-11 20:35:18 +00:00
|
|
|
adder = gst_element_factory_make ("adder", "adderel");
|
2001-04-16 16:34:16 +00:00
|
|
|
|
|
|
|
/* create an audio sink */
|
2002-04-11 20:35:18 +00:00
|
|
|
audiosink = gst_element_factory_make ("esdsink", "play_audio");
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
/* create main bin */
|
2004-03-13 15:27:01 +00:00
|
|
|
main_bin = gst_pipeline_new ("bin");
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
/* link adder and output to bin */
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_INFO ("main: adding adder to bin");
|
|
|
|
gst_bin_add (GST_BIN (main_bin), adder);
|
|
|
|
GST_INFO ("main: adding audiosink to bin");
|
|
|
|
gst_bin_add (GST_BIN (main_bin), audiosink);
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
/* link adder and audiosink */
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_link (gst_element_get_pad (adder, "src"),
|
|
|
|
gst_element_get_pad (audiosink, "sink"));
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/* start looping */
|
2001-04-18 16:08:59 +00:00
|
|
|
input_channels = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
for (i = 1; i < argc; ++i) {
|
2001-04-18 16:08:59 +00:00
|
|
|
printf ("Opening channel %d from file %s...\n", i, argv[i]);
|
|
|
|
channel_in = create_input_channel (i, argv[i]);
|
2001-05-25 21:00:07 +00:00
|
|
|
input_channels = g_list_append (input_channels, channel_in);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (i > 1)
|
|
|
|
gst_element_set_state (main_bin, GST_STATE_PAUSED);
|
|
|
|
gst_bin_add (GST_BIN (main_bin), channel_in->pipe);
|
2001-04-18 16:08:59 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
/* request pads and link to adder */
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_INFO ("requesting pad\n");
|
2002-04-07 23:32:16 +00:00
|
|
|
pad = gst_element_get_request_pad (adder, "sink%d");
|
2001-05-25 21:00:07 +00:00
|
|
|
printf ("\tGot new adder sink pad %s\n", gst_pad_get_name (pad));
|
2001-04-18 16:08:59 +00:00
|
|
|
sprintf (buffer, "channel%d", i);
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_pad_link (gst_element_get_pad (channel_in->pipe, buffer), pad);
|
2001-04-18 16:08:59 +00:00
|
|
|
|
|
|
|
/* register a volume envelope */
|
|
|
|
printf ("\tregistering volume envelope...\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this is the volenv :
|
|
|
|
* each song gets a slot of 5 seconds, with a 5 second fadeout
|
|
|
|
* at the end of that, all audio streams play simultaneously
|
|
|
|
* at a level ensuring no distortion
|
|
|
|
* example for three songs :
|
|
|
|
* song1 : starts at full level, plays 5 seconds, faded out at 10 seconds,
|
2004-03-13 15:27:01 +00:00
|
|
|
* sleep until 25, fade to end level at 30
|
2001-04-18 16:08:59 +00:00
|
|
|
* song2 : starts silent, fades in at 5 seconds, full blast at 10 seconds,
|
2004-03-13 15:27:01 +00:00
|
|
|
* full level until 15, faded out at 20, sleep until 25, fade to end at 30
|
2001-04-18 16:08:59 +00:00
|
|
|
* song3 : starts muted, fades in from 15, full at 20, until 25, fade to end level
|
|
|
|
*/
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (i == 1) {
|
2001-04-18 16:08:59 +00:00
|
|
|
/* first song gets special treatment for end style */
|
2004-03-13 15:27:01 +00:00
|
|
|
env_register_cp (channel_in->volenv, 0.0, 1.0);
|
|
|
|
} else {
|
2004-03-15 19:27:17 +00:00
|
|
|
env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */
|
|
|
|
env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
|
2004-03-13 15:27:01 +00:00
|
|
|
env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
|
2001-04-18 16:08:59 +00:00
|
|
|
}
|
2004-03-15 19:27:17 +00:00
|
|
|
env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
|
2001-04-18 16:08:59 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (i != num_channels) {
|
2004-03-15 19:27:17 +00:00
|
|
|
env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */
|
|
|
|
env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
2004-03-15 19:27:17 +00:00
|
|
|
env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2002-01-11 15:49:47 +00:00
|
|
|
gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w"));
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif
|
2001-04-18 16:08:59 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/* start playing */
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_set_state (main_bin, GST_STATE_PLAYING);
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* write out the schedule */
|
2005-03-07 18:27:42 +00:00
|
|
|
gst_scheduler_show (GST_ELEMENT_SCHEDULER (main_bin));
|
2001-05-25 21:00:07 +00:00
|
|
|
playing = TRUE;
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
j = 0;
|
2002-03-19 04:10:13 +00:00
|
|
|
/*printf ("main: start iterating from 0"); */
|
2004-03-13 15:27:01 +00:00
|
|
|
while (playing && j < 100) {
|
2002-03-19 04:10:13 +00:00
|
|
|
/* printf ("main: iterating %d\n", j); */
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_bin_iterate (GST_BIN (main_bin));
|
|
|
|
/*fprintf(stderr,"after iterate()\n"); */
|
2001-05-25 21:00:07 +00:00
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf ("main: all the channels are open\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
while (playing) {
|
|
|
|
gst_bin_iterate (GST_BIN (main_bin));
|
2002-03-19 04:10:13 +00:00
|
|
|
/*fprintf(stderr,"after iterate()\n"); */
|
2001-04-16 16:34:16 +00:00
|
|
|
}
|
|
|
|
/* stop the bin */
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_set_state (main_bin, GST_STATE_NULL);
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (input_channels) {
|
2001-04-18 16:08:59 +00:00
|
|
|
destroy_input_channel (input_channels->data);
|
|
|
|
input_channels = g_list_next (input_channels);
|
|
|
|
}
|
|
|
|
g_list_free (input_channels);
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_object_unref (GST_OBJECT (audiosink));
|
2001-04-16 16:34:16 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_object_unref (GST_OBJECT (main_bin));
|
|
|
|
|
|
|
|
exit (0);
|
2001-04-16 16:34:16 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
input_channel_t *
|
|
|
|
create_input_channel (int id, char *location)
|
2001-04-17 17:47:45 +00:00
|
|
|
{
|
2001-04-17 21:17:55 +00:00
|
|
|
/* create an input channel, reading from location
|
|
|
|
* return a pointer to the channel
|
2001-04-17 17:47:45 +00:00
|
|
|
* return NULL if failed
|
|
|
|
*/
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
input_channel_t *channel;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
char buffer[20]; /* hold the names */
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
/* GstAutoplug *autoplug;
|
|
|
|
GstCaps *srccaps; */
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *new_element;
|
2001-05-25 21:00:07 +00:00
|
|
|
GstElement *decoder;
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("c_i_p : creating channel with id %d for file %s", id, location);
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
/* allocate channel */
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
channel = (input_channel_t *) malloc (sizeof (input_channel_t));
|
2004-03-13 15:27:01 +00:00
|
|
|
if (channel == NULL) {
|
2001-04-17 21:17:55 +00:00
|
|
|
printf ("create_input_channel : could not allocate memory for channel !\n");
|
2001-04-17 17:47:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
/* create channel */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("c_i_p : creating pipeline");
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
sprintf (buffer, "pipeline%d", id);
|
|
|
|
channel->pipe = gst_bin_new (buffer);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (channel->pipe != NULL);
|
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
/* create elements */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("c_i_p : creating filesrc");
|
2001-04-17 21:17:55 +00:00
|
|
|
|
2002-01-05 23:05:56 +00:00
|
|
|
sprintf (buffer, "filesrc%d", id);
|
2002-04-11 20:35:18 +00:00
|
|
|
channel->filesrc = gst_element_factory_make ("filesrc", buffer);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (channel->filesrc != NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("c_i_p : setting location");
|
|
|
|
g_object_set (G_OBJECT (channel->filesrc), "location", location, NULL);
|
2001-04-17 21:17:55 +00:00
|
|
|
|
2002-01-05 23:05:56 +00:00
|
|
|
/* add filesrc to the bin before autoplug */
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_bin_add (GST_BIN (channel->pipe), channel->filesrc);
|
2001-04-17 21:17:55 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
/* link signal to eos of filesrc */
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (channel->filesrc), "eos", G_CALLBACK (eos), NULL);
|
2001-04-18 14:04:08 +00:00
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : c_i_p : creating volume envelope\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sprintf (buffer, "volenv%d", id);
|
2002-04-11 20:35:18 +00:00
|
|
|
channel->volenv = gst_element_factory_make ("volenv", buffer);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_assert (channel->volenv != NULL);
|
2001-04-17 21:17:55 +00:00
|
|
|
|
|
|
|
/* autoplug the pipe */
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : c_i_p : getting srccaps\n");
|
|
|
|
#endif
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
#ifdef WITH_BUG
|
2002-04-11 20:35:18 +00:00
|
|
|
srccaps = gst_play_type_find (GST_BIN (channel->pipe), channel->filesrc);
|
2001-05-25 21:00:07 +00:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_BUG2
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
2001-04-17 21:17:55 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
pipeline = gst_pipeline_new ("autoplug_pipeline");
|
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (pipeline), channel->pipe);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_bin_remove (GST_BIN (pipeline), channel->pipe);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUTOPLUG
|
2001-04-17 21:17:55 +00:00
|
|
|
if (!srccaps) {
|
|
|
|
g_print ("could not autoplug, unknown media type...\n");
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : c_i_p : creating autoplug\n");
|
|
|
|
#endif
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
autoplug = gst_autoplug_factory_make ("static");
|
2001-04-17 21:17:55 +00:00
|
|
|
g_assert (autoplug != NULL);
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : c_i_p : autoplugging\n");
|
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
new_element = gst_autoplug_to_caps (autoplug, srccaps,
|
|
|
|
gst_caps_new ("audio/raw", NULL), NULL);
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
if (!new_element) {
|
|
|
|
g_print ("could not autoplug, no suitable codecs found...\n");
|
|
|
|
exit (-1);
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
new_element = gst_bin_new ("autoplug_bin");
|
|
|
|
|
|
|
|
/* static plug, use mad plugin and assume mp3 input */
|
2001-08-29 09:00:49 +00:00
|
|
|
printf ("using static plugging for input channel\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
decoder = gst_element_factory_make ("mad", "mpg123");
|
|
|
|
if (!decoder) {
|
2001-08-29 09:00:49 +00:00
|
|
|
fprintf (stderr, "Could not get a decoder element !\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_add (GST_BIN (new_element), decoder);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_add_ghost_pad (new_element,
|
|
|
|
gst_element_get_pad (decoder, "sink"), "sink");
|
|
|
|
gst_element_add_ghost_pad (new_element,
|
|
|
|
gst_element_get_pad (decoder, "src"), "src_00");
|
|
|
|
|
|
|
|
#endif
|
2001-10-17 10:21:27 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2002-01-11 15:49:47 +00:00
|
|
|
gst_xml_write_file (GST_ELEMENT (new_element), fopen ("mixer.gst", "w"));
|
2004-03-13 15:27:01 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_bin_add (GST_BIN (channel->pipe), channel->volenv);
|
2001-04-17 21:17:55 +00:00
|
|
|
gst_bin_add (GST_BIN (channel->pipe), new_element);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_element_link_pads (channel->filesrc, "src", new_element, "sink");
|
|
|
|
gst_element_link_pads (new_element, "src_00", channel->volenv, "sink");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
/* add a ghost pad */
|
|
|
|
sprintf (buffer, "channel%d", id);
|
2001-04-17 21:17:55 +00:00
|
|
|
gst_element_add_ghost_pad (channel->pipe,
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_get_pad (channel->volenv, "src"), buffer);
|
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : c_i_p : end function\n");
|
|
|
|
#endif
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
return channel;
|
2001-04-17 17:47:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
destroy_input_channel (input_channel_t * channel)
|
2001-04-17 17:47:45 +00:00
|
|
|
{
|
|
|
|
/*
|
2001-04-17 21:17:55 +00:00
|
|
|
* destroy an input channel
|
2001-04-17 17:47:45 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-04-17 17:47:45 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("DEBUG : d_i_p : start\n");
|
|
|
|
#endif
|
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
/* destroy elements */
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2003-04-15 17:40:56 +00:00
|
|
|
gst_object_unref (GST_OBJECT (channel->pipe));
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-17 21:17:55 +00:00
|
|
|
free (channel);
|
2001-04-17 17:47:45 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
env_register_cp (GstElement * volenv, double cp_time, double cp_level)
|
2001-04-18 16:08:59 +00:00
|
|
|
{
|
|
|
|
char buffer[30];
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
sprintf (buffer, "%f:%f", cp_time, cp_level);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_object_set (G_OBJECT (volenv), "controlpoint", buffer, NULL);
|
2001-04-17 17:47:45 +00:00
|
|
|
|
2001-04-18 16:08:59 +00:00
|
|
|
}
|