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
03cc5544
Commit
03cc5544
authored
17 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
nothing
parent
b68cbde6
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/audio/Makefile.am
+5
-5
5 additions, 5 deletions
src/audio/Makefile.am
src/audio/alaw.cpp
+1
-1
1 addition, 1 deletion
src/audio/alaw.cpp
src/audio/audiortp.cpp
+5
-7
5 additions, 7 deletions
src/audio/audiortp.cpp
src/audio/gsmcodec.cpp
+51
-10
51 additions, 10 deletions
src/audio/gsmcodec.cpp
with
62 additions
and
23 deletions
src/audio/Makefile.am
+
5
−
5
View file @
03cc5544
...
...
@@ -29,7 +29,7 @@ SPEEX_FLAG=
SPEEX_LIB
=
endif
#SUBDIRS =
ilbc
#SUBDIRS =
gsm
libaudio_la_SOURCES
=
audiofile.cpp tonelist.cpp
\
audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfgenerator.cpp
\
...
...
@@ -63,8 +63,8 @@ uninstall-libcodec_ulaw_so:
rm
-f
$(
sflcodecdir
)
/libcodec_ulaw.so
uninstall-libcodec_alaw_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_alaw.so
uninstall-libcodec_gsm_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_gsm.so
#
uninstall-libcodec_gsm_so:
#
rm -f $(sflcodecdir)/libcodec_gsm.so
uninstall-libcodec_speex_so
:
rm
-f
$(
sflcodecdir
)
/libcodec_speex.so
rm
-rf
$(
sflcodecdir
)
This diff is collapsed.
Click to expand it.
src/audio/alaw.cpp
+
1
−
1
View file @
03cc5544
...
...
@@ -31,7 +31,7 @@ public:
_channel
=
1
;
}
virtual
~
Alaw
(){}
virtual
int
codecDecode
(
short
*
dst
,
unsigned
char
*
src
,
unsigned
int
size
)
{
int16
*
end
=
dst
+
size
;
...
...
This diff is collapsed.
Click to expand it.
src/audio/audiortp.cpp
+
5
−
7
View file @
03cc5544
...
...
@@ -97,13 +97,12 @@ AudioRtp::closeRtpSession () {
// AudioRtpRTX Class //
////////////////////////////////////////////////////////////////////////////////
AudioRtpRTX
::
AudioRtpRTX
(
SIPCall
*
sipcall
,
bool
sym
)
:
_fstream
(
"/tmp/audio.
dat
"
,
std
::
ofstream
::
binary
|
std
::
ios
::
out
|
std
::
ios
::
app
)
:
_fstream
(
"/tmp/audio.
gsm
"
,
std
::
ofstream
::
binary
|
std
::
ios
::
out
|
std
::
ios
::
app
)
{
setCancel
(
cancelDeferred
);
time
=
new
ost
::
Time
();
_ca
=
sipcall
;
_sym
=
sym
;
//std::string s = "snd.dat";
// AudioRtpRTX should be close if we change sample rate
//_codecSampleRate = _ca->getAudioCodec()->getClockRate();
...
...
@@ -141,7 +140,6 @@ AudioRtpRTX::~AudioRtpRTX () {
}
//_debug("terminate audiortprtx ended...\n");
_ca
=
0
;
//fd = fopen("snd_data", "wa");
if
(
!
_sym
)
{
delete
_sessionRecv
;
_sessionRecv
=
NULL
;
delete
_sessionSend
;
_sessionSend
=
NULL
;
...
...
@@ -321,7 +319,6 @@ try {
// we have to get 20ms of data from the mic *20/1000 = /50
int
maxBytesToGet
=
_layerSampleRate
*
_layerFrameSize
*
sizeof
(
SFLDataFormat
)
/
1000
;
// available bytes inside ringbuffer
int
availBytesFromMic
=
audiolayer
->
canGetMic
();
...
...
@@ -332,7 +329,6 @@ try {
int
nbSample
=
audiolayer
->
getMic
(
_dataAudioLayer
,
bytesAvail
)
/
sizeof
(
SFLDataFormat
);
int
nb_sample_up
=
nbSample
;
int
nbSamplesMax
=
_layerFrameSize
*
audiocodec
->
getClockRate
()
/
1000
;
//_fstream.write((char*) _dataAudioLayer, nbSample);
nbSample
=
reSampleData
(
audiocodec
->
getClockRate
(),
nb_sample_up
,
DOWN_SAMPLING
);
...
...
@@ -348,6 +344,7 @@ try {
//_debug("AR: Nb sample: %d int, [0]=%d [1]=%d [2]=%d\n", nbSample, toSIP[0], toSIP[1], toSIP[2]);
// for the mono: range = 0 to RTP_FRAME2SEND * sizeof(int16)
// codecEncode(char *dest, int16* src, size in bytes of the src)
//int compSize = audiocodec->codecEncode(_sendDataEncoded, toSIP, nbSample*sizeof(int16));
int
compSize
=
audiocodec
->
codecEncode
(
_sendDataEncoded
,
toSIP
,
nbSample
*
sizeof
(
int16
));
//printf("jusqu'ici tout vas bien\n");
...
...
@@ -401,7 +398,7 @@ try {
audiocodec
=
loadCodec
(
payload
);
// Decode data with relevant codec
_codecSampleRate
=
audiocodec
->
getClockRate
();
int
max
=
(
int
)(
_codecSampleRate
*
_layerFrameSize
);
int
max
=
(
int
)(
_codecSampleRate
*
_layerFrameSize
/
1000
);
if
(
size
>
max
)
{
_debug
(
"We have received from RTP a packet larger than expected: %s VS %s
\n
"
,
size
,
max
);
...
...
@@ -413,6 +410,7 @@ try {
if
(
audiocodec
!=
NULL
)
{
int
expandedSize
=
audiocodec
->
codecDecode
(
_receiveDataDecoded
,
data
,
size
);
_fstream
.
write
((
char
*
)
_receiveDataDecoded
,
160
);
//buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes
int
nbInt16
=
expandedSize
/
sizeof
(
int16
);
//nbInt16 represents the number of samples we just decoded
...
...
@@ -569,7 +567,7 @@ try {
Thread
::
sleep
(
TimerPort
::
getTimer
());
TimerPort
::
incTimer
(
_layerFrameSize
);
// 'frameSize' ms
}
//
_fstream.close();
_fstream
.
close
();
//_debug("stop stream for audiortp loop\n");
audiolayer
->
stopStream
();
}
catch
(
std
::
exception
&
e
)
{
...
...
This diff is collapsed.
Click to expand it.
src/audio/gsmcodec.cpp
+
51
−
10
View file @
03cc5544
...
...
@@ -19,54 +19,94 @@
*/
#include
<iostream>
extern
"C"
{
#include
<gsm/gsm.h>
}
#include
"audiocodec.h"
#include
"../global.h"
#define GSM_PACKED_FRAME_SIZE_IN_BYTES 33
#define GSM_UNPACKED_FRAME_SIZE_IN_BYTES 320
#define GSM_UNPACKED_FRAME_SIZE_IN_SHORTS 160
/*
void * GSMCodecHandle = 0;
void* (*gsm_session_create)() = 0;
void (*gsm_session_destroy)(void *) = 0;
void (*gsm_session_encode)(void*, unsigned char*, short*) = 0 ;
int (*gsm_session_decode)(void*, short* , unsigned char*) = 0 ;
*/
class
Gsm
:
public
AudioCodec
{
public:
// 3 GSM A 8000 1 [RFC3551]
Gsm
(
int
payload
=
0
)
:
AudioCodec
(
payload
,
"GSM"
)
{
//_description = "GSM";
_clockRate
=
8000
;
_channel
=
1
;
//initGSMStruct();
if
(
!
(
_decode_gsmhandle
=
gsm_create
()
))
_debug
(
"ERROR: decode_gsm_create
\n
"
);
if
(
!
(
_encode_gsmhandle
=
gsm_create
()
))
_debug
(
"AudioCodec: ERROR: encode_gsm_create
\n
"
);
//_encode_state = gsm_session_create();
//_decode_state = gsm_session_create();
}
~
Gsm
(
void
)
{
//gsm_session_destroy(_decode_state);
//gsm_session_destroy(_encode_state);
gsm_destroy
(
_decode_gsmhandle
);
gsm_destroy
(
_encode_gsmhandle
);
}
/*
bool initGSMStruct()
{
if(GSMCodecHandle) return true;
GSMCodecHandle = dlopen("libgsm.so", RTLD_NOW | RTLD_GLOBAL);
if(!GSMCodecHandle) return false;
gsm_session_create = (void * (*)()) dlsym(GSMCodecHandle, "gsm_create");
gsm_session_destroy = (void (*) (void *)) dlsym(GSMCodecHandle, "gsm_destroy");
gsm_session_encode = ( void (*) (void*, unsigned char*, short*)) dlsym(GSMCodecHandle, "gsm_encode");
gsm_session_decode = (int (*) (void*, short*, unsigned char*)) dlsym(GSMCodecHandle, "gsm_decode");
if(!(gsm_session_create && gsm_session_destroy && gsm_session_encode && gsm_session_decode)){
dlclose(GSMCodecHandle);
GSMCodecHandle = 0 ;
return false;}
return true;
}*/
virtual
int
codecDecode
(
short
*
dst
,
unsigned
char
*
src
,
unsigned
int
size
)
{
(
void
)
size
;
if
(
gsm_decode
(
_decode_gsmhandle
,
(
gsm_byte
*
)
src
,
(
gsm_signal
*
)
dst
)
<
0
)
{
_debug
(
"ERROR: gsm_decode
\n
"
);
}
return
320
;
if
(
gsm_decode
(
_decode_gsmhandle
,
(
gsm_byte
*
)
src
,
(
gsm_signal
*
)
dst
)
<
0
)
return
0
;
return
GSM_UNPACKED_FRAME_SIZE_IN_BYTES
;
}
virtual
int
codecEncode
(
unsigned
char
*
dst
,
short
*
src
,
unsigned
int
size
)
{
(
void
)
size
;
if
(
size
<
GSM_UNPACKED_FRAME_SIZE_IN_BYTES
)
return
0
;
//if (gsm_session_encode( gsm_signal*)src, (gsm_byte*)dst);
gsm_encode
(
_encode_gsmhandle
,
(
gsm_signal
*
)
src
,
(
gsm_byte
*
)
dst
);
return
33
;
return
GSM_PACKED_FRAME_SIZE_IN_BYTES
;
}
private
:
gsm
_decode_gsmhandle
;
gsm
_encode_gsmhandle
;
//void * _encode_state;
//void * _decode_state;
};
...
...
@@ -78,3 +118,4 @@ extern "C" AudioCodec* create() {
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