Beispiel #1
0
        public int SetMediaType(AMMediaType pMediaType)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            SetMediaTypeProc _Proc = GetProcDelegate<SetMediaTypeProc>(14);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pMediaType
                        );
        }
Beispiel #2
0
 public static bool AreEquals(AMMediaType _src, AMMediaType _dst)
 {
     if ((_dst.majorType != _src.majorType))
     {
         return false;
     }
     if (_src.subType != _dst.subType)
     {
         return false;
     }
     if (_src.formatType != _dst.formatType)
     {
         return false;
     }
     if (_src.formatSize != _dst.formatSize)
     {
         return false;
     }
     if (_src.formatSize > 0)
     {
         byte[] _source = new byte[_src.formatSize];
         byte[] _dest = new byte[_src.formatSize];
         Marshal.Copy(_src.formatPtr, _source, 0, _source.Length);
         Marshal.Copy(_dst.formatPtr, _dest, 0, _dest.Length);
         for (int i = 0; i < _source.Length; i++)
         {
             if (_dest[i] != _source[i]) return false;
         }
     }
     return true;
 }
Beispiel #3
0
        public int GetMediaType(out AMMediaType ppMediaType)
        {
            ppMediaType = null;
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            GetMediaTypeProc _Proc = GetProcDelegate<GetMediaTypeProc>(13);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        out ppMediaType
                        );
        }
Beispiel #4
0
        public void Set(AMMediaType mt)
        {
            Free();

            majorType = mt.majorType;
            subType = mt.subType;
            fixedSizeSamples = mt.fixedSizeSamples;
            temporalCompression = mt.temporalCompression;
            sampleSize = mt.sampleSize;
            formatType = mt.formatType;
            unkPtr = mt.unkPtr;
            formatPtr = IntPtr.Zero;
            formatSize = mt.formatSize;
            if (unkPtr != IntPtr.Zero)
            {
                Marshal.AddRef(unkPtr);
            }
            if (formatSize > 0)
            {
                SetFormat(mt.formatPtr, formatSize);
            }
        }
Beispiel #5
0
 public static bool IsValid(AMMediaType mt)
 {
     return (mt.majorType != null && mt.majorType != Guid.Empty);
 }
Beispiel #6
0
        public int QueryAccept(AMMediaType pmt)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            QueryAcceptProc _Proc = GetProcDelegate<QueryAcceptProc>(11);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pmt
                        );
        }
Beispiel #7
0
 public int GetCurFile(out string pszFileName, AMMediaType pmt)
 {
     pszFileName = m_sFileName;
     if (pmt != null)
     {
         pmt.Set(Pins[0].CurrentMediaType);
     }
     return NOERROR;
 }
Beispiel #8
0
 public static void AllocFormat(ref AMMediaType mt, int nSize)
 {
     FreeFormat(ref mt);
     if (mt != null && nSize > 0)
     {
         mt.formatPtr = Marshal.AllocCoTaskMem(nSize);
         mt.formatSize = nSize;
     }
 }
Beispiel #9
0
 public static void SetFormat(ref AMMediaType mt, IntPtr pFormat, int nSize)
 {
     AllocFormat(ref mt, nSize);
     if (mt != null && pFormat != IntPtr.Zero)
     {
         COMHelper.API.CopyMemory(mt.formatPtr, pFormat, mt.formatSize);
     }
 }
Beispiel #10
0
        public static void Copy(AMMediaType mt, ref AMMediaType _dest)
        {
            if (((object)_dest) == null)
            {
                _dest = new AMMediaType();
            }
            else
            {
                Free(ref _dest);
            }

            _dest.majorType = mt.majorType;
            _dest.subType = mt.subType;
            _dest.fixedSizeSamples = mt.fixedSizeSamples;
            _dest.temporalCompression = mt.temporalCompression;
            _dest.sampleSize = mt.sampleSize;
            _dest.formatType = mt.formatType;
            _dest.unkPtr = mt.unkPtr;
            _dest.formatPtr = IntPtr.Zero;
            _dest.formatSize = mt.formatSize;
            if (_dest.unkPtr != IntPtr.Zero)
            {
                Marshal.AddRef(_dest.unkPtr);
            }
            if (_dest.formatSize > 0)
            {
                _dest.formatPtr = Marshal.AllocCoTaskMem(_dest.formatSize);
                COMHelper.API.CopyMemory(_dest.formatPtr, mt.formatPtr, _dest.formatSize);
            }
        }
Beispiel #11
0
 public static void Free(ref AMMediaType mt)
 {
     if (mt != null)
     {
         FreeFormat(ref mt);
         if (mt.unkPtr != IntPtr.Zero)
         {
             Marshal.Release(mt.unkPtr);
             mt.unkPtr = IntPtr.Zero;
         }
     }
 }
Beispiel #12
0
 public static void Init(ref AMMediaType mt)
 {
     if (((object)mt) == null)
     {
         mt = new AMMediaType();
     }
     else
     {
         Free(ref mt);
     }
     mt.majorType = Guid.Empty;
     mt.subType = Guid.Empty;
     mt.fixedSizeSamples = true;
     mt.temporalCompression = false;
     mt.sampleSize = 0;
     mt.formatType = Guid.Empty;
     mt.unkPtr = IntPtr.Zero;
     mt.formatPtr = IntPtr.Zero;
     mt.formatSize = 0;
 }
Beispiel #13
0
 public static bool IsPartiallySpecified(AMMediaType mt)
 {
     if ((mt.majorType == Guid.Empty) || (mt.formatType == Guid.Empty))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Beispiel #14
0
        public bool MatchesPartial(AMMediaType _dst)
        {
            if ((_dst.majorType != Guid.Empty) && (majorType != _dst.majorType))
            {
                return false;
            }
            if ((_dst.subType != Guid.Empty) && (subType != _dst.subType))
            {
                return false;
            }
            if (_dst.formatType != Guid.Empty)
            {
                if (formatType != _dst.formatType)
                {
                    return false;
                }
                if (formatSize != _dst.formatSize)
                {
                    return false;
                }
                if (formatSize > 0)
                {
                    byte[] _source = new byte[formatSize];
                    byte[] _dest = new byte[formatSize];
                    Marshal.Copy(formatPtr, _source, 0, _source.Length);
                    Marshal.Copy(_dst.formatPtr, _dest, 0, _dest.Length);
                    for (int i = 0; i < _source.Length; i++)
                    {
                        if (_dest[i] != _source[i]) return false;
                    }
                }

            }
            return true;
        }
Beispiel #15
0
        public int ReceiveConnection(IntPtr pReceivePin, AMMediaType pmt)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            ReceiveConnectionProc _Proc = GetProcDelegate<ReceiveConnectionProc>(4);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pReceivePin, pmt
                        );
        }
Beispiel #16
0
 public static void SetFormat(ref AMMediaType mt, ref WaveFormatEx wfx)
 {
     if (wfx != null)
     {
         int cb = Marshal.SizeOf(wfx);
         IntPtr _ptr = Marshal.AllocCoTaskMem(cb);
         try
         {
             Marshal.StructureToPtr(wfx, _ptr, true);
             SetFormat(ref mt, _ptr, cb);
             if (mt != null)
             {
                 mt.formatType = FormatType.WaveEx;
             }
         }
         finally
         {
             Marshal.FreeCoTaskMem(_ptr);
         }
     }
 }
Beispiel #17
0
        public int ConnectionMediaType(AMMediaType pmt)
        {
            if (m_pUnknown == IntPtr.Zero) return E_NOINTERFACE;

            ConnectionMediaTypeProc _Proc = GetProcDelegate<ConnectionMediaTypeProc>(7);

            if (_Proc == null) return E_UNEXPECTED;

            return (HRESULT)_Proc(
                        m_pUnknown,
                        pmt
                        );
        }
Beispiel #18
0
 public static void SetFormat(ref AMMediaType mt, ref VideoInfoHeader vih)
 {
     if (vih != null)
     {
         int cb = Marshal.SizeOf(vih);
         IntPtr _ptr = Marshal.AllocCoTaskMem(cb);
         try
         {
             Marshal.StructureToPtr(vih, _ptr, true);
             SetFormat(ref mt, _ptr, cb);
             if (mt != null)
             {
                 mt.formatType = FormatType.VideoInfo;
             }
         }
         finally
         {
             Marshal.FreeCoTaskMem(_ptr);
         }
     }
 }
Beispiel #19
0
 public int SetFileName(string pszFileName, AMMediaType pmt)
 {
     if (string.IsNullOrEmpty(pszFileName)) return E_POINTER;
     if (IsActive) return VFW_E_WRONG_STATE;
     m_sFileName = pszFileName;
     return NOERROR;
 }
Beispiel #20
0
 public static void FreeFormat(ref AMMediaType mt)
 {
     if (mt != null)
     {
         if (mt.formatPtr != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(mt.formatPtr);
             mt.formatPtr = IntPtr.Zero;
         }
         mt.formatSize = 0;
     }
 }
Beispiel #21
0
 public override int CheckMediaType(AMMediaType pmt)
 {
     return NOERROR;
 }
Beispiel #22
0
 public AMMediaType(AMMediaType mt)
     : this()
 {
     Set(mt);
 }