Commit a32f63dc authored by hark's avatar hark
Browse files

start of settings in snowbin

parent ea776ac2
......@@ -11,7 +11,7 @@ CFLAGS= -O0 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-unused-variab
all : c-player c-player-0.10 c-player-debug vartest snowControl s2s s2s-cli bigscreen
vartest: vartest.c
gcc -DTESTING -DGTK -g vartest.c -o vartest `pkg-config --cflags --libs gstreamer-interfaces-0.10 gstreamer-pbutils-0.10 gtk+-2.0 gstreamer-0.10` $(CFLAGS)
gcc -DTESTING -DGTK -g vartest.c snowbin.c wraps.c -o vartest `pkg-config --cflags --libs gstreamer-interfaces-0.10 gstreamer-pbutils-0.10 gtk+-2.0 gstreamer-0.10` $(CFLAGS)
#switchs: switchs.c
# gcc -DTESTING -DGTK -g switchs.c -o switchs `pkg-config --cflags --libs gstreamer-interfaces-0.10 gstreamer-pbutils-0.10 gtk+-2.0 gstreamer-0.10` $(CFLAGS)
......
......@@ -73,6 +73,45 @@
#define gst_element_factory_make(element, name) gst_element_factory_make_debug (element, name);
typedef struct snowMixer snowMixer;
struct snowMixer {
//general
char *host; //host
int port; //port
char *control_socket; //ctrsocket
char *state; //snowmix
//video
int width; //system_width
int height; //system_height
char *ratefraction; //ratefraction
//audio
int audio_rate; //rate
int audio_channels; //channels
};
typedef struct snowFeed snowFeed;
struct snowFeed {
//general
int id;
char *control_pipe; //feed_control_pipe
// video
int width; //feed_width
int height; //feed_height
//framerate == mixer framerate
// audio
// int audio_backend; // jack??
int audio_channels; //feed_channels
int audio_rate;
};
typedef struct snowData snowData;
struct snowData {
snowFeed *currentFeed;
snowMixer *mixer;
};
#ifndef CLI
// globall vars
GtkWidget *loaded_label;
......
......@@ -25,11 +25,39 @@
#include "common.h"
#endif
extern GstElement *
get_snowvideobin (gchar * feedname)
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);
}
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 ",
f->id,
f->control_pipe,
f->width,
f->height,
f->audio_channels,
f->audio_rate);
}
extern GstElement *
get_snowvideobin (snowData *sd)
{
GstElement *videorate, *videoconvert, *capsfilter,
*videoscale, *shmsink, *queue;
*videoscale, *shmsink, *queue;
GstPad *vpad, *vghostpad;
GstElement *snowvideobin;
......@@ -55,29 +83,29 @@ get_snowvideobin (gchar * feedname)
#ifdef GST1
GstCaps *caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "BGRA",
//"interlace-mode", G_TYPE_STRING, "progressive",
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 576,
//"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
"framerate", GST_TYPE_FRACTION, 25, 1,
NULL);
"format", G_TYPE_STRING, "BGRA",
//"interlace-mode", G_TYPE_STRING, "progressive",
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 576,
//"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
"framerate", GST_TYPE_FRACTION, 25, 1,
NULL);
#else
GstCaps *caps = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, 32,
"depth", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, 4321,
"red_mask", G_TYPE_INT, 65280,
"green_mask", G_TYPE_INT, 16711680,
"blue_mask", G_TYPE_INT, -16777216,
"interlaced", G_TYPE_BOOLEAN, FALSE,
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 576,
"pixel-aspect-ratio",
GST_TYPE_FRACTION, 4, 3,
"framerate", GST_TYPE_FRACTION, 25, 1,
NULL);
"bpp", G_TYPE_INT, 32,
"depth", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, 4321,
"red_mask", G_TYPE_INT, 65280,
"green_mask", G_TYPE_INT, 16711680,
"blue_mask", G_TYPE_INT, -16777216,
"interlaced", G_TYPE_BOOLEAN, FALSE,
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 576,
"pixel-aspect-ratio",
GST_TYPE_FRACTION, 4, 3,
"framerate", GST_TYPE_FRACTION, 25, 1,
NULL);
#endif
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
......@@ -98,17 +126,17 @@ get_snowvideobin (gchar * feedname)
g_object_set (shmsink, "socket-path", controlpipe, NULL);
#ifndef GST1
g_object_set (shmsink, "shm-size", "23224320", NULL);
// g_object_set (shmsink, "shm-size", "40000000", NULL);
// g_object_set (shmsink, "shm-size", "40000000", NULL);
#endif
g_object_set (shmsink, "wait-for-connection", FALSE, NULL);
#ifdef GST1
// g_object_set (shmsink, "shm-size", "10000000", NULL);
// g_object_set (shmsink, "shm-size", "10000000", NULL);
/* add and link elements in the bin */
gst_bin_add_many (GST_BIN (snowvideobin), queue, videorate, videoscale,
videoconvert, capsfilter, shmsink, NULL);
videoconvert, capsfilter, shmsink, NULL);
if( !gst_element_link_many (queue, videorate, videoscale, videoconvert,capsfilter, shmsink, NULL)) {printf("linking snowbin failed");}
......@@ -116,10 +144,10 @@ get_snowvideobin (gchar * feedname)
/* add and link elements in the bin */
gst_bin_add_many (GST_BIN (snowvideobin), queue, videorate, videoscale,
videoconvert, capsfilter, shmsink, NULL);
videoconvert, capsfilter, shmsink, NULL);
gst_element_link_many (queue, videorate, videoscale, videoconvert,
capsfilter, shmsink, NULL);
capsfilter, shmsink, NULL);
#endif
......@@ -134,8 +162,8 @@ get_snowvideobin (gchar * feedname)
return snowvideobin;
}
extern GstElement *
get_audiobin (gchar * feedname)
extern GstElement *
get_jacksink (gchar * feedname)
{
GstElement *js;
js = gst_element_factory_make ("jackaudiosink", "jackaudiosink");
......@@ -144,26 +172,23 @@ get_audiobin (gchar * feedname)
/* check for jackportpattern */
if (g_object_class_find_property
(G_OBJECT_GET_CLASS (js), "port-pattern"))
{
char *portpattern = "feedfuck/audio_in";
asprintf (&portpattern, "%s/audio_in", feedname);
g_print ("snowaudiobin: feed: %s portpattern is: : %s : \n", feedname, portpattern);
g_object_set (G_OBJECT (js), "port-pattern", portpattern,
NULL);
g_object_set (G_OBJECT (js), "client-name", feedname,
NULL);
}
{
char *portpattern = "feedfuck/audio_in";
asprintf (&portpattern, "%s/audio_in", feedname);
g_print ("snowaudiobin: feed: %s portpattern is: : %s : \n", feedname, portpattern);
g_object_set (G_OBJECT (js), "port-pattern", portpattern,
NULL);
g_object_set (G_OBJECT (js), "client-name", feedname,
NULL);
}
return js;
}
extern GstElement *
get_snowaudiobin (gchar * feedname)
extern GstElement *
get_snowaudiobin (snowData *sd)
{
GstElement *jackaudiosink, *audioconvert;
GstPad *apad, *aghostpad;
......@@ -172,30 +197,17 @@ get_snowaudiobin (gchar * feedname)
g_print ("snowaudiobin: trying to connect to port %s \n", feedname);
snowaudiobin = gst_bin_new ("snowaudiobin");
jackaudiosink = get_audiobin(feedname);
// jackaudiosink = gst_element_factory_make ("jackaudiosink", "jackaudiosink");
// jackaudiosink = gst_element_factory_make ("autoaudiosink", "jackaudiosink");
/* check for jackportpattern */
/*
if (g_object_class_find_property
(G_OBJECT_GET_CLASS (jackaudiosink), "port-pattern"))
{
char *portpattern = NULL;
asprintf (&portpattern, "%s/audio_in", feedname);
g_object_set (G_OBJECT (jackaudiosink), "port-pattern", portpattern,
NULL);
}
*/
jackaudiosink = get_jacksink(feedname);
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
gst_bin_add_many (GST_BIN (snowaudiobin), audioconvert, jackaudiosink,
NULL);
NULL);
gst_element_link_many (audioconvert, jackaudiosink, NULL);
apad = gst_element_get_static_pad (audioconvert, "sink");
......
......@@ -18,7 +18,10 @@
#define SNOWBIN
extern GstBin *get_audiobin ();
//extern GstBin *get_audiobin ();
extern GstBin *get_snowvideobin ();
extern GstBin *get_snowaudiobin ();
extern GstBin *get_snowvideobin (snowData *);
extern GstBin *get_snowaudiobin (snowData *);
extern void print_snowFeed(snowFeed *);
extern void print_snowMixer(snowMixer *);
......@@ -24,10 +24,12 @@
0 == regexec ( &__regex, __sw, 0, NULL, 0 ) ) ) { \
__done = true; __cont = true;
/** Default behaviour */
/// Default behaviour
#define defaults } if ( !__done || __cont ) {
/** Close the switchs */
/// Close the switchs
#define switchs_end } while ( 0 ); regfree(&__regex); }
#endif // __SWITCHS_H__
......@@ -2,68 +2,7 @@
#include "common.h"
#include "switchs.h"
#include <regex.h>
typedef struct snowMixer snowMixer;
struct snowMixer {
//general
char *host; //host
int port; //port
char *control_socket; //ctrsocket
char *state; //snowmix
//video
int width; //system_width
int height; //system_height
char *ratefraction; //ratefraction
//audio
int audio_rate; //rate
int audio_channels; //channels
};
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);
}
typedef struct snowFeed snowFeed;
struct snowFeed {
//general
int id;
char *control_pipe; //feed_control_pipe
// video
int width; //feed_width
int height; //feed_height
//framerate == mixer framerate
// audio
// int audio_backend; // jack??
int audio_channels; //feed_channels
int audio_rate;
};
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 ",
f->id,
f->control_pipe,
f->width,
f->height,
f->audio_channels,
f->audio_rate);
}
typedef struct snowData snowData;
struct snowData {
snowFeed *currentFeed;
snowMixer *mixer;
};
#include "snowbin.h"
struct snowData *snow;
......@@ -77,6 +16,8 @@ get_vars (snowMixer *mixer, snowFeed *feed)
char msgbuf[100];
size_t nmatch = 3;
regmatch_t pmatch[3];
char key[100], value[100];
/* Compile regular expression */
// retsnow = regcomp(&regex, "^Snowmix[[:print:]]*", 0);
// retsnow = regcomp(&regex, "^[_[:alnum:]]*[[:punct:]][[:blank:]][[:alnum:]]*", REG_EXTENDED);
......@@ -94,7 +35,6 @@ get_vars (snowMixer *mixer, snowFeed *feed)
printf("Failed to run command\n" );
exit(1);
}
char *key[100], *value[100];
while (fgets(line, sizeof(line)-1, fp) != NULL) {
......@@ -106,17 +46,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);
// 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);
printf("%s \n ", key, value);
// 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);
switchs(key){
cases("host")
......@@ -167,13 +113,18 @@ get_vars (snowMixer *mixer, snowFeed *feed)
cases("rate")
mixer->audio_rate = atoi(value);
break;
} switchs_end;
defaults
printf("FIX ME: no match for key of %s=%s \n", key, value);
break;
} switchs_end;
// printf("%u", __done);
}
else if (retsnow == REG_NOMATCH) {
//puts("No match");
printf("%s", line);
printf("FIX ME: no match for line: %s", line);
}
else {
regerror(retsnow, &regex, msgbuf, sizeof(msgbuf));
......@@ -198,14 +149,14 @@ init_snowData (snowData *s)
struct snowFeed *feed;
s = (snowData*)malloc(sizeof(struct snowData));
mixer = (snowMixer*)malloc(sizeof(struct snowMixer));
/*
mixer->host = "bla"; //host
mixer->control_socket = "bla"; //ctrsocket
mixer->state = "bla"; //snowmix
mixer->ratefraction = "bla"; //ratefraction
*/
feed = (snowFeed*)malloc(sizeof(struct snowFeed));
//feed->control_pipe = "bla"; //feed_control_pipe
feed->control_pipe = "bla"; //feed_control_pipe
get_vars(mixer, feed);
......@@ -221,16 +172,16 @@ init_snowData (snowData *s)
int
main (int argc, char *argv[])
{
GstBin *snowBin;
GstBin *snowAudioBin;
snow = init_snowData(snow);
// exec script that sets env.
// get_vars(snow->mixer, snow->currentFeed);
snow = init_snowData(snow);
snowBin = get_snowvideobin(snow);
snowAudioBin = get_snowaudiobin(snow);
print_snowMixer(snow->mixer);
print_snowFeed(snow->currentFeed);
// printf("%s", mf->control_pipe );
// printf("feed_rate: %u \n pipe: %s", mf->audio_rate, mf->control_pipe);
}
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