• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 #include "dshow_capture.h"
23 
24 DECLARE_QUERYINTERFACE(enumpins, DShowEnumPins,
25     { {&IID_IUnknown,0}, {&IID_IEnumPins,0} })
DECLARE_ADDREF(enumpins,DShowEnumPins)26 DECLARE_ADDREF(enumpins, DShowEnumPins)
27 DECLARE_RELEASE(enumpins, DShowEnumPins)
28 
29 long ff_dshow_enumpins_Next(DShowEnumPins *this, unsigned long n, IPin **pins,
30                    unsigned long *fetched)
31 {
32     int count = 0;
33     dshowdebug("ff_dshow_enumpins_Next(%p)\n", this);
34     if (!pins)
35         return E_POINTER;
36     if (!this->pos && n == 1) {
37         ff_dshow_pin_AddRef(this->pin);
38         *pins = (IPin *) this->pin;
39         count = 1;
40         this->pos = 1;
41     }
42     if (fetched)
43         *fetched = count;
44     if (!count)
45         return S_FALSE;
46     return S_OK;
47 }
ff_dshow_enumpins_Skip(DShowEnumPins * this,unsigned long n)48 long ff_dshow_enumpins_Skip(DShowEnumPins *this, unsigned long n)
49 {
50     dshowdebug("ff_dshow_enumpins_Skip(%p)\n", this);
51     if (n) /* Any skip will always fall outside of the only valid pin. */
52         return S_FALSE;
53     return S_OK;
54 }
ff_dshow_enumpins_Reset(DShowEnumPins * this)55 long ff_dshow_enumpins_Reset(DShowEnumPins *this)
56 {
57     dshowdebug("ff_dshow_enumpins_Reset(%p)\n", this);
58     this->pos = 0;
59     return S_OK;
60 }
ff_dshow_enumpins_Clone(DShowEnumPins * this,DShowEnumPins ** pins)61 long ff_dshow_enumpins_Clone(DShowEnumPins *this, DShowEnumPins **pins)
62 {
63     DShowEnumPins *new;
64     dshowdebug("ff_dshow_enumpins_Clone(%p)\n", this);
65     if (!pins)
66         return E_POINTER;
67     new = ff_dshow_enumpins_Create(this->pin, this->filter);
68     if (!new)
69         return E_OUTOFMEMORY;
70     new->pos = this->pos;
71     *pins = new;
72     return S_OK;
73 }
74 
ff_dshow_enumpins_Setup(DShowEnumPins * this,DShowPin * pin,DShowFilter * filter)75 static int ff_dshow_enumpins_Setup(DShowEnumPins *this, DShowPin *pin, DShowFilter *filter)
76 {
77     IEnumPinsVtbl *vtbl = this->vtbl;
78     SETVTBL(vtbl, enumpins, QueryInterface);
79     SETVTBL(vtbl, enumpins, AddRef);
80     SETVTBL(vtbl, enumpins, Release);
81     SETVTBL(vtbl, enumpins, Next);
82     SETVTBL(vtbl, enumpins, Skip);
83     SETVTBL(vtbl, enumpins, Reset);
84     SETVTBL(vtbl, enumpins, Clone);
85 
86     this->pin = pin;
87     this->filter = filter;
88     ff_dshow_filter_AddRef(this->filter);
89 
90     return 1;
91 }
ff_dshow_enumpins_Cleanup(DShowEnumPins * this)92 static int ff_dshow_enumpins_Cleanup(DShowEnumPins *this)
93 {
94     ff_dshow_filter_Release(this->filter);
95     return 1;
96 }
97 DECLARE_CREATE(enumpins, DShowEnumPins, ff_dshow_enumpins_Setup(this, pin, filter),
98                DShowPin *pin, DShowFilter *filter)
99 DECLARE_DESTROY(enumpins, DShowEnumPins, ff_dshow_enumpins_Cleanup)
100