dshow_enumpins.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * DirectShow capture interface
  3. * Copyright (c) 2010 Ramiro Polla
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "dshow_capture.h"
  22. DECLARE_QUERYINTERFACE(enumpins, DShowEnumPins,
  23. { {&IID_IUnknown,0}, {&IID_IEnumPins,0} })
  24. DECLARE_ADDREF(enumpins, DShowEnumPins)
  25. DECLARE_RELEASE(enumpins, DShowEnumPins)
  26. long WINAPI ff_dshow_enumpins_Next(DShowEnumPins *this, unsigned long n, IPin **pins,
  27. unsigned long *fetched)
  28. {
  29. int count = 0;
  30. dshowdebug("ff_dshow_enumpins_Next(%p)\n", this);
  31. if (!pins)
  32. return E_POINTER;
  33. if (!this->pos && n == 1) {
  34. ff_dshow_pin_AddRef(this->pin);
  35. *pins = (IPin *) this->pin;
  36. count = 1;
  37. this->pos = 1;
  38. }
  39. if (fetched)
  40. *fetched = count;
  41. if (!count)
  42. return S_FALSE;
  43. return S_OK;
  44. }
  45. long WINAPI ff_dshow_enumpins_Skip(DShowEnumPins *this, unsigned long n)
  46. {
  47. dshowdebug("ff_dshow_enumpins_Skip(%p)\n", this);
  48. if (n) /* Any skip will always fall outside of the only valid pin. */
  49. return S_FALSE;
  50. return S_OK;
  51. }
  52. long WINAPI ff_dshow_enumpins_Reset(DShowEnumPins *this)
  53. {
  54. dshowdebug("ff_dshow_enumpins_Reset(%p)\n", this);
  55. this->pos = 0;
  56. return S_OK;
  57. }
  58. long WINAPI ff_dshow_enumpins_Clone(DShowEnumPins *this, DShowEnumPins **pins)
  59. {
  60. DShowEnumPins *new;
  61. dshowdebug("ff_dshow_enumpins_Clone(%p)\n", this);
  62. if (!pins)
  63. return E_POINTER;
  64. new = ff_dshow_enumpins_Create(this->pin, this->filter);
  65. if (!new)
  66. return E_OUTOFMEMORY;
  67. new->pos = this->pos;
  68. *pins = new;
  69. return S_OK;
  70. }
  71. static int ff_dshow_enumpins_Setup(DShowEnumPins *this, DShowPin *pin, DShowFilter *filter)
  72. {
  73. IEnumPinsVtbl *vtbl = this->vtbl;
  74. SETVTBL(vtbl, enumpins, QueryInterface);
  75. SETVTBL(vtbl, enumpins, AddRef);
  76. SETVTBL(vtbl, enumpins, Release);
  77. SETVTBL(vtbl, enumpins, Next);
  78. SETVTBL(vtbl, enumpins, Skip);
  79. SETVTBL(vtbl, enumpins, Reset);
  80. SETVTBL(vtbl, enumpins, Clone);
  81. this->pin = pin;
  82. this->filter = filter;
  83. ff_dshow_filter_AddRef(this->filter);
  84. return 1;
  85. }
  86. static int ff_dshow_enumpins_Cleanup(DShowEnumPins *this)
  87. {
  88. ff_dshow_filter_Release(this->filter);
  89. return 1;
  90. }
  91. DECLARE_CREATE(enumpins, DShowEnumPins, ff_dshow_enumpins_Setup(this, pin, filter),
  92. DShowPin *pin, DShowFilter *filter)
  93. DECLARE_DESTROY(enumpins, DShowEnumPins, ff_dshow_enumpins_Cleanup)