"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/h460/h46026mgr.cxx" between
h323plus-1_26_9.tar.gz and h323plus-1_27_0.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

h46026mgr.cxx  (h323plus-1_26_9):h46026mgr.cxx  (h323plus-1_27_0)
skipping to change at line 198 skipping to change at line 198
case RTP_Session::DefaultAudioSessionID: return "Audio"; case RTP_Session::DefaultAudioSessionID: return "Audio";
case RTP_Session::DefaultVideoSessionID: return "Video"; case RTP_Session::DefaultVideoSessionID: return "Video";
case RTP_Session::DefaultH224SessionID: return "Data"; case RTP_Session::DefaultH224SessionID: return "Data";
default: return "Generic"; default: return "Generic";
} }
} }
static PString H46026MediaFrameAnalysis(const H46026_UDPFrame & data) static PString H46026MediaFrameAnalysis(const H46026_UDPFrame & data)
{ {
PStringStream rtpInfo; PStringStream rtpInfo;
for (PINDEX i=0; i < data.m_frame.GetSize(); ++i) { for (PINDEX i = 0; i < data.m_frame.GetSize(); ++i) {
H46026_FrameData & frame = data.m_frame[i]; H46026_FrameData & frame = data.m_frame[i];
PASN_OctetString & fdata = frame; PASN_OctetString & fdata = frame;
H46026_MediaFrame & rtpData = (H46026_MediaFrame &)fdata.GetValue(); H46026_MediaFrame & rtpData = (H46026_MediaFrame &)fdata.GetValue();
rtpInfo << "[" << i << "] "; rtpInfo << "[" << i << "] ";
rtpData.PrintInfo(rtpInfo); rtpData.PrintInfo(rtpInfo);
} }
return rtpInfo; return rtpInfo;
} }
//------------------------------------------- //-------------------------------------------
H46026UDPBuffer::H46026UDPBuffer(int sessionId, PBoolean rtp) H46026UDPBuffer::H46026UDPBuffer(int sessionId, PBoolean rtp)
{ {
m_size = 0; m_size = 0;
m_rtp = rtp; m_rtp = rtp;
m_data.m_sessionId.SetValue(sessionId); m_data.m_sessionId.SetValue(sessionId);
m_data.m_dataFrame = m_rtp ? true : false; m_data.m_dataFrame = m_rtp;
m_data.m_frame.SetSize(0); m_data.m_frame.SetSize(0);
} }
H46026_ArrayOf_FrameData & H46026UDPBuffer::GetData() H46026_ArrayOf_FrameData & H46026UDPBuffer::GetData()
{ {
return m_data.m_frame; return m_data.m_frame;
} }
void H46026UDPBuffer::SetFrame(const PBYTEArray & data) void H46026UDPBuffer::SetFrame(const PBYTEArray & data)
{ {
skipping to change at line 264 skipping to change at line 264
//------------------------------------------- //-------------------------------------------
H46026_MediaFrame::H46026_MediaFrame() H46026_MediaFrame::H46026_MediaFrame()
:PBYTEArray(12) :PBYTEArray(12)
{ {
} }
H46026_MediaFrame::H46026_MediaFrame(const BYTE * data, PINDEX len) H46026_MediaFrame::H46026_MediaFrame(const BYTE * data, PINDEX len)
:PBYTEArray(data,len) : PBYTEArray(data, len)
{ {
} }
PBoolean H46026_MediaFrame::GetMarker() const PBoolean H46026_MediaFrame::GetMarker() const
{ {
return (theArray[1]&0x80) != 0; return (theArray[1]&0x80) != 0;
} }
void H46026_MediaFrame::PrintInfo(ostream & strm) const void H46026_MediaFrame::PrintInfo(ostream & strm) const
{ {
strm << "ver=" << (unsigned)((theArray[0]>>6)&3) strm << "ver=" << (unsigned)((theArray[0]>>6)&3)
<< " pt=" << (unsigned)(theArray[1]&0x7f) << " pt=" << (unsigned)(theArray[1]&0x7f)
<< " psz=" << (unsigned)(GetSize() - 12) << " psz=" << (unsigned)(GetSize() - 12)
<< " m=" << GetMarker() << " m=" << GetMarker()
<< " x=" << (unsigned)((theArray[0]&0x10) != 0) << " x=" << (unsigned)((theArray[0]&0x10) != 0)
<< " seq=" << (WORD)(*(PUInt16b *)&theArray[2]) << " seq=" << (WORD)(*(PUInt16b *)&theArray[2])
<< " ts=" << (DWORD)(*(PUInt32b *)&theArray[4]) << " ts=" << (DWORD)(*(PUInt32b *)&theArray[4])
<< " src=" << (DWORD)(*(PUInt32b *)&theArray[8]) << " src=" << (DWORD)(*(PUInt32b *)&theArray[8])
<< " ccnt=" << (unsigned)(theArray[0]&0xf) << " ccnt=" << (unsigned)(theArray[0]&0xf)
<< "\n"; << "\n";
} }
//------------------------------------------- //-------------------------------------------
H46026ChannelManager::H46026ChannelManager() H46026ChannelManager::H46026ChannelManager()
: m_mbps(MAX_VIDEO_KBPS), m_socketPacketReady(false), m_currentPacketTime(0), m _pktCounter(0) : m_mbps(MAX_VIDEO_KBPS), m_socketPacketReady(false), m_currentPacketTime(0), m _pktCounter(0)
{ {
// Initialise the Information PDU RTP Message structure. // Initialise the Information PDU RTP Message structure.
H225_H323_UU_PDU & info = m_uuie.m_h323_uu_pdu; H225_H323_UU_PDU & info = m_uuie.m_h323_uu_pdu;
info.IncludeOptionalField(H225_H323_UU_PDU::e_genericData); info.IncludeOptionalField(H225_H323_UU_PDU::e_genericData);
info.m_genericData.SetSize(1); info.m_genericData.SetSize(1);
H225_GenericData & gen = m_uuie.m_h323_uu_pdu.m_genericData[0]; H225_GenericData & gen = m_uuie.m_h323_uu_pdu.m_genericData[0];
H225_GenericIdentifier & id = gen.m_id; H225_GenericIdentifier & id = gen.m_id;
id.SetTag(H225_GenericIdentifier::e_standard); id.SetTag(H225_GenericIdentifier::e_standard);
PASN_Integer & asnInt = id; PASN_Integer & asnInt = id;
asnInt.SetValue(26); asnInt.SetValue(26);
gen.IncludeOptionalField(H225_GenericData::e_parameters); gen.IncludeOptionalField(H225_GenericData::e_parameters);
gen.m_parameters.SetSize(1); gen.m_parameters.SetSize(1);
skipping to change at line 351 skipping to change at line 351
} }
PBoolean H46026ChannelManager::SignalMsgOut(const Q931 & pdu) PBoolean H46026ChannelManager::SignalMsgOut(const Q931 & pdu)
{ {
socketOrder::MessageHeader prior; socketOrder::MessageHeader prior;
prior.id = NextPacketCounter(); prior.id = NextPacketCounter();
prior.sessionId = 0; prior.sessionId = 0;
prior.crv = pdu.GetCallReference(); prior.crv = pdu.GetCallReference();
prior.priority = socketOrder::Priority_High; prior.priority = socketOrder::Priority_High;
prior.packTime = PTimer::Tick().GetMilliSeconds(); prior.packTime = PTimer::Tick().GetMilliSeconds();
prior.delay = PACKETDELAY(pdu.GetIE(Q931::UserUserIE).GetSize(),m_mbps); prior.delay = PACKETDELAY(pdu.GetIE(Q931::UserUserIE).GetSize(), m_mbps);
return WriteQueue(pdu, prior); return WriteQueue(pdu, prior);
} }
PBoolean H46026ChannelManager::SignalMsgOut(const BYTE * data, PINDEX len) PBoolean H46026ChannelManager::SignalMsgOut(const BYTE * data, PINDEX len)
{ {
PBYTEArray msg(data,len); PBYTEArray msg(data,len);
socketOrder::MessageHeader prior; socketOrder::MessageHeader prior;
prior.id = NextPacketCounter(); prior.id = NextPacketCounter();
prior.sessionId = 0; prior.sessionId = 0;
prior.crv = 0; prior.crv = 0;
prior.priority = socketOrder::Priority_High; prior.priority = socketOrder::Priority_High;
prior.packTime = PTimer::Tick().GetMilliSeconds(); prior.packTime = PTimer::Tick().GetMilliSeconds();
prior.delay = PACKETDELAY(len,m_mbps); prior.delay = PACKETDELAY(len, m_mbps);
return WriteQueue(msg, prior); return WriteQueue(msg, prior);
} }
H46026UDPBuffer * H46026ChannelManager::GetRTPBuffer(unsigned crv, int sessionId ) H46026UDPBuffer * H46026ChannelManager::GetRTPBuffer(unsigned crv, int sessionId )
{ {
H46026RTPBuffer::iterator r = m_rtpBuffer.find(crv); H46026RTPBuffer::iterator r = m_rtpBuffer.find(crv);
if (r != m_rtpBuffer.end()) { if (r != m_rtpBuffer.end()) {
H46026CallMap::iterator c = r->second.find(sessionId); H46026CallMap::iterator c = r->second.find(sessionId);
if (c != r->second.end()) if (c != r->second.end())
return c->second; return c->second;
} }
m_rtpBuffer[crv][sessionId] = new H46026UDPBuffer(sessionId,true); m_rtpBuffer[crv][sessionId] = new H46026UDPBuffer(sessionId, true);
return m_rtpBuffer[crv][sessionId]; return m_rtpBuffer[crv][sessionId];
} }
PBoolean H46026ChannelManager::PackageFrame(PBoolean rtp, unsigned crv, PacketTy pes id, PINDEX sessionId, H46026_UDPFrame & data) PBoolean H46026ChannelManager::PackageFrame(PBoolean rtp, unsigned crv, PacketTy pes id, PINDEX sessionId, H46026_UDPFrame & data)
{ {
// Build Packet // Build Packet
Q931 mediaPDU; Q931 mediaPDU;
BuildRTPFrame(mediaPDU, m_uuie, crv, data); BuildRTPFrame(mediaPDU, m_uuie, crv, data);
// Set metadata // Set metadata
skipping to change at line 407 skipping to change at line 407
prior.priority = socketOrder::Priority_Discretion; prior.priority = socketOrder::Priority_Discretion;
break; break;
case e_Data: case e_Data:
default: default:
prior.priority = socketOrder::Priority_High; prior.priority = socketOrder::Priority_High;
} }
} else } else
prior.priority = socketOrder::Priority_Low; prior.priority = socketOrder::Priority_Low;
prior.id = NextPacketCounter(); prior.id = NextPacketCounter();
prior.packTime = PTimer::Tick().GetMilliSeconds(); prior.packTime = PTimer::Tick().GetMilliSeconds();
prior.delay = PACKETDELAY(mediaPDU.GetIE(Q931::UserUserIE).GetSize(),m_mbps) ; prior.delay = PACKETDELAY(mediaPDU.GetIE(Q931::UserUserIE).GetSize(), m_mbps );
if (PTrace::CanTrace(6)) { if (PTrace::CanTrace(6)) {
PStringStream info; PStringStream info;
info << "Build #" << prior.id << (rtp ? "\nMedia" : " Control") << ":" << H46026MediaTypeAsString(id) << " Delay:" << prior.delay info << "Build #" << prior.id << (rtp ? "\nMedia" : " Control") << ":" << H46026MediaTypeAsString(id) << " Delay:" << prior.delay
<< "ms Priority:" << H46026PriorityAsString(prior.priority) << "\n" << H46026MediaFrameAnalysis(data); << "ms Priority:" << H46026PriorityAsString(prior.priority) << "\n" << H46026MediaFrameAnalysis(data);
if (PTrace::CanTrace(7)) { if (PTrace::CanTrace(7)) {
if (rtp) info << data; if (rtp) info << data;
else info << "\n" << data; else info << "\n" << data;
PTRACE(7,"H46026\t" << info); PTRACE(7,"H46026\t" << info);
} else { } else {
skipping to change at line 435 skipping to change at line 435
PBoolean H46026ChannelManager::RTPFrameOut(unsigned crv, PacketTypes id, PINDEX sessionId, PBoolean rtp, PBYTEArray & data) PBoolean H46026ChannelManager::RTPFrameOut(unsigned crv, PacketTypes id, PINDEX sessionId, PBoolean rtp, PBYTEArray & data)
{ {
return RTPFrameOut(crv, id, sessionId, rtp, data.GetPointer() , data.GetSize ()); return RTPFrameOut(crv, id, sessionId, rtp, data.GetPointer() , data.GetSize ());
} }
PBoolean H46026ChannelManager::RTPFrameOut(unsigned crv, PacketTypes id, PINDEX sessionId, PBoolean rtp, const BYTE * data, PINDEX len) PBoolean H46026ChannelManager::RTPFrameOut(unsigned crv, PacketTypes id, PINDEX sessionId, PBoolean rtp, const BYTE * data, PINDEX len)
{ {
PWaitAndSignal m(m_writeMutex); PWaitAndSignal m(m_writeMutex);
H46026_MediaFrame msg(data,len); H46026_MediaFrame msg(data, len);
if (rtp) { if (rtp) {
H46026UDPBuffer * buffer = GetRTPBuffer(crv,sessionId); H46026UDPBuffer * buffer = GetRTPBuffer(crv, sessionId);
if (!buffer) return false; if (!buffer) return false;
PBoolean toSend = false; PBoolean toSend = false;
switch (id) { switch (id) {
case e_Audio: case e_Audio:
buffer->SetFrame(msg); buffer->SetFrame(msg);
if (buffer->GetPacketCount() >= MAX_AUDIO_FRAMES) if (buffer->GetPacketCount() >= MAX_AUDIO_FRAMES)
toSend = true; toSend = true;
break; break;
case e_Video: case e_Video:
skipping to change at line 468 skipping to change at line 468
buffer->SetFrame(msg); buffer->SetFrame(msg);
toSend = true; toSend = true;
} }
if (toSend) { if (toSend) {
PBoolean sent = PackageFrame(rtp, crv, id, sessionId, buffer->GetBuf fer()); PBoolean sent = PackageFrame(rtp, crv, id, sessionId, buffer->GetBuf fer());
buffer->ClearBuffer(); buffer->ClearBuffer();
return sent; return sent;
} else } else
return ProcessQueue(); return ProcessQueue();
} else { } else {
H46026UDPBuffer data(sessionId,rtp); H46026UDPBuffer data(sessionId, rtp);
data.SetFrame(msg); data.SetFrame(msg);
return PackageFrame(rtp, crv, id, sessionId, data.GetBuffer()); return PackageFrame(rtp, crv, id, sessionId, data.GetBuffer());
} }
} }
PBoolean H46026ChannelManager::ProcessQueue() PBoolean H46026ChannelManager::ProcessQueue()
{ {
PWaitAndSignal m(m_queueMutex); PWaitAndSignal m(m_queueMutex);
if (m_socketQueue.size() == 0) { if (m_socketQueue.size() == 0) {
skipping to change at line 501 skipping to change at line 501
PTRACE(5,"H46026\tPossible pipe blockage detected. Delay " << stackTime << " Dropping video frames..."); PTRACE(5,"H46026\tPossible pipe blockage detected. Delay " << stackTime << " Dropping video frames...");
unsigned crv = m_socketQueue.top().second.crv; unsigned crv = m_socketQueue.top().second.crv;
PINDEX sessionId = m_socketQueue.top().second.sessionId; PINDEX sessionId = m_socketQueue.top().second.sessionId;
while (m_socketQueue.size()>0 && m_socketQueue.top().second.priority == socketOrder::Priority_Discretion) { while (m_socketQueue.size()>0 && m_socketQueue.top().second.priority == socketOrder::Priority_Discretion) {
m_socketQueue.pop(); m_socketQueue.pop();
} }
FastUpdatePictureRequired(crv, sessionId); FastUpdatePictureRequired(crv, sessionId);
// TODO: Flow Control based on the Time in the queue (stackTime) - SH // TODO: Flow Control based on the Time in the queue (stackTime) - SH
} }
m_socketPacketReady = (m_socketQueue.size() > 0); m_socketPacketReady = (!m_socketQueue.empty());
return true; return true;
} }
unsigned H46026ChannelManager::NextPacketCounter() unsigned H46026ChannelManager::NextPacketCounter()
{ {
m_pktCounter++; m_pktCounter++;
if (m_pktCounter > 65500) if (m_pktCounter > 65500)
m_pktCounter = 1; m_pktCounter = 1;
skipping to change at line 543 skipping to change at line 543
PString callId = PString(); PString callId = PString();
H46026_UDPFrame frameData; H46026_UDPFrame frameData;
if ((q931.GetMessageType() == Q931::InformationMsg) && ReadRTPFrame(q931, fr ameData)) { if ((q931.GetMessageType() == Q931::InformationMsg) && ReadRTPFrame(q931, fr ameData)) {
if (PTrace::CanTrace(6) && frameData.m_dataFrame) { if (PTrace::CanTrace(6) && frameData.m_dataFrame) {
PStringStream info; PStringStream info;
info << "Received Media:" << H46026MediaSessionId(frameData.m_sessio nId) info << "Received Media:" << H46026MediaSessionId(frameData.m_sessio nId)
<< "\n" << H46026MediaFrameAnalysis(frameData); << "\n" << H46026MediaFrameAnalysis(frameData);
if (PTrace::CanTrace(7)) { if (PTrace::CanTrace(7)) {
info << "\n" << frameData; info << "\n" << frameData;
PTRACE(7,"H46026\t" << info); PTRACE(7, "H46026\t" << info);
} else { } else {
PTRACE(6,"H46026\t" << info); PTRACE(6, "H46026\t" << info);
} }
} }
for (PINDEX i=0; i < frameData.m_frame.GetSize(); ++i) { for (PINDEX i=0; i < frameData.m_frame.GetSize(); ++i) {
PASN_OctetString & data = frameData.m_frame[i]; PASN_OctetString & data = frameData.m_frame[i];
RTPFrameIn(q931.GetCallReference(), frameData.m_sessionId.GetValue() , frameData.m_dataFrame, data.GetValue()); RTPFrameIn(q931.GetCallReference(), frameData.m_sessionId.GetValue() , frameData.m_dataFrame, data.GetValue());
} }
} else } else
SignalMsgIn(q931); SignalMsgIn(q931);
return true; return true;
} }
void H46026ChannelManager::SignalMsgIn(const Q931 & pdu) void H46026ChannelManager::SignalMsgIn(const Q931 & pdu)
{ {
SignalMsgIn(pdu.GetCallReference(),pdu); SignalMsgIn(pdu.GetCallReference(), pdu);
} }
PBoolean H46026ChannelManager::SocketOut(PBYTEArray & data, PINDEX & len) PBoolean H46026ChannelManager::SocketOut(PBYTEArray & data, PINDEX & len)
{ {
return SocketOut(data.GetPointer(), len); return SocketOut(data.GetPointer(), len);
} }
PBoolean H46026ChannelManager::SocketOut(BYTE * data, PINDEX & len) PBoolean H46026ChannelManager::SocketOut(BYTE * data, PINDEX & len)
{ {
if (!m_socketPacketReady) if (!m_socketPacketReady)
return false; return false;
PInt64 nowTime = PTimer::Tick().GetMilliSeconds(); PInt64 nowTime = PTimer::Tick().GetMilliSeconds();
if (m_currentPacketTime > nowTime) if (m_currentPacketTime > nowTime)
return false; return false;
PBoolean gotPacket = false; PBoolean gotPacket = false;
m_queueMutex.Wait(); m_queueMutex.Wait();
if (m_socketQueue.size() > 0) { if (!m_socketQueue.empty()) {
PTRACE(6,"H46026\tSending #" << m_socketQueue.top().second.id << " d elay " << m_socketQueue.top().second.delay << "ms"); PTRACE(6,"H46026\tSending #" << m_socketQueue.top().second.id << " d elay " << m_socketQueue.top().second.delay << "ms");
m_currentPacketTime = nowTime + m_socketQueue.top().second.delay; m_currentPacketTime = nowTime + m_socketQueue.top().second.delay;
len = m_socketQueue.top().first.GetSize(); len = m_socketQueue.top().first.GetSize();
memcpy(data, (const BYTE *)m_socketQueue.top().first, len); memcpy(data, (const BYTE *)m_socketQueue.top().first, len);
m_socketQueue.pop(); m_socketQueue.pop();
gotPacket = true; gotPacket = true;
} else { } else {
m_currentPacketTime = nowTime; m_currentPacketTime = nowTime;
} }
m_queueMutex.Signal(); m_queueMutex.Signal();
 End of changes. 17 change blocks. 
26 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)