Commit c3664153 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

strmbase: Merge enumpins.c into filter.c.

parent 38291846
......@@ -9,7 +9,6 @@ C_SRCS = \
avimux.c \
capturegraph.c \
dllfunc.c \
enumpins.c \
filter.c \
mediatype.c \
pin.c \
......
......@@ -3,7 +3,6 @@ MODULE = libstrmbase.a
C_SRCS = \
dispatch.c \
dllfunc.c \
enumpins.c \
filter.c \
mediatype.c \
outputqueue.c \
......
/*
* Implementation of IEnumPins Interface
*
* Copyright 2003 Robert Shearman
* Copyright 2010 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "strmbase_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
typedef struct IEnumPinsImpl
{
IEnumPins IEnumPins_iface;
LONG refCount;
unsigned int uIndex, count;
struct strmbase_filter *base;
DWORD Version;
} IEnumPinsImpl;
static inline IEnumPinsImpl *impl_from_IEnumPins(IEnumPins *iface)
{
return CONTAINING_RECORD(iface, IEnumPinsImpl, IEnumPins_iface);
}
static const struct IEnumPinsVtbl IEnumPinsImpl_Vtbl;
HRESULT enum_pins_create(struct strmbase_filter *base, IEnumPins **out)
{
IEnumPinsImpl *object;
if (!out)
return E_POINTER;
if (!(object = heap_alloc_zero(sizeof(*object))))
{
*out = NULL;
return E_OUTOFMEMORY;
}
object->IEnumPins_iface.lpVtbl = &IEnumPinsImpl_Vtbl;
object->refCount = 1;
object->base = base;
IBaseFilter_AddRef(&base->IBaseFilter_iface);
object->Version = base->pin_version;
while (base->ops->filter_get_pin(base, object->count))
++object->count;
TRACE("Created enumerator %p.\n", object);
*out = &object->IEnumPins_iface;
return S_OK;
}
static HRESULT WINAPI IEnumPinsImpl_QueryInterface(IEnumPins * iface, REFIID riid, LPVOID * ppv)
{
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
*ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown))
*ppv = iface;
else if (IsEqualIID(riid, &IID_IEnumPins))
*ppv = iface;
if (*ppv)
{
IUnknown_AddRef((IUnknown *)(*ppv));
return S_OK;
}
FIXME("No interface for %s!\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI IEnumPinsImpl_AddRef(IEnumPins * iface)
{
IEnumPinsImpl *This = impl_from_IEnumPins(iface);
ULONG ref = InterlockedIncrement(&This->refCount);
TRACE("(%p)->(): new ref = %u\n", iface, ref);
return ref;
}
static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface)
{
IEnumPinsImpl *This = impl_from_IEnumPins(iface);
ULONG ref = InterlockedDecrement(&This->refCount);
TRACE("(%p)->(): new ref = %u\n", iface, ref);
if (!ref)
{
IBaseFilter_Release(&This->base->IBaseFilter_iface);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin ** ppPins, ULONG * pcFetched)
{
IEnumPinsImpl *This = impl_from_IEnumPins(iface);
ULONG i;
TRACE("(%p)->(%u, %p, %p)\n", iface, cPins, ppPins, pcFetched);
if (!ppPins)
return E_POINTER;
if (cPins > 1 && !pcFetched)
return E_INVALIDARG;
if (pcFetched)
*pcFetched = 0;
if (This->Version != This->base->pin_version)
return VFW_E_ENUM_OUT_OF_SYNC;
for (i = 0; i < cPins; ++i)
{
struct strmbase_pin *pin = This->base->ops->filter_get_pin(This->base, This->uIndex + i);
if (!pin)
break;
IPin_AddRef(ppPins[i] = &pin->IPin_iface);
}
if (pcFetched)
*pcFetched = i;
This->uIndex += i;
if (i < cPins)
return S_FALSE;
return S_OK;
}
static HRESULT WINAPI IEnumPinsImpl_Skip(IEnumPins *iface, ULONG count)
{
IEnumPinsImpl *enum_pins = impl_from_IEnumPins(iface);
TRACE("enum_pins %p, count %u.\n", enum_pins, count);
if (enum_pins->Version != enum_pins->base->pin_version)
return VFW_E_ENUM_OUT_OF_SYNC;
if (enum_pins->uIndex + count > enum_pins->count)
return S_FALSE;
enum_pins->uIndex += count;
return S_OK;
}
static HRESULT WINAPI IEnumPinsImpl_Reset(IEnumPins *iface)
{
IEnumPinsImpl *enum_pins = impl_from_IEnumPins(iface);
TRACE("iface %p.\n", iface);
if (enum_pins->Version != enum_pins->base->pin_version)
{
enum_pins->count = 0;
while (enum_pins->base->ops->filter_get_pin(enum_pins->base, enum_pins->count))
++enum_pins->count;
}
enum_pins->Version = enum_pins->base->pin_version;
enum_pins->uIndex = 0;
return S_OK;
}
static HRESULT WINAPI IEnumPinsImpl_Clone(IEnumPins *iface, IEnumPins **out)
{
IEnumPinsImpl *enum_pins = impl_from_IEnumPins(iface);
HRESULT hr;
TRACE("iface %p, out %p.\n", iface, out);
if (FAILED(hr = enum_pins_create(enum_pins->base, out)))
return hr;
return IEnumPins_Skip(*out, enum_pins->uIndex);
}
static const IEnumPinsVtbl IEnumPinsImpl_Vtbl =
{
IEnumPinsImpl_QueryInterface,
IEnumPinsImpl_AddRef,
IEnumPinsImpl_Release,
IEnumPinsImpl_Next,
IEnumPinsImpl_Skip,
IEnumPinsImpl_Reset,
IEnumPinsImpl_Clone
};
......@@ -22,6 +22,182 @@
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
struct enum_pins
{
IEnumPins IEnumPins_iface;
LONG refcount;
unsigned int index, count;
int version;
struct strmbase_filter *filter;
};
static const IEnumPinsVtbl enum_pins_vtbl;
static HRESULT enum_pins_create(struct strmbase_filter *filter, IEnumPins **out)
{
struct enum_pins *object;
if (!out)
return E_POINTER;
if (!(object = heap_alloc_zero(sizeof(*object))))
{
*out = NULL;
return E_OUTOFMEMORY;
}
object->IEnumPins_iface.lpVtbl = &enum_pins_vtbl;
object->refcount = 1;
object->filter = filter;
IBaseFilter_AddRef(&filter->IBaseFilter_iface);
object->version = filter->pin_version;
while (filter->ops->filter_get_pin(filter, object->count))
++object->count;
TRACE("Created enumerator %p.\n", object);
*out = &object->IEnumPins_iface;
return S_OK;
}
static inline struct enum_pins *impl_from_IEnumPins(IEnumPins *iface)
{
return CONTAINING_RECORD(iface, struct enum_pins, IEnumPins_iface);
}
static HRESULT WINAPI enum_pins_QueryInterface(IEnumPins *iface, REFIID iid, void **out)
{
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumPins))
{
IEnumPins_AddRef(iface);
*out = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI enum_pins_AddRef(IEnumPins *iface)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
ULONG refcount = InterlockedIncrement(&enum_pins->refcount);
TRACE("%p increasing refcount to %u.\n", enum_pins, refcount);
return refcount;
}
static ULONG WINAPI enum_pins_Release(IEnumPins *iface)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
ULONG refcount = InterlockedDecrement(&enum_pins->refcount);
TRACE("%p decreasing refcount to %u.\n", enum_pins, refcount);
if (!refcount)
{
IBaseFilter_Release(&enum_pins->filter->IBaseFilter_iface);
heap_free(enum_pins);
}
return refcount;
}
static HRESULT WINAPI enum_pins_Next(IEnumPins *iface, ULONG count, IPin **pins, ULONG *ret_count)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
unsigned int i;
TRACE("iface %p, count %u, pins %p, ret_count %p.\n", iface, count, pins, ret_count);
if (!pins)
return E_POINTER;
if (count > 1 && !ret_count)
return E_INVALIDARG;
if (ret_count)
*ret_count = 0;
if (enum_pins->version != enum_pins->filter->pin_version)
return VFW_E_ENUM_OUT_OF_SYNC;
for (i = 0; i < count; ++i)
{
struct strmbase_pin *pin = enum_pins->filter->ops->filter_get_pin(enum_pins->filter, enum_pins->index + i);
if (!pin)
break;
IPin_AddRef(pins[i] = &pin->IPin_iface);
}
if (ret_count)
*ret_count = i;
enum_pins->index += i;
return i == count ? S_OK : S_FALSE;
}
static HRESULT WINAPI enum_pins_Skip(IEnumPins *iface, ULONG count)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
TRACE("iface %p, count %u.\n", iface, count);
if (enum_pins->version != enum_pins->filter->pin_version)
return VFW_E_ENUM_OUT_OF_SYNC;
if (enum_pins->index + count > enum_pins->count)
return S_FALSE;
enum_pins->index += count;
return S_OK;
}
static HRESULT WINAPI enum_pins_Reset(IEnumPins *iface)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
TRACE("iface %p.\n", iface);
if (enum_pins->version != enum_pins->filter->pin_version)
{
enum_pins->count = 0;
while (enum_pins->filter->ops->filter_get_pin(enum_pins->filter, enum_pins->count))
++enum_pins->count;
}
enum_pins->version = enum_pins->filter->pin_version;
enum_pins->index = 0;
return S_OK;
}
static HRESULT WINAPI enum_pins_Clone(IEnumPins *iface, IEnumPins **out)
{
struct enum_pins *enum_pins = impl_from_IEnumPins(iface);
HRESULT hr;
TRACE("iface %p, out %p.\n", iface, out);
if (FAILED(hr = enum_pins_create(enum_pins->filter, out)))
return hr;
return IEnumPins_Skip(*out, enum_pins->index);
}
static const IEnumPinsVtbl enum_pins_vtbl =
{
enum_pins_QueryInterface,
enum_pins_AddRef,
enum_pins_Release,
enum_pins_Next,
enum_pins_Skip,
enum_pins_Reset,
enum_pins_Clone,
};
static inline struct strmbase_filter *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, struct strmbase_filter, IUnknown_inner);
......
......@@ -77,7 +77,6 @@ void QualityControlRender_DoQOS(QualityControlImpl *priv);
void QualityControlRender_BeginRender(QualityControlImpl *This, REFERENCE_TIME start, REFERENCE_TIME stop);
void QualityControlRender_EndRender(QualityControlImpl *This);
HRESULT enum_pins_create(struct strmbase_filter *filter, IEnumPins **enum_pins);
HRESULT enum_media_types_create(struct strmbase_pin *pin, IEnumMediaTypes **enum_media_types) DECLSPEC_HIDDEN;
HRESULT WINAPI RendererPosPassThru_RegisterMediaTime(IUnknown *iface, REFERENCE_TIME start);
......
......@@ -6,7 +6,6 @@ PARENTSRC = ../strmbase
C_SRCS = \
dllfunc.c \
enumpins.c \
filter.c \
gst_cbs.c \
gstdemux.c \
......
......@@ -5,7 +5,6 @@ PARENTSRC = ../strmbase
C_SRCS = \
dllfunc.c \
enumpins.c \
filter.c \
main.c \
mediatype.c \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment