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
85a76811
Commit
85a76811
authored
12 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #9979: AudioRtpRecord: let AudioRtpRecord handle fadeIn internally
parent
859e5e3a
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
+14
-12
14 additions, 12 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
daemon/src/audio/audiortp/audio_rtp_record_handler.h
+7
-9
7 additions, 9 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.h
with
21 additions
and
21 deletions
daemon/src/audio/audiortp/audio_rtp_record_handler.cpp
+
14
−
12
View file @
85a76811
...
...
@@ -29,6 +29,7 @@
#include
"audio_rtp_record_handler.h"
#include
<fstream>
#include
<algorithm>
#include
"logger.h"
#include
"sip/sipcall.h"
...
...
@@ -52,7 +53,7 @@ AudioRtpRecord::AudioRtpRecord() :
,
codecFrameSize_
(
0
)
,
converterSamplingRate_
(
0
)
,
dtmfQueue_
()
,
micAmpl
Factor_
(
INIT_FADE_IN_FACTOR
)
,
fade
Factor_
(
INIT_FADE_IN_FACTOR
)
,
noiseSuppress_
(
0
)
,
audioProcessMutex_
()
,
callId_
(
""
)
...
...
@@ -138,7 +139,7 @@ int AudioRtpRecordHandler::processDataEncode()
int
samples
=
bytesToGet
/
sizeof
(
SFLDataFormat
);
fadeIn
(
micData
,
samples
,
&
audioRtpRecord_
.
micAmplFactor_
);
audioRtpRecord_
.
fadeInDecodedData
(
samples
);
if
(
Manager
::
instance
().
getEchoCancelState
())
echoCanceller
.
getData
(
micData
);
...
...
@@ -169,10 +170,6 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
if
(
getCodecPayloadType
()
!=
payloadType
)
return
;
int
codecSampleRate
=
getCodecSampleRate
();
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
int
inSamples
=
0
;
SFLDataFormat
*
spkrDataDecoded
=
audioRtpRecord_
.
decData_
.
data
();
{
...
...
@@ -181,7 +178,7 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
inSamples
=
audioRtpRecord_
.
audioCodec_
->
decode
(
spkrDataDecoded
,
spkrData
,
size
);
}
fadeIn
(
spkrData
Decoded
,
inSamples
,
&
audioRtpRecord_
.
micAmplFactor_
);
audioRtpRecord_
.
fadeIn
Decoded
Data
(
inSamples
);
// Normalize incomming signal
gainController
.
process
(
spkrDataDecoded
,
inSamples
);
...
...
@@ -189,6 +186,9 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
SFLDataFormat
*
out
=
spkrDataDecoded
;
int
outSamples
=
inSamples
;
int
codecSampleRate
=
getCodecSampleRate
();
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
// test if resampling is required
if
(
codecSampleRate
!=
mainBufferSampleRate
)
{
out
=
audioRtpRecord_
.
resampledData_
.
data
();
...
...
@@ -203,15 +203,17 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
Manager
::
instance
().
getMainBuffer
()
->
putData
(
out
,
outSamples
*
sizeof
(
SFLDataFormat
),
id_
);
}
void
AudioRtpRecord
Handler
::
fadeIn
(
SFLDataFormat
*
audio
,
size_t
size
,
SFLDataFormat
*
factor
)
void
AudioRtpRecord
::
fadeIn
DecodedData
(
size_t
size
)
{
// if factor reaches 0, this function should have no effect
if
(
!
audio
or
!
factor
or
*
factor
<=
0
)
if
(
fadeFactor_
<=
0
or
size
>
decData_
.
size
()
)
return
;
while
(
size
>
0
)
audio
[
--
size
]
/=
*
f
actor
;
std
::
transform
(
decData_
.
begin
(),
decData_
.
begin
()
+
size
,
decData_
.
begin
(),
std
::
bind1st
(
std
::
divides
<
double
>
(),
fadeF
actor
_
))
;
*
factor
/=
FADEIN_STEP_SIZE
;
// Factor used to increase volume in fade in
const
SFLDataFormat
FADEIN_STEP_SIZE
=
4
;
fadeFactor_
/=
FADEIN_STEP_SIZE
;
}
}
This diff is collapsed.
Click to expand it.
daemon/src/audio/audiortp/audio_rtp_record_handler.h
+
7
−
9
View file @
85a76811
...
...
@@ -51,9 +51,6 @@ namespace sfl {
// Frequency (in packet number)
#define RTP_TIMESTAMP_RESET_FREQ 100
// Factor use to increase volume in fade in
#define FADEIN_STEP_SIZE 4;
static
const
int
schedulingTimeout
=
4000
;
static
const
int
expireTimeout
=
1000000
;
...
...
@@ -92,12 +89,18 @@ class AudioRtpRecord {
int
codecFrameSize_
;
int
converterSamplingRate_
;
std
::
list
<
int
>
dtmfQueue_
;
SFLDataFormat
micAmpl
Factor_
;
SFLDataFormat
fade
Factor_
;
NoiseSuppress
*
noiseSuppress_
;
ost
::
Mutex
audioProcessMutex_
;
std
::
string
callId_
;
unsigned
int
dtmfPayloadType_
;
private:
friend
class
AudioRtpRecordHandler
;
/**
* Ramp In audio data to avoid audio click from peer
*/
void
fadeInDecodedData
(
size_t
size
);
NON_COPYABLE
(
AudioRtpRecord
);
};
...
...
@@ -154,11 +157,6 @@ class AudioRtpRecordHandler {
*/
void
processDataDecode
(
unsigned
char
*
spkrData
,
size_t
size
,
int
payloadType
);
/**
* Ramp In audio data to avoid audio click from peer
*/
void
fadeIn
(
SFLDataFormat
*
audio
,
size_t
size
,
SFLDataFormat
*
factor
);
void
setDtmfPayloadType
(
unsigned
int
payloadType
)
{
audioRtpRecord_
.
dtmfPayloadType_
=
payloadType
;
}
...
...
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