mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-18 13:49:58 +01:00
Fix bugs in mcast
git-svn-id: svn://code.dyne.org/veejay/trunk@1406 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
@@ -152,18 +152,18 @@ void *reader_thread(void *data)
|
||||
ret = vj_client_read_i ( v, tag->socket_frame,tag->socket_len );
|
||||
if( ret <= 0 )
|
||||
{
|
||||
if( tag->source_type == VJ_TAG_TYPE_NET )
|
||||
{
|
||||
// if( tag->source_type == VJ_TAG_TYPE_NET )
|
||||
// {
|
||||
veejay_msg(VEEJAY_MSG_DEBUG,
|
||||
"%s:%d failed to read frame",
|
||||
tag->source_name,
|
||||
tag->video_channel );
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
wait_time += 10;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// wait_time += 10;
|
||||
// }
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
@@ -204,6 +204,9 @@ void *reader_thread(void *data)
|
||||
if( success <= 0 )
|
||||
{
|
||||
wait_time = 4000;
|
||||
#ifdef STRICT_CHECKING
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Tried to connect to %s:%d code=%d", tag->source_name,tag->video_channel,success);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -328,10 +331,21 @@ int net_thread_start(vj_client *v, vj_tag *tag)
|
||||
t->state = 1;
|
||||
t->remote = v;
|
||||
t->grab = 1;
|
||||
|
||||
|
||||
if( tag->source_type == VJ_TAG_TYPE_MCAST )
|
||||
{
|
||||
char start_mcast[6];
|
||||
snprintf(start_mcast,sizeof(start_mcast), "%03d:;", VIMS_VIDEO_MCAST_START);
|
||||
char start_mcast[8];
|
||||
|
||||
int gs = 0;
|
||||
char *gs_str = getenv( "VEEJAY_MCAST_GREYSCALE" );
|
||||
if( gs_str ) {
|
||||
gs = atoi(gs_str);
|
||||
if(gs < 0 || gs > 1 )
|
||||
gs = 0;
|
||||
}
|
||||
|
||||
snprintf(start_mcast,sizeof(start_mcast), "%03d:%d;", VIMS_VIDEO_MCAST_START,gs);
|
||||
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Request mcast stream from %s port %d",
|
||||
tag->source_name, tag->video_channel);
|
||||
|
||||
@@ -217,7 +217,9 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
||||
int res = recv(v->sock_fd, chunk, PACKET_PAYLOAD_SIZE, 0 );
|
||||
if( res <= 0 )
|
||||
{
|
||||
if(res == - 1)
|
||||
veejay_msg(VEEJAY_MSG_ERROR, "Error receiving multicast packet:%s", strerror(errno));
|
||||
|
||||
return 0;
|
||||
}
|
||||
hdr = packet_get_header(chunk);
|
||||
@@ -262,10 +264,10 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
||||
}
|
||||
|
||||
d_slot = o;
|
||||
|
||||
// veejay_msg(VEEJAY_MSG_DEBUG, "Dropping frame in slot %d (%d/%d packets)",
|
||||
// d_slot, q->slot[d_slot]->count,q->slot[d_slot]->hdr.length );
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Dropping frame in slot %d (%d/%d packets)",
|
||||
d_slot, q->slot[d_slot]->count,q->slot[d_slot]->hdr.length );
|
||||
#endif
|
||||
free(q->slot[d_slot]->buf);
|
||||
q->slot[d_slot]->buf = NULL;
|
||||
q->slot[d_slot]->count = 0;
|
||||
@@ -293,7 +295,7 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
||||
{
|
||||
pb->rdy = 1;
|
||||
q->last = hdr.usec;
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -302,7 +304,7 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
||||
uint8_t *mcast_recv_frame( mcast_receiver *v, int *dw, int *dh, int *dfmt, int *len )
|
||||
{
|
||||
packet_slot_t *q = (packet_slot_t*) v->next;
|
||||
int i;
|
||||
int i,n;
|
||||
for(i = 0; i < PACKET_SLOTS; i ++ )
|
||||
{
|
||||
//@ find rdy frames or too-old-frames and free them
|
||||
@@ -317,12 +319,17 @@ uint8_t *mcast_recv_frame( mcast_receiver *v, int *dw, int *dh, int *dfmt, int *
|
||||
}
|
||||
|
||||
//@ is there something todo
|
||||
if( mcast_poll_timeout( v, 1000 ) == 0 )
|
||||
return NULL;
|
||||
// if( mcast_poll_timeout( v, 1000 ) == 0 )
|
||||
// return NULL;
|
||||
|
||||
while( mcast_recv_packet_frame(v) )
|
||||
while( (n = mcast_recv_packet_frame(v) ) )
|
||||
{
|
||||
//@ do nothing
|
||||
if( n == 2 ) {
|
||||
#ifdef STRICT_CHECKING
|
||||
|
||||
#endif
|
||||
break; //@ full frame
|
||||
}
|
||||
}
|
||||
|
||||
int d_slot = -1;
|
||||
@@ -342,23 +349,22 @@ uint8_t *mcast_recv_frame( mcast_receiver *v, int *dw, int *dh, int *dfmt, int *
|
||||
//@ find newer packet buffer with complete frame
|
||||
for(i = 0; i < PACKET_SLOTS; i ++ )
|
||||
{
|
||||
if( q->slot[i]->rdy == 1 && q->slot[i]->hdr.usec < t1) {
|
||||
if( q->slot[i]->rdy == 1 && q->slot[i]->hdr.usec > t1) {
|
||||
full_frame = 1;
|
||||
d_slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#ifdef STRICT_CHECKING
|
||||
//@debug queue
|
||||
/* for( i = 0; i < PACKET_SLOTS; i ++ ) {
|
||||
for( i = 0; i < PACKET_SLOTS; i ++ ) {
|
||||
packet_buffer_t *p = q->slot[i];
|
||||
veejay_msg(VEEJAY_MSG_INFO, "Slot %d: %d bytes, %d/%d queued, rdy=%d, t1=%ld",
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Slot %d: %d bytes, %d/%d queued, rdy=%d, t1=%ld",
|
||||
i, p->len, p->count,p->hdr.length, p->rdy,(long) p->hdr.usec );
|
||||
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
//@ return newest full frame
|
||||
if( full_frame ) {
|
||||
packet_buffer_t *pb = q->slot[d_slot];
|
||||
|
||||
@@ -77,6 +77,7 @@ vj_client *vj_client_alloc( int w, int h, int f )
|
||||
v->space = (uint8_t*) malloc( sizeof(uint8_t) * w * h * 4 );
|
||||
memset(v->space,0,sizeof(uint8_t)*w*h*4);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ static int _vj_server_multicast( vj_server *v, char *group_name, int port )
|
||||
link[i]->n_retrieved = 0;
|
||||
}
|
||||
v->link = (void**) link;
|
||||
|
||||
veejay_msg(VEEJAY_MSG_INFO, "UDP multicast frame sender ready at (group '%s')",
|
||||
group_name );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user