Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.5 KiB

  1. //==========================================================================;
  2. //
  3. // pbsegimpl.h : additional infrastructure to support implementing IMSVidGraphSegment for
  4. // playback segments
  5. // nicely from c++
  6. // Copyright (c) Microsoft Corporation 1999.
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. #pragma once
  10. #ifndef PBSEGIMPL_H
  11. #define PBSEGIMPL_H
  12. #include <segimpl.h>
  13. #include <evcode.h>
  14. #include <deviceeventimpl.h>
  15. namespace MSVideoControl {
  16. template<class T, enum MSVidSegmentType segtype, LPCGUID pCategory, class MostDerivedClass = IMSVidGraphSegment>
  17. class DECLSPEC_NOVTABLE IMSVidPBGraphSegmentImpl :
  18. public IMSVidGraphSegmentImpl<T, segtype, pCategory, MostDerivedClass> {
  19. protected:
  20. public:
  21. // DON'T addref the container. we're guaranteed nested lifetimes
  22. // and an addref creates circular refcounts so we never unload.
  23. IMSVidPBGraphSegmentImpl() {}
  24. virtual ~IMSVidPBGraphSegmentImpl() {}
  25. STDMETHOD(OnEventNotify)(LONG lEvent, LONG_PTR lParm1, LONG_PTR lParm2) {
  26. if (lEvent == EC_COMPLETE) {
  27. T* pt = static_cast<T*>(this);
  28. CComQIPtr<IMSVidPlayback> ppb(this);
  29. if (!ppb) {
  30. return E_UNEXPECTED;
  31. }
  32. pt->Fire_EndOfMedia(ppb);
  33. // call Stop to make sure graph is stopped properly
  34. PQVidCtl pV(m_pContainer);
  35. pV->Stop();
  36. return NOERROR; // we notify caller that we handled the event if stop() fails
  37. }
  38. return E_NOTIMPL;
  39. }
  40. };
  41. template <class T, const IID* piid = &IID_IMSVidPlaybackEvent, class CDV = CComDynamicUnkArray>
  42. class CProxy_PlaybackEvent : public CProxy_DeviceEvent<T, piid, CDV>
  43. {
  44. public:
  45. VOID Fire_EndOfMedia(IMSVidPlayback *pPBDev)
  46. {
  47. T* pT = static_cast<T*>(this);
  48. int nConnectionIndex;
  49. CComVariant* pvars = new CComVariant[1];
  50. int nConnections = m_vec.GetSize();
  51. for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
  52. {
  53. pT->Lock();
  54. CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
  55. pT->Unlock();
  56. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
  57. if (pDispatch != NULL)
  58. {
  59. pvars[0] = pPBDev;
  60. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  61. pDispatch->Invoke(eventidEndOfMedia, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  62. }
  63. }
  64. delete[] pvars;
  65. }
  66. };
  67. }; // namespace
  68. #endif
  69. // end of file - pbsegimpl.h