コード例 #1
0
ファイル: MediaObject.cs プロジェクト: gema-arta/StreamAudio
        /// <summary>
        /// retrieves the media type that was set for an output stream, if any
        /// </summary>
        /// <param name="outputStreamIndex">Output stream index</param>
        /// <returns>DMO Media Type or null if no more available</returns>
        public DmoMediaType GetOutputCurrentType(int outputStreamIndex)
        {
            DmoMediaType mediaType;
            int          hresult = mediaObject.GetOutputCurrentType(outputStreamIndex, out mediaType);

            if (hresult == HResult.S_OK)
            {
                // this frees the format (if present)
                // we should therefore come up with a way of marshaling the format
                // into a completely managed structure
                DmoInterop.MoFreeMediaType(ref mediaType);
                return(mediaType);
            }
            else
            {
                if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_SET)
                {
                    throw new InvalidOperationException("Media type was not set.");
                }
                else
                {
                    throw Marshal.GetExceptionForHR(hresult);
                }
            }
        }
コード例 #2
0
ファイル: MediaObject.cs プロジェクト: gema-arta/StreamAudio
        /// <summary>
        /// Tests if the specified Wave Format is supported for output
        /// n.b. may need to set the input type first
        /// </summary>
        /// <param name="outputStreamIndex">Output stream index</param>
        /// <param name="waveFormat">Wave format</param>
        /// <returns>True if supported</returns>
        public bool SupportsOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat)
        {
            DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
            bool         supported = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);

            DmoInterop.MoFreeMediaType(ref mediaType);
            return(supported);
        }
コード例 #3
0
        /// <summary>
        /// Requests whether the specified Wave format is supported as an input
        /// </summary>
        /// <param name="inputStreamIndex">Input stream index</param>
        /// <param name="waveFormat">Wave format</param>
        /// <returns>true if supported</returns>
        // Token: 0x0600031F RID: 799 RVA: 0x0000A7A8 File Offset: 0x000089A8
        public bool SupportsInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat)
        {
            DmoMediaType mediaType = this.CreateDmoMediaTypeForWaveFormat(waveFormat);
            bool         result    = this.SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);

            DmoInterop.MoFreeMediaType(ref mediaType);
            return(result);
        }
コード例 #4
0
ファイル: MediaObject.cs プロジェクト: gema-arta/StreamAudio
        /// <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);
        }
コード例 #5
0
        /// <summary>
        /// Helper function to make a DMO Media Type to represent a particular WaveFormat
        /// </summary>
        // Token: 0x06000320 RID: 800 RVA: 0x0000A7D0 File Offset: 0x000089D0
        private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat)
        {
            DmoMediaType result           = default(DmoMediaType);
            int          formatBlockBytes = Marshal.SizeOf(waveFormat);

            DmoInterop.MoInitMediaType(ref result, formatBlockBytes);
            result.SetWaveFormat(waveFormat);
            return(result);
        }
コード例 #6
0
ファイル: MediaObject.cs プロジェクト: gema-arta/StreamAudio
        /// <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");
            }
        }
コード例 #7
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");
            }
        }
コード例 #8
0
        /// <summary>
        /// retrieves the media type that was set for an output stream, if any
        /// </summary>
        /// <param name="outputStreamIndex">Output stream index</param>
        /// <returns>DMO Media Type or null if no more available</returns>
        // Token: 0x06000318 RID: 792 RVA: 0x0000A430 File Offset: 0x00008630
        public DmoMediaType GetOutputCurrentType(int outputStreamIndex)
        {
            DmoMediaType result;
            int          outputCurrentType = this.mediaObject.GetOutputCurrentType(outputStreamIndex, out result);

            if (outputCurrentType == 0)
            {
                DmoInterop.MoFreeMediaType(ref result);
                return(result);
            }
            if (outputCurrentType == -2147220989)
            {
                throw new InvalidOperationException("Media type was not set.");
            }
            throw Marshal.GetExceptionForHR(outputCurrentType);
        }
コード例 #9
0
 /// <summary>
 /// Gets the DMO Media Output type
 /// </summary>
 /// <param name="outputStream">The output stream</param>
 /// <param name="outputTypeIndex">Output type index</param>
 /// <returns>DMO Media Type or null if no more available</returns>
 // Token: 0x06000317 RID: 791 RVA: 0x0000A3CC File Offset: 0x000085CC
 public DmoMediaType?GetOutputType(int outputStream, int outputTypeIndex)
 {
     try
     {
         DmoMediaType value;
         if (this.mediaObject.GetOutputType(outputStream, outputTypeIndex, out value) == 0)
         {
             DmoInterop.MoFreeMediaType(ref value);
             return(new DmoMediaType?(value));
         }
     }
     catch (COMException exception)
     {
         if (exception.GetHResult() != -2147220986)
         {
             throw;
         }
     }
     return(null);
 }
コード例 #10
0
ファイル: DmoEnumerator.cs プロジェクト: phucpdph10868/EOS
        private static IEnumerable <DmoDescriptor> GetDmos(Guid category)
        {
            IEnumDmo enumDmo;
            int      hresult = DmoInterop.DMOEnum(ref category, DmoEnumFlags.None, 0, null, 0, null, out enumDmo);

            Marshal.ThrowExceptionForHR(hresult);
            int itemsFetched;

            do
            {
                Guid   guid;
                IntPtr namePointer;
                enumDmo.Next(1, out guid, out namePointer, out itemsFetched);
                if (itemsFetched == 1)
                {
                    string name = Marshal.PtrToStringUni(namePointer);
                    Marshal.FreeCoTaskMem(namePointer);
                    yield return(new DmoDescriptor(name, guid));
                }
            }while (itemsFetched > 0);
            yield break;
        }
コード例 #11
0
ファイル: MediaObject.cs プロジェクト: gema-arta/StreamAudio
 /// <summary>
 /// Gets the DMO Media Output type
 /// </summary>
 /// <param name="outputStream">The output stream</param>
 /// <param name="outputTypeIndex">Output type index</param>
 /// <returns>DMO Media Type or null if no more available</returns>
 public DmoMediaType?GetOutputType(int outputStream, int outputTypeIndex)
 {
     try
     {
         DmoMediaType mediaType;
         int          hresult = mediaObject.GetOutputType(outputStream, outputTypeIndex, out mediaType);
         if (hresult == HResult.S_OK)
         {
             // this frees the format (if present)
             // we should therefore come up with a way of marshaling the format
             // into a completely managed structure
             DmoInterop.MoFreeMediaType(ref mediaType);
             return(mediaType);
         }
     }
     catch (COMException e)
     {
         if (e.ErrorCode != (int)DmoHResults.DMO_E_NO_MORE_ITEMS)
         {
             throw;
         }
     }
     return(null);
 }