Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
859e5e3a
Commit
859e5e3a
authored
12 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #9979: use std::tr1::array instead of plain array for audio buffers
This will allow us to do more compile-time bounds checking.
parent
42b52b0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
+17
-20
17 additions, 20 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
daemon/src/audio/audiortp/audio_rtp_record_handler.h
+6
-5
6 additions, 5 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.h
with
23 additions
and
25 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
+
17
−
20
View file @
859e5e3a
...
...
@@ -37,28 +37,27 @@
namespace
sfl
{
static
const
SFLDataFormat
initFadeinFactor
=
32000
;
static
const
SFLDataFormat
INIT_FADE_IN_FACTOR
=
32000
;
AudioRtpRecord
::
AudioRtpRecord
()
:
audioCodec_
(
0
)
,
audioCodecMutex_
()
,
codecPayloadType_
(
0
)
,
hasDynamicPayloadType_
(
false
)
,
decData_
()
// std::tr1::arrays will be 0-initialized
,
resampledData_
()
,
encodedData_
()
,
converter_
(
0
)
,
codecSampleRate_
(
0
)
,
codecFrameSize_
(
0
)
,
converterSamplingRate_
(
0
)
,
dtmfQueue_
()
,
micAmplFactor_
(
initFadeinFactor
)
,
micAmplFactor_
(
INIT_FADE_IN_FACTOR
)
,
noiseSuppress_
(
0
)
,
audioProcessMutex_
()
,
callId_
(
""
)
,
dtmfPayloadType_
(
101
)
// same as Asterisk
{
memset
(
decData_
,
0x0
,
sizeof
decData_
);
memset
(
resampledData_
,
0x0
,
sizeof
resampledData_
);
memset
(
encodedData_
,
0x0
,
sizeof
encodedData_
);
}
{}
AudioRtpRecord
::~
AudioRtpRecord
()
{
...
...
@@ -116,14 +115,10 @@ void AudioRtpRecordHandler::putDtmfEvent(int digit)
int
AudioRtpRecordHandler
::
processDataEncode
()
{
SFLDataFormat
*
micData
=
audioRtpRecord_
.
decData_
;
unsigned
char
*
micDataEncoded
=
audioRtpRecord_
.
encodedData_
;
SFLDataFormat
*
micDataConverted
=
audioRtpRecord_
.
resampledData_
;
int
codecSampleRate
=
getCodecSampleRate
();
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
double
resampleFactor
=
(
double
)
mainBufferSampleRate
/
codecSampleRate
;
double
resampleFactor
=
(
double
)
mainBufferSampleRate
/
codecSampleRate
;
// compute nb of byte to get coresponding to 1 audio frame
int
samplesToGet
=
resampleFactor
*
getCodecFrameSize
();
...
...
@@ -132,10 +127,12 @@ int AudioRtpRecordHandler::processDataEncode()
if
(
Manager
::
instance
().
getMainBuffer
()
->
availForGet
(
id_
)
<
bytesToGet
)
return
0
;
SFLDataFormat
*
micData
=
audioRtpRecord_
.
decData_
.
data
();
int
bytes
=
Manager
::
instance
().
getMainBuffer
()
->
getData
(
micData
,
bytesToGet
,
id_
);
if
(
bytes
!=
bytesToGet
)
{
ERROR
(
"%s : asked %d bytes from mainbuffer, got %d"
,
__PRETTY_FUNCTION__
,
bytesToGet
,
bytes
);
ERROR
(
"%s : asked %d bytes from mainbuffer, got %d"
,
__PRETTY_FUNCTION__
,
bytesToGet
,
bytes
);
return
0
;
}
...
...
@@ -147,6 +144,7 @@ int AudioRtpRecordHandler::processDataEncode()
echoCanceller
.
getData
(
micData
);
SFLDataFormat
*
out
=
micData
;
SFLDataFormat
*
micDataConverted
=
audioRtpRecord_
.
resampledData_
.
data
();
if
(
codecSampleRate
!=
mainBufferSampleRate
)
{
out
=
micDataConverted
;
...
...
@@ -161,6 +159,7 @@ int AudioRtpRecordHandler::processDataEncode()
{
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioCodecMutex_
);
unsigned
char
*
micDataEncoded
=
audioRtpRecord_
.
encodedData_
.
data
();
return
audioRtpRecord_
.
audioCodec_
->
encode
(
micDataEncoded
,
out
,
getCodecFrameSize
());
}
}
...
...
@@ -172,16 +171,14 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
int
codecSampleRate
=
getCodecSampleRate
();
SFLDataFormat
*
spkrDataDecoded
=
audioRtpRecord_
.
decData_
;
SFLDataFormat
*
spkrDataConverted
=
audioRtpRecord_
.
resampledData_
;
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
int
inSamples
;
int
inSamples
=
0
;
SFLDataFormat
*
spkrDataDecoded
=
audioRtpRecord_
.
decData_
.
data
();
{
ost
::
MutexLock
lock
(
audioRtpRecord_
.
audioCodecMutex_
);
// Return the size of data in samples
inSamples
=
audioRtpRecord_
.
audioCodec_
->
decode
(
spkrDataDecoded
,
spkrData
,
size
);
inSamples
=
audioRtpRecord_
.
audioCodec_
->
decode
(
spkrDataDecoded
,
spkrData
,
size
);
}
fadeIn
(
spkrDataDecoded
,
inSamples
,
&
audioRtpRecord_
.
micAmplFactor_
);
...
...
@@ -194,10 +191,10 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
// test if resampling is required
if
(
codecSampleRate
!=
mainBufferSampleRate
)
{
out
=
audioRtpRecord_
.
resampledData_
.
data
();
// Do sample rate conversion
outSamples
=
((
float
)
inSamples
*
((
float
)
mainBufferSampleRate
/
(
float
)
codecSampleRate
));
audioRtpRecord_
.
converter_
->
resample
(
spkrDataDecoded
,
spkrDataConverted
,
codecSampleRate
,
mainBufferSampleRate
,
inSamples
);
out
=
spkrDataConverted
;
audioRtpRecord_
.
converter_
->
resample
(
spkrDataDecoded
,
out
,
codecSampleRate
,
mainBufferSampleRate
,
inSamples
);
}
if
(
Manager
::
instance
().
getEchoCancelState
())
...
...
This diff is collapsed.
Click to expand it.
daemon/src/audio/audiortp/audio_rtp_record_handler.h
+
6
−
5
View file @
859e5e3a
...
...
@@ -34,6 +34,7 @@
using
std
::
ptrdiff_t
;
#include
<ccrtp/rtp.h>
#include
<tr1/array>
#include
<list>
class
SIPCall
;
...
...
@@ -72,7 +73,7 @@ timeval2microtimeout(const timeval& t)
/**
* Class meant to store internal data in order to encode/decode,
* resample, process, and packetize audio streams. This class should not be
* handled directly. Use AudioRtpRecor
r
dHand
e
ler
* handled directly. Use AudioRtpRecordHandler
*/
class
AudioRtpRecord
{
public:
...
...
@@ -83,9 +84,9 @@ class AudioRtpRecord {
ost
::
Mutex
audioCodecMutex_
;
int
codecPayloadType_
;
bool
hasDynamicPayloadType_
;
SFLDataFormat
decData_
[
DEC_BUFFER_SIZE
]
;
SFLDataFormat
resampledData_
[
DEC_BUFFER_SIZE
]
;
unsigned
char
encodedData_
[
DEC_BUFFER_SIZE
]
;
std
::
tr1
::
array
<
SFLDataFormat
,
DEC_BUFFER_SIZE
>
decData_
;
std
::
tr1
::
array
<
SFLDataFormat
,
DEC_BUFFER_SIZE
>
resampledData_
;
std
::
tr1
::
array
<
unsigned
char
,
DEC_BUFFER_SIZE
>
encodedData_
;
SamplerateConverter
*
converter_
;
int
codecSampleRate_
;
int
codecFrameSize_
;
...
...
@@ -136,7 +137,7 @@ class AudioRtpRecordHandler {
}
const
unsigned
char
*
getMicDataEncoded
()
const
{
return
audioRtpRecord_
.
encodedData_
;
return
audioRtpRecord_
.
encodedData_
.
data
()
;
}
void
initBuffers
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment