Skip to content
Snippets Groups Projects
Commit 20b924da authored by Alexandre Bourget's avatar Alexandre Bourget
Browse files

DEBUG: dump audio data directly to /tmp/audio.dat

parent a7d25038
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <assert.h> #include <assert.h>
#include <string> #include <string>
#include <cstring> #include <cstring>
#include <fstream> // fstream + iostream pour fstream debugging..
#include <iostream> // removeable...
#include "../global.h" #include "../global.h"
#include "../manager.h" #include "../manager.h"
...@@ -91,7 +93,9 @@ AudioRtp::closeRtpSession () { ...@@ -91,7 +93,9 @@ AudioRtp::closeRtpSession () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AudioRtpRTX Class // // AudioRtpRTX Class //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) { AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym)
: _fstream("/tmp/audio.dat", std::ofstream::binary)
{
setCancel(cancelDeferred); setCancel(cancelDeferred);
time = new ost::Time(); time = new ost::Time();
_ca = sipcall; _ca = sipcall;
...@@ -360,9 +364,16 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) ...@@ -360,9 +364,16 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
nbInt16=RTP_20S_8KHZ_MAX; nbInt16=RTP_20S_8KHZ_MAX;
} }
/* WRITE IN A FILE FOR DEBUG */
// crache _receiveDataDecoded sur le disque pour analyse avec autre chose.
_fstream.write((char *) _receiveDataDecoded, size);
_fstream.flush();
SFLDataFormat* toAudioLayer; SFLDataFormat* toAudioLayer;
int nbSample = nbInt16; int nbSample = nbInt16;
// 48000 / 8000 = 6 .. Samplerate will convert to 48000 ?! // 48000 / 8000 = 6, the number of samples for the maximum rate conversion.
int nbSampleMaxRate = nbInt16 * 6; // TODO: change it int nbSampleMaxRate = nbInt16 * 6; // TODO: change it
if ( audiolayer->getSampleRate() != audiocodec->getClockRate() && nbSample) { if ( audiolayer->getSampleRate() != audiocodec->getClockRate() && nbSample) {
...@@ -374,13 +385,16 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) ...@@ -374,13 +385,16 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
SRC_DATA src_data; SRC_DATA src_data;
src_data.data_in = _floatBuffer8000; src_data.data_in = _floatBuffer8000;
src_data.data_out = _floatBuffer48000; src_data.data_out = _floatBuffer48000;
src_data.input_frames = nbSample; src_data.input_frames = RTP_20S_8KHZ_MAX;
src_data.output_frames = nbSample * audiolayer->getSample() / audiocodec->getClockRate(); src_data.output_frames = RTP_20S_48KHZ_MAX;
src_data.src_ratio = factord; src_data.src_ratio = factord;
src_short_to_float_array(_receiveDataDecoded, _floatBuffer8000, nbSample); src_short_to_float_array(_receiveDataDecoded, _floatBuffer8000, nbSample);
src_simple (&src_data, SRC_SINC_BEST_QUALITY/*SRC_SINC_MEDIUM_QUALITY*/, 1); // 1=mono channel
int err = src_simple (&src_data, SRC_SINC_BEST_QUALITY /* SRC_SINC_MEDIUM_QUALITY*/, 1); // 1=mono channel
// Truncate number of samples if too high (ouch!)
nbSample = ( src_data.output_frames_gen > RTP_20S_48KHZ_MAX) ? RTP_20S_48KHZ_MAX : src_data.output_frames_gen; nbSample = ( src_data.output_frames_gen > RTP_20S_48KHZ_MAX) ? RTP_20S_48KHZ_MAX : src_data.output_frames_gen;
#ifdef DATAFORMAT_IS_FLOAT #ifdef DATAFORMAT_IS_FLOAT
toAudioLayer = _floatBuffer48000; toAudioLayer = _floatBuffer48000;
#else #else
...@@ -388,6 +402,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) ...@@ -388,6 +402,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
toAudioLayer = _dataAudioLayer; toAudioLayer = _dataAudioLayer;
#endif #endif
} else { } else {
nbSample = nbInt16; nbSample = nbInt16;
#ifdef DATAFORMAT_IS_FLOAT #ifdef DATAFORMAT_IS_FLOAT
...@@ -398,6 +413,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) ...@@ -398,6 +413,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
toAudioLayer = _receiveDataDecoded; // int to int toAudioLayer = _receiveDataDecoded; // int to int
#endif #endif
} }
audiolayer->putMain(toAudioLayer, nbSample * sizeof(SFLDataFormat)); audiolayer->putMain(toAudioLayer, nbSample * sizeof(SFLDataFormat));
//_debug("ARTP: %d\n", nbSample * sizeof(SFLDataFormat)); //_debug("ARTP: %d\n", nbSample * sizeof(SFLDataFormat));
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <fstream> // fstream + iostream for _fstream debugging...
#include <iostream>
#include <ccrtp/rtp.h> #include <ccrtp/rtp.h>
#include <cc++/numbers.h> #include <cc++/numbers.h>
...@@ -70,6 +72,9 @@ private: ...@@ -70,6 +72,9 @@ private:
/** Buffer for 8000Hz samples for mic conversion */ /** Buffer for 8000Hz samples for mic conversion */
int16* _intBuffer8000; int16* _intBuffer8000;
/** Debugging output file */
std::ofstream _fstream;
void initAudioRtpSession(void); void initAudioRtpSession(void);
void sendSessionFromMic(int); void sendSessionFromMic(int);
void receiveSessionForSpkr(int&); void receiveSessionForSpkr(int&);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment