Exemplo n.º 1
0
        /// <summary>
        /// Helper function to make a DMO Media Type to represent a particular WaveFormat
        /// </summary>
        private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat)
        {
            DmoMediaType mediaType        = new DmoMediaType();
            int          waveFormatExSize = Marshal.SizeOf(waveFormat); // 18 + waveFormat.ExtraSize;

            DmoInterop.MoInitMediaType(ref mediaType, waveFormatExSize);
            mediaType.SetWaveFormat(waveFormat);
            return(mediaType);
        }
Exemplo n.º 2
0
        private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat)
        {
            DmoMediaType result           = default(DmoMediaType);
            int          formatBlockBytes = Marshal.SizeOf(waveFormat);

            DmoInterop.MoInitMediaType(ref result, formatBlockBytes);
            result.SetWaveFormat(waveFormat);
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the input type to the specified Wave format
        /// </summary>
        /// <param name="inputStreamIndex">Input stream index</param>
        /// <param name="waveFormat">Wave format</param>
        // Token: 0x0600031E RID: 798 RVA: 0x0000A770 File Offset: 0x00008970
        public void SetInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat)
        {
            DmoMediaType mediaType = this.CreateDmoMediaTypeForWaveFormat(waveFormat);
            bool         flag      = this.SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.None);

            DmoInterop.MoFreeMediaType(ref mediaType);
            if (!flag)
            {
                throw new ArgumentException("Media Type not supported");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set output type to the specified wave format
        /// n.b. may need to set input type first
        /// </summary>
        /// <param name="outputStreamIndex">Output stream index</param>
        /// <param name="waveFormat">Wave format</param>
        public void SetOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat)
        {
            DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
            bool         succeeded = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.None);

            DmoInterop.MoFreeMediaType(ref mediaType);
            if (!succeeded)
            {
                throw new ArgumentException("Media Type not supported");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Helper method to call SetOutputType
        /// </summary>
        // Token: 0x06000323 RID: 803 RVA: 0x0000A834 File Offset: 0x00008A34
        private bool SetOutputType(int outputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
        {
            int num = this.mediaObject.SetOutputType(outputStreamIndex, ref mediaType, flags);

            if (num == -2147220987)
            {
                return(false);
            }
            if (num == 0)
            {
                return(true);
            }
            throw Marshal.GetExceptionForHR(num);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the input type helper method
        /// </summary>
        /// <param name="inputStreamIndex">Input stream index</param>
        /// <param name="mediaType">Media type</param>
        /// <param name="flags">Flags (can be used to test rather than set)</param>
        // Token: 0x0600031C RID: 796 RVA: 0x0000A718 File Offset: 0x00008918
        private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
        {
            int num = this.mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);

            if (num == 0)
            {
                return(true);
            }
            if (num == -2147220991)
            {
                throw new ArgumentException("Invalid stream index");
            }
            return(false);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Sets the input type helper method
 /// </summary>
 /// <param name="inputStreamIndex">Input stream index</param>
 /// <param name="mediaType">Media type</param>
 /// <param name="flags">Flags (can be used to test rather than set)</param>
 /// <returns>true if successful</returns>
 private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
 {
     try
     {
         mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);
     }
     catch (COMException e)
     {
         if (e.ErrorCode == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
         {
             return(false);
         }
         throw;
     }
     return(true);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Helper method to call SetOutputType
        /// </summary>
        private bool SetOutputType(int outputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
        {
            int hresult = mediaObject.SetOutputType(outputStreamIndex, ref mediaType, flags);

            if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
            {
                return(false);
            }
            else if (hresult == HResult.S_OK)
            {
                return(true);
            }
            else
            {
                throw Marshal.GetExceptionForHR(hresult);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sets the input type helper method
        /// </summary>
        /// <param name="inputStreamIndex">Input stream index</param>
        /// <param name="mediaType">Media type</param>
        /// <param name="flags">Flags (can be used to test rather than set)</param>
        private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
        {
            int hResult = mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);

            if (hResult != HResult.S_OK)
            {
                if (hResult == (int)DmoHResults.DMO_E_INVALIDSTREAMINDEX)
                {
                    throw new ArgumentException("Invalid stream index");
                }
                if (hResult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
                {
                    Debug.WriteLine("Media type was not accepted");
                }

                return(false);
            }
            return(true);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Checks if a specified output type is supported
 /// n.b. you may need to set the input type first
 /// </summary>
 /// <param name="outputStreamIndex">Output stream index</param>
 /// <param name="mediaType">Media type</param>
 /// <returns>True if supported</returns>
 public bool SupportsOutputType(int outputStreamIndex, DmoMediaType mediaType)
 {
     return SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Sets the input type helper method
        /// </summary>
        /// <param name="inputStreamIndex">Input stream index</param>
        /// <param name="mediaType">Media type</param>
        /// <param name="flags">Flags (can be used to test rather than set)</param>
        private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
        {
            int hResult = mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);
            if (hResult != HResult.S_OK)
            {
                if (hResult == (int)DmoHResults.DMO_E_INVALIDSTREAMINDEX)
                {
                    throw new ArgumentException("Invalid stream index");
                }
                if (hResult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
                {
                    Debug.WriteLine("Media type was not accepted");
                }

                return false;
            }
            return true;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Helper function to make a DMO Media Type to represent a particular WaveFormat
 /// </summary>
 private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat)
 {
     DmoMediaType mediaType = new DmoMediaType();
     int waveFormatExSize = Marshal.SizeOf(waveFormat);  // 18 + waveFormat.ExtraSize;
     DmoInterop.MoInitMediaType(ref mediaType, waveFormatExSize);
     mediaType.SetWaveFormat(waveFormat);
     return mediaType;
 }
Exemplo n.º 13
0
 public static extern int MoInitMediaType(
     [In, Out] ref DmoMediaType mediaType, int formatBlockBytes);
Exemplo n.º 14
0
 public static extern int MoFreeMediaType(
     [In] ref DmoMediaType mediaType);
Exemplo n.º 15
0
 /// <summary>
 /// Querys whether a specified input type is supported
 /// </summary>
 /// <param name="inputStreamIndex">Input stream index</param>
 /// <param name="mediaType">Media type to check</param>
 /// <returns>true if supports</returns>
 // Token: 0x0600031B RID: 795 RVA: 0x0000A70C File Offset: 0x0000890C
 public bool SupportsInputType(int inputStreamIndex, DmoMediaType mediaType)
 {
     return(this.SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Helper method to call SetOutputType
 /// </summary>
 private bool SetOutputType(int outputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
 {
     int hresult = mediaObject.SetOutputType(outputStreamIndex, ref mediaType, flags);
     if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
     {
         return false;
     }
     else if (hresult == HResult.S_OK)
     {
         return true;
     }
     else
     {
         throw Marshal.GetExceptionForHR(hresult);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Sets the input type helper method
 /// </summary>
 /// <param name="inputStreamIndex">Input stream index</param>
 /// <param name="mediaType">Media type</param>
 /// <param name="flags">Flags (can be used to test rather than set)</param>
 /// <returns>true if successful</returns>
 private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
 {
     try
     {
         mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);
     }
     catch (COMException e)
     {
         if (e.ErrorCode == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
         {
             return false;
         }
         throw;
     }
     return true;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Sets the output type
 /// n.b. may need to set the input type first
 /// </summary>
 /// <param name="outputStreamIndex">Output stream index</param>
 /// <param name="mediaType">Media type to set</param>
 public void SetOutputType(int outputStreamIndex, DmoMediaType mediaType)
 {
     if (!SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.None))
     {
         throw new ArgumentException("Media Type not supported");
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Checks if a specified output type is supported
 /// n.b. you may need to set the input type first
 /// </summary>
 /// <param name="outputStreamIndex">Output stream index</param>
 /// <param name="mediaType">Media type</param>
 /// <returns>True if supported</returns>
 public bool SupportsOutputType(int outputStreamIndex, DmoMediaType mediaType)
 {
     return(SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY));
 }