Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
be6905d9
Commit
be6905d9
authored
Oct 12, 2011
by
Tristan Matthews
Browse files
* #7131: cleanup, remove underscore prefix vars
parent
d2f15f8d
Changes
64
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/audiortp/audio_rtp_factory.cpp
View file @
be6905d9
...
...
@@ -42,17 +42,17 @@
namespace
sfl
{
AudioRtpFactory
::
AudioRtpFactory
(
SIPCall
*
ca
)
:
_
rtpSession
(
NULL
),
remoteContext
(
NULL
),
localContext
(
NULL
),
ca_
(
ca
)
AudioRtpFactory
::
AudioRtpFactory
(
SIPCall
*
ca
)
:
rtpSession
_
(
NULL
),
remoteContext
_
(
NULL
),
localContext
_
(
NULL
),
ca_
(
ca
)
{}
AudioRtpFactory
::~
AudioRtpFactory
()
{
delete
_
rtpSession
;
delete
rtpSession
_
;
}
void
AudioRtpFactory
::
initAudioRtpConfig
()
{
if
(
_
rtpSession
!=
NULL
)
if
(
rtpSession
_
!=
NULL
)
stop
();
std
::
string
accountId
(
Manager
::
instance
().
getAccountFromCall
(
ca_
->
getCallId
()));
...
...
@@ -60,150 +60,136 @@ void AudioRtpFactory::initAudioRtpConfig()
SIPAccount
*
account
=
dynamic_cast
<
SIPAccount
*>
(
Manager
::
instance
().
getAccount
(
accountId
));
if
(
account
)
{
_
srtpEnabled
=
account
->
getSrtpEnabled
();
srtpEnabled
_
=
account
->
getSrtpEnabled
();
std
::
string
key
(
account
->
getSrtpKeyExchange
());
if
(
key
==
"sdes"
)
_
keyExchangeProtocol
=
Sdes
;
keyExchangeProtocol
_
=
Sdes
;
else
if
(
key
==
"zrtp"
)
_
keyExchangeProtocol
=
Zrtp
;
keyExchangeProtocol
_
=
Zrtp
;
else
_
keyExchangeProtocol
=
Symmetric
;
keyExchangeProtocol
_
=
Symmetric
;
_
helloHashEnabled
=
account
->
getZrtpHelloHash
();
helloHashEnabled
_
=
account
->
getZrtpHelloHash
();
}
else
{
_
srtpEnabled
=
false
;
_
keyExchangeProtocol
=
Symmetric
;
_
helloHashEnabled
=
false
;
srtpEnabled
_
=
false
;
keyExchangeProtocol
_
=
Symmetric
;
helloHashEnabled
_
=
false
;
}
}
void
AudioRtpFactory
::
initAudioSymmetricRtpSession
()
{
ost
::
MutexLock
m
(
_
audioRtpThreadMutex
);
ost
::
MutexLock
m
(
audioRtpThreadMutex
_
);
if
(
_
srtpEnabled
)
{
if
(
srtpEnabled
_
)
{
std
::
string
zidFilename
(
Manager
::
instance
().
voipPreferences
.
getZidFile
());
switch
(
_
keyExchangeProtocol
)
{
switch
(
keyExchangeProtocol
_
)
{
case
Zrtp
:
_rtpSession
=
new
AudioZrtpSession
(
ca_
,
zidFilename
);
if
(
_helloHashEnabled
)
{
// TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's
// not even available at that point.
ca_
->
getLocalSDP
()
->
setZrtpHash
(
static_cast
<
AudioZrtpSession
*>
(
_rtpSession
)
->
getHelloHash
());
}
rtpSession_
=
new
AudioZrtpSession
(
ca_
,
zidFilename
);
// TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's
// not even available at that point.
if
(
helloHashEnabled_
)
ca_
->
getLocalSDP
()
->
setZrtpHash
(
static_cast
<
AudioZrtpSession
*>
(
rtpSession_
)
->
getHelloHash
());
break
;
case
Sdes
:
_
rtpSession
=
new
AudioSrtpSession
(
ca_
);
rtpSession
_
=
new
AudioSrtpSession
(
ca_
);
break
;
default:
throw
UnsupportedRtpSessionType
(
"Unsupported Rtp Session Exception Type!"
);
}
}
else
{
_rtpSession
=
new
AudioSymmetricRtpSession
(
ca_
);
}
}
else
rtpSession_
=
new
AudioSymmetricRtpSession
(
ca_
);
}
void
AudioRtpFactory
::
start
(
AudioCodec
*
audiocodec
)
{
if
(
_
rtpSession
==
NULL
)
{
if
(
rtpSession
_
==
NULL
)
throw
AudioRtpFactoryException
(
"AudioRtpFactory: Error: RTP session was null when trying to start audio thread"
);
}
if
(
_rtpSession
->
getAudioRtpType
()
==
Sdes
)
{
if
(
localContext
&&
remoteContext
)
{
static_cast
<
AudioSrtpSession
*>
(
_rtpSession
)
->
restoreCryptoContext
(
localContext
,
remoteContext
);
}
}
if
(
rtpSession_
->
getAudioRtpType
()
==
Sdes
)
if
(
localContext_
and
remoteContext_
)
static_cast
<
AudioSrtpSession
*>
(
rtpSession_
)
->
restoreCryptoContext
(
localContext_
,
remoteContext_
);
if
(
_
rtpSession
->
startRtpThread
(
audiocodec
)
!=
0
)
{
if
(
rtpSession
_
->
startRtpThread
(
audiocodec
)
!=
0
)
throw
AudioRtpFactoryException
(
"AudioRtpFactory: Error: Failed to start AudioZrtpSession thread"
);
}
}
void
AudioRtpFactory
::
stop
(
void
)
void
AudioRtpFactory
::
stop
()
{
ost
::
MutexLock
mutex
(
_
audioRtpThreadMutex
);
ost
::
MutexLock
mutex
(
audioRtpThreadMutex
_
);
if
(
_
rtpSession
==
NULL
)
if
(
rtpSession
_
==
NULL
)
return
;
if
(
_
rtpSession
->
getAudioRtpType
()
==
Sdes
)
{
localContext
=
static_cast
<
AudioSrtpSession
*>
(
_
rtpSession
)
->
_
localCryptoCtx
;
remoteContext
=
static_cast
<
AudioSrtpSession
*>
(
_
rtpSession
)
->
_
remoteCryptoCtx
;
if
(
rtpSession
_
->
getAudioRtpType
()
==
Sdes
)
{
localContext
_
=
static_cast
<
AudioSrtpSession
*>
(
rtpSession
_
)
->
localCryptoCtx
_
;
remoteContext
_
=
static_cast
<
AudioSrtpSession
*>
(
rtpSession
_
)
->
remoteCryptoCtx
_
;
}
delete
_
rtpSession
;
_
rtpSession
=
NULL
;
delete
rtpSession
_
;
rtpSession
_
=
NULL
;
}
int
AudioRtpFactory
::
getSessionMedia
()
{
if
(
_
rtpSession
==
NULL
)
{
if
(
rtpSession
_
==
NULL
)
throw
AudioRtpFactoryException
(
"AudioRtpFactory: Error: RTP session was null when trying to get session media type"
);
}
return
_
rtpSession
->
getCodecPayloadType
();
return
rtpSession
_
->
getCodecPayloadType
();
}
void
AudioRtpFactory
::
updateSessionMedia
(
AudioCodec
*
audiocodec
)
{
if
(
_rtpSession
==
NULL
)
{
throw
AudioRtpFactoryException
(
"AudioRtpFactory: Error: _rtpSession was null when trying to update IP address"
);
}
if
(
rtpSession_
==
NULL
)
throw
AudioRtpFactoryException
(
"AudioRtpFactory: Error: rtpSession_ was null when trying to update IP address"
);
_
rtpSession
->
updateSessionMedia
(
audiocodec
);
rtpSession
_
->
updateSessionMedia
(
audiocodec
);
}
void
AudioRtpFactory
::
updateDestinationIpAddress
(
void
)
void
AudioRtpFactory
::
updateDestinationIpAddress
()
{
if
(
_
rtpSession
)
_
rtpSession
->
updateDestinationIpAddress
();
if
(
rtpSession
_
)
rtpSession
_
->
updateDestinationIpAddress
();
}
sfl
::
AudioZrtpSession
*
AudioRtpFactory
::
getAudioZrtpSession
()
{
if
(
_rtpSession
->
getAudioRtpType
()
==
Zrtp
)
{
return
static_cast
<
AudioZrtpSession
*>
(
_rtpSession
);
}
else
{
throw
AudioRtpFactoryException
(
"RTP: Error: _rtpSession is NULL in getAudioZrtpSession"
);
}
if
(
rtpSession_
->
getAudioRtpType
()
==
Zrtp
)
return
static_cast
<
AudioZrtpSession
*>
(
rtpSession_
);
else
throw
AudioRtpFactoryException
(
"RTP: Error: rtpSession_ is NULL in getAudioZrtpSession"
);
}
void
sfl
::
AudioRtpFactory
::
initLocalCryptoInfo
()
{
if
(
_rtpSession
&&
_rtpSession
->
getAudioRtpType
()
==
Sdes
)
{
static_cast
<
AudioSrtpSession
*>
(
_rtpSession
)
->
initLocalCryptoInfo
();
ca_
->
getLocalSDP
()
->
setLocalSdpCrypto
(
static_cast
<
AudioSrtpSession
*>
(
_rtpSession
)
->
getLocalCryptoInfo
());
if
(
rtpSession_
&&
rtpSession_
->
getAudioRtpType
()
==
Sdes
)
{
static_cast
<
AudioSrtpSession
*>
(
rtpSession_
)
->
initLocalCryptoInfo
();
ca_
->
getLocalSDP
()
->
setLocalSdpCrypto
(
static_cast
<
AudioSrtpSession
*>
(
rtpSession_
)
->
getLocalCryptoInfo
());
}
}
void
AudioRtpFactory
::
setRemoteCryptoInfo
(
sfl
::
SdesNegotiator
&
nego
)
{
if
(
_rtpSession
&&
_rtpSession
->
getAudioRtpType
()
==
Sdes
)
{
static_cast
<
AudioSrtpSession
*>
(
_rtpSession
)
->
setRemoteCryptoInfo
(
nego
);
}
else
{
throw
AudioRtpFactoryException
(
"RTP: Error: _rtpSession is NULL in setRemoteCryptoInfo"
);
}
if
(
rtpSession_
&&
rtpSession_
->
getAudioRtpType
()
==
Sdes
)
static_cast
<
AudioSrtpSession
*>
(
rtpSession_
)
->
setRemoteCryptoInfo
(
nego
);
else
throw
AudioRtpFactoryException
(
"RTP: Error: rtpSession_ is NULL in setRemoteCryptoInfo"
);
}
void
AudioRtpFactory
::
setDtmfPayloadType
(
unsigned
int
payloadType
)
{
if
(
_
rtpSession
)
_
rtpSession
->
setDtmfPayloadType
(
payloadType
);
if
(
rtpSession
_
)
rtpSession
_
->
setDtmfPayloadType
(
payloadType
);
}
void
AudioRtpFactory
::
sendDtmfDigit
(
int
digit
)
{
_
rtpSession
->
putDtmfEvent
(
digit
);
rtpSession
_
->
putDtmfEvent
(
digit
);
}
}
daemon/src/audio/audiortp/audio_rtp_factory.h
View file @
be6905d9
...
...
@@ -99,17 +99,17 @@ class AudioRtpFactory {
* Update current RTP destination address with one stored in call
* @param None
*/
void
updateDestinationIpAddress
(
void
);
void
updateDestinationIpAddress
();
bool
isSdesEnabled
(
void
)
const
{
return
_
srtpEnabled
&&
_
keyExchangeProtocol
==
sfl
::
Sdes
;
bool
isSdesEnabled
()
const
{
return
srtpEnabled
_
and
keyExchangeProtocol
_
==
sfl
::
Sdes
;
}
/**
* Manually set the srtpEnable option (usefull for RTP fallback)
*/
void
setSrtpEnabled
(
bool
enable
)
{
_
srtpEnabled
=
enable
;
srtpEnabled
_
=
enable
;
}
/**
...
...
@@ -138,26 +138,26 @@ class AudioRtpFactory {
void
sendDtmfDigit
(
int
digit
);
private:
AudioRtpSession
*
_
rtpSession
;
ost
::
Mutex
_
audioRtpThreadMutex
;
AudioRtpSession
*
rtpSession
_
;
ost
::
Mutex
audioRtpThreadMutex
_
;
// Field used when initializinga udio rtp session
// May be set manually or from config using initAudioRtpConfig
bool
_
srtpEnabled
;
bool
srtpEnabled
_
;
// Field used when initializinga udio rtp session
// May be set manually or from config using initAudioRtpConfig
RtpMethod
_
keyExchangeProtocol
;
RtpMethod
keyExchangeProtocol
_
;
// Field used when initializinga udio rtp session
// May be set manually or from config using initAudioRtpConfig
bool
_
helloHashEnabled
;
bool
helloHashEnabled
_
;
/** Remote srtp crypto context to be set into incoming data queue. */
ost
::
CryptoContext
*
remoteContext
;
ost
::
CryptoContext
*
remoteContext
_
;
/** Local srtp crypto context to be set into outgoing data queue. */
ost
::
CryptoContext
*
localContext
;
ost
::
CryptoContext
*
localContext
_
;
SIPCall
*
ca_
;
};
...
...
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
View file @
be6905d9
...
...
@@ -38,76 +38,66 @@ namespace sfl {
static
const
SFLDataFormat
initFadeinFactor
=
32000
;
AudioRtpRecord
::
AudioRtpRecord
()
:
_audioCodec
(
NULL
)
,
_hasDynamicPayloadType
(
false
)
,
_converter
(
NULL
)
,
_codecSampleRate
(
0
)
,
_codecFrameSize
(
0
)
,
_micAmplFactor
(
initFadeinFactor
)
,
_noiseSuppress
(
NULL
)
,
_callId
(
""
)
,
_dtmfPayloadType
(
101
)
// same as Asterisk
{
}
AudioRtpRecord
::
AudioRtpRecord
()
:
audioCodec_
(
NULL
)
,
hasDynamicPayloadType_
(
false
)
,
converter_
(
NULL
)
,
codecSampleRate_
(
0
)
,
codecFrameSize_
(
0
)
,
micAmplFactor_
(
initFadeinFactor
)
,
noiseSuppress_
(
NULL
)
,
callId_
(
""
)
,
dtmfPayloadType_
(
101
)
// same as Asterisk
{}
AudioRtpRecord
::~
AudioRtpRecord
()
{
delete
_
converter
;
delete
_
audioCodec
;
delete
_
noiseSuppress
;
delete
converter
_
;
delete
audioCodec
_
;
delete
noiseSuppress
_
;
}
AudioRtpRecordHandler
::
AudioRtpRecordHandler
(
SIPCall
*
ca
)
:
_audioRtpRecord
(),
id_
(
ca
->
getCallId
()),
echoCanceller
(
ca
->
getMemoryPool
()),
gainController
(
8000
,
-
10.0
)
{
}
AudioRtpRecordHandler
::
AudioRtpRecordHandler
(
SIPCall
*
ca
)
:
audioRtpRecord_
(),
id_
(
ca
->
getCallId
()),
echoCanceller
(
ca
->
getMemoryPool
()),
gainController
(
8000
,
-
10.0
)
{}
AudioRtpRecordHandler
::~
AudioRtpRecordHandler
()
{}
void
AudioRtpRecordHandler
::
setRtpMedia
(
AudioCodec
*
audioCodec
)
{
_
audioRtpRecord
.
audioCodecMutex
.
enter
(
);
ost
::
MutexLock
lock
(
audioRtpRecord
_
.
audioCodecMutex
_
);
delete
_
audioRtpRecord
.
_audioCodec
;
delete
audioRtpRecord_
.
audioCodec
_
;
// Set varios codec info to reduce indirection
_audioRtpRecord
.
_audioCodec
=
audioCodec
;
_audioRtpRecord
.
_codecPayloadType
=
audioCodec
->
getPayloadType
();
_audioRtpRecord
.
_codecSampleRate
=
audioCodec
->
getClockRate
();
_audioRtpRecord
.
_codecFrameSize
=
audioCodec
->
getFrameSize
();
_audioRtpRecord
.
_hasDynamicPayloadType
=
audioCodec
->
hasDynamicPayload
();
_audioRtpRecord
.
audioCodecMutex
.
leave
();
audioRtpRecord_
.
audioCodec_
=
audioCodec
;
audioRtpRecord_
.
codecPayloadType_
=
audioCodec
->
getPayloadType
();
audioRtpRecord_
.
codecSampleRate_
=
audioCodec
->
getClockRate
();
audioRtpRecord_
.
codecFrameSize_
=
audioCodec
->
getFrameSize
();
audioRtpRecord_
.
hasDynamicPayloadType_
=
audioCodec
->
hasDynamicPayload
();
}
void
AudioRtpRecordHandler
::
initBuffers
()
{
// Set sampling rate, main buffer choose the highest one
Manager
::
instance
().
audioSamplingRateChanged
(
_
audioRtpRecord
.
_codecSampleRate
);
Manager
::
instance
().
audioSamplingRateChanged
(
audioRtpRecord_
.
codecSampleRate
_
);
// initialize SampleRate converter using AudioLayer's sampling rate
// (internal buffers initialized with maximal sampling rate and frame size)
delete
_
audioRtpRecord
.
_converter
;
_
audioRtpRecord
.
_converter
=
new
SamplerateConverter
(
getCodecSampleRate
());
delete
audioRtpRecord_
.
converter
_
;
audioRtpRecord_
.
converter
_
=
new
SamplerateConverter
(
getCodecSampleRate
());
}
void
AudioRtpRecordHandler
::
initNoiseSuppress
()
{
_audioRtpRecord
.
audioProcessMutex
.
enter
();
delete
_audioRtpRecord
.
_noiseSuppress
;
_audioRtpRecord
.
_noiseSuppress
=
new
NoiseSuppress
(
getCodecFrameSize
(),
getCodecSampleRate
());
_audioRtpRecord
.
audioProcessMutex
.
leave
();
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioProcessMutex_
);
delete
audioRtpRecord_
.
noiseSuppress_
;
audioRtpRecord_
.
noiseSuppress_
=
new
NoiseSuppress
(
getCodecFrameSize
(),
getCodecSampleRate
());
}
void
AudioRtpRecordHandler
::
putDtmfEvent
(
int
digit
)
{
_
audioRtpRecord
.
_dtmfQueue
.
push_back
(
digit
);
audioRtpRecord_
.
dtmfQueue
_
.
push_back
(
digit
);
}
#ifdef DUMP_PROCESS_DATA_ENCODE
...
...
@@ -116,9 +106,9 @@ std::ofstream teststream("test_process_data_encode.raw");
int
AudioRtpRecordHandler
::
processDataEncode
(
void
)
{
SFLDataFormat
*
micData
=
_
audioRtpRecord
.
decData
;
unsigned
char
*
micDataEncoded
=
_
audioRtpRecord
.
encodedData
;
SFLDataFormat
*
micDataConverted
=
_
audioRtpRecord
.
resampledData
;
SFLDataFormat
*
micData
=
audioRtpRecord
_
.
decData
_
;
unsigned
char
*
micDataEncoded
=
audioRtpRecord
_
.
encodedData
_
;
SFLDataFormat
*
micDataConverted
=
audioRtpRecord
_
.
resampledData
_
;
int
codecSampleRate
=
getCodecSampleRate
();
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
...
...
@@ -129,9 +119,8 @@ int AudioRtpRecordHandler::processDataEncode(void)
int
samplesToGet
=
resampleFactor
*
getCodecFrameSize
();
int
bytesToGet
=
samplesToGet
*
sizeof
(
SFLDataFormat
);
if
(
Manager
::
instance
().
getMainBuffer
()
->
availForGet
(
id_
)
<
bytesToGet
)
{
if
(
Manager
::
instance
().
getMainBuffer
()
->
availForGet
(
id_
)
<
bytesToGet
)
return
0
;
}
int
bytes
=
Manager
::
instance
().
getMainBuffer
()
->
getData
(
micData
,
bytesToGet
,
id_
);
...
...
@@ -142,7 +131,7 @@ int AudioRtpRecordHandler::processDataEncode(void)
int
samples
=
bytesToGet
/
sizeof
(
SFLDataFormat
);
fadeIn
(
micData
,
samples
,
&
_
audioRtpRecord
.
_micAmplFactor
);
fadeIn
(
micData
,
samples
,
&
audioRtpRecord_
.
micAmplFactor
_
);
if
(
Manager
::
instance
().
getEchoCancelState
())
echoCanceller
.
getData
(
micData
);
...
...
@@ -155,18 +144,19 @@ int AudioRtpRecordHandler::processDataEncode(void)
if
(
codecSampleRate
!=
mainBufferSampleRate
)
{
out
=
micDataConverted
;
_
audioRtpRecord
.
_converter
->
resample
(
micData
,
micDataConverted
,
codecSampleRate
,
mainBufferSampleRate
,
samplesToGet
);
audioRtpRecord_
.
converter
_
->
resample
(
micData
,
micDataConverted
,
codecSampleRate
,
mainBufferSampleRate
,
samplesToGet
);
}
if
(
Manager
::
instance
().
audioPreference
.
getNoiseReduce
())
{
_audioRtpRecord
.
audioProcessMutex
.
enter
();
_audioRtpRecord
.
_noiseSuppress
->
process
(
micData
,
getCodecFrameSize
());
_audioRtpRecord
.
audioProcessMutex
.
leave
();
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioProcessMutex_
);
audioRtpRecord_
.
noiseSuppress_
->
process
(
micData
,
getCodecFrameSize
());
}
_audioRtpRecord
.
audioCodecMutex
.
enter
();
int
compSize
=
_audioRtpRecord
.
_audioCodec
->
encode
(
micDataEncoded
,
out
,
getCodecFrameSize
());
_audioRtpRecord
.
audioCodecMutex
.
leave
();
int
compSize
;
{
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioCodecMutex_
);
compSize
=
audioRtpRecord_
.
audioCodec_
->
encode
(
micDataEncoded
,
out
,
getCodecFrameSize
());
}
return
compSize
;
}
...
...
@@ -178,19 +168,19 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, unsigned
int
codecSampleRate
=
getCodecSampleRate
();
SFLDataFormat
*
spkrDataDecoded
=
_
audioRtpRecord
.
decData
;
SFLDataFormat
*
spkrDataConverted
=
_
audioRtpRecord
.
resampledData
;
SFLDataFormat
*
spkrDataDecoded
=
audioRtpRecord
_
.
decData
_
;
SFLDataFormat
*
spkrDataConverted
=
audioRtpRecord
_
.
resampledData
_
;
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
_audioRtpRecord
.
audioCodecMutex
.
enter
()
;
// Return the size of data in samples
int
inSamples
=
_audioRtpRecord
.
_audioCodec
->
decode
(
spkrDataDecoded
,
spkrData
,
size
);
_audioRtpRecord
.
audioCodecMutex
.
leave
();
int
inSamples
;
{
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioCodecMutex_
);
// Return the size of data in samples
inSamples
=
audioRtpRecord_
.
audioCodec_
->
decode
(
spkrDataDecoded
,
spkrData
,
size
);
}
fadeIn
(
spkrDataDecoded
,
inSamples
,
&
_
audioRtpRecord
.
_micAmplFactor
);
fadeIn
(
spkrDataDecoded
,
inSamples
,
&
audioRtpRecord_
.
micAmplFactor
_
);
// Normalize incomming signal
gainController
.
process
(
spkrDataDecoded
,
inSamples
);
...
...
@@ -202,7 +192,7 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, unsigned
if
(
codecSampleRate
!=
mainBufferSampleRate
)
{
// Do sample rate conversion
outSamples
=
((
float
)
inSamples
*
((
float
)
mainBufferSampleRate
/
(
float
)
codecSampleRate
));
_
audioRtpRecord
.
_converter
->
resample
(
spkrDataDecoded
,
spkrDataConverted
,
codecSampleRate
,
mainBufferSampleRate
,
inSamples
);
audioRtpRecord_
.
converter
_
->
resample
(
spkrDataDecoded
,
spkrDataConverted
,
codecSampleRate
,
mainBufferSampleRate
,
inSamples
);
out
=
spkrDataConverted
;
}
...
...
@@ -223,5 +213,4 @@ void AudioRtpRecordHandler::fadeIn(SFLDataFormat *audio, int size, SFLDataFormat
*
factor
/=
FADEIN_STEP_SIZE
;
}
}
daemon/src/audio/audiortp/audio_rtp_record_handler.h
View file @
be6905d9
...
...
@@ -78,24 +78,23 @@ class AudioRtpRecord {
AudioRtpRecord
();
~
AudioRtpRecord
();
AudioCodec
*
_audioCodec
;
ost
::
Mutex
audioCodecMutex
;
int
_codecPayloadType
;
bool
_hasDynamicPayloadType
;
SFLDataFormat
decData
[
DEC_BUFFER_SIZE
];
SFLDataFormat
resampledData
[
DEC_BUFFER_SIZE
];
unsigned
char
encodedData
[
DEC_BUFFER_SIZE
];
SamplerateConverter
*
_converter
;
int
_codecSampleRate
;
int
_codecFrameSize
;
int
_converterSamplingRate
;
std
::
list
<
int
>
_dtmfQueue
;
SFLDataFormat
_micAmplFactor
;
NoiseSuppress
*
_noiseSuppress
;
ost
::
Mutex
audioProcessMutex
;
std
::
string
_callId
;
unsigned
int
_dtmfPayloadType
;
AudioCodec
*
audioCodec_
;
ost
::
Mutex
audioCodecMutex_
;
int
codecPayloadType_
;
bool
hasDynamicPayloadType_
;
SFLDataFormat
decData_
[
DEC_BUFFER_SIZE
];
SFLDataFormat
resampledData_
[
DEC_BUFFER_SIZE
];
unsigned
char
encodedData_
[
DEC_BUFFER_SIZE
];
SamplerateConverter
*
converter_
;
int
codecSampleRate_
;
int
codecFrameSize_
;
int
converterSamplingRate_
;
std
::
list
<
int
>
dtmfQueue_
;
SFLDataFormat
micAmplFactor_
;
NoiseSuppress
*
noiseSuppress_
;
ost
::
Mutex
audioProcessMutex_
;
std
::
string
callId_
;
unsigned
int
dtmfPayloadType_
;
};
...
...
@@ -107,45 +106,44 @@ class AudioRtpRecordHandler {
/**
* Set rtp media for this session
*/
void
setRtpMedia
(
AudioCodec
*
audioCodec
);
AudioCodec
*
getAudioCodec
(
void
)
const
{
return
_
audioRtpRecord
.
_audioCodec
;
AudioCodec
*
getAudioCodec
()
const
{
return
audioRtpRecord_
.
audioCodec
_
;
}
int
getCodecPayloadType
(
void
)
const
{
return
_
audioRtpRecord
.
_codecPayloadType
;
int
getCodecPayloadType
()
const
{
return
audioRtpRecord_
.
codecPayloadType
_
;
}
int
getCodecSampleRate
(
void
)
const
{
return
_
audioRtpRecord
.
_codecSampleRate
;
int
getCodecSampleRate
()
const
{
return
audioRtpRecord_
.
codecSampleRate
_
;
}
int
getCodecFrameSize
(
void
)
const
{
return
_
audioRtpRecord
.
_codecFrameSize
;
int
getCodecFrameSize
()
const
{
return
audioRtpRecord_
.
codecFrameSize
_
;
}
bool
getHasDynamicPayload
(
void
)
const
{
return
_
audioRtpRecord
.
_hasDynamicPayloadType
;
bool
getHasDynamicPayload
()
const
{
return
audioRtpRecord_
.
hasDynamicPayloadType
_
;
}
int
DtmfPending
(
void
)
const
{
return
_
audioRtpRecord
.
_dtmfQueue
.
size
()
>
0
;
int
DtmfPending
()
const
{
return
audioRtpRecord_
.
dtmfQueue
_
.
size
()
>
0
;
}
const
unsigned
char
*
getMicDataEncoded
(
void
)
const
{
return
_
audioRtpRecord
.
encodedData
;
const
unsigned
char
*
getMicDataEncoded
()
const
{
return
audioRtpRecord
_
.
encodedData
_
;
}
void
initBuffers
(
void
);
void
initBuffers
();
void
initNoiseSuppress
(
void
);
void
initNoiseSuppress
();
/**
* Encode audio data from mainbuffer
*/
int
processDataEncode
(
void
);
int
processDataEncode
();