mirror of
https://github.com/game-stop/veejay.git
synced 2026-01-06 06:55:31 +01:00
undo generator hack, there is a seperate tag type for generators.
This commit is contained in:
@@ -1101,7 +1101,21 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
||||
break;
|
||||
case VJ_TAG_TYPE_GENERATOR:
|
||||
|
||||
sprintf(tag->source_name, "[GEN %d]", channel );
|
||||
sprintf(tag->source_name, "[GEN]" );
|
||||
|
||||
if( channel == -1 && filename == NULL ) {
|
||||
int total = 0;
|
||||
int agen = plug_find_generator_plugins( &total, 0 );
|
||||
|
||||
if( agen >= 0 ) {
|
||||
char *plugname = plug_get_name( agen );
|
||||
channel = agen;
|
||||
veejay_msg(VEEJAY_MSG_INFO, "First available generator is '%s'",plugname );
|
||||
free(plugname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(channel >= 0 || filename != NULL) {
|
||||
char *plugname = NULL;
|
||||
if( filename != NULL ) {
|
||||
@@ -1141,7 +1155,7 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
||||
|
||||
sprintf(tag->source_name, "[%d,%d,%d]",
|
||||
tag->color_r,tag->color_g,tag->color_b );
|
||||
|
||||
/*
|
||||
if( channel == -1 ) {
|
||||
int total = 0;
|
||||
int agen = plug_find_generator_plugins( &total, 0 );
|
||||
@@ -1178,7 +1192,7 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int
|
||||
free(tag);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
tag->active = 1;
|
||||
break;
|
||||
@@ -3762,6 +3776,22 @@ int vj_tag_get_frame(int t1, uint8_t *buffer[3], uint8_t * abuffer)
|
||||
|
||||
break;
|
||||
case VJ_TAG_TYPE_GENERATOR:
|
||||
_tmp.len = len;
|
||||
_tmp.uv_len = uv_len;
|
||||
_tmp.data[0] = buffer[0];
|
||||
_tmp.data[1] = buffer[1];
|
||||
_tmp.data[2] = buffer[2];
|
||||
_tmp.width = width;
|
||||
_tmp.height = height;
|
||||
_tmp.format = PIX_FMT_YUVJ422P;
|
||||
if( tag->generator ) {
|
||||
plug_push_frame( tag->generator, 1, 0, &_tmp );
|
||||
plug_set_parameter( tag->generator, 0,1,&(tag->color_r) );
|
||||
plug_set_parameter( tag->generator, 1,1,&(tag->color_g) );
|
||||
plug_set_parameter( tag->generator, 2,1,&(tag->color_b) );
|
||||
plug_process( tag->generator );
|
||||
}
|
||||
break;
|
||||
case VJ_TAG_TYPE_COLOR:
|
||||
_tmp.len = len;
|
||||
_tmp.uv_len = uv_len;
|
||||
@@ -3771,20 +3801,10 @@ int vj_tag_get_frame(int t1, uint8_t *buffer[3], uint8_t * abuffer)
|
||||
_tmp.width = width;
|
||||
_tmp.height = height;
|
||||
_tmp.format = PIX_FMT_YUVJ422P;
|
||||
if(tag->generator == NULL ) {
|
||||
dummy_rgb_apply( &_tmp, width, height,
|
||||
tag->color_r,tag->color_g,tag->color_b );
|
||||
}
|
||||
else {
|
||||
plug_push_frame( tag->generator, 1, 0, &_tmp );
|
||||
plug_set_parameter( tag->generator, 0,1,&(tag->color_r) );
|
||||
plug_set_parameter( tag->generator, 1,1,&(tag->color_g) );
|
||||
plug_set_parameter( tag->generator, 2,1,&(tag->color_b) );
|
||||
plug_process( tag->generator );
|
||||
}
|
||||
dummy_rgb_apply( &_tmp, width, height, tag->color_r,tag->color_g,tag->color_b );
|
||||
break;
|
||||
|
||||
case VJ_TAG_TYPE_NONE:
|
||||
case VJ_TAG_TYPE_NONE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
116
veejay-current/veejay-server/veejay/vj-share.c
Normal file
116
veejay-current/veejay-server/veejay/vj-share.c
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2002-2011 Niels Elburg <nwelburg@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License , or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <libvjmem/vjmem.h>
|
||||
#include <libvjmsg/vj-msg.h>
|
||||
#include <veejay/vims.h>
|
||||
#include <libvjnet/vj-client.h>
|
||||
|
||||
|
||||
static vj_client *vj_share_connect(char *hostname, int port)
|
||||
{
|
||||
vj_client *c = vj_client_alloc( 0,0,0 );
|
||||
if(!c) return NULL;
|
||||
int res = 0;
|
||||
if( hostname == NULL )
|
||||
res = vj_client_connect( c, "127.0.0.1", NULL, port );
|
||||
else
|
||||
res = vj_client_connect( c, hostname, NULL, port );
|
||||
if(!res) {
|
||||
vj_client_free(c);
|
||||
c = NULL;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
static void vj_flush(vj_client *sayvims,int frames) {
|
||||
int n = 0;
|
||||
char status[100];
|
||||
bzero(status,100);
|
||||
|
||||
while(frames>0) {
|
||||
if( vj_client_poll(sayvims, V_STATUS ))
|
||||
{
|
||||
char sta_len[6];
|
||||
bzero(sta_len, 6 );
|
||||
int nb = vj_client_read( sayvims, V_STATUS, sta_len, 5 );
|
||||
if(sta_len[0] == 'V' )
|
||||
{
|
||||
int bytes = 0;
|
||||
sscanf( sta_len + 1, "%03d", &bytes );
|
||||
if(bytes > 0 )
|
||||
{
|
||||
bzero(status, 100);
|
||||
int n = vj_client_read(sayvims,V_STATUS,status,bytes);
|
||||
if( n )
|
||||
{
|
||||
frames -- ;
|
||||
}
|
||||
if( n<= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t vj_share_pull_master( void *shm, char *master_host, int master_port )
|
||||
{
|
||||
char tmp[64];
|
||||
vj_client *c = vj_share_connect( master_host, master_port );
|
||||
if(!c) {
|
||||
veejay_msg(0, "Error connecting to %s:%d",master_host, master_port );
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(tmp,0,sizeof(tmp));
|
||||
|
||||
vj_client_send( c, V_CMD, "425:0;" );
|
||||
|
||||
vj_client_read( c, V_CMD, tmp, 16 ); //@ get SHM id from
|
||||
|
||||
// int32_t key = atoi(tmp);
|
||||
|
||||
int32_t key = strtol( tmp, (char**) NULL, 10);
|
||||
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Veejay sister at port %d says shared resoure ID is %d",master_port,key);
|
||||
|
||||
vj_client_send( c, V_CMD, "025:1;" ); //@ master starts writing frames to shm
|
||||
|
||||
vj_shm_set_id( key ); //@ temporary store
|
||||
|
||||
|
||||
vj_flush(c,1);
|
||||
|
||||
vj_client_close( c );
|
||||
|
||||
vj_client_free( c );
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
6
veejay-current/veejay-server/veejay/vj-share.h
Normal file
6
veejay-current/veejay-server/veejay/vj-share.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef VJSHARE
|
||||
#define VJSHARE
|
||||
int32_t vj_share_pull_master( void *shm, char *master_host, int master_port );
|
||||
|
||||
#endif
|
||||
|
||||
318
veejay-current/veejay-server/veejay/vj-splitdisplay.c
Normal file
318
veejay-current/veejay-server/veejay/vj-splitdisplay.c
Normal file
@@ -0,0 +1,318 @@
|
||||
#include <config.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <libvjmsg/vj-msg.h>
|
||||
#include <libvjmem/vjmem.h>
|
||||
#ifdef STRICT_CHECKING
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <veejay/vj-splitdisplay.h>
|
||||
#include <libstream/vj-tag.h>
|
||||
#include <veejay/vj-lib.h>
|
||||
|
||||
#define MAX_REGIONS 8
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sample_id;
|
||||
int active;
|
||||
} split_sample_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int x;
|
||||
int y;
|
||||
} split_geom_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
split_sample_t **samples;
|
||||
int width;
|
||||
int height;
|
||||
int num_screens;
|
||||
uint8_t *area;
|
||||
uint8_t *darea[3]; //@ temporary draw/queue buffer
|
||||
uint8_t *ptr[3];
|
||||
char layout[ 1+ MAX_REGIONS ];
|
||||
} split_display_t;
|
||||
|
||||
|
||||
static void vj_split_change_screens(split_display_t *sd, int n)
|
||||
{
|
||||
int k;
|
||||
if( sd->samples && n != sd->num_screens ) {
|
||||
for( k = 0; k < sd->num_screens; k ++ )
|
||||
{
|
||||
if(sd->samples[k])
|
||||
free(sd->samples[k]);
|
||||
}
|
||||
free(sd->samples);
|
||||
}
|
||||
|
||||
sd->num_screens = n;
|
||||
sd->samples = (split_sample_t**) (vj_calloc(sizeof(split_sample_t*) * n ));
|
||||
for( k = 0; k < sd->num_screens; k ++ ) {
|
||||
sd->samples[k] = (split_sample_t*) vj_calloc(sizeof(split_sample_t));
|
||||
}
|
||||
|
||||
int auto_n = vj_tag_size()-1;
|
||||
if( (auto_n - sd->num_screens ) < 0 )
|
||||
{
|
||||
veejay_msg(0, "Stream limit is %d! Create more tags first", auto_n );
|
||||
return;
|
||||
}
|
||||
|
||||
sd->samples[0]->sample_id = 2;
|
||||
sd->samples[1]->sample_id = 4;
|
||||
sd->samples[2]->sample_id = 6;
|
||||
|
||||
for( k = 0; k < sd->num_screens; k ++ ) {
|
||||
// sd->samples[k]->sample_id = ( auto_n - sd->num_screens ) + k;
|
||||
veejay_msg(VEEJAY_MSG_DEBUG , "Split #%d = %d", k, sd->samples[k]->sample_id );
|
||||
}
|
||||
}
|
||||
|
||||
void *vj_split_display(int w, int h)
|
||||
{
|
||||
split_display_t *sd = (split_display_t*) vj_calloc( sizeof( split_display_t));
|
||||
sd->area = (uint8_t*) vj_calloc(sizeof(uint8_t) * w * h * 6 );
|
||||
sd->width = w;
|
||||
sd->height = h;
|
||||
sd->darea[0] = sd->area + (w*h*3);
|
||||
sd->darea[1] = sd->darea[0] + (w*h);
|
||||
sd->darea[2] = sd->darea[1] + ( (w*h)>>1);
|
||||
vj_split_change_screens(sd, 3);
|
||||
|
||||
return sd;
|
||||
}
|
||||
|
||||
void vj_split_get_frame( void *sd, uint8_t *row[3] )
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*)sd;
|
||||
if( sdt->ptr[0] == NULL ) {
|
||||
row[0] = sdt->area;
|
||||
row[1] = sdt->area + (sdt->width * sdt->height);
|
||||
row[2] = row[1] + ( (sdt->width*sdt->height)>>1);
|
||||
} else {
|
||||
row[0] = sdt->ptr[0];
|
||||
row[1] = sdt->ptr[1];
|
||||
row[2] = sdt->ptr[2];
|
||||
}
|
||||
}
|
||||
|
||||
static void vj_split_clear_region ( split_display_t *sdt , int position )
|
||||
{
|
||||
uint8_t *plane_y = sdt->area;
|
||||
uint8_t *plane_u = plane_y + (sdt->width * sdt->height);
|
||||
uint8_t *plane_v = plane_u + ((sdt->width * sdt->height)>>1);
|
||||
|
||||
int off_x = ( sdt->width / sdt->num_screens ) * position;
|
||||
int stop_x = ( sdt->width / sdt->num_screens ) + off_x;
|
||||
int w = sdt->width;
|
||||
int h = sdt->height;
|
||||
int x,y;
|
||||
uint8_t black = get_pixel_range_min_Y();
|
||||
/*
|
||||
for( y = 0; y < h; y ++ ) {
|
||||
for( x = off_x; x < stop_x; x ++ ) {
|
||||
plane_y[ y * w + x] = black;
|
||||
}
|
||||
}
|
||||
|
||||
off_x = off_x;
|
||||
off_x = stop_x;
|
||||
|
||||
for( y = 0; y < h ; y ++ ) {
|
||||
for( x = off_x; x < stop_x ; x ++ ) {
|
||||
plane_u[ y * w + x ] = 128;
|
||||
plane_v[ y * w + x ] = 128;
|
||||
}
|
||||
}*/
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "clear split #%d (%d -> %d)", position, (sdt->width*sdt->height),
|
||||
((sdt->width*sdt->height)>>1) );
|
||||
}
|
||||
|
||||
static void vj_split_push_frame( split_display_t *sdt, uint8_t *data[3], int position )
|
||||
{
|
||||
uint8_t *plane_y = sdt->ptr[0];
|
||||
uint8_t *plane_u = sdt->ptr[1];
|
||||
uint8_t *plane_v = sdt->ptr[2];
|
||||
|
||||
if( sdt->ptr[0] == NULL ) {
|
||||
plane_y = sdt->area;
|
||||
plane_u = plane_y + (sdt->width * sdt->height);
|
||||
plane_v = plane_u + ((sdt->width * sdt->height)>>1);
|
||||
}
|
||||
|
||||
int off_x = ( sdt->width / sdt->num_screens ) * position;
|
||||
int stop_x = ( sdt->width / sdt->num_screens ) + off_x;
|
||||
int w = sdt->width;
|
||||
int h = sdt->height;
|
||||
int x,y;
|
||||
|
||||
for( y = 0; y < h; y ++ ) {
|
||||
for( x = off_x; x < stop_x; x ++ ) {
|
||||
plane_y[ y * w + x] = data[0][ y * w + x ];
|
||||
}
|
||||
}
|
||||
|
||||
off_x = off_x >> 1;
|
||||
off_x = stop_x >> 1;
|
||||
|
||||
for( y = 0; y < h ; y ++ ) {
|
||||
for( x = off_x; x < stop_x ; x ++ ) {
|
||||
plane_u[ y * w + x ] = data[1][y * w + x];
|
||||
plane_v[ y * w + x ] = data[2][y * w + x];
|
||||
}
|
||||
}
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "push split #%d", position );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
[00000000000000000000000000000000] 0
|
||||
[10000000000000000000000000000000] 1
|
||||
[01000000000000000000000000000000] 2
|
||||
[11000000000000000000000000000000] 3
|
||||
[00100000000000000000000000000000] 4
|
||||
[10100000000000000000000000000000] 5
|
||||
[01100000000000000000000000000000] 6
|
||||
[11100000000000000000000000000000] 7
|
||||
|
||||
...
|
||||
|
||||
*/
|
||||
|
||||
void vj_split_set_stream_in_screen( void *sd, int stream_id, int screen_no )
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
int n = sdt->num_screens;
|
||||
if( screen_no < 1 ) screen_no = 1; else if ( screen_no > 7 ) screen_no = 7;
|
||||
if( sdt->num_screens <= screen_no ) {
|
||||
n = screen_no + 1;
|
||||
if( n > 7 )
|
||||
{
|
||||
n = 7;
|
||||
return;
|
||||
}
|
||||
}
|
||||
vj_split_change_screens( sdt, n );
|
||||
sdt->samples[ screen_no ]->sample_id = stream_id;
|
||||
}
|
||||
|
||||
int vj_split_get_num_screens( void *sd )
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
return sdt->num_screens;
|
||||
}
|
||||
|
||||
|
||||
static int testing_interval = 0;
|
||||
static int testing_value = 0;
|
||||
void vj_split_change_screen_setup(void *sd, int value)
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
char str[ 1 + (8 * sizeof(int)) ];
|
||||
int i;
|
||||
|
||||
//@ one to rule them all
|
||||
testing_interval ++;
|
||||
if( testing_interval > 100 )
|
||||
{
|
||||
testing_value ++ ;
|
||||
if( testing_value > 7 )
|
||||
testing_value = 0;
|
||||
testing_interval = 0;
|
||||
}
|
||||
veejay_msg(0, "%d / %d __ %d", testing_interval, 100, testing_value );
|
||||
|
||||
int my_precious = testing_value;
|
||||
|
||||
memset( str, 0,1 + (8*sizeof(int)));
|
||||
for ( i = 0; i < (8*sizeof(int)); i ++ ) {
|
||||
str[i] = ( my_precious & 1 ) + '0';
|
||||
my_precious = my_precious >> 1;
|
||||
}
|
||||
|
||||
for( i = 0; i < sdt->num_screens; i ++ ) {
|
||||
sdt->samples[i]->active = ( str[i] == '1' ? 1 : 0);
|
||||
}
|
||||
|
||||
memset( sdt->layout,0,sizeof(char)*MAX_REGIONS);
|
||||
for( i = 0; i < sdt->num_screens;i ++ )
|
||||
{
|
||||
sdt->layout[i] = str[i];
|
||||
if( sdt->layout[i] == '1' ) {
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Split #%d = %d, (active=%d)",
|
||||
i, sdt->samples[i]->sample_id, sdt->samples[i]->active );
|
||||
} else {
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Split %d = off (sample %d)",
|
||||
i, sdt->samples[i]->sample_id );
|
||||
}
|
||||
}
|
||||
|
||||
veejay_msg(VEEJAY_MSG_INFO, "Changed screen setup to %d/ %s",my_precious,sdt->layout );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void vj_split_get_layout( void *sd, char *dst )
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
strncpy(dst, sdt->layout, 8 );
|
||||
}
|
||||
|
||||
int *vj_split_get_samples( void *sd )
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
int *res = (int*) vj_malloc(sizeof(int)* MAX_REGIONS);
|
||||
int i;
|
||||
for( i = 0; i <MAX_REGIONS; i ++ ) {
|
||||
res[i] = sdt->samples[i]->sample_id;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void vj_split_change_num_screens( void *sd, int n_screens )
|
||||
{
|
||||
if( n_screens < 1 || n_screens > 8 )
|
||||
return;
|
||||
|
||||
split_display_t *sdt = (split_display_t*) sd;
|
||||
|
||||
vj_split_change_screens( sdt, n_screens );
|
||||
}
|
||||
|
||||
|
||||
void vj_split_process_frame( void *sd , uint8_t *dst[3])
|
||||
{
|
||||
split_display_t *sdt = (split_display_t*)sd;
|
||||
|
||||
sdt->ptr[0] = dst[0];
|
||||
sdt->ptr[1] = dst[1];
|
||||
sdt->ptr[2] = dst[2];
|
||||
|
||||
int k;
|
||||
for ( k = 0; k < sdt->num_screens ; k ++ )
|
||||
{
|
||||
if( sdt->samples[k]->sample_id == 0 ) {
|
||||
vj_split_clear_region( sdt, k );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( sdt->samples[k]->active == 0 ) {
|
||||
vj_split_clear_region( sdt, k );
|
||||
continue;
|
||||
}
|
||||
|
||||
//@ streams only for now
|
||||
if(! vj_tag_get_frame( sdt->samples[k]->sample_id, sdt->darea, NULL ) )
|
||||
continue;
|
||||
|
||||
vj_split_push_frame( sdt, sdt->darea, k );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
19
veejay-current/veejay-server/veejay/vj-splitdisplay.h
Normal file
19
veejay-current/veejay-server/veejay/vj-splitdisplay.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef SPLITDISPLAY
|
||||
#define SPLITDISPLAY
|
||||
void *vj_split_display(int w, int h);
|
||||
void vj_split_process_frame( void *sd, uint8_t *work_buffer[3] );
|
||||
|
||||
void vj_split_change_num_screens( void *sd, int n_screens );
|
||||
void vj_split_change_screen_setup(void *sd, int value);
|
||||
|
||||
int vj_split_get_num_screens( void *sd );
|
||||
|
||||
void vj_split_set_stream_in_screen( void *sd, int stream_id, int screen_no );
|
||||
|
||||
void vj_split_get_frame( void *sd, uint8_t *row[3] );
|
||||
|
||||
void vj_split_get_layout( void *sd, char *dst );
|
||||
|
||||
int *vj_split_get_samples( void *sd );
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user