Skip to content
Snippets Groups Projects
Commit 6745c09a authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

remove warnings in iaxvoiplink, iaxcall

parent f8b2c9e1
Branches
Tags
No related merge requests found
...@@ -195,6 +195,10 @@ AlsaLayer::putUrgent(void* buffer, int toCopy) ...@@ -195,6 +195,10 @@ AlsaLayer::putUrgent(void* buffer, int toCopy)
int int
AlsaLayer::canGetMic() AlsaLayer::canGetMic()
{ {
_debug("alsa\n");
int avail; int avail;
if ( _CaptureHandle ) { if ( _CaptureHandle ) {
avail = snd_pcm_avail_update( _CaptureHandle ); avail = snd_pcm_avail_update( _CaptureHandle );
......
...@@ -199,6 +199,7 @@ PulseLayer::putUrgent(void* buffer, int toCopy) ...@@ -199,6 +199,7 @@ PulseLayer::putUrgent(void* buffer, int toCopy)
int int
PulseLayer::canGetMic() PulseLayer::canGetMic()
{ {
_debug("pulseaudio");
if( record ) if( record )
return _micRingBuffer.AvailForGet(); return _micRingBuffer.AvailForGet();
else else
......
...@@ -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]) {
......
...@@ -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) {
...@@ -250,12 +252,13 @@ IAXVoIPLink::sendAudioFromMic(void) ...@@ -250,12 +252,13 @@ IAXVoIPLink::sendAudioFromMic(void)
// Send sound here // Send sound here
if (audiolayer) { if (audiolayer) {
_debug("hum");
// 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);
// 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 +266,17 @@ IAXVoIPLink::sendAudioFromMic(void) ...@@ -263,17 +266,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 +485,8 @@ IAXVoIPLink::transfer(const CallID& id, const std::string& to) ...@@ -482,6 +485,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 +503,8 @@ IAXVoIPLink::refuse(const CallID& id) ...@@ -498,6 +503,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 +517,8 @@ IAXVoIPLink::carryingDTMFdigits(const CallID& id, char code) ...@@ -510,6 +517,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 +584,6 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) ...@@ -575,7 +584,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 +683,13 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) ...@@ -675,6 +683,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 +706,28 @@ IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call) ...@@ -691,28 +706,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);
......
...@@ -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; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment