mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added some fixes for payload calculation
This commit is contained in:
parent
172f18b5e8
commit
0a91084011
|
@ -328,6 +328,8 @@ int video_decoder_refresh(av_session_t* _phone, int width, int height)
|
|||
|
||||
void *encode_video_thread(void *arg)
|
||||
{
|
||||
INFO("Started encode video thread!");
|
||||
|
||||
av_session_t* _phone = arg;
|
||||
|
||||
codec_state *cs = _phone->cs;
|
||||
|
@ -423,6 +425,7 @@ void *encode_video_thread(void *arg)
|
|||
|
||||
void *encode_audio_thread(void *arg)
|
||||
{
|
||||
INFO("Started encode audio thread!");
|
||||
av_session_t* _phone = arg;
|
||||
|
||||
codec_state *cs = _phone->cs;
|
||||
|
@ -438,7 +441,7 @@ void *encode_audio_thread(void *arg)
|
|||
|
||||
if (sample >= frame_size) {
|
||||
alcCaptureSamples((ALCdevice*)_phone->audio_capture_device, frame, frame_size);
|
||||
encoded_size = opus_encode(cs->audio_encoder, frame, frame_size, encoded_data, 480);
|
||||
encoded_size = opus_encode(cs->audio_encoder, frame, frame_size, encoded_data, MAX_RTP_SIZE);
|
||||
|
||||
if (encoded_size <= 0) {
|
||||
printf("Could not encode audio packet\n");
|
||||
|
@ -461,6 +464,7 @@ void *encode_audio_thread(void *arg)
|
|||
|
||||
void *decode_video_thread(void *arg)
|
||||
{
|
||||
INFO("Started decode audio thread!");
|
||||
av_session_t* _phone = arg;
|
||||
|
||||
codec_state *cs = _phone->cs;
|
||||
|
@ -513,6 +517,7 @@ void *decode_video_thread(void *arg)
|
|||
|
||||
void *decode_audio_thread(void *arg)
|
||||
{
|
||||
INFO("Started decode audio thread!");
|
||||
av_session_t* _phone = arg;
|
||||
|
||||
codec_state *cs = _phone->cs;
|
||||
|
@ -572,27 +577,28 @@ void *decode_audio_thread(void *arg)
|
|||
queue(j_buf, r_msg);
|
||||
}
|
||||
|
||||
/* grab a packet from the queue */
|
||||
success = 0;
|
||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &val);
|
||||
|
||||
if (val > 0)
|
||||
/* grab a packet from the queue */
|
||||
if (val > 0) {
|
||||
r_msg = dequeue(j_buf, &success);
|
||||
}
|
||||
|
||||
if (success > 0) {
|
||||
/* good packet */
|
||||
if (success == 1) {
|
||||
dec_frame_len = opus_decode(cs->audio_decoder, r_msg->data, r_msg->length, PCM, frame_size, 0);
|
||||
//rtp_free_msg(NULL, r_msg);
|
||||
rtp_free_msg(NULL, r_msg);
|
||||
}
|
||||
|
||||
/* lost packet */
|
||||
if (success == 2) {
|
||||
printf("lost packet\n");
|
||||
else if (success == 2) {
|
||||
printf("Lost packet\n");
|
||||
dec_frame_len = opus_decode(cs->audio_decoder, NULL, 0, PCM, frame_size, 1);
|
||||
}
|
||||
|
||||
if (dec_frame_len > 0) {
|
||||
if (dec_frame_len) {
|
||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &val);
|
||||
|
||||
if (val <= 0)
|
||||
|
@ -611,7 +617,7 @@ void *decode_audio_thread(void *arg)
|
|||
alSourceQueueBuffers(source, 1, &buffer);
|
||||
|
||||
if (alGetError() != AL_NO_ERROR) {
|
||||
fprintf(stderr, "error: could not buffer audio\n");
|
||||
fprintf(stderr, "Error: could not buffer audio\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ void t_randomstr ( uint8_t* str, size_t size ) {
|
|||
size_t _it = 0;
|
||||
|
||||
for ( ; _it < size; _it++ ) {
|
||||
str[_it] = _bytes[ randombytes_random() % 61 ];
|
||||
str[_it] = _bytes[ random_int() % 61 ];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ uint8_t* add_header ( RTPHeader* header, uint8_t* payload )
|
|||
_it+=4; U32_to_bytes( _it, header->csrc[_x]);
|
||||
}
|
||||
|
||||
return _it;
|
||||
return _it + 4;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,7 +378,7 @@ uint8_t* add_ext_header ( RTPExtHeader* header, uint8_t* payload )
|
|||
_it+=4; U32_to_bytes(_it, header->table[_x]);
|
||||
}
|
||||
|
||||
return _it;
|
||||
return _it + 4;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -605,7 +605,7 @@ RTPMessage* rtp_new_message ( RTPSession* session, const uint8_t* data, uint32_t
|
|||
*/
|
||||
|
||||
/* Appends _data on to _retu->_data */
|
||||
memcpy ( _from_pos + 1, data, length );
|
||||
memcpy ( _from_pos, data, length );
|
||||
|
||||
_retu->length = _total_length;
|
||||
|
||||
|
@ -832,7 +832,7 @@ RTPSession* rtp_init_session ( int payload_type,
|
|||
_retu->extension = 0; /* If extension to header is needed */
|
||||
_retu->cc = 1; /* Amount of contributors */
|
||||
_retu->csrc = NULL; /* Container */
|
||||
_retu->ssrc = randombytes_random();
|
||||
_retu->ssrc = random_int();
|
||||
_retu->marker = 0;
|
||||
_retu->payload_type = payload_table[payload_type];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user