protected void ProcessVideoFrame(UniversalVideoFrame vidframe) { /// Tell our host we have data /// if (OnNewVideoFrame != null) { OnNewVideoFrame(vidframe); } }
protected void ExtractAndNotifyPacket(byte[] bData) { /// See if we have enough data to examine the rest of our header, if not, wait until the /// next time around /// ByteBuffer.AppendData(bData); while (true) { if (ByteBuffer.Size <= 0) { break; } else if (CurrentVideoFrame != null) { /// See if we have enough data for the video part of this frame /// if (ByteBuffer.Size < CurrentVideoFrame.Length) { return; } CurrentVideoFrame.FrameData = ByteBuffer.GetNSamples(ByteBuffer.Size); ProcessVideoFrame(CurrentVideoFrame); CurrentVideoFrame = null; } else if (ByteBuffer.Size >= 17) { CurrentVideoFrame = new UniversalVideoFrame(); bool bValid = CurrentVideoFrame.SetHeader(bData); if (bValid == false) { CurrentVideoFrame = null; // int nAt = ByteBuffer.FindBytes(new byte[] { 0x22, 0x77, 0x77, 0x22 }); if (nAt == 0) { ByteBuffer.GetAllSamples(); // flush...nothing but bad data } else { ByteBuffer.GetNSamples(nAt); // found the header at another location... should never happen, may want to abort the stream here instead } } } } }
public bool SendVideoFrame(UniversalVideoFrame frame) { if (Connected == false) { return(false); } lock (SendingLock) { if (m_bIsSending == false) { m_bIsSending = true; } else { return(false); } } bSendingBuffer = frame.AllData; socket.BeginSend(bSendingBuffer, 0, bSendingBuffer.Length, System.Net.Sockets.SocketFlags.None, new AsyncCallback(SendComplete), this); return(true); }