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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
5f6ae1f1
Commit
5f6ae1f1
authored
15 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[
#959
] Add noise canceller for incoming data
parent
ad0e5c23
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/audio/audiortp/AudioRtpSession.h
+46
-6
46 additions, 6 deletions
sflphone-common/src/audio/audiortp/AudioRtpSession.h
with
46 additions
and
6 deletions
sflphone-common/src/audio/audiortp/AudioRtpSession.h
+
46
−
6
View file @
5f6ae1f1
...
@@ -251,6 +251,8 @@ namespace sfl {
...
@@ -251,6 +251,8 @@ namespace sfl {
*/
*/
int
_currentTime
;
int
_currentTime
;
SpeexPreprocessState
*
_noiseState
;
protected
:
protected
:
SIPCall
*
_ca
;
SIPCall
*
_ca
;
...
@@ -280,6 +282,7 @@ namespace sfl {
...
@@ -280,6 +282,7 @@ namespace sfl {
_timestampCount
(
0
),
_timestampCount
(
0
),
_countNotificationTime
(
0
),
_countNotificationTime
(
0
),
_jbuffer
(
NULL
),
_jbuffer
(
NULL
),
_noiseState
(
NULL
),
_ca
(
sipcall
)
_ca
(
sipcall
)
{
{
setCancel
(
cancelDefault
);
setCancel
(
cancelDefault
);
...
@@ -333,9 +336,16 @@ namespace sfl {
...
@@ -333,9 +336,16 @@ namespace sfl {
delete
_audiocodec
;
_audiocodec
=
NULL
;
delete
_audiocodec
;
_audiocodec
=
NULL
;
}
}
if
(
_jbuffer
)
{
jb_destroy
(
_jbuffer
);
jb_destroy
(
_jbuffer
);
}
}
if
(
_noiseState
)
{
speex_preprocess_state_destroy
(
_noiseState
);
}
}
template
<
typename
D
>
template
<
typename
D
>
void
AudioRtpSession
<
D
>::
initBuffers
()
void
AudioRtpSession
<
D
>::
initBuffers
()
{
{
...
@@ -403,6 +413,29 @@ namespace sfl {
...
@@ -403,6 +413,29 @@ namespace sfl {
_debug
(
"RTP: Setting static payload format"
);
_debug
(
"RTP: Setting static payload format"
);
static_cast
<
D
*>
(
this
)
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
(
(
ost
::
StaticPayloadType
)
_audiocodec
->
getPayload
()));
static_cast
<
D
*>
(
this
)
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
(
(
ost
::
StaticPayloadType
)
_audiocodec
->
getPayload
()));
}
}
if
(
_noiseState
)
{
speex_preprocess_state_destroy
(
_noiseState
);
_noiseState
=
NULL
;
}
_noiseState
=
speex_preprocess_state_init
(
_codecSampleRate
,
_codecFrameSize
);
int
i
=
1
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_DENOISE
,
&
i
);
i
=-
20
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
i
);
i
=
0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
i
=
8000
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC_TARGET
,
&
i
);
i
=
16000
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_AGC_LEVEL
,
&
i
);
i
=
0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB
,
&
i
);
float
f
=
0.0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB_DECAY
,
&
f
);
f
=
0.0
;
speex_preprocess_ctl
(
_noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB_LEVEL
,
&
f
);
}
}
template
<
typename
D
>
template
<
typename
D
>
...
@@ -596,6 +629,8 @@ namespace sfl {
...
@@ -596,6 +629,8 @@ namespace sfl {
// Store the number of samples for recording
// Store the number of samples for recording
_nSamplesSpkr
=
nbSample
;
_nSamplesSpkr
=
nbSample
;
speex_preprocess_run
(
_noiseState
,
_spkrDataConverted
);
// put data in audio layer, size in byte
// put data in audio layer, size in byte
_manager
->
getAudioDriver
()
->
getMainBuffer
()
->
putData
(
_spkrDataConverted
,
nbSample
*
sizeof
(
SFLDataFormat
),
100
,
_ca
->
getCallId
());
_manager
->
getAudioDriver
()
->
getMainBuffer
()
->
putData
(
_spkrDataConverted
,
nbSample
*
sizeof
(
SFLDataFormat
),
100
,
_ca
->
getCallId
());
...
@@ -604,6 +639,7 @@ namespace sfl {
...
@@ -604,6 +639,7 @@ namespace sfl {
// Store the number of samples for recording
// Store the number of samples for recording
_nSamplesSpkr
=
nbSample
;
_nSamplesSpkr
=
nbSample
;
// speex_preprocess_run(_noiseState, _spkrDataDecoded);
// put data in audio layer, size in byte
// put data in audio layer, size in byte
_manager
->
getAudioDriver
()
->
getMainBuffer
()
->
putData
(
_spkrDataDecoded
,
expandedSize
,
100
,
_ca
->
getCallId
());
_manager
->
getAudioDriver
()
->
getMainBuffer
()
->
putData
(
_spkrDataDecoded
,
expandedSize
,
100
,
_ca
->
getCallId
());
...
@@ -684,14 +720,17 @@ namespace sfl {
...
@@ -684,14 +720,17 @@ namespace sfl {
if
(
adu
)
{
if
(
adu
)
{
if
(
_jbuffer
->
frames
)
{
//
if(_jbuffer->frames) {
// _debug("_jbuffer->frames->prev->ts %d, _jbuffer->frames->ts %d", _jbuffer->frames->prev->ts, _jbuffer->frames->ts);
// _debug("_jbuffer->frames->prev->ts %d, _jbuffer->frames->ts %d", _jbuffer->frames->prev->ts, _jbuffer->frames->ts);
// _debug("_jbuffer->info.conf.max_jitterbuf %d", _jbuffer->info.conf.max_jitterbuf);
// _debug("_jbuffer->info.conf.max_jitterbuf %d", _jbuffer->info.conf.max_jitterbuf);
}
//
}
// _debug("PUT_DATA: _ts %d, _currentTime %d", _ts, _currentTime);
// _debug("PUT_DATA: _ts %d, _currentTime %d", _ts, _currentTime);
spkrDataIn
=
(
unsigned
char
*
)
adu
->
getData
();
// data in char
spkrDataIn
=
(
unsigned
char
*
)
adu
->
getData
();
// data in char
size
=
adu
->
getSize
();
// size in char
size
=
adu
->
getSize
();
// size in char
result
=
jb_put
(
_jbuffer
,
spkrDataIn
,
JB_TYPE_VOICE
,
_packetLength
,
_ts
+=
20
,
_currentTime
);
result
=
jb_put
(
_jbuffer
,
spkrDataIn
,
JB_TYPE_VOICE
,
_packetLength
,
_ts
+=
20
,
_currentTime
);
/*
/*
switch(result) {
switch(result) {
...
@@ -710,6 +749,7 @@ namespace sfl {
...
@@ -710,6 +749,7 @@ namespace sfl {
}
}
// _debug("GET_DATA: _currentTime %d", _currentTime);
// _debug("GET_DATA: _currentTime %d", _currentTime);
result
=
jb_get
(
_jbuffer
,
&
frame
,
_currentTime
+=
20
,
_packetLength
);
result
=
jb_get
(
_jbuffer
,
&
frame
,
_currentTime
+=
20
,
_packetLength
);
/*
/*
switch(result) {
switch(result) {
...
@@ -728,7 +768,7 @@ namespace sfl {
...
@@ -728,7 +768,7 @@ namespace sfl {
// DTMF over RTP, size must be over 4 in order to process it as voice data
// DTMF over RTP, size must be over 4 in order to process it as voice data
if
(
size
>
4
)
{
if
(
size
>
4
)
{
// processDataDecode(spkrDataIn, size);
// processDataDecode(spkrDataIn, size);
if
(
result
==
0
)
{
if
(
result
==
JB_OK
)
{
processDataDecode
((
unsigned
char
*
)(
frame
.
data
),
160
);
processDataDecode
((
unsigned
char
*
)(
frame
.
data
),
160
);
}
}
}
}
...
...
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