//------------------------------------------------------------------------------------- int PacketSender::handleOutputNotification(int fd) { processSend(NULL); return 0; }
GF_Err PNC_processBIFSGenerator(PNC_CallbackData * data) { const int tmpBufferSize = 2048; char *tmpBuffer = (char*)alloca(tmpBufferSize); int byteRead=0; char *bsBuffer; int retour=0; GF_Err e; if (data->server_socket) { data->socket = NULL; e = gf_sk_accept(data->server_socket, &(data->socket)); if (e){ return GF_OK; } else { dprintf(DEBUG_RTP_serv_generator, "New TCP client connected !\n"); } } do { if (data->socket == NULL) return GF_OK; e = gf_sk_receive(data->socket, tmpBuffer, tmpBufferSize, 0, & byteRead); switch (e) { case GF_IP_NETWORK_EMPTY: e = GF_OK; break; case GF_OK: if (byteRead > 0){ dprintf(DEBUG_RTP_serv_generator, "Received %d bytes\n", byteRead); /* We copy data in buffer */ memcpy( &(data->buffer[data->bufferPosition]), tmpBuffer, byteRead ); data->buffer[data->bufferPosition + byteRead] = '\0'; retour = findCommand( data->buffer, data->bufferPosition); data->bufferPosition += byteRead; if (retour >= 0){ /** OK, it means we found a command ! */ if (strncmp(&(data->buffer[retour+13]), "SEND_CRITICAL", 13)==0){ bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 26, RECV_BUFFER_SIZE_FOR_COMMANDS); data->bufferPosition = 0; return processSendCritical(data, bsBuffer); } if (strncmp(&(data->buffer[retour+13]), "SEND", 4)==0){ bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 17, RECV_BUFFER_SIZE_FOR_COMMANDS); data->bufferPosition = 0; return processSend(data, bsBuffer); } if (strncmp(&(data->buffer[retour+13]), "RAP", 3)==0){ bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 16, RECV_BUFFER_SIZE_FOR_COMMANDS); data->bufferPosition = 0; return processRap(data, bsBuffer); } if (strncmp(&(data->buffer[retour+13]), "RAP_RESET", 9)==0){ bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 22, RECV_BUFFER_SIZE_FOR_COMMANDS); data->bufferPosition = 0; return processRapReset(data, bsBuffer); } /** If we are here, it means probably we did not received fully the command */ break; } } /* No bytes were received */ break; default: fprintf(stderr, "Socket error while receiving BIFS data %s\n", gf_error_to_string(e)); if (data->socket != NULL){ gf_sk_del(data->socket); data->socket = NULL; } return e; } } while (e == GF_OK); return GF_OK; }