protected override IMFSourceReader CreateReader(MediaFoundationReader.MediaFoundationReaderSettings settings)
        {
            IMFSourceReader expr_15 = MediaFoundationApi.CreateSourceReaderFromByteStream(MediaFoundationApi.CreateByteStream(new ComStream(this.stream)));

            expr_15.SetStreamSelection(-2, false);
            expr_15.SetStreamSelection(-3, true);
            expr_15.SetCurrentMediaType(-3, IntPtr.Zero, new MediaType
            {
                MajorType = MediaTypes.MFMediaType_Audio,
                SubType   = settings.RequestFloatOutput ? AudioSubtypes.MFAudioFormat_Float : AudioSubtypes.MFAudioFormat_PCM
            }.MediaFoundationObject);
            return(expr_15);
        }
示例#2
0
        protected void Init(MediaFoundationReader.MediaFoundationReaderSettings initialSettings)
        {
            MediaFoundationApi.Startup();
            this.settings = (initialSettings ?? new MediaFoundationReader.MediaFoundationReaderSettings());
            IMFSourceReader iMFSourceReader = this.CreateReader(this.settings);

            this.waveFormat = this.GetCurrentWaveFormat(iMFSourceReader);
            iMFSourceReader.SetStreamSelection(-3, true);
            this.length = this.GetLength(iMFSourceReader);
            if (this.settings.SingleReaderObject)
            {
                this.pReader = iMFSourceReader;
            }
        }
示例#3
0
        protected virtual IMFSourceReader CreateReader(MediaFoundationReader.MediaFoundationReaderSettings settings)
        {
            IMFSourceReader iMFSourceReader;

            MediaFoundationInterop.MFCreateSourceReaderFromURL(this.file, null, out iMFSourceReader);
            iMFSourceReader.SetStreamSelection(-2, false);
            iMFSourceReader.SetStreamSelection(-3, true);
            MediaType mediaType = new MediaType();

            mediaType.MajorType = MediaTypes.MFMediaType_Audio;
            mediaType.SubType   = (settings.RequestFloatOutput ? AudioSubtypes.MFAudioFormat_Float : AudioSubtypes.MFAudioFormat_PCM);
            MediaType currentMediaType = MediaFoundationReader.GetCurrentMediaType(iMFSourceReader);

            mediaType.ChannelCount = currentMediaType.ChannelCount;
            mediaType.SampleRate   = currentMediaType.SampleRate;
            iMFSourceReader.SetCurrentMediaType(-3, IntPtr.Zero, mediaType.MediaFoundationObject);
            Marshal.ReleaseComObject(currentMediaType.MediaFoundationObject);
            return(iMFSourceReader);
        }
 public StreamMediaFoundationReader(Stream stream, MediaFoundationReader.MediaFoundationReaderSettings settings = null)
 {
     this.stream = stream;
     base.Init(settings);
 }
示例#5
0
 public MediaFoundationReader(string file, MediaFoundationReader.MediaFoundationReaderSettings settings)
 {
     this.file = file;
     this.Init(settings);
 }