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 );
|
ret = vj_client_read_i ( v, tag->socket_frame,tag->socket_len );
|
||||||
if( ret <= 0 )
|
if( ret <= 0 )
|
||||||
{
|
{
|
||||||
if( tag->source_type == VJ_TAG_TYPE_NET )
|
// if( tag->source_type == VJ_TAG_TYPE_NET )
|
||||||
{
|
// {
|
||||||
veejay_msg(VEEJAY_MSG_DEBUG,
|
veejay_msg(VEEJAY_MSG_DEBUG,
|
||||||
"%s:%d failed to read frame",
|
"%s:%d failed to read frame",
|
||||||
tag->source_name,
|
tag->source_name,
|
||||||
tag->video_channel );
|
tag->video_channel );
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
wait_time += 10;
|
// wait_time += 10;
|
||||||
}
|
// }
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -204,6 +204,9 @@ void *reader_thread(void *data)
|
|||||||
if( success <= 0 )
|
if( success <= 0 )
|
||||||
{
|
{
|
||||||
wait_time = 4000;
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -328,10 +331,21 @@ int net_thread_start(vj_client *v, vj_tag *tag)
|
|||||||
t->state = 1;
|
t->state = 1;
|
||||||
t->remote = v;
|
t->remote = v;
|
||||||
t->grab = 1;
|
t->grab = 1;
|
||||||
|
|
||||||
|
|
||||||
if( tag->source_type == VJ_TAG_TYPE_MCAST )
|
if( tag->source_type == VJ_TAG_TYPE_MCAST )
|
||||||
{
|
{
|
||||||
char start_mcast[6];
|
char start_mcast[8];
|
||||||
snprintf(start_mcast,sizeof(start_mcast), "%03d:;", VIMS_VIDEO_MCAST_START);
|
|
||||||
|
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",
|
veejay_msg(VEEJAY_MSG_DEBUG, "Request mcast stream from %s port %d",
|
||||||
tag->source_name, tag->video_channel);
|
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 );
|
int res = recv(v->sock_fd, chunk, PACKET_PAYLOAD_SIZE, 0 );
|
||||||
if( res <= 0 )
|
if( res <= 0 )
|
||||||
{
|
{
|
||||||
|
if(res == - 1)
|
||||||
veejay_msg(VEEJAY_MSG_ERROR, "Error receiving multicast packet:%s", strerror(errno));
|
veejay_msg(VEEJAY_MSG_ERROR, "Error receiving multicast packet:%s", strerror(errno));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
hdr = packet_get_header(chunk);
|
hdr = packet_get_header(chunk);
|
||||||
@@ -262,10 +264,10 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
|||||||
}
|
}
|
||||||
|
|
||||||
d_slot = o;
|
d_slot = o;
|
||||||
|
#ifdef STRICT_CHECKING
|
||||||
// veejay_msg(VEEJAY_MSG_DEBUG, "Dropping frame in slot %d (%d/%d packets)",
|
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 );
|
d_slot, q->slot[d_slot]->count,q->slot[d_slot]->hdr.length );
|
||||||
|
#endif
|
||||||
free(q->slot[d_slot]->buf);
|
free(q->slot[d_slot]->buf);
|
||||||
q->slot[d_slot]->buf = NULL;
|
q->slot[d_slot]->buf = NULL;
|
||||||
q->slot[d_slot]->count = 0;
|
q->slot[d_slot]->count = 0;
|
||||||
@@ -293,7 +295,7 @@ int mcast_recv_packet_frame( mcast_receiver *v )
|
|||||||
{
|
{
|
||||||
pb->rdy = 1;
|
pb->rdy = 1;
|
||||||
q->last = hdr.usec;
|
q->last = hdr.usec;
|
||||||
return 0;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
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 )
|
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;
|
packet_slot_t *q = (packet_slot_t*) v->next;
|
||||||
int i;
|
int i,n;
|
||||||
for(i = 0; i < PACKET_SLOTS; i ++ )
|
for(i = 0; i < PACKET_SLOTS; i ++ )
|
||||||
{
|
{
|
||||||
//@ find rdy frames or too-old-frames and free them
|
//@ 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
|
//@ is there something todo
|
||||||
if( mcast_poll_timeout( v, 1000 ) == 0 )
|
// if( mcast_poll_timeout( v, 1000 ) == 0 )
|
||||||
return NULL;
|
// 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;
|
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
|
//@ find newer packet buffer with complete frame
|
||||||
for(i = 0; i < PACKET_SLOTS; i ++ )
|
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;
|
full_frame = 1;
|
||||||
d_slot = i;
|
d_slot = i;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
#ifdef STRICT_CHECKING
|
||||||
//@debug queue
|
//@debug queue
|
||||||
/* for( i = 0; i < PACKET_SLOTS; i ++ ) {
|
for( i = 0; i < PACKET_SLOTS; i ++ ) {
|
||||||
packet_buffer_t *p = q->slot[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 );
|
i, p->len, p->count,p->hdr.length, p->rdy,(long) p->hdr.usec );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@ return newest full frame
|
//@ return newest full frame
|
||||||
if( full_frame ) {
|
if( full_frame ) {
|
||||||
packet_buffer_t *pb = q->slot[d_slot];
|
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 );
|
v->space = (uint8_t*) malloc( sizeof(uint8_t) * w * h * 4 );
|
||||||
memset(v->space,0,sizeof(uint8_t)*w*h*4);
|
memset(v->space,0,sizeof(uint8_t)*w*h*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ static int _vj_server_multicast( vj_server *v, char *group_name, int port )
|
|||||||
link[i]->n_retrieved = 0;
|
link[i]->n_retrieved = 0;
|
||||||
}
|
}
|
||||||
v->link = (void**) link;
|
v->link = (void**) link;
|
||||||
|
|
||||||
veejay_msg(VEEJAY_MSG_INFO, "UDP multicast frame sender ready at (group '%s')",
|
veejay_msg(VEEJAY_MSG_INFO, "UDP multicast frame sender ready at (group '%s')",
|
||||||
group_name );
|
group_name );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user