/// <summary> /// /// </summary> /// <param name="pDESGroup">Timeline DESGroup info</param> /// <param name="pCallback">Client callback</param> /// <param name="pEventSink">Event sync to call on file complete</param> /// <param name="ec">Event code to send on file completion</param> public DESCallback( DESGroup pDESGroup, IDESCombineCB pCallback, IMediaEventSink pEventSink, EventCode ec, List <Layer> myDS ) { m_pCallback = pCallback; m_DESGroup = pDESGroup; m_pEventSink = pEventSink; m_ec = ec; MarqueeDS = myDS; m_iCurFrame = 0; m_iCurFile = 0; MediaFile mf = m_DESGroup.File(m_iCurFile); if (mf != null) { m_CurFileName = mf.FileName; m_iMaxFrame = mf.LengthInFrames; } else { m_CurFileName = null; m_iMaxFrame = int.MaxValue; } OffsetArrX = new float[MarqueeDS.Count]; OffsetArrY = new float[MarqueeDS.Count]; }
/// <summary> /// /// </summary> /// <param name="pGroup">Timeline group info</param> /// <param name="pCallback">Client callback</param> /// <param name="pEventSink">Event sync to call on file complete</param> /// <param name="ec">Event code to send on file completion</param> public AVCallback( MediaGroup pGroup, IDESCombineCB pCallback, IMediaEventSink pEventSink, EventCode ec ) { m_pCallback = pCallback; m_Group = pGroup; m_pEventSink = pEventSink; m_ec = ec; m_iCurFrame = 0; m_iCurFile = 0; MediaFile mf = m_Group.File(m_iCurFile); if (mf != null) { m_CurFileName = mf.FileName; m_iMaxFrame = mf.LengthInFrames; } else { m_CurFileName = null; m_iMaxFrame = int.MaxValue; } }
/// <summary> /// /// </summary> /// <param name="pGroup">Timeline group info</param> /// <param name="pCallback">Client callback</param> /// <param name="pEventSink">Event sync to call on file complete</param> /// <param name="ec">Event code to send on file completion</param> public CallbackHandler( IGroup pGroup, IDESCombineCB pCallback, IMediaEventSink pEventSink, EventCode ec ) { m_pCallback = pCallback; m_Group = pGroup; m_pEventSink = pEventSink; m_ec = ec; m_iCurFrame = 0; m_iCurFile = 0; // TODO: fix this or chuck it MediaFile mf = null; // m_Group.File(m_iCurFile); if (mf != null) { m_CurFileName = mf.FileName; m_iMaxFrame = mf.LengthInFrames; } else { m_CurFileName = null; m_iMaxFrame = int.MaxValue; } }
private void Configure() { int hr; m_FilterGraph = (IFilterGraph2) new FilterGraph(); DsROTEntry rot = new DsROTEntry(m_FilterGraph); hr = m_FilterGraph.RenderFile("foo.avi", null); DsError.ThrowExceptionForHR(hr); m_mes = (IMediaEventSink)m_FilterGraph; }
protected int m_TokenCounter; // Counter. Incremented whenever we create new samples. #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> public EVRCustomPresenter() { if (System.Threading.Thread.CurrentThread.GetApartmentState() != System.Threading.ApartmentState.MTA) { throw new Exception("Unsupported theading model"); } m_iDiscarded = 0; m_pClock = null; m_pMixer = null; m_pMediaEventSink = null; m_h2 = null; m_pMediaType = null; m_bSampleNotify = false; m_bRepaint = false; m_bEndStreaming = false; m_bPrerolled = false; m_RenderState = RenderState.Shutdown; m_fRate = 1.0f; m_TokenCounter = 0; m_pD3DPresentEngine = new D3DPresentEngine(); m_FrameStep = new FrameStep(); // Frame-stepping information. m_nrcSource = new MFVideoNormalizedRect(0.0f, 0.0f, 1.0f, 1.0f); m_scheduler = new Scheduler(D3DPresentEngine.PRESENTER_BUFFER_COUNT, m_pD3DPresentEngine); // Manages scheduling of samples. m_SamplePool = new SamplePool(D3DPresentEngine.PRESENTER_BUFFER_COUNT); // Pool of allocated samples. // Force load of mf.dll now, rather than when we try to start streaming DllCanUnloadNow(); }
//public void InitServicePointers(IMFTopologyServiceLookup pLookup) public int InitServicePointers(IntPtr p1Lookup) { // Make sure we *never* leave this entry point with an exception try { TRACE(("InitServicePointers")); int hr; int dwObjectCount = 0; IMFTopologyServiceLookup pLookup = null; IHack h1 = (IHack)new Hack(); try { h1.Set(p1Lookup, typeof(IMFTopologyServiceLookup).GUID, true); pLookup = (IMFTopologyServiceLookup)h1; lock (this) { // Do not allow initializing when playing or paused. if (IsActive()) { throw new COMException("EVRCustomPresenter::InitServicePointers", MFError.MF_E_INVALIDREQUEST); } SafeRelease(m_pClock); m_pClock = null; SafeRelease(m_pMixer); m_pMixer = null; SafeRelease(m_h2); m_h2 = null; m_pMediaEventSink = null; // SafeRelease(m_pMediaEventSink); dwObjectCount = 1; object[] o = new object[1]; try { // Ask for the clock. Optional, because the EVR might not have a clock. hr = pLookup.LookupService( MFServiceLookupType.Global, // Not used. 0, // Reserved. MFServices.MR_VIDEO_RENDER_SERVICE, // Service to look up. typeof(IMFClock).GUID, // Interface to look up. o, ref dwObjectCount // Number of elements in the previous parameter. ); MFError.ThrowExceptionForHR(hr); m_pClock = (IMFClock)o[0]; } catch { } // Ask for the mixer. (Required.) dwObjectCount = 1; hr = pLookup.LookupService( MFServiceLookupType.Global, 0, MFServices.MR_VIDEO_MIXER_SERVICE, typeof(IMFTransform).GUID, o, ref dwObjectCount ); MFError.ThrowExceptionForHR(hr); m_pMixer = (IMFTransform)o[0]; // Make sure that we can work with this mixer. ConfigureMixer(m_pMixer); // Ask for the EVR's event-sink interface. (Required.) dwObjectCount = 1; IMFTopologyServiceLookupAlt pLookup2 = (IMFTopologyServiceLookupAlt)pLookup; IntPtr[] p2 = new IntPtr[1]; hr = pLookup2.LookupService( MFServiceLookupType.Global, 0, MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMediaEventSink).GUID, p2, ref dwObjectCount ); MFError.ThrowExceptionForHR(hr); m_h2 = (IHack)new Hack(); m_h2.Set(p2[0], typeof(IMediaEventSink).GUID, false); m_pMediaEventSink = (IMediaEventSink)m_h2; // Successfully initialized. Set the state to "stopped." m_RenderState = RenderState.Stopped; } } finally { SafeRelease(h1); } return S_Ok; } catch (Exception e) { return Marshal.GetHRForException(e); } }
public int ReleaseServicePointers() { // Make sure we *never* leave this entry point with an exception try { TRACE(("ReleaseServicePointers")); // Enter the shut-down state. { lock (this) { m_RenderState = RenderState.Shutdown; } } // Flush any samples that were scheduled. Flush(); // Clear the media type and release related resources (surfaces, etc). SetMediaType(null); // Release all services that were acquired from InitServicePointers. SafeRelease(m_pClock); m_pClock = null; SafeRelease(m_pMixer); m_pMixer = null; SafeRelease(m_h2); m_h2 = null; m_pMediaEventSink = null; // SafeRelease(m_pMediaEventSink); return S_Ok; } catch (Exception e) { return Marshal.GetHRForException(e); } }
public override void Dispose() { base.Dispose(); if (m_DeviceManager != null) { Marshal.ReleaseComObject(m_DeviceManager); m_DeviceManager = null; } m_pClock = null; if (m_pMixer != IntPtr.Zero) { Marshal.Release(m_pMixer); m_pMixer = IntPtr.Zero; } m_pMediaEventSink = null; m_pMediaType = null; }
public int ReleaseServicePointersImpl() { try { HRESULT hr = S_OK; // Enter the shut-down state. lock (m_ObjectLock) { m_RenderState = RENDER_STATE.RENDER_STATE_SHUTDOWN; } // Flush any samples that were scheduled. Flush(); // Clear the media type and release related resources (surfaces, etc). SetMediaType(null); // Release all services that were acquired from InitServicePointers. m_pClock = null; if (m_pMixer != IntPtr.Zero) { Marshal.Release(m_pMixer); m_pMixer = IntPtr.Zero; } m_pMediaEventSink = null; return hr; } catch (Exception _exception) { throw _exception; } }
public int InitServicePointersImpl(IntPtr pLookup) { try { if (pLookup == IntPtr.Zero) return E_POINTER; HRESULT hr = S_OK; lock (m_ObjectLock) { // Do not allow initializing when playing or paused. if (IsActive()) return MFHelper.MF_E_INVALIDREQUEST; if (m_pMixer != IntPtr.Zero) { Marshal.Release(m_pMixer); m_pMixer = IntPtr.Zero; } m_pClock = null; m_pMediaEventSink = null; uint dwObjectCount; MFTopologyServiceLookup _lookUp = new MFTopologyServiceLookup(pLookup); if (hr.Succeeded) { // Ask for the clock. Optional, because the EVR might not have a clock. dwObjectCount = 1; IntPtr[] o = new IntPtr[dwObjectCount]; _lookUp.LookupService( MFServiceLookUpType.GLOBAL, 0, MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFClock).GUID, o, ref dwObjectCount ); if (o[0] != IntPtr.Zero && dwObjectCount > 0) { m_pClock = (IMFClock)Marshal.GetObjectForIUnknown(o[0]); } // Ask for the mixer. (Required.) dwObjectCount = 1; hr = (HRESULT)_lookUp.LookupService( MFServiceLookUpType.GLOBAL, 0, MFServices.MR_VIDEO_MIXER_SERVICE, typeof(IMFTransform).GUID, o, ref dwObjectCount); hr.Assert(); if (o[0] != IntPtr.Zero && dwObjectCount > 0) { m_pMixer = o[0]; } hr = ConfigureMixer((IMFTransform)Marshal.GetObjectForIUnknown(m_pMixer)); hr.Assert(); if (hr.Failed) return hr; o[0] = IntPtr.Zero; // Ask for the EVR's event-sink interface. (Required.) dwObjectCount = 1; hr = (HRESULT)_lookUp.LookupService( MFServiceLookUpType.GLOBAL, 0, MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMediaEventSink).GUID, o, ref dwObjectCount); hr.Assert(); if (hr.Failed) return hr; if (o[0] != IntPtr.Zero && dwObjectCount > 0) { m_pMediaEventSink = new MediaEventSink(o[0]); } // Successfully initialized. Set the state to "stopped." m_RenderState = RENDER_STATE.RENDER_STATE_STOPPED; } _lookUp.Dispose(); } return hr; } catch (Exception _exception) { throw _exception; } }