Skip to content
Snippets Groups Projects
Commit 4b565bec authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2176] Fix fix audio stream binding in iax

parent d055eea4
No related branches found
No related tags found
No related merge requests found
...@@ -271,6 +271,8 @@ IAXVoIPLink::sendAudioFromMic (void) ...@@ -271,6 +271,8 @@ IAXVoIPLink::sendAudioFromMic (void)
AudioCodec *ac; AudioCodec *ac;
IAXCall *currentCall; IAXCall *currentCall;
// We have to update the audio layer type in case we switched // We have to update the audio layer type in case we switched
// TODO Find out a better way to do it // TODO Find out a better way to do it
updateAudiolayer(); updateAudiolayer();
...@@ -278,10 +280,14 @@ IAXVoIPLink::sendAudioFromMic (void) ...@@ -278,10 +280,14 @@ IAXVoIPLink::sendAudioFromMic (void)
currentCall = getIAXCall (Manager::instance().getCurrentCallId()); currentCall = getIAXCall (Manager::instance().getCurrentCallId());
if (!currentCall) { if (!currentCall) {
// Let's mind our own business. // Let's mind our own business.
return; return;
} }
if (currentCall -> getAudioCodec() < 0) if (currentCall -> getAudioCodec() < 0)
return; return;
...@@ -307,9 +313,13 @@ IAXVoIPLink::sendAudioFromMic (void) ...@@ -307,9 +313,13 @@ IAXVoIPLink::sendAudioFromMic (void)
return; return;
} }
// Send sound here // Send sound here
if (audiolayer) { if (audiolayer) {
// 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
maxBytesToGet = audiolayer->getSampleRate() * audiolayer->getFrameSize() / 1000 * sizeof (SFLDataFormat); maxBytesToGet = audiolayer->getSampleRate() * audiolayer->getFrameSize() / 1000 * sizeof (SFLDataFormat);
...@@ -330,6 +340,8 @@ IAXVoIPLink::sendAudioFromMic (void) ...@@ -330,6 +340,8 @@ IAXVoIPLink::sendAudioFromMic (void)
// Get bytes from micRingBuffer to data_from_mic // Get bytes from micRingBuffer to data_from_mic
nbSample_ = audiolayer->getMainBuffer()->getData (micData, bytesAvail, 100, currentCall->getCallId()) / sizeof (SFLDataFormat); nbSample_ = audiolayer->getMainBuffer()->getData (micData, bytesAvail, 100, currentCall->getCallId()) / sizeof (SFLDataFormat);
// Store the number of samples for recording // Store the number of samples for recording
nbSampleForRec_ = nbSample_; nbSampleForRec_ = nbSample_;
...@@ -526,6 +538,7 @@ IAXVoIPLink::peerHungup (const CallID& id) ...@@ -526,6 +538,7 @@ IAXVoIPLink::peerHungup (const CallID& id)
IAXCall* call = getIAXCall (id); IAXCall* call = getIAXCall (id);
std::string reason = "Dumped Call"; std::string reason = "Dumped Call";
CHK_VALID_CALL; CHK_VALID_CALL;
_mutexIAX.enterMutex(); _mutexIAX.enterMutex();
_mutexIAX.leaveMutex(); _mutexIAX.leaveMutex();
...@@ -769,6 +782,9 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call) ...@@ -769,6 +782,9 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call)
case IAX_EVENT_ANSWER: case IAX_EVENT_ANSWER:
if (call->getConnectionState() != Call::Connected) { if (call->getConnectionState() != Call::Connected) {
Manager::instance().addStream(call->getCallId());
call->setConnectionState (Call::Connected); call->setConnectionState (Call::Connected);
call->setState (Call::Active); call->setState (Call::Active);
audiolayer->startStream(); audiolayer->startStream();
...@@ -850,6 +866,8 @@ IAXVoIPLink::iaxHandleVoiceEvent (iax_event* event, IAXCall* call) ...@@ -850,6 +866,8 @@ IAXVoIPLink::iaxHandleVoiceEvent (iax_event* event, IAXCall* call)
int expandedSize, nbSample_; int expandedSize, nbSample_;
AudioCodec *ac; 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
...@@ -860,6 +878,7 @@ IAXVoIPLink::iaxHandleVoiceEvent (iax_event* event, IAXCall* call) ...@@ -860,6 +878,7 @@ IAXVoIPLink::iaxHandleVoiceEvent (iax_event* event, IAXCall* call)
} }
if (audiolayer) { if (audiolayer) {
// On-the-fly codec changing (normally, when we receive a full packet) // On-the-fly codec changing (normally, when we receive a full packet)
// as per http://tools.ietf.org/id/draft-guy-iax-03.txt // as per http://tools.ietf.org/id/draft-guy-iax-03.txt
// - subclass holds the voiceformat property. // - subclass holds the voiceformat property.
...@@ -1000,6 +1019,8 @@ IAXVoIPLink::iaxHandlePrecallEvent (iax_event* event) ...@@ -1000,6 +1019,8 @@ IAXVoIPLink::iaxHandlePrecallEvent (iax_event* event)
id = Manager::instance().getNewCallID(); id = Manager::instance().getNewCallID();
_debug("-------------------------------------------------------------- callid %s", id.c_str());
call = new IAXCall (id, Call::Incoming); call = new IAXCall (id, Call::Incoming);
if (!call) { if (!call) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment