diff --git a/veejay-current/gveejay-reloaded/gveejay.c b/veejay-current/gveejay-reloaded/gveejay.c index bea7267d..090e1974 100644 --- a/veejay-current/gveejay-reloaded/gveejay.c +++ b/veejay-current/gveejay-reloaded/gveejay.c @@ -70,12 +70,12 @@ static int set_option( const char *name, char *value ) if( strcmp(name, "h") == 0 || strcmp(name, "hostname") == 0 ) { strcpy( hostname, optarg ); - launcher = 1; + launcher ++; } else if( strcmp(name, "p") == 0 || strcmp(name ,"port") == 0 ) { - port_num = atoi(optarg); - launcher = 1; + if(sscanf( optarg, "%d", &port_num )) + launcher++; } else if (strcmp(name, "X") == 0 ) { @@ -125,9 +125,9 @@ int main(int argc, char *argv[]) { if(!argc) usage(argv[0]); // default host to connect to - sprintf(hostname, "localhost"); + sprintf(hostname, "127.0.0.1"); - while( ( n = getopt( argc, argv, "s:h:pP::nvHf:X:")) != EOF ) + while( ( n = getopt( argc, argv, "s:h:p:P::nvHf:X:")) != EOF ) { sprintf(option, "%c", n ); err += set_option( option, optarg); @@ -138,13 +138,6 @@ int main(int argc, char *argv[]) { if( err ) usage(argv[0]); -/* struct sched_param schp; - memset( &schp, 0, sizeof( schp )); - schp.sched_priority = sched_get_priority_min(SCHED_RR ); - if( sched_setscheduler( 0, SCHED_FIFO, &schp ) != 0 ) - veejay_msg(0, "Error setting RR"); -*/ - if( !g_thread_supported() ) { g_thread_init(NULL); @@ -170,6 +163,16 @@ int main(int argc, char *argv[]) { vj_gui_init( skins[0].file, launcher, hostname, port_num ); vj_gui_style_setup(); + struct sched_param schp; + memset( &schp, 0, sizeof( schp )); + schp.sched_priority = sched_get_priority_min(SCHED_RR ); + if( sched_setscheduler( 0, SCHED_FIFO, &schp ) != 0 ) + veejay_msg(0, "Error setting RR"); + else + veejay_msg(VEEJAY_MSG_INFO, "GVeejayReloaded running with low priority"); + + + while(gveejay_running()) { is_alive(); diff --git a/veejay-current/gveejay-reloaded/sequence.c b/veejay-current/gveejay-reloaded/sequence.c index 3f991145..10ab388a 100644 --- a/veejay-current/gveejay-reloaded/sequence.c +++ b/veejay-current/gveejay-reloaded/sequence.c @@ -683,12 +683,24 @@ static GdkPixbuf **gvr_grab_images(void *preview) if(v->grey_scale) { uint8_t *rgb = v->tmp_buffer; - unsigned int j = 0; - for( j = 0; j < (v->width*v->height); j+=3 ) + uint8_t *plane = v->data_buffer; + unsigned int j,k = 0; + unsigned int stride = v->width * 3; + /* for( j = 0; j < (v->width*v->height); j+=3 ) { rgb[j+0] = v->data_buffer[j]; rgb[j+1] = v->data_buffer[j]; rgb[j+2] = v->data_buffer[j]; + }*/ + for( j = 0; j < v->height; j ++ ) + { + for( k = 0; k < v->width ; k ++ ) + { + uint8_t *p = rgb + j * stride + (k*3); + p[0] = plane[j * v->width + k]; + p[1] = plane[j * v->width + k]; + p[2] = plane[j * v->width + k]; + } } list[i] = gdk_pixbuf_new_from_data(v->tmp_buffer, GDK_COLORSPACE_RGB, FALSE, 8, v->width,v->height,v->width * 3, NULL,NULL ); diff --git a/veejay-current/gveejay-reloaded/vj-api.c b/veejay-current/gveejay-reloaded/vj-api.c index f218913f..c2a865bf 100644 --- a/veejay-current/gveejay-reloaded/vj-api.c +++ b/veejay-current/gveejay-reloaded/vj-api.c @@ -2154,14 +2154,14 @@ static gchar *recv_log_vims(int slen, int *bytes_written) gchar tmp[slen+1]; bzero(tmp,slen+1); - vj_client_read( info->client, V_MSG, tmp, slen ); + vj_client_read( info->client, V_CMD, tmp, slen ); int len = atoi(tmp); gchar *result = NULL; int n = 0; if(len > 0) { result = g_new( gchar, len+1 ); - n = vj_client_read( info->client, V_MSG, result, len ); + n = vj_client_read( info->client, V_CMD, result, len ); *bytes_written = n; result[len] = '\0'; } diff --git a/veejay-current/libstream/vj-net.c b/veejay-current/libstream/vj-net.c index 40351439..9aba0289 100644 --- a/veejay-current/libstream/vj-net.c +++ b/veejay-current/libstream/vj-net.c @@ -74,15 +74,6 @@ void *reader_thread(void *data) error = 1; } - if( tag->source_type == VJ_TAG_TYPE_NET ) - { - if( vj_client_poll(v, V_STATUS ) ) - { - vj_client_flush ( v, V_STATUS); - } - } - - lock(t); if( t->grab && tag->source_type == VJ_TAG_TYPE_NET && retrieve== 0) @@ -234,21 +225,22 @@ int net_thread_start(vj_client *v, vj_tag *tag) { int success = 0; int res = 0; + if(tag->source_type == VJ_TAG_TYPE_MCAST ) - success = vj_client_connect( v, NULL,tag->source_name,tag->video_channel); + success = vj_client_connect( v,NULL,tag->source_name,tag->video_channel ); else - success = vj_client_connect( v, tag->source_name,NULL,tag->video_channel); + success = vj_client_connect_dat( v, tag->source_name,tag->video_channel ); if( success <= 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to establish connection with %s on port %d", - tag->source_name, tag->video_channel ); + tag->source_name, tag->video_channel + 5); return 0; } else { veejay_msg(VEEJAY_MSG_INFO, "Connecton established with %s:%d",tag->source_name, - tag->video_channel); + tag->video_channel + 5); } threaded_t *t = (threaded_t*)tag->priv; diff --git a/veejay-current/libvjnet/cmd.c b/veejay-current/libvjnet/cmd.c index 16a6e364..1aa28332 100644 --- a/veejay-current/libvjnet/cmd.c +++ b/veejay-current/libvjnet/cmd.c @@ -48,7 +48,7 @@ int sock_t_connect( vj_sock_t *s, char *host, int port ) s->sock_fd = socket( AF_INET, SOCK_STREAM , 0); if(s->sock_fd < 0) { - veejay_msg(VEEJAY_MSG_ERROR, "Connection error with Veejay host %s:%d %s ", host,port,strerror(errno)); + veejay_msg(VEEJAY_MSG_ERROR, "Socket error with Veejay host %s:%d %s ", host,port,strerror(errno)); return 0; } s->port_num = port; @@ -59,6 +59,8 @@ int sock_t_connect( vj_sock_t *s, char *host, int port ) if( connect( s->sock_fd, (struct sockaddr*) &s->addr, sizeof( struct sockaddr )) == -1 ) { + veejay_msg(VEEJAY_MSG_ERROR, "Connection error with Veejay host %s:%d %s", + host, port, strerror(errno)); return 0; } unsigned int tmp = sizeof(int); @@ -147,6 +149,7 @@ int sock_t_recv_w( vj_sock_t *s, void *dst, int len ) { int done = 0; int bytes_left = s->recv_size; + while( done < len ) { n = recv( s->sock_fd, dst + done,bytes_left,0 ); diff --git a/veejay-current/libvjnet/common.h b/veejay-current/libvjnet/common.h index 2c373abb..520579ff 100644 --- a/veejay-current/libvjnet/common.h +++ b/veejay-current/libvjnet/common.h @@ -24,7 +24,6 @@ #define VSOCK_C 1 #define V_STATUS 0 #define V_CMD 1 -#define V_MSG 2 #define VMCAST_S 4 #define VMCAST_C 5 diff --git a/veejay-current/libvjnet/vj-client.c b/veejay-current/libvjnet/vj-client.c index 82f8c216..a1c80373 100644 --- a/veejay-current/libvjnet/vj-client.c +++ b/veejay-current/libvjnet/vj-client.c @@ -59,7 +59,6 @@ vj_client *vj_client_alloc( int w, int h, int f ) v->c = (conn_type_t**) malloc(sizeof(conn_type_t*) * 3); v->c[0] = (conn_type_t*) malloc(sizeof(conn_type_t)); v->c[1] = (conn_type_t*) malloc(sizeof(conn_type_t)); - v->c[2] = (conn_type_t*) malloc(sizeof(conn_type_t)); v->blob = (unsigned char*) malloc(sizeof(unsigned char) * PACKET_LEN ); v->mcast = 0; if( w > 0 && h > 0 ) @@ -75,8 +74,6 @@ void vj_client_free(vj_client *v) free(v->c[0]); if(v->c[1]) free(v->c[1]); - if(v->c[2]) - free(v->c[2]); if(v->c) free(v->c); if(v->blob) @@ -104,6 +101,31 @@ void vj_client_flush(vj_client *v, int num_frames) } } +int vj_client_connect_dat(vj_client *v, char *host, int port_id ) +{ + int error = 0; + if(host == NULL) + { + veejay_msg(VEEJAY_MSG_ERROR, "Invalid host name"); + return 0; + } + if(port_id < 1 || port_id > 65535) + { + veejay_msg(VEEJAY_MSG_ERROR, "Invalid port number. Use [1-65535]"); + return 0; + } + v->c[0]->type = VSOCK_C; + v->c[0]->fd = alloc_sock_t(); + free(v->c[1]); + v->c[1] = NULL; + if( sock_t_connect( v->c[0]->fd, host, port_id + 5 ) ) + { + veejay_msg(VEEJAY_MSG_INFO, "Connect to DAT port %d", port_id + 5); + return 1; + } + return error; +} + int vj_client_connect(vj_client *v, char *host, char *group_name, int port_id ) { int error = 0; @@ -119,10 +141,7 @@ int vj_client_connect(vj_client *v, char *host, char *group_name, int port_id ) v->c[0]->fd = alloc_sock_t(); v->c[1]->type = VSOCK_S; v->c[1]->fd = alloc_sock_t(); - v->c[2]->type = VSOCK_C; - v->c[2]->fd = alloc_sock_t(); - - if(!v->c[0]->fd || !v->c[1]->fd || !v->c[2] ) + if(!v->c[0]->fd || !v->c[1]->fd ) { return 0; } @@ -130,8 +149,7 @@ int vj_client_connect(vj_client *v, char *host, char *group_name, int port_id ) { if( sock_t_connect( v->c[1]->fd, host, port_id + VJ_STA_PORT ) ) { - if( sock_t_connect( v->c[2]->fd, host, port_id + VJ_MSG_PORT ) ) - return 1; + return 1; } } } @@ -169,12 +187,6 @@ int vj_client_poll_w( vj_client *v, int sock_type ) if(v->c[0]->type == VSOCK_C) return ( sock_t_poll_w( v->c[0]->fd )); } - if(sock_type == V_MSG ) - { - if(v->c[2]->type == VSOCK_C) - return ( sock_t_poll_w( v->c[2]->fd )); - } - return 0; } @@ -192,12 +204,6 @@ int vj_client_poll( vj_client *v, int sock_type ) if(v->c[0]->type == VMCAST_C ) return ( mcast_poll( v->c[0]->r )); } - if(sock_type == V_MSG ) - { - if(v->c[2]->type == VSOCK_C) - return ( sock_t_poll( v->c[2]->fd )); - } - return 0; } @@ -220,9 +226,6 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) int conv = 1; int y_len = 0; int uv_len = 0; -veejay_msg(0, "Error: use v->c[2]->type (verify)"); - assert(0); - compile error here if( v->c[0]->type == VMCAST_C ) { @@ -327,11 +330,6 @@ int vj_client_get_status_fd(vj_client *v, int sock_type ) else return v->c[0]->r->sock_fd; } - if(sock_type == V_MSG ) - { - return v->c[2]->fd->sock_fd; - } - return 0; } @@ -347,11 +345,6 @@ int vj_client_read(vj_client *v, int sock_type, uint8_t *dst, int bytes ) if(v->c[0]->type == VSOCK_C) return ( sock_t_recv( v->c[0]->fd, dst, bytes ) ); } - if( sock_type == V_MSG ) - { - if(v->c[2]->type == VSOCK_C) - return ( sock_t_recv( v->c[2]->fd, dst, bytes ) ); - } return 0; } @@ -369,16 +362,6 @@ int vj_client_send(vj_client *v, int sock_type,char *buf ) return ( mcast_send( v->c[0]->s, (void*) v->blob, len + 5, v->ports[1] )); } - if( sock_type == V_MSG ) - { - - // format msg - int len = strlen( buf ); - sprintf(v->blob, "V%03dD%s", len, buf); - if(v->c[2]->type == VSOCK_C) - return ( sock_t_send( v->c[2]->fd, v->blob, len + 5 )); - } - return 1; } @@ -395,16 +378,6 @@ int vj_client_send_buf(vj_client *v, int sock_type,unsigned char *buf, int len ) return ( mcast_send( v->c[0]->s, (void*) v->blob, len + 5, v->ports[1] )); } - if( sock_type == V_MSG ) - { - - // format msg - sprintf(v->blob, "V%03dD", len); - veejay_memcpy(v->blob+5, buf, len); - if(v->c[2]->type == VSOCK_C) - return ( sock_t_send( v->c[2]->fd, v->blob, len + 5 )); - } - return 1; } @@ -422,16 +395,6 @@ int vj_client_send_bufX(vj_client *v, int sock_type,unsigned char *buf, int len return ( mcast_send( v->c[0]->s, (void*) v->blob, len + 9, v->ports[1] )); } - if( sock_type == V_MSG ) - { - - // format msg - sprintf(v->blob, "K%08d", len); - veejay_memcpy(v->blob+9, buf, len); - if(v->c[2]->type == VSOCK_C) - return ( sock_t_send( v->c[2]->fd, v->blob, len + 9 )); - } - return 1; } @@ -439,17 +402,22 @@ int vj_client_close( vj_client *v ) { if(v) { - if(v->c[0]->type == VSOCK_C) - sock_t_close(v->c[0]->fd ); - if(v->c[1]->type == VSOCK_S) - sock_t_close(v->c[1]->fd ); - if(v->c[2]->type == VSOCK_C ) - sock_t_close(v->c[2]->fd ); - if(v->c[0]->type == VMCAST_C) + if(v->c[0]) { - mcast_close_receiver( v->c[0]->r ); - mcast_close_sender( v->c[0]->s ); + if(v->c[0]->type == VSOCK_C) + sock_t_close(v->c[0]->fd ); + else if ( v->c[0]->type == VMCAST_C ) + { + mcast_close_receiver( v->c[0]->r ); + mcast_close_sender( v->c[0]->s ); + } } + if(v->c[1]) + { + if(v->c[1]->type == VSOCK_S) + sock_t_close(v->c[1]->fd ); + } + return 1; } return 0; diff --git a/veejay-current/libvjnet/vj-server.c b/veejay-current/libvjnet/vj-server.c index 3edd284c..8fca48ac 100644 --- a/veejay-current/libvjnet/vj-server.c +++ b/veejay-current/libvjnet/vj-server.c @@ -126,8 +126,6 @@ static int _vj_server_multicast( vj_server *v, char *group_name, int port ) v->link = (void**) link; veejay_msg(VEEJAY_MSG_INFO, "UDP multicast frame sender ready at port %d (group '%s')", v->ports[0], group_name ); - veejay_msg(VEEJAY_MSG_INFO, "UDP multicast command receiver ready at port %d (group '%s')", - v->ports[1], group_name ); return 1; } @@ -155,8 +153,6 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) port_num = port_offset + VJ_CMD_PORT; if( vjs->server_type == V_STATUS ) port_num = port_offset + VJ_STA_PORT; - if( vjs->server_type == V_MSG ) - port_num = port_offset + VJ_MSG_PORT; vjs->myself.sin_port = htons(port_num); veejay_memset(&(vjs->myself.sin_zero), 0, 8); @@ -183,20 +179,16 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) veejay_msg(0, "Cannot read socket buffer size: %s", strerror(errno)); return 0; } - veejay_msg(VEEJAY_MSG_INFO, "\tSocket send size is %d", vjs->send_size); if( setsockopt( vjs->handle, SOL_SOCKET, SO_RCVBUF, (const char*) &send_size, sizeof(send_size)) == 1 ) { veejay_msg(0, "Cannot set recv buffer sze:%s", strerror(errno)); return 0; } - int recv_size = 0; - if( getsockopt( vjs->handle, SOL_SOCKET, SO_RCVBUF, (unsigned char*) &recv_size, &tmp) == -1 ) + if( getsockopt( vjs->handle, SOL_SOCKET, SO_RCVBUF, (unsigned char*) &(vjs->recv_size), &tmp) == -1 ) { veejay_msg(0, "Cannot read socket buffer receive size %s" , strerror(errno)); return 0; } - veejay_msg(VEEJAY_MSG_INFO, "\tSocket recv size is %d", recv_size ); - link = (vj_link **) vj_malloc(sizeof(vj_link *) * VJ_MAX_CONNECTIONS); if(!link) @@ -222,8 +214,23 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) } vjs->link = (void**) link; vjs->nr_of_connections = vjs->handle; - veejay_msg(VEEJAY_MSG_INFO, "TCP/IP Unicast %s channel ready at port %d", - (vjs->server_type == V_STATUS ? "status" : "command" ), port_num ); + + switch(vjs->server_type ) + { + case V_STATUS: + veejay_msg(VEEJAY_MSG_INFO,"TCP/IP unicast VIMS status socket ready at port %d, (R:%d, S:%d)", + port_num, vjs->recv_size, vjs->send_size ); + break; + case V_CMD: + veejay_msg(VEEJAY_MSG_INFO,"TCP/IP unicast VIMS control socket ready at port %d (R:%d, S:%d)", + port_num, vjs->recv_size, vjs->send_size ); + break; + default: +#ifdef STRICT_CHECKING + assert(0); +#endif + break; + } return 1; } @@ -263,9 +270,9 @@ vj_server *vj_server_alloc(int port_offset, char *mcast_group_name, int type) int vj_server_send( vj_server *vje, int link_id, uint8_t *buf, int len ) { - unsigned int total = 0; - unsigned int bytes_left = len; - int n; + unsigned int total = 0; + unsigned int bytes_left = len; + int n; #ifdef STRICT_CHECKING assert( vje->send_size > 0 ); assert( len > 0 ); @@ -273,22 +280,12 @@ int vj_server_send( vj_server *vje, int link_id, uint8_t *buf, int len ) assert( link_id >= 0 ); #endif -//veejay_msg(VEEJAY_MSG_DEBUG, "%s: %p, link_id=%d, len=%d",__FUNCTION__,vje, link_id, len ); if( !vje->use_mcast) { vj_link **Link = (vj_link**) vje->link; #ifdef STRICT_CHECKING - assert( Link[link_id]->in_use == 1 ); -#endif - - if (len <= 0 || Link[link_id]->in_use==0) - { - veejay_msg(VEEJAY_MSG_ERROR, "Nothing to send or link %d is inactive", link_id); - return 0; - } -#ifdef STRICT_CHECKING - assert( Link[link_id]->handle >= 0 ); + assert( Link[link_id]->in_use == 1 ); #endif total = sock_t_send_fd( Link[link_id]->handle, vje->send_size, buf, len, 0); if( total <= 0 ) @@ -297,33 +294,14 @@ int vj_server_send( vj_server *vje, int link_id, uint8_t *buf, int len ) (char*)(inet_ntoa(vje->remote.sin_addr)),strerror(errno)); return 0; } - -/* - while (total < len) - { - n = send(Link[link_id]->handle, buf + total, bytes_left, 0); - if (n <= 0) - { - veejay_msg(VEEJAY_MSG_ERROR,"Send error to %s: %s", - (char*) (inet_ntoa( vje->remote.sin_addr )), - strerror(errno)); - return -1; - } - - total += n; - bytes_left -= n; - }*/ } else { vj_proto **proto = (vj_proto**) vje->protocol; - if( vje->server_type == V_CMD ) return mcast_send( proto[0]->s, buf, bytes_left, vje->ports[0] ); } - - - return total; + return total; } int vj_server_link_can_write( vj_server *vje, int link_id ) @@ -371,6 +349,34 @@ int vj_server_link_can_write( vj_server *vje, int link_id ) return 0; } +static int vj_server_send_frame_now( vj_server *vje, int link_id, uint8_t *buf, int len ) +{ + unsigned int total = 0; + unsigned int bytes_left = len; + int n; +#ifdef STRICT_CHECKING + assert( vje->send_size > 0 ); + assert( len > 0 ); + assert( buf != NULL ); + assert( link_id >= 0 ); +#endif + + vj_link **Link = (vj_link**) vje->link; +#ifdef STRICT_CHECKING + assert( Link[link_id]->in_use == 1 ); +#endif + + total = sock_t_send_fd( Link[link_id]->handle, vje->send_size, buf, len, 0); + if( total <= 0 ) + { + veejay_msg(0,"Unable to send buffer to %s:%s", + (char*)(inet_ntoa(vje->remote.sin_addr)),strerror(errno)); + return 0; + } + + return total; +} + int vj_server_send_frame( vj_server *vje, int link_id, uint8_t *buf, int len, VJFrame *frame, long ms ) { @@ -378,7 +384,7 @@ int vj_server_send_frame( vj_server *vje, int link_id, uint8_t *buf, int len, { if( vj_server_link_can_write( vje, link_id )) { - return vj_server_send( vje, link_id, buf, len ); + return vj_server_send_frame_now( vje, link_id, buf, len ); } else veejay_msg(0, "Cant send frame, socket not ready"); @@ -499,10 +505,6 @@ int vj_server_poll(vj_server * vje) FD_SET( Link[i]->handle, &(vje->fds) ); FD_SET( Link[i]->handle, &(vje->wds) ); } - if(vje->server_type == V_MSG) - { - FD_SET( Link[i]->handle, &(vje->wds) ); - } if(vje->server_type == V_STATUS ) FD_SET( Link[i]->handle, &(vje->wds)); } @@ -801,7 +803,8 @@ int vj_server_new_connection(vj_server *vje) } char *host = inet_ntoa( vje->remote.sin_addr ); - veejay_msg(VEEJAY_MSG_INFO, "Connection with %s ", host); + veejay_msg(VEEJAY_MSG_INFO, "Connection with %s on port %d", host, + vje->remote.sin_port); if( vje->nr_of_connections < fd ) vje->nr_of_connections = fd; diff --git a/veejay-current/libvjnet/vj-server.h b/veejay-current/libvjnet/vj-server.h index b2a06b70..c04f9c99 100644 --- a/veejay-current/libvjnet/vj-server.h +++ b/veejay-current/libvjnet/vj-server.h @@ -40,6 +40,7 @@ typedef struct vj_server_t { void **protocol; char *recv_buf; int send_size; + int recv_size; } vj_server; vj_server *vj_server_alloc(int port, char *mcast_group_name, int type); diff --git a/veejay-current/veejay/liblavplayvj.c b/veejay-current/veejay/liblavplayvj.c index 85a20f33..89d1e5dd 100644 --- a/veejay-current/veejay/liblavplayvj.c +++ b/veejay-current/veejay/liblavplayvj.c @@ -1177,12 +1177,13 @@ void veejay_pipe_write_status(veejay_t * info, int link_id) d_len = strlen(info->status_what); snprintf(info->status_msg,MESSAGE_SIZE, "V%03dS%s", d_len, info->status_what); - res = vj_server_send(info->vjs[1],link_id, info->status_msg, strlen(info->status_msg)); + res = vj_server_send(info->vjs[VEEJAY_PORT_STA],link_id, info->status_msg, strlen(info->status_msg)); - if( res <= 0) { /* close command socket */ - _vj_server_del_client(info->vjs[1], link_id ); - _vj_server_del_client(info->vjs[0], link_id ); - _vj_server_del_client(info->vjs[3], link_id ); + if( res <= 0) + { /* close command socket */ + veejay_msg(VEEJAY_MSG_DEBUG ,"Error sending status message , closing connection(s)"); + _vj_server_del_client(info->vjs[VEEJAY_PORT_CMD], link_id ); + _vj_server_del_client(info->vjs[VEEJAY_PORT_STA], link_id ); } if (info->uc->chain_changed == 1) info->uc->chain_changed = 0; @@ -2560,39 +2561,39 @@ int vj_server_setup(veejay_t * info) { if (info->uc->port == 0) info->uc->port = VJ_PORT; - info->vjs[0] = vj_server_alloc(info->uc->port, NULL, V_CMD); - - if(!info->vjs[0]) + info->vjs[VEEJAY_PORT_CMD] = vj_server_alloc(info->uc->port, NULL, V_CMD); + if(!info->vjs[VEEJAY_PORT_CMD]) return 0; - info->vjs[1] = vj_server_alloc(info->uc->port, NULL, V_STATUS); - if(!info->vjs[1]) + info->vjs[VEEJAY_PORT_STA] = vj_server_alloc(info->uc->port, NULL, V_STATUS); + if(!info->vjs[VEEJAY_PORT_STA]) return 0; - info->vjs[3] = vj_server_alloc(info->uc->port, NULL, V_MSG ); - if(!info->vjs[3]) + //@ second VIMS control port + info->vjs[VEEJAY_PORT_DAT] = vj_server_alloc(info->uc->port + 5, NULL, V_CMD ); + if(!info->vjs[VEEJAY_PORT_DAT]) return 0; - info->vjs[2] = NULL; + info->vjs[VEEJAY_PORT_MAT] = NULL; if( info->settings->use_vims_mcast ) { - info->vjs[2] = + info->vjs[VEEJAY_PORT_MAT] = vj_server_alloc(info->uc->port, info->settings->vims_group_name, V_CMD ); - if(!info->vjs[2]) + if(!info->vjs[VEEJAY_PORT_MAT]) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to initialize mcast sender"); return 0; } else - veejay_msg(VEEJAY_MSG_INFO, "VIMS multicast channel ready at port %d group %s", + veejay_msg(VEEJAY_MSG_INFO, "UDP multicast frame sender socket ready at port %d group %s", info->uc->port, info->settings->vims_group_name ); } if(info->settings->use_mcast) { GoMultiCast( info->settings->group_name ); } - info->osc = (void*) vj_osc_allocate(info->uc->port+2); + info->osc = (void*) vj_osc_allocate(info->uc->port+4); if(!info->osc) { @@ -2602,8 +2603,6 @@ int vj_server_setup(veejay_t * info) return 0; } - // see libvjnet/common.h - if( info->settings->use_mcast ) veejay_msg(VEEJAY_MSG_INFO, "UDP multicast OSC channel ready at port %d (group '%s')", info->uc->port + 2, info->settings->group_name ); @@ -2614,7 +2613,7 @@ int vj_server_setup(veejay_t * info) if(vj_osc_setup_addr_space(info->osc) == 0) veejay_msg(VEEJAY_MSG_INFO, "Initialized OSC (http://www.cnmat.berkeley.edu/OpenSoundControl/)"); - if (info->osc == NULL || info->vjs[0] == NULL || info->vjs[1] == NULL) + if (info->osc == NULL || info->vjs[VEEJAY_PORT_CMD] == NULL || info->vjs[VEEJAY_PORT_STA] == NULL) { veejay_msg(0, "Unable to setup basic network I/O. Abort"); return 0; diff --git a/veejay-current/veejay/vj-event.c b/veejay-current/veejay/vj-event.c index 6259382a..c1089177 100644 --- a/veejay-current/veejay/vj-event.c +++ b/veejay-current/veejay/vj-event.c @@ -63,7 +63,7 @@ #ifdef STRICT_CHECKING #include #endif - +#include #ifdef HAVE_FREETYPE #include #endif @@ -284,18 +284,13 @@ veejay_msg(VEEJAY_MSG_INFO, "--------------------------------------------------- #define SEND_MSG(v,str)\ {\ -vj_server_send(v->vjs[0], v->uc->current_link, str, strlen(str));\ +vj_server_send(v->vjs[VEEJAY_PORT_CMD], v->uc->current_link, str, strlen(str));\ } #define RAW_SEND_MSG(v,str,len)\ {\ -vj_server_send(v->vjs[0],v->uc->current_link, str, len );\ +vj_server_send(v->vjs[VEEJAY_PORT_CMD],v->uc->current_link, str, len );\ } -#define SEND_LOG_MSG(v,str)\ -{\ -vj_server_send(v->vjs[3], v->uc->current_link,str,strlen(str));\ -} - /* some macros for commonly used checks */ #define SAMPLE_PLAYING(v) ( (v->uc->playback_mode == VJ_PLAYBACK_MODE_SAMPLE) ) @@ -1096,7 +1091,7 @@ int vj_event_parse_msg( void *ptr, char *msg, int msg_len ) } if( net_id >= 400 && net_id < 499 ) - vj_server_client_promote( v->vjs[0] , v->uc->current_link ); + vj_server_client_promote( v->vjs[VEEJAY_PORT_CMD] , v->uc->current_link ); np = vj_event_vevo_get_num_args( net_id ); @@ -1214,22 +1209,25 @@ void vj_event_update_remote(void *ptr) veejay_t *v = (veejay_t*)ptr; int i; - if( vj_server_poll( v->vjs[0] ) ) - vj_server_new_connection( v->vjs[0] ); - if( vj_server_poll( v->vjs[1] ) ) - vj_server_new_connection( v->vjs[1] ); - if( vj_server_poll( v->vjs[3] ) ) - vj_server_new_connection( v->vjs[3] ); + if( vj_server_poll( v->vjs[VEEJAY_PORT_CMD] ) ) + vj_server_new_connection( v->vjs[VEEJAY_PORT_CMD] ); + if( vj_server_poll( v->vjs[VEEJAY_PORT_STA] ) ) + vj_server_new_connection( v->vjs[VEEJAY_PORT_STA] ); + + if( vj_server_poll( v->vjs[VEEJAY_PORT_DAT] ) ) + { + vj_server_new_connection( v->vjs[VEEJAY_PORT_DAT] ); + } if( v->settings->use_vims_mcast ) { - int res = vj_server_update(v->vjs[2],0 ); + int res = vj_server_update(v->vjs[VEEJAY_PORT_MAT],0 ); if(res > 0) { v->uc->current_link = 0; char *buf = NULL; int len =0; - while( ( buf = vj_server_retrieve_msg( v->vjs[2], 0, buf,&len )) != NULL ) + while( ( buf = vj_server_retrieve_msg( v->vjs[VEEJAY_PORT_MAT], 0, buf,&len )) != NULL ) { vj_event_parse_msg( v, buf,len ); @@ -1238,21 +1236,22 @@ void vj_event_update_remote(void *ptr) } + v->settings->is_dat = 0; for( i = 0; i < VJ_MAX_CONNECTIONS; i ++ ) { - if( vj_server_link_used( v->vjs[0], i ) ) + if( vj_server_link_used( v->vjs[VEEJAY_PORT_CMD], i ) ) { int res = 1; while( res != 0 ) { - res = vj_server_update( v->vjs[0], i ); + res = vj_server_update( v->vjs[VEEJAY_PORT_CMD], i ); if(res>0) { v->uc->current_link = i; int n = 0; int len = 0; char *buf = NULL; - while( (buf= vj_server_retrieve_msg(v->vjs[0],i,buf, &len))!= NULL ) + while( (buf= vj_server_retrieve_msg(v->vjs[VEEJAY_PORT_CMD],i,buf, &len))!= NULL ) { vj_event_parse_msg( v, buf,len ); n++; @@ -1260,16 +1259,46 @@ void vj_event_update_remote(void *ptr) } if( res == -1 ) { - _vj_server_del_client( v->vjs[0], i ); - _vj_server_del_client( v->vjs[1], i ); - _vj_server_del_client( v->vjs[3], i ); + _vj_server_del_client( v->vjs[VEEJAY_PORT_CMD], i ); + _vj_server_del_client( v->vjs[VEEJAY_PORT_STA], i ); } } } } + v->settings->is_dat = 1; + for( i = 0; i < VJ_MAX_CONNECTIONS; i ++ ) + { + if( vj_server_link_used( v->vjs[VEEJAY_PORT_DAT], i ) ) + { + int res = 1; + while( res != 0 ) + { + res = vj_server_update( v->vjs[VEEJAY_PORT_DAT], i ); + if(res>0) + { + v->uc->current_link = i; + int n = 0; + int len = 0; + char *buf = NULL; + while( (buf= vj_server_retrieve_msg(v->vjs[VEEJAY_PORT_DAT],i,buf, &len))!= NULL ) + { + vj_event_parse_msg( v, buf,len ); + n++; + } + } + if( res == -1 ) + { + _vj_server_del_client( v->vjs[VEEJAY_PORT_DAT], i ); + } + } + } + } + v->settings->is_dat = 0; + + for( i = 0; i < VJ_MAX_CONNECTIONS; i ++ ) - if( vj_server_link_used( v->vjs[1], i )) + if( vj_server_link_used( v->vjs[VEEJAY_PORT_STA], i )) veejay_pipe_write_status( v, i ); if(!veejay_keep_messages()) @@ -7530,7 +7559,9 @@ void vj_event_send_log ( void *ptr, const char format[], va_list ap ) if(messages) free(messages); - SEND_LOG_MSG( v, _s_print_buf ); + veejay_msg(VEEJAY_MSG_DEBUG, "\tDebug: send log %s", _s_print_buf); + + SEND_MSG( v, _s_print_buf ); } void vj_event_send_chain_entry ( void *ptr, const char format[], va_list ap ) @@ -7831,6 +7862,13 @@ void vj_event_send_frame ( void *ptr, const char format[], va_list ap ) veejay_t *v = (veejay_t*) ptr; //@ schedule //@ warn about 2nd connection + if (!v->settings->is_dat ) + { + veejay_msg(1, "Wrong control port for retrieving frames!"); + SEND_MSG(v, "00000000000000000000"); //@ send empty header only (20 bytes) + return; + } + if( v->settings->unicast_frame_sender && v->uc->current_link != v->settings->unicast_link_id ) { diff --git a/veejay-current/veejay/vj-global.h b/veejay-current/veejay/vj-global.h index d2b0ff72..f820cdbd 100644 --- a/veejay-current/veejay/vj-global.h +++ b/veejay-current/veejay/vj-global.h @@ -78,6 +78,11 @@ enum { #define FMT_420F 2 #define FMT_422F 3 +#define VEEJAY_PORT_CMD 0 +#define VEEJAY_PORT_STA 1 +#define VEEJAY_PORT_DAT 3 +#define VEEJAY_PORT_MAT 2 + #define FMT_RGB24 2 #define FMT_RGB32 1 diff --git a/veejay-current/veejay/vj-lib.h b/veejay-current/veejay/vj-lib.h index 1199a281..ee8cd006 100644 --- a/veejay-current/veejay/vj-lib.h +++ b/veejay-current/veejay/vj-lib.h @@ -172,6 +172,7 @@ typedef struct { subsample_mode_t sample_mode; int unicast_link_id; int unicast_frame_sender; + int is_dat; int mcast_frame_sender; int use_mcast; char *group_name; diff --git a/veejay-current/veejay/vj-perform.c b/veejay-current/veejay/vj-perform.c index 9c424b23..857cd9ea 100644 --- a/veejay-current/veejay/vj-perform.c +++ b/veejay-current/veejay/vj-perform.c @@ -1143,7 +1143,9 @@ int vj_perform_send_primary_frame_s2(veejay_t *info, int mcast, int to_link_id) compr_len = vj_perform_compress_frame(info,socket_buffer ); } - int id = (mcast ? 2: 0); + //@ was 0, but collides with VIMS . use seperate socket + + int id = (mcast ? 2: 3); int __socket_len = hlen + compr_len; #ifdef STRICT_CHECKING @@ -1157,6 +1159,8 @@ int vj_perform_send_primary_frame_s2(veejay_t *info, int mcast, int to_link_id) veejay_msg(VEEJAY_MSG_ERROR, "Error sending frame to remote"); //__send_frame=0; + if(!mcast ) + _vj_server_del_client( info->vjs[id], to_link_id ); } return 1; }