public void SendFrame(int nWidth, int nHeight, byte [] bCompressedFrame) { //System.Drawing.Imaging.BitmapData data = Frame.LockBits(new System.Drawing.Rectangle(0, 0, Frame.Width, Frame.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, // System.Drawing.Imaging.PixelFormat.Format24bppRgb); //byte[] bRGBFrame = new byte[Frame.Width*3*Frame.Height]; //unsafe //{ // byte *pSrc = (byte *) data.Scan0.ToPointer(); // fixed (byte* pDest = &bRGBFrame[0]) // { // CopyMemory(pDest, pSrc, Frame.Width*Frame.Height*3); // } //} //Frame.UnlockBits(data); lock (SocketLock) { int nAt = 0; /// Send the data packets /// int nPacket = 0; while (true) { int nNextSize = ((bCompressedFrame.Length - nAt) > 60000) ? 60000 : (bCompressedFrame.Length - nAt); byte [] bNextData = new byte[nNextSize]; Array.Copy(bCompressedFrame, nAt, bNextData, 0, nNextSize); nAt += nNextSize; RTP.RTPPacket datapacket = FormatNextPacket(bNextData); datapacket.Marker = (nPacket == 0)?true:false; datapacket.TimeStamp = m_nFrame; byte[] bDataPacket = datapacket.GetBytes(); if (MultiCastSendSocket != null) { MultiCastSendSocket.Send(bDataPacket); } if (nAt >= (bCompressedFrame.Length - 1)) { break; } nPacket++; } } m_nFrame++; }
public void SendPacket(byte [] bCompressedAudio) { lock (SocketLock) { /// Send the data packets /// RTP.RTPPacket datapacket = FormatNextPacket(bCompressedAudio); byte[] bDataPacket = datapacket.GetBytes(); if (MultiCastSendSocket != null) { MultiCastSendSocket.Send(bDataPacket); } } }