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
ce2ee36d
Commit
ce2ee36d
authored
16 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
Temporary: speex narrowband and wideband coexist
parent
44742a6b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/audio/codecs/Makefile.am
+16
-3
16 additions, 3 deletions
src/audio/codecs/Makefile.am
src/audio/codecs/speexcodec_nb.cpp
+1
-1
1 addition, 1 deletion
src/audio/codecs/speexcodec_nb.cpp
src/audio/codecs/speexcodec_wb.cpp
+154
-0
154 additions, 0 deletions
src/audio/codecs/speexcodec_wb.cpp
with
171 additions
and
4 deletions
src/audio/codecs/Makefile.am
+
16
−
3
View file @
ce2ee36d
...
@@ -22,6 +22,15 @@ libcodec_speex_nb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP)
...
@@ -22,6 +22,15 @@ libcodec_speex_nb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP)
INSTALL_SPEEX_NB_RULE
=
install-libcodec_speex_nb_so
INSTALL_SPEEX_NB_RULE
=
install-libcodec_speex_nb_so
endif
endif
if
BUILD_SPEEX
SPEEX_WB_LIB
=
libcodec_speex_wb.so
libcodec_speex_wb_so_SOURCES
=
speexcodec_wb.cpp
libcodec_speex_wb_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_speex_wb_so_CXXFLAGS
=
-fPIC
-g
-Wall
$(
SPEEXDSP
)
libcodec_speex_wb_so_LDFLAGS
=
--shared
-lc
-lspeex
$(
SPEEX_NIMP
)
INSTALL_SPEEX_WB_RULE
=
install-libcodec_speex_wb_so
endif
if
BUILD_ILBC
if
BUILD_ILBC
ILBC_LIB
=
libcodec_ilbc.so
ILBC_LIB
=
libcodec_ilbc.so
libcodec_ilbc_so_SOURCES
=
ilbc.cpp
libcodec_ilbc_so_SOURCES
=
ilbc.cpp
...
@@ -32,7 +41,7 @@ INSTALL_ILBC_RULE = install-libcodec_ilbc_so
...
@@ -32,7 +41,7 @@ INSTALL_ILBC_RULE = install-libcodec_ilbc_so
SUBDIRS
=
ilbc
SUBDIRS
=
ilbc
endif
endif
noinst_PROGRAMS
=
libcodec_ulaw.so libcodec_alaw.so
$(
GSM_LIB
)
$(
SPEEX_NB_LIB
)
$(
ILBC_LIB
)
noinst_PROGRAMS
=
libcodec_ulaw.so libcodec_alaw.so
$(
GSM_LIB
)
$(
SPEEX_NB_LIB
)
$(
SPEEX_WB_LIB
)
$(
ILBC_LIB
)
noinst_HEADERS
=
audiocodec.h
noinst_HEADERS
=
audiocodec.h
...
@@ -48,8 +57,8 @@ libcodec_alaw_so_LDFLAGS = --shared -lc
...
@@ -48,8 +57,8 @@ libcodec_alaw_so_LDFLAGS = --shared -lc
install-exec-local
:
install-libcodec_ulaw_so install-libcodec_alaw_so $(INSTALL_GSM_RULE) $(INSTALL_SPEEX_NB_RULE) $(INSTALL_ILBC_RULE)
install-exec-local
:
install-libcodec_ulaw_so install-libcodec_alaw_so $(INSTALL_GSM_RULE) $(INSTALL_SPEEX_NB_RULE)
$(INSTALL_SPEEX_WB_RULE)
$(INSTALL_ILBC_RULE)
uninstall-local
:
uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_nb_so
uninstall-local
:
uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_nb_so
uninstall-libcodec_speex_wb_so
install-libcodec_ulaw_so
:
libcodec_ulaw.so
install-libcodec_ulaw_so
:
libcodec_ulaw.so
mkdir
-p
$(
sflcodecdir
)
mkdir
-p
$(
sflcodecdir
)
...
@@ -60,6 +69,8 @@ install-libcodec_gsm_so: libcodec_gsm.so
...
@@ -60,6 +69,8 @@ install-libcodec_gsm_so: libcodec_gsm.so
$(
INSTALL_PROGRAM
)
libcodec_gsm.so
$(
sflcodecdir
)
$(
INSTALL_PROGRAM
)
libcodec_gsm.so
$(
sflcodecdir
)
install-libcodec_speex_nb_so
:
libcodec_speex_nb.so
install-libcodec_speex_nb_so
:
libcodec_speex_nb.so
$(
INSTALL_PROGRAM
)
libcodec_speex_nb.so
$(
sflcodecdir
)
$(
INSTALL_PROGRAM
)
libcodec_speex_nb.so
$(
sflcodecdir
)
install-libcodec_speex_wb_so
:
libcodec_speex_wb.so
$(
INSTALL_PROGRAM
)
libcodec_speex_wb.so
$(
sflcodecdir
)
install-libcodec_ilbc_so
:
libcodec_ilbc.so
install-libcodec_ilbc_so
:
libcodec_ilbc.so
$(
INSTALL_PROGRAM
)
libcodec_ilbc.so
$(
sflcodecdir
)
$(
INSTALL_PROGRAM
)
libcodec_ilbc.so
$(
sflcodecdir
)
...
@@ -72,6 +83,8 @@ uninstall-libcodec_gsm_so:
...
@@ -72,6 +83,8 @@ uninstall-libcodec_gsm_so:
rm
-f
$(
sflcodecdir
)
/libcodec_gsm.so
rm
-f
$(
sflcodecdir
)
/libcodec_gsm.so
uninstall-libcodec_speex_nb_so
:
uninstall-libcodec_speex_nb_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_speex_nb.so
rm
-f
$(
sflcodecdir
)
/libcodec_speex_nb.so
uninstall-libcodec_speex_wb_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_speex_wb.so
rm
-rf
$(
sflcodecdir
)
rm
-rf
$(
sflcodecdir
)
uninstall-libcodec_ilbc_so
:
uninstall-libcodec_ilbc_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_ilbc.so
rm
-f
$(
sflcodecdir
)
/libcodec_ilbc.so
...
...
This diff is collapsed.
Click to expand it.
src/audio/codecs/speexcodec_nb.cpp
+
1
−
1
View file @
ce2ee36d
...
@@ -145,7 +145,7 @@ class Speex : public AudioCodec{
...
@@ -145,7 +145,7 @@ class Speex : public AudioCodec{
// the class factories
// the class factories
extern
"C"
AudioCodec
*
create
()
{
extern
"C"
AudioCodec
*
create
()
{
return
new
Speex
(
11
1
);
return
new
Speex
(
11
0
);
}
}
extern
"C"
void
destroy
(
AudioCodec
*
a
)
{
extern
"C"
void
destroy
(
AudioCodec
*
a
)
{
...
...
This diff is collapsed.
Click to expand it.
src/audio/codecs/speexcodec_wb.cpp
0 → 100644
+
154
−
0
View file @
ce2ee36d
/*
* Copyright (C) 2007-2009 Savoir-Faire Linux inc.
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include
"audiocodec.h"
#include
<cstdio>
#include
<speex/speex.h>
#include
<speex/speex_preprocess.h>
class
Speex
:
public
AudioCodec
{
public:
Speex
(
int
payload
=
0
)
:
AudioCodec
(
payload
,
"speex"
),
_speexModePtr
(
NULL
),
_speex_dec_bits
(),
_speex_enc_bits
(),
_speex_dec_state
(),
_speex_enc_state
(),
_speex_frame_size
(),
_preprocess_state
()
{
_clockRate
=
16000
;
_channel
=
1
;
_bitrate
=
0
;
_bandwidth
=
0
;
initSpeex
();
}
Speex
(
const
Speex
&
);
Speex
&
operator
=
(
const
Speex
&
);
void
initSpeex
()
{
int
_samplingRate
=
16000
;
// 8000 HZ --> Narrow-band mode
// TODO Manage the other modes
_speexModePtr
=
&
speex_wb_mode
;
// _speexModePtr = &speex_wb_mode;
// Init the decoder struct
speex_bits_init
(
&
_speex_dec_bits
);
_speex_dec_state
=
speex_decoder_init
(
_speexModePtr
);
// Init the encoder struct
speex_bits_init
(
&
_speex_enc_bits
);
_speex_enc_state
=
speex_encoder_init
(
_speexModePtr
);
speex_encoder_ctl
(
_speex_enc_state
,
SPEEX_SET_SAMPLING_RATE
,
&
_clockRate
);
speex_decoder_ctl
(
_speex_dec_state
,
SPEEX_GET_FRAME_SIZE
,
&
_speex_frame_size
);
#ifdef HAVE_SPEEXDSP_LIB
int
enable
=
1
;
int
quality
=
10
;
int
complex
=
10
;
int
attenuation
=
-
10
;
speex_encoder_ctl
(
_speex_enc_state
,
SPEEX_SET_VAD
,
&
enable
);
speex_encoder_ctl
(
_speex_enc_state
,
SPEEX_SET_DTX
,
&
enable
);
speex_encoder_ctl
(
_speex_enc_state
,
SPEEX_SET_VBR_QUALITY
,
&
quality
);
speex_encoder_ctl
(
_speex_enc_state
,
SPEEX_SET_COMPLEXITY
,
&
complex
);
// Init the decoder struct
speex_decoder_ctl
(
_speex_dec_state
,
SPEEX_GET_FRAME_SIZE
,
&
_speex_frame_size
);
// Init the preprocess struct
_preprocess_state
=
speex_preprocess_state_init
(
_speex_frame_size
,
_clockRate
);
speex_preprocess_ctl
(
_preprocess_state
,
SPEEX_PREPROCESS_SET_DENOISE
,
&
enable
);
speex_preprocess_ctl
(
_preprocess_state
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
attenuation
);
speex_preprocess_ctl
(
_preprocess_state
,
SPEEX_PREPROCESS_SET_VAD
,
&
enable
);
speex_preprocess_ctl
(
_preprocess_state
,
SPEEX_PREPROCESS_SET_AGC
,
&
enable
);
#endif
}
~
Speex
()
{
terminateSpeex
();
}
void
terminateSpeex
()
{
// Destroy the decoder struct
speex_bits_destroy
(
&
_speex_dec_bits
);
speex_decoder_destroy
(
_speex_dec_state
);
_speex_dec_state
=
0
;
// Destroy the encoder struct
speex_bits_destroy
(
&
_speex_enc_bits
);
speex_encoder_destroy
(
_speex_enc_state
);
_speex_enc_state
=
0
;
}
virtual
int
codecDecode
(
short
*
dst
,
unsigned
char
*
src
,
unsigned
int
size
)
{
int
ratio
=
320
/
_speex_frame_size
;
speex_bits_read_from
(
&
_speex_dec_bits
,
(
char
*
)
src
,
size
);
speex_decode_int
(
_speex_dec_state
,
&
_speex_dec_bits
,
dst
);
return
2
*
_speex_frame_size
*
ratio
;
}
virtual
int
codecEncode
(
unsigned
char
*
dst
,
short
*
src
,
unsigned
int
size
)
{
speex_bits_reset
(
&
_speex_enc_bits
);
#ifdef HAVE_SPEEXDSP_LIB
speex_preprocess_run
(
_preprocess_state
,
src
);
#endif
speex_encode_int
(
_speex_enc_state
,
src
,
&
_speex_enc_bits
);
int
nbBytes
=
speex_bits_write
(
&
_speex_enc_bits
,
(
char
*
)
dst
,
size
);
printf
(
"Codec::codecEncode() nbBytes: %i
\n
"
,
nbBytes
);
return
nbBytes
;
}
private
:
const
SpeexMode
*
_speexModePtr
;
SpeexBits
_speex_dec_bits
;
SpeexBits
_speex_enc_bits
;
void
*
_speex_dec_state
;
void
*
_speex_enc_state
;
int
_speex_frame_size
;
SpeexPreprocessState
*
_preprocess_state
;
};
// the class factories
extern
"C"
AudioCodec
*
create
()
{
return
new
Speex
(
111
);
}
extern
"C"
void
destroy
(
AudioCodec
*
a
)
{
delete
a
;
}
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