コード例 #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>
        /// 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");
            }
        }
コード例 #5
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");
            }
        }
コード例 #6
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);
        }
コード例 #7
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);
 }
コード例 #8
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);
 }