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