private int NetCallBack_V2(int lRealHandle, ref PACKET_INFO_EX pFrame, int dwUser) { //bool bResult = ; //try //{ // if (bResult) // { // return bResult; // } //} return(0); }
private int DataCallBack_V2(int lRealHandle, ref PACKET_INFO_EX pFrame, int dwUser) { //https://github.com/peidongbin/git/blob/b597b13707c7f865b01062318dc048b92f985226/Monitorsever/Monitorsever/video.cs if (pFrame.nPacketType == 0 || pFrame.nPacketType == 10) { return(1); //if not image frame } IntPtr yuvdata = Marshal.AllocHGlobal(200); int decode_result = 0; int len = 0; try { len = FFmpeg.avcodec_decode_video(pCodecCtx_pt, yuvdata, ref decode_result, pFrame.pPacketBuffer, (int)pFrame.dwPacketSize); pCodecCtx = (FFmpeg.AVCodecContext)Marshal.PtrToStructure(pCodecCtx_pt, typeof(FFmpeg.AVCodecContext)); } catch (Exception e) { Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".DataCallBack_V2.Exception(" + e.Message + ")", "WEB ERROR"); } if (len > 0 && decodeFrameRuning == false) { decodeFrameRuning = true; width = pCodecCtx.width; height = pCodecCtx.height; FFmpeg.AVPicture avpicture = (FFmpeg.AVPicture)Marshal.PtrToStructure(yuvdata, typeof(FFmpeg.AVPicture)); data = new byte[avpicture.linesize[0] * height * 2]; Marshal.Copy(avpicture.data[0], data, 0, avpicture.linesize[0] * height); Marshal.Copy(avpicture.data[1], data, (width + 32) * height, avpicture.linesize[1] * (height / 2)); Marshal.Copy(avpicture.data[2], data, (width + 32) * height * 5 / 4, avpicture.linesize[1] * (height / 2)); Task.Factory.StartNew(DecodeFarme); } return(1); }