Update vocoder data transfers in both directions. @param transaction The transaction object for this call. @param TCH The traffic channel for this call. @return bytes transferred. */
| 701 | @return bytes transferred. |
| 702 | */ |
| 703 | static unsigned newUpdateCallTraffic(TranEntry *transaction, GSM::TCHFACCHLogicalChannel *TCH) |
| 704 | { |
| 705 | // We dont set the state Active until both SIP dialog and MS side have acked. |
| 706 | LOG(DEBUG); |
| 707 | if (transaction->getGSMState() != CCState::Active) { return false; } |
| 708 | unsigned activity = 0; |
| 709 | |
| 710 | // Both the rx and tx directions block if rtp_session_set_blocking_mode() is true. |
| 711 | |
| 712 | // Transfer in the uplink direction (GSM->RTP). |
| 713 | // Flush FIFO to limit latency. |
| 714 | unsigned numFlushed = 0; |
| 715 | { |
| 716 | unsigned maxQ = gConfig.getNum("GSM.MaxSpeechLatency"); |
| 717 | static Timeval testTimeStart; |
| 718 | while (TCH->queueSize()>maxQ) { |
| 719 | if (numFlushed == 0) testTimeStart.now(); |
| 720 | numFlushed++; |
| 721 | // (pat) LOG is too slow to call in here. With 1000 backed up the delay is 1/2 sec. |
| 722 | //LOG(DEBUG) <<TCH <<" ulFrame flushed"<<LOGVAR(TCH->queueSize()); |
| 723 | delete TCH->recvTCH(); |
| 724 | } |
| 725 | if (numFlushed) { LOG(DEBUG) <<TCH <<" ulFrame flushed "<<numFlushed <<" in "<<testTimeStart.elapsed() << " msecs"; } |
| 726 | } |
| 727 | if (GSM::AudioFrame *ulFrame = TCH->recvTCH()) { |
| 728 | activity += ulFrame->sizeBytes(); |
| 729 | // Send on RTP. |
| 730 | LOG(DEBUG) <<TCH <<LOGVAR(*ulFrame); |
| 731 | transaction->txFrame(ulFrame,numFlushed); |
| 732 | delete ulFrame; |
| 733 | } |
| 734 | |
| 735 | // Transfer in the downlink direction (RTP->GSM). |
| 736 | // Blocking call. On average returns 1 time per 20 ms. |
| 737 | // Returns non-zero if anything really happened. |
| 738 | // Make the rxFrame buffer big enough for G.711. |
| 739 | if (GSM::AudioFrame *dlFrame = transaction->rxFrame()) { |
| 740 | activity += dlFrame->sizeBytes(); |
| 741 | if (activity == 0) { activity++; } // Make sure we signal activity. |
| 742 | LOG(DEBUG) <<TCH <<LOGVAR(*dlFrame); |
| 743 | TCH->sendTCH(dlFrame); |
| 744 | } |
| 745 | |
| 746 | // Return a flag so the caller will know if anything transferred. |
| 747 | LOG(DEBUG) <<LOGVAR(activity); |
| 748 | return activity; |
| 749 | } |
| 750 | |
| 751 | // Check for any message or timer activity on this channel. Return true if something happened. |
| 752 | // The delay is how often we poll, used on SDCCH. |
no test coverage detected