dshow_enumpins.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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(libAVEnumPins,
  23. { {&IID_IUnknown,0}, {&IID_IEnumPins,0} })
  24. DECLARE_ADDREF(libAVEnumPins)
  25. DECLARE_RELEASE(libAVEnumPins)
  26. long WINAPI
  27. libAVEnumPins_Next(libAVEnumPins *this, unsigned long n, IPin **pins,
  28. unsigned long *fetched)
  29. {
  30. int count = 0;
  31. dshowdebug("libAVEnumPins_Next(%p)\n", this);
  32. if (!pins)
  33. return E_POINTER;
  34. if (!this->pos && n == 1) {
  35. libAVPin_AddRef(this->pin);
  36. *pins = (IPin *) this->pin;
  37. count = 1;
  38. this->pos = 1;
  39. }
  40. if (fetched)
  41. *fetched = count;
  42. if (!count)
  43. return S_FALSE;
  44. return S_OK;
  45. }
  46. long WINAPI
  47. libAVEnumPins_Skip(libAVEnumPins *this, unsigned long n)
  48. {
  49. dshowdebug("libAVEnumPins_Skip(%p)\n", this);
  50. if (n) /* Any skip will always fall outside of the only valid pin. */
  51. return S_FALSE;
  52. return S_OK;
  53. }
  54. long WINAPI
  55. libAVEnumPins_Reset(libAVEnumPins *this)
  56. {
  57. dshowdebug("libAVEnumPins_Reset(%p)\n", this);
  58. this->pos = 0;
  59. return S_OK;
  60. }
  61. long WINAPI
  62. libAVEnumPins_Clone(libAVEnumPins *this, libAVEnumPins **pins)
  63. {
  64. libAVEnumPins *new;
  65. dshowdebug("libAVEnumPins_Clone(%p)\n", this);
  66. if (!pins)
  67. return E_POINTER;
  68. new = libAVEnumPins_Create(this->pin, this->filter);
  69. if (!new)
  70. return E_OUTOFMEMORY;
  71. new->pos = this->pos;
  72. *pins = new;
  73. return S_OK;
  74. }
  75. static int
  76. libAVEnumPins_Setup(libAVEnumPins *this, libAVPin *pin, libAVFilter *filter)
  77. {
  78. IEnumPinsVtbl *vtbl = this->vtbl;
  79. SETVTBL(vtbl, libAVEnumPins, QueryInterface);
  80. SETVTBL(vtbl, libAVEnumPins, AddRef);
  81. SETVTBL(vtbl, libAVEnumPins, Release);
  82. SETVTBL(vtbl, libAVEnumPins, Next);
  83. SETVTBL(vtbl, libAVEnumPins, Skip);
  84. SETVTBL(vtbl, libAVEnumPins, Reset);
  85. SETVTBL(vtbl, libAVEnumPins, Clone);
  86. this->pin = pin;
  87. this->filter = filter;
  88. libAVFilter_AddRef(this->filter);
  89. return 1;
  90. }
  91. static int
  92. libAVEnumPins_Cleanup(libAVEnumPins *this)
  93. {
  94. libAVFilter_Release(this->filter);
  95. return 1;
  96. }
  97. DECLARE_CREATE(libAVEnumPins, libAVEnumPins_Setup(this, pin, filter),
  98. libAVPin *pin, libAVFilter *filter)
  99. DECLARE_DESTROY(libAVEnumPins, libAVEnumPins_Cleanup)