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
018cee26
Commit
018cee26
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Plain Diff
Merge branch 'iax_warnings'
parents
98ffaab1
25a15c21
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/audiostream.cpp
+1
-1
1 addition, 1 deletion
src/audio/audiostream.cpp
src/iaxcall.cpp
+6
-4
6 additions, 4 deletions
src/iaxcall.cpp
src/iaxvoiplink.cpp
+48
-24
48 additions, 24 deletions
src/iaxvoiplink.cpp
src/iaxvoiplink.h
+4
-2
4 additions, 2 deletions
src/iaxvoiplink.h
with
59 additions
and
31 deletions
src/audio/audiostream.cpp
+
1
−
1
View file @
018cee26
...
@@ -28,7 +28,7 @@ AudioStream::AudioStream( pa_context* context, int type, std::string desc, doubl
...
@@ -28,7 +28,7 @@ AudioStream::AudioStream( pa_context* context, int type, std::string desc, doubl
sample_spec
.
rate
=
44100
;
sample_spec
.
rate
=
44100
;
sample_spec
.
channels
=
1
;
sample_spec
.
channels
=
1
;
channel_map
.
channels
=
1
;
channel_map
.
channels
=
1
;
pa_cvolume_set
(
&
_volume
,
1
,
PA_VOLUME_
MUTED
)
;
// * vol / 100 ;
pa_cvolume_set
(
&
_volume
,
1
,
PA_VOLUME_
NORM
)
;
// * vol / 100 ;
_audiostream
=
createStream
(
context
);
_audiostream
=
createStream
(
context
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/iaxcall.cpp
+
6
−
4
View file @
018cee26
...
@@ -55,9 +55,11 @@ IAXCall::setFormat(int format)
...
@@ -55,9 +55,11 @@ IAXCall::setFormat(int format)
int
int
IAXCall
::
getSupportedFormat
()
IAXCall
::
getSupportedFormat
()
{
{
CodecOrder
map
=
getCodecMap
().
getActiveCodecs
()
;
CodecOrder
map
;
int
format
=
0
;
int
format
=
0
;
int
iter
;
unsigned
int
iter
;
map
=
getCodecMap
().
getActiveCodecs
();
for
(
iter
=
0
;
iter
<
map
.
size
()
;
iter
++
){
for
(
iter
=
0
;
iter
<
map
.
size
()
;
iter
++
){
switch
(
map
[
iter
])
{
switch
(
map
[
iter
])
{
...
@@ -85,7 +87,7 @@ IAXCall::getFirstMatchingFormat(int needles)
...
@@ -85,7 +87,7 @@ IAXCall::getFirstMatchingFormat(int needles)
{
{
CodecOrder
map
=
getCodecMap
().
getActiveCodecs
();
CodecOrder
map
=
getCodecMap
().
getActiveCodecs
();
int
format
=
0
;
int
format
=
0
;
int
iter
;
unsigned
int
iter
;
for
(
iter
=
0
;
iter
<
map
.
size
()
;
iter
++
)
{
for
(
iter
=
0
;
iter
<
map
.
size
()
;
iter
++
)
{
switch
(
map
[
iter
])
{
switch
(
map
[
iter
])
{
...
...
This diff is collapsed.
Click to expand it.
src/iaxvoiplink.cpp
+
48
−
24
View file @
018cee26
...
@@ -216,6 +216,9 @@ IAXVoIPLink::getEvent()
...
@@ -216,6 +216,9 @@ IAXVoIPLink::getEvent()
void
void
IAXVoIPLink
::
sendAudioFromMic
(
void
)
IAXVoIPLink
::
sendAudioFromMic
(
void
)
{
{
int
maxBytesToGet
,
availBytesFromMic
,
bytesAvail
,
nbSample
,
compSize
;
AudioCodec
*
ac
;
IAXCall
*
currentCall
=
getIAXCall
(
Manager
::
instance
().
getCurrentCallId
());
IAXCall
*
currentCall
=
getIAXCall
(
Manager
::
instance
().
getCurrentCallId
());
if
(
!
currentCall
)
{
if
(
!
currentCall
)
{
...
@@ -226,7 +229,6 @@ IAXVoIPLink::sendAudioFromMic(void)
...
@@ -226,7 +229,6 @@ IAXVoIPLink::sendAudioFromMic(void)
if
(
currentCall
->
getAudioCodec
()
<
0
)
if
(
currentCall
->
getAudioCodec
()
<
0
)
return
;
return
;
// Just make sure the currentCall is in state to receive audio right now.
// Just make sure the currentCall is in state to receive audio right now.
//_debug("Here we get: connectionState: %d state: %d \n",
//_debug("Here we get: connectionState: %d state: %d \n",
// currentCall->getConnectionState(),
// currentCall->getConnectionState(),
...
@@ -237,7 +239,7 @@ IAXVoIPLink::sendAudioFromMic(void)
...
@@ -237,7 +239,7 @@ IAXVoIPLink::sendAudioFromMic(void)
return
;
return
;
}
}
AudioCodec
*
ac
=
currentCall
->
getCodecMap
().
getCodec
(
currentCall
->
getAudioCodec
()
);
ac
=
currentCall
->
getCodecMap
().
getCodec
(
currentCall
->
getAudioCodec
()
);
if
(
!
ac
)
{
if
(
!
ac
)
{
// Audio codec still not determined.
// Audio codec still not determined.
if
(
audiolayer
)
{
if
(
audiolayer
)
{
...
@@ -252,10 +254,15 @@ IAXVoIPLink::sendAudioFromMic(void)
...
@@ -252,10 +254,15 @@ IAXVoIPLink::sendAudioFromMic(void)
// we have to get 20ms of data from the mic *20/1000 = /50
// we have to get 20ms of data from the mic *20/1000 = /50
// rate/50 shall be lower than IAX__20S_48KHZ_MAX
// rate/50 shall be lower than IAX__20S_48KHZ_MAX
int
maxBytesToGet
=
audiolayer
->
getSampleRate
()
*
audiolayer
->
getFrameSize
()
/
1000
*
sizeof
(
SFLDataFormat
);
maxBytesToGet
=
audiolayer
->
getSampleRate
()
*
audiolayer
->
getFrameSize
()
/
1000
*
sizeof
(
SFLDataFormat
);
// We have to update the audio layer type in case we switched
// TODO Find out a better way to do it
updateAudiolayer
();
// available bytes inside ringbuffer
// available bytes inside ringbuffer
int
availBytesFromMic
=
audiolayer
->
canGetMic
();
availBytesFromMic
=
audiolayer
->
canGetMic
();
if
(
availBytesFromMic
<
maxBytesToGet
)
{
if
(
availBytesFromMic
<
maxBytesToGet
)
{
// We need packets full!
// We need packets full!
...
@@ -263,17 +270,17 @@ IAXVoIPLink::sendAudioFromMic(void)
...
@@ -263,17 +270,17 @@ IAXVoIPLink::sendAudioFromMic(void)
}
}
// take the lowest
// take the lowest
int
bytesAvail
=
(
availBytesFromMic
<
maxBytesToGet
)
?
availBytesFromMic
:
maxBytesToGet
;
bytesAvail
=
(
availBytesFromMic
<
maxBytesToGet
)
?
availBytesFromMic
:
maxBytesToGet
;
//_debug("available = %d, maxBytesToGet = %d\n", availBytesFromMic, maxBytesToGet);
//_debug("available = %d, maxBytesToGet = %d\n", availBytesFromMic, maxBytesToGet);
// Get bytes from micRingBuffer to data_from_mic
// Get bytes from micRingBuffer to data_from_mic
int
nbSample
=
audiolayer
->
getMic
(
micData
,
bytesAvail
)
/
sizeof
(
SFLDataFormat
);
nbSample
=
audiolayer
->
getMic
(
micData
,
bytesAvail
)
/
sizeof
(
SFLDataFormat
);
// resample
// resample
nbSample
=
converter
->
downsampleData
(
micData
,
micDataConverted
,
(
int
)
ac
->
getClockRate
()
,
(
int
)
audiolayer
->
getSampleRate
()
,
nbSample
);
nbSample
=
converter
->
downsampleData
(
micData
,
micDataConverted
,
(
int
)
ac
->
getClockRate
()
,
(
int
)
audiolayer
->
getSampleRate
()
,
nbSample
);
// for the mono: range = 0 to IAX_FRAME2SEND * sizeof(int16)
// for the mono: range = 0 to IAX_FRAME2SEND * sizeof(int16)
int
compSize
=
ac
->
codecEncode
(
micDataEncoded
,
micDataConverted
,
nbSample
*
sizeof
(
int16
));
compSize
=
ac
->
codecEncode
(
micDataEncoded
,
micDataConverted
,
nbSample
*
sizeof
(
int16
));
// Send it out!
// Send it out!
_mutexIAX
.
enterMutex
();
_mutexIAX
.
enterMutex
();
...
@@ -482,6 +489,8 @@ IAXVoIPLink::transfer(const CallID& id, const std::string& to)
...
@@ -482,6 +489,8 @@ IAXVoIPLink::transfer(const CallID& id, const std::string& to)
iax_transfer
(
call
->
getSession
(),
callto
);
iax_transfer
(
call
->
getSession
(),
callto
);
_mutexIAX
.
leaveMutex
();
_mutexIAX
.
leaveMutex
();
return
true
;
// should we remove it?
// should we remove it?
// removeCall(id);
// removeCall(id);
}
}
...
@@ -498,6 +507,8 @@ IAXVoIPLink::refuse(const CallID& id)
...
@@ -498,6 +507,8 @@ IAXVoIPLink::refuse(const CallID& id)
iax_reject
(
call
->
getSession
(),
(
char
*
)
reason
.
c_str
());
iax_reject
(
call
->
getSession
(),
(
char
*
)
reason
.
c_str
());
_mutexIAX
.
leaveMutex
();
_mutexIAX
.
leaveMutex
();
removeCall
(
id
);
removeCall
(
id
);
return
true
;
}
}
bool
bool
...
@@ -510,6 +521,8 @@ IAXVoIPLink::carryingDTMFdigits(const CallID& id, char code)
...
@@ -510,6 +521,8 @@ IAXVoIPLink::carryingDTMFdigits(const CallID& id, char code)
_mutexIAX
.
enterMutex
();
_mutexIAX
.
enterMutex
();
iax_send_dtmf
(
call
->
getSession
(),
code
);
iax_send_dtmf
(
call
->
getSession
(),
code
);
_mutexIAX
.
leaveMutex
();
_mutexIAX
.
leaveMutex
();
return
true
;
}
}
...
@@ -575,7 +588,6 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
...
@@ -575,7 +588,6 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
// note activity?
// note activity?
//
//
CallID
id
=
call
->
getCallId
();
CallID
id
=
call
->
getCallId
();
int16
*
output
=
0
;
// for audio output
switch
(
event
->
etype
)
{
switch
(
event
->
etype
)
{
case
IAX_EVENT_HANGUP
:
case
IAX_EVENT_HANGUP
:
...
@@ -675,6 +687,13 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
...
@@ -675,6 +687,13 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
void
void
IAXVoIPLink
::
iaxHandleVoiceEvent
(
iax_event
*
event
,
IAXCall
*
call
)
IAXVoIPLink
::
iaxHandleVoiceEvent
(
iax_event
*
event
,
IAXCall
*
call
)
{
{
unsigned
char
*
data
;
unsigned
int
size
,
max
,
nbInt16
;
int
expandedSize
,
nbSample
;
AudioCodec
*
ac
;
// If we receive datalen == 0, some things of the jitter buffer in libiax2/iax.c
// If we receive datalen == 0, some things of the jitter buffer in libiax2/iax.c
// were triggered
// were triggered
if
(
!
event
->
datalen
)
{
if
(
!
event
->
datalen
)
{
...
@@ -691,28 +710,28 @@ IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call)
...
@@ -691,28 +710,28 @@ IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call)
call
->
setFormat
(
event
->
subclass
);
call
->
setFormat
(
event
->
subclass
);
}
}
//_debug("Receive: len=%d, format=%d, _receiveDataDecoded=%p\n", event->datalen, call->getFormat(), _receiveDataDecoded);
//_debug("Receive: len=%d, format=%d, _receiveDataDecoded=%p\n", event->datalen, call->getFormat(), _receiveDataDecoded);
AudioCodec
*
ac
=
call
->
getCodecMap
().
getCodec
(
call
->
getAudioCodec
()
);
ac
=
call
->
getCodecMap
().
getCodec
(
call
->
getAudioCodec
()
);
unsigned
char
*
data
=
(
unsigned
char
*
)
event
->
data
;
data
=
(
unsigned
char
*
)
event
->
data
;
unsigned
int
size
=
event
->
datalen
;
size
=
event
->
datalen
;
// Decode data with relevant codec
// Decode data with relevant codec
int
max
=
(
int
)(
ac
->
getClockRate
()
*
audiolayer
->
getFrameSize
()
/
1000
);
max
=
(
int
)(
ac
->
getClockRate
()
*
audiolayer
->
getFrameSize
()
/
1000
);
if
(
size
>
max
)
{
if
(
size
>
max
)
{
_debug
(
"The size %d is bigger than expected %d. Packet cropped. Ouch!
\n
"
,
size
,
max
);
_debug
(
"The size %d is bigger than expected %d. Packet cropped. Ouch!
\n
"
,
size
,
max
);
size
=
max
;
size
=
max
;
}
}
int
expandedSize
=
ac
->
codecDecode
(
spkrDataDecoded
,
data
,
size
);
expandedSize
=
ac
->
codecDecode
(
spkrDataDecoded
,
data
,
size
);
int
nbInt16
=
expandedSize
/
sizeof
(
int16
);
nbInt16
=
expandedSize
/
sizeof
(
int16
);
if
(
nbInt16
>
max
)
{
if
(
nbInt16
>
max
)
{
_debug
(
"We have decoded an IAX VOICE packet larger than expected: %
s
VS %
s
. Cropping.
\n
"
,
nbInt16
,
max
);
_debug
(
"We have decoded an IAX VOICE packet larger than expected: %
i
VS %
i
. Cropping.
\n
"
,
nbInt16
,
max
);
nbInt16
=
max
;
nbInt16
=
max
;
}
}
int
nbSample
=
nbInt16
;
nbSample
=
nbInt16
;
// resample
// resample
nbInt16
=
converter
->
upsampleData
(
spkrDataDecoded
,
spkrDataConverted
,
ac
->
getClockRate
()
,
audiolayer
->
getSampleRate
()
,
nbSample
);
nbInt16
=
converter
->
upsampleData
(
spkrDataDecoded
,
spkrDataConverted
,
ac
->
getClockRate
()
,
audiolayer
->
getSampleRate
()
,
nbSample
);
...
@@ -872,3 +891,8 @@ IAXVoIPLink::iaxCodecMapToFormat(IAXCall* call)
...
@@ -872,3 +891,8 @@ IAXVoIPLink::iaxCodecMapToFormat(IAXCall* call)
}
}
void
IAXVoIPLink
::
updateAudiolayer
(
void
)
{
audiolayer
=
NULL
;
audiolayer
=
Manager
::
instance
().
getAudioDriver
();
}
This diff is collapsed.
Click to expand it.
src/iaxvoiplink.h
+
4
−
2
View file @
018cee26
...
@@ -124,7 +124,7 @@ class IAXVoIPLink : public VoIPLink
...
@@ -124,7 +124,7 @@ class IAXVoIPLink : public VoIPLink
* @return bool true on success
* @return bool true on success
* false otherwise
* false otherwise
*/
*/
bool
cancel
(
const
CallID
&
id
)
{
return
false
;
}
bool
cancel
(
const
CallID
&
id
UNUSED
)
{
return
false
;
}
/**
/**
* Put a call on hold
* Put a call on hold
...
@@ -168,7 +168,7 @@ class IAXVoIPLink : public VoIPLink
...
@@ -168,7 +168,7 @@ class IAXVoIPLink : public VoIPLink
*/
*/
bool
carryingDTMFdigits
(
const
CallID
&
id
,
char
code
);
bool
carryingDTMFdigits
(
const
CallID
&
id
,
char
code
);
bool
sendMessage
(
const
std
::
string
&
to
,
const
std
::
string
&
body
)
{
return
false
;
}
bool
sendMessage
(
const
std
::
string
&
to
UNUSED
,
const
std
::
string
&
body
UNUSED
)
{
return
false
;
}
bool
isContactPresenceSupported
()
{
return
false
;
}
bool
isContactPresenceSupported
()
{
return
false
;
}
...
@@ -188,6 +188,8 @@ class IAXVoIPLink : public VoIPLink
...
@@ -188,6 +188,8 @@ class IAXVoIPLink : public VoIPLink
*/
*/
void
setPass
(
const
std
::
string
&
pass
)
{
_pass
=
pass
;
}
void
setPass
(
const
std
::
string
&
pass
)
{
_pass
=
pass
;
}
void
updateAudiolayer
(
void
);
private
:
private
:
/**
/**
* Get IAX Call from an id
* Get IAX Call from an id
...
...
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