示例#1
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>
        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
        /// <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>
        /// 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");
            }
        }
示例#4
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>
 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.GetHResult() != (int)DmoHResults.DMO_E_NO_MORE_ITEMS)
         {
             throw;
         }
     }
     return(null);
 }