1
0

seekpt.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //------------------------------------------------------------------------------
  2. // File: SeekPT.cpp
  3. //
  4. // Desc: DirectShow base classes.
  5. //
  6. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #include <streams.h>
  9. #include "seekpt.h"
  10. //==================================================================
  11. // CreateInstance
  12. // This goes in the factory template table to create new instances
  13. // If there is already a mapper instance - return that, else make one
  14. // and save it in a static variable so that forever after we can return that.
  15. //==================================================================
  16. CUnknown * CSeekingPassThru::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
  17. {
  18. return new CSeekingPassThru(NAME("Seeking PassThru"),pUnk, phr);
  19. }
  20. STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
  21. {
  22. if (riid == IID_ISeekingPassThru) {
  23. return GetInterface((ISeekingPassThru *) this, ppv);
  24. } else {
  25. if (m_pPosPassThru &&
  26. (riid == IID_IMediaSeeking ||
  27. riid == IID_IMediaPosition)) {
  28. return m_pPosPassThru->NonDelegatingQueryInterface(riid,ppv);
  29. } else {
  30. return CUnknown::NonDelegatingQueryInterface(riid, ppv);
  31. }
  32. }
  33. }
  34. CSeekingPassThru::CSeekingPassThru( __in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr )
  35. : CUnknown(pName, pUnk, phr),
  36. m_pPosPassThru(NULL)
  37. {
  38. }
  39. CSeekingPassThru::~CSeekingPassThru()
  40. {
  41. delete m_pPosPassThru;
  42. }
  43. STDMETHODIMP CSeekingPassThru::Init(BOOL bRendererSeeking, IPin *pPin)
  44. {
  45. HRESULT hr = NOERROR;
  46. if (m_pPosPassThru) {
  47. hr = E_FAIL;
  48. } else {
  49. m_pPosPassThru =
  50. bRendererSeeking ?
  51. new CRendererPosPassThru(
  52. NAME("Render Seeking COM object"),
  53. (IUnknown *)this,
  54. &hr,
  55. pPin) :
  56. new CPosPassThru(
  57. NAME("Render Seeking COM object"),
  58. (IUnknown *)this,
  59. &hr,
  60. pPin);
  61. if (!m_pPosPassThru) {
  62. hr = E_OUTOFMEMORY;
  63. } else {
  64. if (FAILED(hr)) {
  65. delete m_pPosPassThru;
  66. m_pPosPassThru = NULL;
  67. }
  68. }
  69. }
  70. return hr;
  71. }