mirror of
https://github.com/danog/libtgvoip.git
synced 2024-11-30 04:39:03 +01:00
Increase packet buffer pool size
This commit is contained in:
parent
d876d08313
commit
b09ce7f5e4
@ -12,7 +12,7 @@
|
||||
using namespace tgvoip;
|
||||
|
||||
BufferPool::BufferPool(unsigned int size, unsigned int count){
|
||||
assert(count<=64);
|
||||
assert(count<=1024);
|
||||
init_mutex(mutex);
|
||||
buffers[0]=(unsigned char*) malloc(size*count);
|
||||
bufferCount=count;
|
||||
|
@ -24,7 +24,7 @@ private:
|
||||
uint64_t usedBuffers;
|
||||
int bufferCount;
|
||||
size_t size;
|
||||
unsigned char* buffers[64];
|
||||
unsigned char* buffers[1024];
|
||||
tgvoip_mutex_t mutex;
|
||||
};
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ void tgvoip::OpusEncoder::Encode(unsigned char *data, size_t len){
|
||||
}else if(r==1){
|
||||
LOGW("DTX");
|
||||
}else if(running){
|
||||
//LOGV("Packet size = %d", r);
|
||||
InvokeCallback(buffer, (size_t)r);
|
||||
//LOGV("OPUS Packet size = %d", r);
|
||||
InvokeCallback(buffer, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ VoIPController::VoIPController() : activeNetItfName(""),
|
||||
proxyAddress(""),
|
||||
proxyUsername(""),
|
||||
proxyPassword(""),
|
||||
outgoingPacketsBufferPool(1024, 64){
|
||||
outgoingPacketsBufferPool(1024, 1024){
|
||||
seq=1;
|
||||
lastRemoteSeq=0;
|
||||
state=STATE_WAIT_INIT;
|
||||
@ -267,7 +267,7 @@ VoIPController::VoIPController() : activeNetItfName(""),
|
||||
stm->type=STREAM_TYPE_AUDIO;
|
||||
stm->codec=CODEC_OPUS;
|
||||
stm->enabled=1;
|
||||
stm->frameDuration=60;
|
||||
stm->frameDuration=60; //ServerConfig::GetSharedInstance()->GetInt("audio_frame_size", 100);
|
||||
outgoingStreams.push_back(stm);
|
||||
|
||||
memset(signalBarsHistory, 0, sizeof(signalBarsHistory));
|
||||
@ -414,7 +414,7 @@ void* VoIPController::StartTickThread(void* controller){
|
||||
|
||||
void VoIPController::Start(){
|
||||
int res;
|
||||
LOGW("Starting voip controller");
|
||||
LOGW("========= Starting voip controller =========");
|
||||
int32_t cfgFrameSize=60; //ServerConfig::GetSharedInstance()->GetInt("audio_frame_size", 60);
|
||||
if(cfgFrameSize==20 || cfgFrameSize==40 || cfgFrameSize==60)
|
||||
outgoingStreams[0]->frameDuration=(uint16_t) cfgFrameSize;
|
||||
@ -450,6 +450,7 @@ void VoIPController::HandleAudioInput(unsigned char *data, size_t len){
|
||||
LOGV("waiting for RLC, dropping outgoing audio packet");
|
||||
return;
|
||||
}
|
||||
//LOGE("GOT PACKET OF SIZE %i", len);
|
||||
|
||||
unsigned char* buf=outgoingPacketsBufferPool.Get();
|
||||
if(buf){
|
||||
@ -472,6 +473,8 @@ void VoIPController::HandleAudioInput(unsigned char *data, size_t len){
|
||||
/*.endpoint=*/NULL,
|
||||
};
|
||||
sendQueue->Put(p);
|
||||
} else {
|
||||
LOGE("============ COULD NOT GET BUFFER ========");
|
||||
}
|
||||
|
||||
audioTimestampOut+=outgoingStreams[0]->frameDuration;
|
||||
@ -700,7 +703,6 @@ void VoIPController::RunRecvThread(){
|
||||
readSockets.push_back(realUdpSocket);
|
||||
errorSockets.push_back(realUdpSocket);
|
||||
|
||||
//if(useTCP){
|
||||
for(std::vector<Endpoint*>::iterator itr=endpoints.begin();itr!=endpoints.end();++itr){
|
||||
if((*itr)->type==EP_TYPE_TCP_RELAY){
|
||||
if((*itr)->socket){
|
||||
@ -709,7 +711,6 @@ void VoIPController::RunRecvThread(){
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
bool selRes=NetworkSocket::Select(readSockets, errorSockets, selectCanceller);
|
||||
if(!selRes){
|
||||
@ -790,13 +791,13 @@ void VoIPController::RunRecvThread(){
|
||||
stats.bytesRecvdMobile+=(uint64_t)len;
|
||||
else
|
||||
stats.bytesRecvdWifi+=(uint64_t)len;
|
||||
BufferInputStream in(buffer, (size_t)len);
|
||||
try{
|
||||
if(memcmp(buffer, srcEndpoint->type==EP_TYPE_UDP_RELAY || srcEndpoint->type==EP_TYPE_TCP_RELAY ? (void*)srcEndpoint->peerTag : (void*)callID, 16)!=0){
|
||||
LOGW("Received packet has wrong peerTag");
|
||||
|
||||
continue;
|
||||
}
|
||||
BufferInputStream in(buffer, (size_t)len);
|
||||
in.Seek(16);
|
||||
if(in.Remaining()>=16 && (srcEndpoint->type==EP_TYPE_UDP_RELAY || srcEndpoint->type==EP_TYPE_TCP_RELAY)
|
||||
&& *reinterpret_cast<uint64_t*>(buffer+16)==0xFFFFFFFFFFFFFFFFLL && *reinterpret_cast<uint32_t*>(buffer+24)==0xFFFFFFFF){
|
||||
@ -811,7 +812,7 @@ void VoIPController::RunRecvThread(){
|
||||
unsigned char myIP[16];
|
||||
in.ReadBytes(myIP, 16);
|
||||
int32_t myPort=in.ReadInt32();
|
||||
udpConnectivityState=UDP_AVAILABIE;
|
||||
udpConnectivityState=UDP_AVAILABLE;
|
||||
//LOGV("Received UDP ping reply from %s:%d: date=%d, queryID=%lld, my IP=%s, my port=%d", srcEndpoint->address.ToString().c_str(), srcEndpoint->port, date, queryID, IPv6Address(myIP).ToString().c_str(), myPort);
|
||||
}
|
||||
}else if(tlid==TLID_UDP_REFLECTOR_PEER_INFO){
|
||||
@ -1808,6 +1809,7 @@ void VoIPController::SendPacket(unsigned char *data, size_t len, Endpoint* ep){
|
||||
stats.bytesSentWifi+=(uint64_t)out.GetLength();
|
||||
|
||||
NetworkPacket pkt;
|
||||
//LOGE("WILL SEND PACKET OF SIZE %i", out.GetLength());
|
||||
pkt.address=(NetworkAddress*)&ep->address;
|
||||
pkt.port=ep->port;
|
||||
pkt.length=out.GetLength();
|
||||
|
@ -355,7 +355,7 @@ private:
|
||||
enum{
|
||||
UDP_UNKNOWN=0,
|
||||
UDP_PING_SENT,
|
||||
UDP_AVAILABIE,
|
||||
UDP_AVAILABLE,
|
||||
UDP_NOT_AVAILABLE
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user