예제 #1
0
        //解码回调函数
        private void DecCallbackFUN(int nPort, IntPtr pBuf, int nSize, ref PlayCtrl.FRAME_INFO pFrameInfo, int nUser)  //int nReserved1, int nReserved2
        {
            int channel = -1;

            foreach (var item in channelPortDict)
            {
                if (item.Value == nPort)
                {
                    channel = item.Key;
                    break;
                }
            }



            // 将pBuf解码后视频输入写入文件中(解码后YUV数据量极大,尤其是高清码流,不建议在回调函数中处理)
            if (pFrameInfo.nType == 3) //#define T_YV12	3
            {
                if (gloparaDict.ContainsKey(channel))
                {
                    MODSDK.JTMOD_FRAME_INFO frameInfo = new MODSDK.JTMOD_FRAME_INFO();
                    frameInfo.size        = (ushort)Marshal.SizeOf(frameInfo);
                    frameInfo.nWidth      = (ushort)picCapture.Width;
                    frameInfo.nHeight     = (ushort)picCapture.Height;
                    frameInfo.datatype    = 1;
                    frameInfo.lDataLen    = (uint)nSize;
                    frameInfo.iFrameIndex = pFrameInfo.dwFrameNum;
                    frameInfo.timestamp   = (uint)pFrameInfo.nStamp;
                    frameInfo.pData       = pBuf;
                    frameInfo.importGrade = 1;

                    //MODSDK.JtModProcess(glopara, ref frameInfo);

                    int result = MODSDK.JtModProcess(gloparaDict[channel], ref frameInfo);
                }



                //    //    FileStream fs = null;
                //    //    BinaryWriter bw = null;
                //    //    try
                //    //    {
                //    //        fs = new FileStream("DecodedVideo.yuv", FileMode.Append);
                //    //        bw = new BinaryWriter(fs);
                //    //        byte[] byteBuf = new byte[nSize];
                //    //        Marshal.Copy(pBuf, byteBuf, 0, nSize);
                //    //        bw.Write(byteBuf);
                //    //        bw.Flush();
                //    //    }
                //    //    catch (System.Exception ex)
                //    //    {
                //    //        MessageBox.Show(ex.ToString());
                //    //    }
                //    //    finally
                //    //    {
                //    //        bw.Close();
                //    //        fs.Close();
                //    //    }
            }
        }
예제 #2
0
        //解码回调函数
        private void DecCallbackFUN(int nPort, IntPtr pBuf, int nSize, ref PlayCtrl.FRAME_INFO pFrameInfo, int nUser)
        {
            // 将pBuf解码后视频输入写入文件中(解码后YUV数据量极大,尤其是高清码流,不建议在回调函数中处理)
            if (pFrameInfo.nType == 3) //#define T_YV12	3
            {
                MODSDK.JTMOD_FRAME_INFO frameInfo = new MODSDK.JTMOD_FRAME_INFO();
                frameInfo.size = (ushort)Marshal.SizeOf(frameInfo);
                frameInfo.nWidth = (ushort)picCapture.Width;
                frameInfo.nHeight = (ushort)picCapture.Height;
                frameInfo.datatype = 1;
                frameInfo.lDataLen = (uint)nSize;
                frameInfo.iFrameIndex = pFrameInfo.dwFrameNum;
                frameInfo.timestamp = (uint)pFrameInfo.nStamp;
                frameInfo.pData = pBuf;
                frameInfo.importGrade = 1;

                MODSDK.JtModProcess(glopara, ref frameInfo);

                //    FileStream fs = null;
                //    BinaryWriter bw = null;
                //    try
                //    {
                //        fs = new FileStream("DecodedVideo.yuv", FileMode.Append);
                //        bw = new BinaryWriter(fs);
                //        byte[] byteBuf = new byte[nSize];
                //        Marshal.Copy(pBuf, byteBuf, 0, nSize);
                //        bw.Write(byteBuf);
                //        bw.Flush();
                //    }
                //    catch (System.Exception ex)
                //    {
                //        MessageBox.Show(ex.ToString());
                //    }
                //    finally
                //    {
                //        bw.Close();
                //        fs.Close();
                //    }
            }
        }