Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.6 KiB

  1. #include "precomp.h"
  2. #include "NacList.h"
  3. #include "PacketSender.h"
  4. PacketSender::PacketSender() :
  5. m_SendQueue(PS_INITSIZE, PS_GROWRATE) // shouldn't ever get big
  6. {
  7. InitializeCriticalSection(&m_cs);
  8. }
  9. PacketSender::~PacketSender()
  10. {
  11. DeleteCriticalSection(&m_cs);
  12. }
  13. // takes the first packets out of the queue and sends it
  14. // returns true if a packet was taken out of the queue and sent
  15. BOOL PacketSender::SendPacket()
  16. {
  17. BOOL bRet;
  18. PS_QUEUE_ELEMENT pqe;
  19. WSABUF wsabuf;
  20. RTP_HDR *pRtpHdr;
  21. DWORD dwType=PS_AUDIO;
  22. EnterCriticalSection(&m_cs);
  23. bRet = m_SendQueue.PopFront(&pqe);
  24. if (bRet)
  25. {
  26. ASSERT(pqe.data);
  27. pRtpHdr = (RTP_HDR*)(pqe.data - sizeof(RTP_HDR));
  28. *(DWORD *)pRtpHdr = 0;
  29. pRtpHdr->ts = pqe.pMP->GetTimestamp();
  30. pRtpHdr->m = pqe.fMark;
  31. pRtpHdr->payload = pqe.pMP->GetPayload();
  32. if (pqe.pHeaderInfo && pqe.dwHdrSize && (pqe.dwPacketType==PS_VIDEO))
  33. {
  34. CopyMemory(pqe.data, pqe.pHeaderInfo, pqe.dwHdrSize);
  35. }
  36. wsabuf.buf = (char *)pRtpHdr;
  37. wsabuf.len = pqe.dwSize + sizeof(RTP_HDR);
  38. if (FAILED(pqe.pRTPSend->Send(&wsabuf, 1, NULL, NULL)))
  39. {
  40. LOG(((pqe.dwPacketType == PS_VIDEO) ? LOGMSG_VIDSEND_AUD_NOT_SEND : LOGMSG_AUDSEND_AUD_NOT_SEND, pqe.dwSize + sizeof (RTP_HDR), pqe.pMP->m_timestamp));
  41. DEBUGMSG (ZONE_DP, ("Check_Send: pRTPSend->Send failed\r\n" ));
  42. }
  43. else
  44. {
  45. LOG(((pqe.dwPacketType == PS_VIDEO) ? LOGMSG_VIDSEND_AUD_SEND : LOGMSG_AUDSEND_AUD_SEND, pqe.dwSize + sizeof (RTP_HDR), pqe.pMP->m_timestamp, GetTickCount()));
  46. }
  47. if (pqe.pHeaderInfo)
  48. {
  49. MemFree ((BYTE *)(pqe.pHeaderInfo));
  50. }
  51. }
  52. LeaveCriticalSection(&m_cs);
  53. return bRet;
  54. }