2011-05-21 15:24:50 +03:00
|
|
|
/*
|
|
|
|
* DirectShow capture interface
|
|
|
|
* Copyright (c) 2010 Ramiro Polla
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg 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.
|
|
|
|
*
|
|
|
|
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2012-05-24 14:59:33 +03:00
|
|
|
#include "dshow_capture.h"
|
2011-05-21 15:24:50 +03:00
|
|
|
|
2021-01-22 00:45:48 +02:00
|
|
|
DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,
|
2014-03-27 23:37:48 +03:00
|
|
|
{ {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
|
2021-01-22 00:45:48 +02:00
|
|
|
DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
|
|
|
|
DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
|
2011-05-21 15:24:50 +03:00
|
|
|
|
2022-01-02 11:49:38 +02:00
|
|
|
long WINAPI ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
|
2011-05-21 15:24:50 +03:00
|
|
|
AM_MEDIA_TYPE **types, unsigned long *fetched)
|
|
|
|
{
|
|
|
|
int count = 0;
|
2021-01-22 00:45:48 +02:00
|
|
|
dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
|
2011-05-21 15:24:50 +03:00
|
|
|
if (!types)
|
|
|
|
return E_POINTER;
|
|
|
|
if (!this->pos && n == 1) {
|
|
|
|
if (!IsEqualGUID(&this->type.majortype, &GUID_NULL)) {
|
|
|
|
AM_MEDIA_TYPE *type = av_malloc(sizeof(AM_MEDIA_TYPE));
|
2015-10-26 20:49:21 +02:00
|
|
|
if (!type)
|
|
|
|
return E_OUTOFMEMORY;
|
2011-05-21 15:24:50 +03:00
|
|
|
ff_copy_dshow_media_type(type, &this->type);
|
|
|
|
*types = type;
|
|
|
|
count = 1;
|
|
|
|
}
|
|
|
|
this->pos = 1;
|
|
|
|
}
|
|
|
|
if (fetched)
|
|
|
|
*fetched = count;
|
|
|
|
if (!count)
|
|
|
|
return S_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 11:49:38 +02:00
|
|
|
long WINAPI ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
|
2011-05-21 15:24:50 +03:00
|
|
|
{
|
2021-01-22 00:45:48 +02:00
|
|
|
dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
|
2011-05-21 15:24:50 +03:00
|
|
|
if (n) /* Any skip will always fall outside of the only valid type. */
|
|
|
|
return S_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 11:49:38 +02:00
|
|
|
long WINAPI ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
|
2011-05-21 15:24:50 +03:00
|
|
|
{
|
2021-01-22 00:45:48 +02:00
|
|
|
dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
|
2011-05-21 15:24:50 +03:00
|
|
|
this->pos = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 11:49:38 +02:00
|
|
|
long WINAPI ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
|
2011-05-21 15:24:50 +03:00
|
|
|
{
|
2021-01-22 00:45:48 +02:00
|
|
|
DShowEnumMediaTypes *new;
|
|
|
|
dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
|
2011-05-21 15:24:50 +03:00
|
|
|
if (!enums)
|
|
|
|
return E_POINTER;
|
2021-01-22 00:45:48 +02:00
|
|
|
new = ff_dshow_enummediatypes_Create(&this->type);
|
2011-05-21 15:24:50 +03:00
|
|
|
if (!new)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
new->pos = this->pos;
|
|
|
|
*enums = new;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-22 00:45:48 +02:00
|
|
|
static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
|
2011-05-21 15:24:50 +03:00
|
|
|
{
|
2014-03-27 23:37:48 +03:00
|
|
|
IEnumMediaTypesVtbl *vtbl = this->vtbl;
|
2021-01-22 00:45:48 +02:00
|
|
|
SETVTBL(vtbl, enummediatypes, QueryInterface);
|
|
|
|
SETVTBL(vtbl, enummediatypes, AddRef);
|
|
|
|
SETVTBL(vtbl, enummediatypes, Release);
|
|
|
|
SETVTBL(vtbl, enummediatypes, Next);
|
|
|
|
SETVTBL(vtbl, enummediatypes, Skip);
|
|
|
|
SETVTBL(vtbl, enummediatypes, Reset);
|
|
|
|
SETVTBL(vtbl, enummediatypes, Clone);
|
2011-05-21 15:24:50 +03:00
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
this->type.majortype = GUID_NULL;
|
|
|
|
} else {
|
|
|
|
ff_copy_dshow_media_type(&this->type, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2021-01-22 00:45:48 +02:00
|
|
|
DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
|
|
|
|
DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)
|