protected override unsafe void Dispose(bool disposing) { if (disposing) { if (mediaEngineNotifyImpl != null) { mediaEngineNotifyImpl.Dispose(); mediaEngineNotifyImpl = null; } } base.Dispose(disposing); }
/// <summary> /// Initializes an instance of the <see cref="MediaEngine"/> class. /// </summary> /// <param name="factory"></param> /// <param name="attributes"></param> /// <param name="createFlags"> </param> public MediaEngine(MediaEngineClassFactory factory, MediaEngineAttributes attributes = null, MediaEngineCreateFlags createFlags = MediaEngineCreateFlags.None, MediaEngineNotifyDelegate playbackCallback = null) { // Create engine attributes if null attributes = attributes ?? new MediaEngineAttributes(); PlaybackEvent = playbackCallback; // Setup by default the MediaEngine notify as it is mandatory mediaEngineNotifyImpl = new MediaEngineNotifyImpl(this); try { attributes.Set(MediaEngineAttributeKeys.Callback, new ComObject(MediaEngineNotifyShadow.ToIntPtr(mediaEngineNotifyImpl))); factory.CreateInstance(createFlags, attributes, this); } catch { mediaEngineNotifyImpl.Dispose(); mediaEngineNotifyImpl = null; throw; } }
/// <summary> /// Initializes an instance of the <see cref="MediaEngine"/> class. /// </summary> /// <param name="factory"></param> /// <param name="attributes"></param> /// <param name="createFlags"> </param> /// <param name="playbackCallback"></param> /// <msdn-id>hh447921</msdn-id> /// <unmanaged>HRESULT IMFMediaEngineClassFactory::CreateInstance([In] MF_MEDIA_ENGINE_CREATEFLAGS dwFlags,[In] IMFAttributes* pAttr,[Out, Fast] IMFMediaEngine** ppPlayer)</unmanaged> /// <unmanaged-short>IMFMediaEngineClassFactory::CreateInstance</unmanaged-short> public MediaEngine(MediaEngineClassFactory factory, MediaEngineAttributes attributes = null, MediaEngineCreateFlags createFlags = MediaEngineCreateFlags.None, MediaEngineNotifyDelegate playbackCallback = null) { // Create engine attributes if null attributes = attributes ?? new MediaEngineAttributes(); if (playbackCallback != null) { PlaybackEvent += playbackCallback; } // Setup by default the MediaEngine notify as it is mandatory mediaEngineNotifyImpl = new MediaEngineNotifyImpl(this); try { attributes.Set(MediaEngineAttributeKeys.Callback, new ComObject(MediaEngineNotifyShadow.ToIntPtr(mediaEngineNotifyImpl))); factory.CreateInstance(createFlags, attributes, this); } catch { mediaEngineNotifyImpl.Dispose(); mediaEngineNotifyImpl = null; throw; } }