Example #1
0
        static public ffmpeg.net.AVFormatContext CreateOutput(string sType, System.IO.Stream cStream)
        {
            net.AVFormatContext cRetVal = new net.AVFormatContext();
            int nError = 0;

            cRetVal._cStream = cStream;
            //lock (helper._oSyncRootGlobal)
            {
                if (0 != (nError = avformat_alloc_output_context2(ref cRetVal._p, NULL, new StringBuilder(sType), null)))
                {
                    throw new Exception("avformat_alloc_output_context2:" + helper.ErrorDescriptionGet(nError)); // Couldn't open file
                }
                //cRetVal._p = avformat_alloc_context();
                cRetVal._st = (AVFormatContextInternal)Marshal.PtrToStructure(cRetVal._p, typeof(AVFormatContextInternal));
                int nBufferSize = 32768;
                cRetVal._pAVIOBuffer     = av_malloc(nBufferSize + Constants.FF_INPUT_BUFFER_PADDING_SIZE);
                cRetVal.fAVIOBufferRead  = cRetVal.StreamRead;
                cRetVal.fAVIOBufferSeek  = cRetVal.StreamSeek;
                cRetVal.fAVIOBufferWrite = cRetVal.StreamWrite;
                cRetVal._st.pb           = cRetVal._pAVIOContext = avio_alloc_context(cRetVal._pAVIOBuffer, nBufferSize, 1, NULL, Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferRead), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferWrite), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek));
                if ("mpegts" == sType)
                {
                    av_opt_set(cRetVal._st.priv_data, new StringBuilder("mpegts_flags"), new StringBuilder("resend_headers"), 0);
                }
                Marshal.StructureToPtr(cRetVal._st, cRetVal._p, true);
            }
            cRetVal._bMarshalOutNeeds = true;
            return(cRetVal);
        }
Example #2
0
        static public ffmpeg.net.AVFormatContext OpenInput(System.IO.Stream cStream, string sFormat)
        {
            net.AVFormatContext cRetVal = new net.AVFormatContext();
            int nError = 0;

            cRetVal._cStream = cStream;
            //lock (helper._oSyncRootGlobal)
            {
                cRetVal._p  = avformat_alloc_context();
                cRetVal._st = (AVFormatContextInternal)Marshal.PtrToStructure(cRetVal._p, typeof(AVFormatContextInternal));
                int nBufferSize = 32768;
                cRetVal._pAVIOBuffer    = av_malloc(nBufferSize + Constants.FF_INPUT_BUFFER_PADDING_SIZE);
                cRetVal.fAVIOBufferRead = cRetVal.StreamRead;
                cRetVal.fAVIOBufferSeek = cRetVal.StreamSeek;
                cRetVal._st.pb          = cRetVal._pAVIOContext = avio_alloc_context(cRetVal._pAVIOBuffer, nBufferSize, 0, NULL, Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferRead), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek));
                Marshal.StructureToPtr(cRetVal._st, cRetVal._p, true);

                IntPtr pFormat = NULL;
                if (null != sFormat)
                {
                    pFormat = av_find_input_format(sFormat);
                }
                if (0 != (nError = avformat_open_input(ref cRetVal._p, "buffer" + cStream.GetHashCode() + ".ts", pFormat, NULL)))
                {
                    throw new Exception(helper.ErrorDescriptionGet(nError));                     // Couldn't open file
                }
            }
            cRetVal._bMarshalOutNeeds = true;
            return(cRetVal);
        }
Example #3
0
 static public ffmpeg.net.AVFormatContext CreateOutput(string sFile)
 {
     net.AVFormatContext cRetVal = new net.AVFormatContext();
     //lock (helper._oSyncRootGlobal)
     {
         avformat_alloc_output_context2(ref cRetVal._p, NULL, null, new StringBuilder(sFile));
         if (NULL == cRetVal._p)
         {
             throw new Exception("avformat_alloc_output_context2");
         }
     }
     cRetVal._bMarshalOutNeeds = true;
     return(cRetVal);
 }
Example #4
0
        static public ffmpeg.net.AVFormatContext OpenInput(string sFile, string sFormat)
        {
            net.AVFormatContext cRetVal = new net.AVFormatContext();
            int    nError  = 0;
            IntPtr pFormat = NULL;

            if (null != sFormat)
            {
                pFormat = av_find_input_format(sFormat);
            }
            //lock (helper._oSyncRootGlobal)
            {
                if (0 != (nError = avformat_open_input(ref cRetVal._p, Encoding.UTF8.GetBytes(sFile), pFormat, NULL)))
                {
                    throw new Exception(helper.ErrorDescriptionGet(nError));                     // Couldn't open file
                }
            }
            cRetVal._bMarshalOutNeeds = true;
            return(cRetVal);
        }
Example #5
0
		static public ffmpeg.net.AVFormatContext CreateOutput(string sType, System.IO.Stream cStream)
		{
            net.AVFormatContext cRetVal = new net.AVFormatContext();
            int nError = 0;
            cRetVal._cStream = cStream;
            //lock (helper._oSyncRootGlobal)
            {
                if (0 != (nError = avformat_alloc_output_context2(ref cRetVal._p, NULL, new StringBuilder(sType), null)))
                    throw new Exception("avformat_alloc_output_context2:" + helper.ErrorDescriptionGet(nError)); // Couldn't open file
                //cRetVal._p = avformat_alloc_context();
                cRetVal._st = (AVFormatContextInternal)Marshal.PtrToStructure(cRetVal._p, typeof(AVFormatContextInternal));
                int nBufferSize = 32768;
                cRetVal._pAVIOBuffer = av_malloc(nBufferSize + Constants.FF_INPUT_BUFFER_PADDING_SIZE);
                cRetVal.fAVIOBufferRead = cRetVal.StreamRead;
                cRetVal.fAVIOBufferSeek = cRetVal.StreamSeek;
                cRetVal.fAVIOBufferWrite = cRetVal.StreamWrite;
                cRetVal._st.pb = cRetVal._pAVIOContext = avio_alloc_context(cRetVal._pAVIOBuffer, nBufferSize, 1, NULL, Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferRead), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferWrite), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek));
                if ("mpegts" == sType)
                    av_opt_set(cRetVal._st.priv_data, new StringBuilder("mpegts_flags"), new StringBuilder("resend_headers"), 0);
                Marshal.StructureToPtr(cRetVal._st, cRetVal._p, true);
            }
            cRetVal._bMarshalOutNeeds = true;
            return cRetVal;
		}
Example #6
0
		static public ffmpeg.net.AVFormatContext CreateOutput(string sFile)
		{
			net.AVFormatContext cRetVal = new net.AVFormatContext();
			//lock (helper._oSyncRootGlobal)
			{
                avformat_alloc_output_context2(ref cRetVal._p, NULL, null, new StringBuilder(sFile));
				if (NULL == cRetVal._p)
					throw new Exception("avformat_alloc_output_context2");
			}
			cRetVal._bMarshalOutNeeds = true;
			return cRetVal;
		}
Example #7
0
        static public ffmpeg.net.AVFormatContext OpenInput(System.IO.Stream cStream, string sFormat)
        {
            net.AVFormatContext cRetVal = new net.AVFormatContext();
			int nError = 0;
            cRetVal._cStream = cStream;
			//lock (helper._oSyncRootGlobal)
			{
                cRetVal._p = avformat_alloc_context();
                cRetVal._st = (AVFormatContextInternal)Marshal.PtrToStructure(cRetVal._p, typeof(AVFormatContextInternal));
                int nBufferSize = 32768;
                cRetVal._pAVIOBuffer = av_malloc(nBufferSize + Constants.FF_INPUT_BUFFER_PADDING_SIZE);
                cRetVal.fAVIOBufferRead = cRetVal.StreamRead;
                cRetVal.fAVIOBufferSeek = cRetVal.StreamSeek;
                cRetVal._st.pb = cRetVal._pAVIOContext = avio_alloc_context(cRetVal._pAVIOBuffer, nBufferSize, 0, NULL, Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferRead), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek), Marshal.GetFunctionPointerForDelegate(cRetVal.fAVIOBufferSeek));
                Marshal.StructureToPtr(cRetVal._st, cRetVal._p, true);

                IntPtr pFormat = NULL;
                if (null != sFormat)
                    pFormat = av_find_input_format(sFormat);
                if (0 != (nError = avformat_open_input(ref cRetVal._p, "buffer" + cStream.GetHashCode() + ".ts", pFormat, NULL)))
					throw new Exception(helper.ErrorDescriptionGet(nError)); // Couldn't open file
			}
			cRetVal._bMarshalOutNeeds = true;
			return cRetVal;
		}
Example #8
0
		static public ffmpeg.net.AVFormatContext OpenInput(string sFile, string sFormat)
		{
			net.AVFormatContext cRetVal = new net.AVFormatContext();
			int nError = 0;
            IntPtr pFormat = NULL;
            if(null != sFormat)
                pFormat = av_find_input_format(sFormat);
			//lock (helper._oSyncRootGlobal)
			{
                if (0 != (nError = avformat_open_input(ref cRetVal._p, Encoding.UTF8.GetBytes(sFile), pFormat, NULL)))
					throw new Exception(helper.ErrorDescriptionGet(nError)); // Couldn't open file
			}
			cRetVal._bMarshalOutNeeds = true;
			return cRetVal;
		}