Commit 456d00df authored by hark's avatar hark
Browse files

bkp

parent 05bd5f39
ldd `gst-inspect-1.0 audioconvert | grep File | sed -e 's%^[^/]*%%'` | grep orc
*.swp
vartest
bigscreen
c-player
......@@ -6,4 +7,4 @@ s2s-cli
snowControl
c-player-0.10
c-player-cli
c-player-debug
......@@ -8,11 +8,14 @@ CFLAGS= -O0 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-unused-variab
#-std=c99
# -Werror -Wconversion -Wsign-conversion
all : c-player c-player-0.10 c-player-debug vartest snowControl s2s s2s-cli
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)
#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)
c-player-0.10 : c-player.c
......
......@@ -40,6 +40,9 @@ if [ X$ctrsocket = X -o X$system_width = X -o X$system_height = X ] ; then
fi
VIDEOFORMAT=$VIDEOBGRA', width=(int)'$system_width', height=(int)'$system_height', framerate=(fraction)'$ratefraction
echo host: $ip
echo port: $port
echo feed_id: $feed_id
echo feed_rate: $feed_rate
echo feed_channels: $feed_channels
echo feed_control_pipe: $feed_control_pipe
......
#ifndef __SWITCHS_H__
#define __SWITCHS_H__
#include <string.h>
#include <regex.h>
#include <stdbool.h>
/** Begin a switch for the string x */
#define switchs(x) \
{ char *__sw = (x); bool __done = false; bool __cont = false; \
regex_t __regex; regcomp(&__regex, ".*", 0); do {
/** Check if the string matches the cases argument (case sensitive) */
#define cases(x) } if ( __cont || !strcmp ( __sw, x ) ) \
{ __done = true; __cont = true;
/** Check if the string matches the icases argument (case insensitive) */
#define icases(x) } if ( __cont || !strcasecmp ( __sw, x ) ) { \
__done = true; __cont = true;
/** Check if the string matches the specified regular expression using regcomp(3) */
#define cases_re(x,flags) } regfree ( &__regex ); if ( __cont || ( \
0 == regcomp ( &__regex, x, flags ) && \
0 == regexec ( &__regex, __sw, 0, NULL, 0 ) ) ) { \
__done = true; __cont = true;
/** Default behaviour */
#define defaults } if ( !__done || __cont ) {
/** Close the switchs */
#define switchs_end } while ( 0 ); regfree(&__regex); }
#endif // __SWITCHS_H__
/* get vars from snowmix */
#include "common.h"
#include "switchs.h"
#include <regex.h>
/*
ctrsocket: /tmp/mixer1
system_width: 1280
system_height: 720
ratefraction: 25/1
snowmix: running
channels: 2
rate: 48000
*/
struct snowmixer {
int width;
int height;
char *ctrlsocket;
int audio_rate;
int audio_channels;
char *state;
char *ratefraction;
};
/*
feed_rate: 48000
feed_channels: 1
feed_control_pipe: /tmp/feed1-control-pipe
feed_width: 1280
feed_height: 720
*/
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);
}
struct feed {
typedef struct snowFeed snowFeed;
struct snowFeed {
//general
int id;
int rate;
char *control_pipe;
int width;
int height;
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);
}
struct snowmixer mm;
struct feed mf;
typedef struct snowData snowData;
struct snowData {
int currentFeed feed;
int mixer;
}
struct snowData *snow;
int
get_vars ()
get_vars (snowMixer *mixer, snowFeed *feed)
{
FILE *fp;
char line[1035];
regex_t regex;
int reti;
int retsnow;
char msgbuf[100];
size_t nmatch = 3;
regmatch_t pmatch[3];
/* Compile regular expression */
reti = regcomp(&regex, "^a[[:alnum:]]", 0);
if (reti) {
// retsnow = regcomp(&regex, "^Snowmix[[:print:]]*", 0);
// retsnow = regcomp(&regex, "^[_[:alnum:]]*[[:punct:]][[:blank:]][[:alnum:]]*", REG_EXTENDED);
retsnow = regcomp(&regex, "^\([_[:alnum:]]*\)[[:punct:]][[:blank:]]\([[:print:]]*\)", REG_EXTENDED);
if (retsnow) {
fprintf(stderr, "Could not compile regex\n");
exit(1);
}
......@@ -64,20 +94,89 @@ get_vars ()
printf("Failed to run command\n" );
exit(1);
}
char *key[100], *value[100];
/* Read the output a line at a time - output it. */
while (fgets(line, sizeof(line)-1, fp) != NULL) {
printf("%s", line);
/* Execute regular expression */
reti = regexec(&regex, line, 0, NULL, 0);
if (!reti) {
puts("Match");
retsnow = regexec(&regex, line, nmatch, pmatch, 0);
if (!retsnow) {
//puts("Match");
// 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);
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);
switchs(key){
cases("host")
mixer->host = strdup(value);
break;
cases("port")
mixer->port = atoi(value);
break;
cases("feed_id")
feed->id = atoi(value);
break;
cases("feed_rate")
feed->audio_rate = atoi(value);
break;
cases("feed_width")
feed->width = atoi(value);
break;
cases("feed_height")
feed->height = atoi(value);
break;
cases("feed_control_pipe")
feed->control_pipe = strdup(value);
break;
cases("ctrsocket")
// strncpy(mixer->ctrlsocket, value, 100);
mixer->control_socket = strdup(value);
break;
cases("system_width")
mixer->width = atoi(value);
break;
cases("system_height")
mixer->height = atoi(value);
break;
cases("ratefraction")
// strncpy(mixer->ratefraction, value, 100);
mixer->ratefraction = strdup(value);
break;
cases("snowmix")
// strncpy(mixer->state, value, 100);
mixer->state = strdup(value);
break;
cases("channels")
mixer->audio_channels = atoi(value);
break;
cases("feed_channels")
feed->audio_channels = atoi(value);
break;
cases("rate")
mixer->audio_rate = atoi(value);
break;
} switchs_end;
}
else if (reti == REG_NOMATCH) {
puts("No match");
else if (retsnow == REG_NOMATCH) {
//puts("No match");
printf("%s", line);
}
else {
regerror(reti, &regex, msgbuf, sizeof(msgbuf));
regerror(retsnow, &regex, msgbuf, sizeof(msgbuf));
fprintf(stderr, "Regex match failed: %s\n", msgbuf);
exit(1);
}
......@@ -92,30 +191,36 @@ get_vars ()
return 0;
}
void
init_snowData (snowData *s)
{
struct snowMixer *mixer;
struct snowFeed *feed;
s = (snowData*)malloc(sizeof(struct snowData));
mixer = (snowMixer*)malloc(sizeof(struct snowMixer));
feed = (snowFeed*)malloc(sizeof(struct snowFeed));
get_vars(mixer, feed);
s->currentFeed = feed;
s->mixer = mixer;
}
int
main (int argc, char *argv[])
{
/*
feed_rate: 48000
feed_channels: 1
feed_control_pipe: /tmp/feed1-control-pipe
feed_width: 1280
feed_height: 720
ctrsocket: /tmp/mixer1
system_width: 1280
system_height: 720
ratefraction: 25/1
snowmix: running
channels: 2
rate: 48000
*/
// exec script that sets env.
get_vars();
// system("./vartest.sh");
char *feed_rate;
feed_rate = getenv("feed_rate");
printf("feed_rate: %s \n", feed_rate);
init_snowData(snow);
// exec script that sets env.
// get_vars(snow->mixer, snow->currentFeed);
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);
}
#!/bin/bash
# Deliver mixer1 output to dummy.
set -e
SM=/crypthome/hark/src/Snowmix-0.4.5/
#include "switchs.h"
# IMPORTANT >>>>>You need to get port, ip and feed_id right<<<<<
port=9999
ip=127.0.0.1
# Set video feed
feed_id=1
audio_feed_id=1
# Check for SM variable and the snowmix and gstreamer settings
if [ X$SM = X -o ! -f $SM/scripts/gstreamer-settings -o ! -f $SM/scripts/snowmix-settings ] ; then
#echo "You need to se the environment variable SM to the base of the Snowmix directory"
exit 1
fi
# Load the Snowmix and GStreamer settings
. $SM/scripts/gstreamer-settings
. $SM/scripts/snowmix-settings
# This will set
# a) feed_rate
# b) feed_channels
# c) feed_control_pipe
# d) feed_width
# e) feed_height
# f) ctrsocket
# g) system_width
# h) system_height
# i) ratefraction
# j) snowmix
# k) channels
# l) rate
if [ X$ctrsocket = X -o X$system_width = X -o X$system_height = X ] ; then
# echo Failed to get control pipe or width or height from running snowmix
exit 2
fi
VIDEOFORMAT=$VIDEOBGRA', width=(int)'$system_width', height=(int)'$system_height', framerate=(fraction)'$ratefraction
echo feed_rate: $feed_rate
echo feed_channels: $feed_channels
echo feed_control_pipe: $feed_control_pipe
echo feed_width: $feed_width
echo feed_height: $feed_height
echo ctrsocket: $ctrsocket
echo system_width: $system_width
echo system_height: $system_height
echo ratefraction: $ratefraction
echo snowmix: $snowmix
echo channels: $channels
echo rate: $rate
echo videoformat: $VIDEOFORMAT
#make vartest
#./vartest
#env
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