Commit 6d699e07 authored by hark's avatar hark
Browse files

multiple audio sink support

parent 22860285
......@@ -164,16 +164,6 @@ preview_cb (GtkCheckButton * preview_check, PlayerData * data)
{
g_print ("turning on preview checkcb \n");
teebin_preview_on(data);
/* gst_element_set_state (pData->playbin2, GST_STATE_NULL);
GstElement *videosink, *audiosink;
videosink = gst_element_factory_make ("xvimagesink", "xvimagesink");
audiosink =
gst_element_factory_make ("autoaudiosink", "autoaudiosink");
g_object_set (pData->playbin2, "video-sink", videosink, NULL);
g_object_set (pData->playbin2, "audio-sink", audiosink, NULL);
gst_element_set_state (pData->playbin2, GST_STATE_PLAYING);
*/
preview = 1;
break;
}
......@@ -181,23 +171,10 @@ preview_cb (GtkCheckButton * preview_check, PlayerData * data)
{
g_print ("turning off preview checkcb \n");
teebin_preview_off(data);
/*
gst_element_set_state (globalData.playbin2, GST_STATE_NULL);
g_object_set (globalData.playbin2, "video-sink",
get_snowvideobin (feedname), NULL);
g_object_set (globalData.playbin2, "audio-sink",
get_snowaudiobin (feedname), NULL);
*/
preview = 0;
break;
}
}
// printf ("preveiw is %i\n", preview);
}
#endif
......@@ -848,10 +825,8 @@ static void init_media()
g_print ("sink: %s \n", sink);
#define SNOWBIN
#ifdef SNOWBIN
if (strcmp (sink, "snowbin") == 0)
{
GstElement *audiosink, *xvimagesink;
xvimagesink = gst_element_factory_make("xvimagesink", "xvimagesink");
......@@ -859,24 +834,12 @@ static void init_media()
/*set snowvideobin as sink */
g_object_set (pData->playbin2, "video-sink",
create_teebin(xvimagesink, get_snowvideobin(pData->snow)), NULL);
// g_object_set (globalData.playbin2, "video-sink",
// get_snowvideobin(feedname), NULL);
// create_teebin(xvimagesink, create_rtmpbin()), NULL);
/*set snowaudiobin as sink */
g_object_set (pData->playbin2, "audio-sink",
get_snowaudiobin (pData->snow), NULL);
//audiosink = gst_element_factory_make ("jackaudiosink", "jackaudiosink");
//g_object_set (globalData.playbin2, "audio-sink", audiosink, NULL);
//g_object_set (audiosink, "port-pattern", feedname, NULL);
}
else
{
audiosink = get_snowaudiobin(pData->snow);
g_object_set (pData->playbin2, "audio-sink",audiosink, NULL);
#else
/*
g_print ("autosink \n");
GstElement *videosink, *audiosink;
videosink = gst_element_factory_make ("xvimagesink", "xvimagesink");
......@@ -884,11 +847,8 @@ static void init_media()
g_object_set (pData->playbin2, "video-sink", videosink, NULL);
g_object_set (pData->playbin2, "audio-sink", audiosink, NULL);
}
#else
g_print (" SNOWBIN is not defined (port it to gst1.0)");
*/
#endif
if (!pData->playbin2)
......@@ -935,8 +895,15 @@ main (int argc, char *argv[])
/* deal with command line arguments */
// feed, filename,
int opt = 0;
int feedid = 1;
int audiosink = 23;
while ((opt = getopt (argc, argv, "i:f:s:")) != -1)
/* Initialize our global data structures */
pData = (PlayerData*)malloc(sizeof(struct PlayerData));
snowbin_init_snowData(pData);
while ((opt = getopt (argc, argv, "i:f:a:s:")) != -1)
{
switch (opt)
{
......@@ -945,11 +912,27 @@ main (int argc, char *argv[])
// playuri = optarg;
// break;
case 'f':
feedname = optarg;
feedid = atoi(optarg);
break;
case 's':
sink = optarg;
break;
case 'a':
if (strcmp(optarg,"snowmix") == 0)
{
pData->snow->audiosink = SNOWMIX;
} else if (strcmp(optarg,"jack") == 0)
{
pData->snow->audiosink = JACK;
} else if (strcmp(optarg,"auto") == 0)
{
pData->snow->audiosink = AUTO;
} else if (strcmp(optarg,"fake") == 0)
{
pData->snow->audiosink = FAKE;
}
break;
case '?':
/* Case when user enters the command as
* $ ./cmd_exe -i
......@@ -957,21 +940,19 @@ main (int argc, char *argv[])
if (optopt == 'u')
{
printf ("\nMissing mandatory input option \n");
exit(1);
}
else
{
printf
("\nInvalid option received \n -i playuri \n -f feedname \n -s sink \n");
("\nInvalid option received possible options: \n -a audiosink [snowmix|jack|auto|fake] \n -i playuri \n -f feedid \n -s sink (not working) \n");
exit(1);
}
break;
} //switch
} //while
/* Initialize our data structure */
//memset (&playerData, 0, sizeof (globalData));
pData = (PlayerData*)malloc(sizeof(struct PlayerData));
#ifdef GTK
......@@ -986,9 +967,6 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
#endif
/* initialize snowbin */
snowbin_init_snowData(pData);
/* initialize gstreamer */
init_media();
......
......@@ -88,6 +88,10 @@
#define gst_element_factory_make(element, name) gst_element_factory_make_debug (element, name);
enum {
STOMDING,
ANDERDING,
WTF,
AUTO,
JACK,
SNOWMIX,
FAKE
......
......@@ -80,7 +80,7 @@ open_client_socket(char *host, char *port)
}
//set nonblocking
// fcntl(sockfd, F_SETFL, O_NONBLOCK);
// fcntl(sockfd, F_SETFL, O_NONBLOCK);
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
s, sizeof s);
......@@ -132,23 +132,23 @@ get_vars (snowMixer *mixer, snowFeed *feed)
// printf("%s m1: %s m2: %s m3: %s", line, pmatch[0], pmatch[1], pmatch[2]);
int n = 0;
/*
/*
printf("With the whole expression, "
"a matched substring \"%.*s\" is found at position %d to %d.\n",
pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so],
pmatch[n].rm_so, pmatch[n].rm_eo - 1);
*/
*/
n = 1;
// snprintf(key, sizeof(&key), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so],pmatch[n].rm_so, pmatch[n].rm_eo - 1);
// | lenght | start? |
// snprintf(key, sizeof(&key), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so],pmatch[n].rm_so, pmatch[n].rm_eo - 1);
// | lenght | start? |
snprintf(key, sizeof(key), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so]);
n = 2;
// snprintf(value, sizeof(&value), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so],pmatch[n].rm_so, pmatch[n].rm_eo - 1);
// snprintf(value, sizeof(&value), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so],pmatch[n].rm_so, pmatch[n].rm_eo - 1);
snprintf(value, sizeof(value), "%.*s",pmatch[n].rm_eo - pmatch[n].rm_so, &line[pmatch[n].rm_so]);
// printf("keyvalue: %s %s \n ", key, value);
// printf("keyvalue: %s %s \n ", key, value);
switchs(key){
cases("host")
......@@ -165,7 +165,7 @@ get_vars (snowMixer *mixer, snowFeed *feed)
break;
cases("feed_width")
feed->width = atoi(value);
break;
break;
cases("feed_height")
feed->height = atoi(value);
break;
......@@ -173,8 +173,8 @@ get_vars (snowMixer *mixer, snowFeed *feed)
feed->control_pipe = strdup(value);
break;
cases("ctrsocket")
// strncpy(mixer->ctrlsocket, value, 100);
mixer->control_socket = strdup(value);
// strncpy(mixer->ctrlsocket, value, 100);
mixer->control_socket = strdup(value);
break;
cases("system_width")
mixer->width = atoi(value);
......@@ -183,13 +183,13 @@ get_vars (snowMixer *mixer, snowFeed *feed)
mixer->height = atoi(value);
break;
cases("ratefraction")
// strncpy(mixer->ratefraction, value, 100);
mixer->ratefraction = strdup(value);
break;
// strncpy(mixer->ratefraction, value, 100);
mixer->ratefraction = strdup(value);
break;
cases("snowmix")
// strncpy(mixer->state, value, 100);
mixer->state = strdup(value);
break;
// strncpy(mixer->state, value, 100);
mixer->state = strdup(value);
break;
cases("channels")
mixer->audio_channels = atoi(value);
break;
......@@ -200,11 +200,11 @@ get_vars (snowMixer *mixer, snowFeed *feed)
mixer->audio_rate = atoi(value);
break;
defaults
printf("FIX ME: no match for key of %s=%s \n", key, value);
printf("FIX ME: no match for key of %s=%s \n", key, value);
break;
} switchs_end;
// printf("%u", __done);
// printf("%u", __done);
}
......@@ -231,21 +231,21 @@ get_vars (snowMixer *mixer, snowFeed *feed)
extern void
extern void
print_snowMixer (snowMixer *m)
{
printf("\n \n snowMixer: \n host %s \n port %u \n control_socket %s \n state %s \n width %u \n height %u \n ratefraction %s \n audio_rate %u \n audio_channels %u \n",
m->host,
m->port,
m->control_socket,
m->state,
m->width,
m->height,
m->ratefraction,
m->audio_rate,
m->audio_channels);
m->host,
m->port,
m->control_socket,
m->state,
m->width,
m->height,
m->ratefraction,
m->audio_rate,
m->audio_channels);
}
extern void
extern void
print_snowFeed (snowFeed *f)
{
printf("\n \n snowFeed \nid %u \n control_pipe %s \n width %u \n height %u \n audio_channels %u \n audio_rate %u \n ",
......@@ -382,8 +382,8 @@ get_jacksink (int feedid)
g_object_set (G_OBJECT (js), "port-pattern", portpattern,
NULL);
}
g_object_set (G_OBJECT (js), "client-name", feedname,
NULL);
g_object_set (G_OBJECT (js), "client-name", feedname,
NULL);
return js;
}
......@@ -403,17 +403,17 @@ get_snowaudiosink (int feedid)
// file descriptor sink
socket = open_client_socket("localhost", "9999" );
write(socket, startaudio, strlen(startaudio));
// set filedescriptor
fdsink = gst_element_factory_make("fdsink","fdsink");
g_object_set( G_OBJECT (fdsink), "fd", socket, NULL);
// fdsink = gst_element_factory_make("fakesink","fakesink123");
// fdsink = gst_element_factory_make("fakesink","fakesink123");
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert123");
// gst_bin_add_many (GST_BIN (abin), audioconvert, fdsink,NULL);
// gst_element_link_many (audioconvert, fdsink, NULL);
// gst_bin_add_many (GST_BIN (abin), audioconvert, fdsink,NULL);
// gst_element_link_many (audioconvert, fdsink, NULL);
printf("END: createing snowaudiosinke \n \n \n ");
......@@ -423,7 +423,7 @@ get_snowaudiosink (int feedid)
}
extern int
extern int
snowbin_init_snowData (PlayerData *s)
{
......@@ -444,8 +444,8 @@ snowbin_init_snowData (PlayerData *s)
// set audiosink
sd->audiosink = SNOWMIX;
// print_snowMixer(snow->mixer);
// print_snowFeed(snow->currentFeed);
// print_snowMixer(snow->mixer);
// print_snowFeed(snow->currentFeed);
sd->currentFeed = feed;
sd->mixer = mixer;
......@@ -462,40 +462,62 @@ get_snowaudiobin (snowData *sd)
GstElement *snowaudiobin;
char *feedname = "feedfuck";
asprintf (&feedname, "feed%u", sd->currentFeed->id);
//common
snowaudiobin = gst_bin_new ("snowaudiobin");
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
//common
printf("========snowaudiobin thinks audiosink is: %u \n", sd->audiosink);
if (sd->audiosink == JACK)
{
//jack
audiosink = get_jacksink(sd->currentFeed->id);
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, audiosink,
NULL);
gst_element_link_many (audioconvert, audiosink, NULL);
printf("JACK \n ");
//jack
audiosink = get_jacksink(sd->currentFeed->id);
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, audiosink,
NULL);
gst_element_link_many (audioconvert, audiosink, NULL);
} else if (sd->audiosink == SNOWMIX)
{
// snow
audiosink = get_snowaudiosink(sd->currentFeed->id);
// snow
printf ("SNOW");
audiosink = get_snowaudiosink(sd->currentFeed->id);
GstCaps *caps = gst_caps_new_simple ("audio/x-raw",
"rate", G_TYPE_INT, 4800,
"channels", G_TYPE_INT, 2,
"format", G_TYPE_STRING, "S16LE",
NULL);
GstCaps *caps = gst_caps_new_simple ("audio/x-raw",
"rate", G_TYPE_INT, 4800,
"channels", G_TYPE_INT, 2,
"format", G_TYPE_STRING, "S16LE",
NULL);
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter123");
g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter123");
g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, capsfilter, audiosink,
NULL);
gst_element_link_many (audioconvert, capsfilter, audiosink, NULL);
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, capsfilter, audiosink,
NULL);
gst_element_link_many (audioconvert, capsfilter, audiosink, NULL);
} else if (sd->audiosink == FAKE)
{
// fake
audiosink = gst_element_factory_make ("fakesink", "fakesink123");
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, audiosink,
NULL);
gst_element_link_many (audioconvert, audiosink, NULL);
} else if (sd->audiosink == AUTO)
{
// fake
audiosink = gst_element_factory_make ("autoaudiosink", "autoaudiosink123");
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, audiosink,
NULL);
gst_element_link_many (audioconvert, audiosink, NULL);
}
// common
// common
apad = gst_element_get_static_pad (audioconvert, "sink");
aghostpad = gst_ghost_pad_new ("sink", apad);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment