<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hello to all again,</p>
<p><br>
</p>
<p>I am trying to send audio through tox with portaudio and opus encoding, i test them both in local and has good quality
<br>
</p>
<p>and i try to send the appropiate variables through <span>toxav_audio_send_frame</span>() but it returns the
<span>TOXAV_ERR_SEND_FRAME_INVALID</span> error all the time.</p>
<p>Can anyone give a hand what variables to place inside the<span> toxav_audio_send_frame</span>() function ?</p>
<p><br>
</p>
<p><b>This code is portaudio and opus for local tests working good :</b></p>
<p></p>
<div>
<div>// initialize opus<br>
encr = opus_encoder_create(TestSampleRate, TestChannels, OPUS_APPLICATION_AUDIO, NULL);<br>
decr = opus_decoder_create(TestSampleRate, TestChannels, NULL);</div>
<br>
while (connected){<br>
//// With Opus Encoding - Decoding<br>
Pa_ReadStream(TestStream, captured.data(), TestBufferSize);<br>
enc_bytes = opus_encode(encr, reinterpret_cast<opus_int16 const*>(captured.data()), TestBufferSize, reinterpret_cast<opus_uint8*>(encoded.data()), encoded.size());<br>
<br>
dec_bytes = opus_decode(decr, reinterpret_cast<opus_uint8*>(encoded.data()), enc_bytes, reinterpret_cast<opus_int16*>(decoded.data()), TestBufferSize, 0);<br>
Pa_WriteStream(TestStream, decoded.data(), TestBufferSize);<br>
}<br>
<br>
<br>
<b>And here in this code i try to recieve and send with the above code through Tox but cant make it cause of wrong parameters :</b><br>
// initialize opus<br>
<div>encr = opus_encoder_create(TestSampleRate, TestChannels, OPUS_APPLICATION_AUDIO, NULL);<br>
decr = opus_decoder_create(TestSampleRate, TestChannels, NULL);<br>
<br>
////// SEND AUDIO FRAME<br>
while (connected){<br>
//// With Opus Encoding <br>
Pa_ReadStream(TestStream, captured.data(), TestBufferSize);<br>
enc_bytes = opus_encode(encr, reinterpret_cast<opus_int16 const*>(captured.data()), TestBufferSize, reinterpret_cast<opus_uint8*>(encoded.data()), encoded.size());<br>
<br>
size_t SampleCounter = ((TestSampleRate)* (enc_bytes) / 1000);<br>
TOXAV_ERR_SEND_FRAME SendAudioError;<br>
toxav_audio_send_frame(avtox, FriendID, reinterpret_cast<int16_t*>(encoded.data()), SampleCounter, (uint8_t)TestChannels, (uint32_t)TestSampleRate, &SendAudioError);<br>
switch (SendAudioError) {<br>
case TOXAV_ERR_SEND_FRAME_OK:<br>
printf("Audio Frame Sended OK \n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_NULL:<br>
printf("The Audio Samples were NULL !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND:<br>
printf("Audio Send Friend not Found !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL:<br>
printf("Friend Not In Audio Call with You !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_SYNC:<br>
printf("Audio Syncronization Failed !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_INVALID:<br>
printf("Audio Parameteres Invalid !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED:<br>
printf("Audio Disabled By Friend or You !\n");<br>
break;<br>
case TOXAV_ERR_SEND_FRAME_RTP_FAILED:<br>
printf("Audio Failed To Send Frame !\n");<br>
break;<br>
}<br>
Pa_Sleep(1000);<br>
}<br>
<br>
////// RECIEVE AUDIO FRAME<br>
static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data){<br>
<br>
dec_bytes = opus_decode(decr, reinterpret_cast<opus_uint8*>(&pcm), (opus_int32)sample_count, reinterpret_cast<opus_int16*>(decoded.data()), TestBufferSize, 0);<br>
Pa_WriteStream(TestStream, decoded.data(), TestBufferSize);<br>
<br>
}</div>
<br>
</div>
<p>Can anyone advice me what to enter as parameters in the <span>toxav_audio_send_frame</span>() and in
<span>static void t_toxav_receive_audio_frame_cb</span>() ?</p>
<p>sorry for my noobish question and thanks for your time but i really need to make it work and i almost combined many variables and couldnt make it</p>
<p>someone with good knowledge on what to send i think is very easy to tell me what vars should i use in the send and recieve function</p>
<p><br>
</p>
<p>Thanks in advance</p>
<p><br>
</p>
<p><br>
</p>
<p></p>
</div>
</body>
</html>