2011-05-21 12:24:50 +00: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 11:59:33 +00:00
|
|
|
#include "dshow_capture.h"
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
2021-01-21 22:45:48 +00:00
|
|
|
#define imemoffset offsetof(DShowPin, imemvtbl)
|
2011-05-21 12:24:50 +00:00
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
DECLARE_QUERYINTERFACE(pin, DShowPin,
|
2011-05-21 12:24:50 +00:00
|
|
|
{ {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,imemoffset} })
|
2021-01-21 22:45:48 +00:00
|
|
|
DECLARE_ADDREF(pin, DShowPin)
|
|
|
|
DECLARE_RELEASE(pin, DShowPin)
|
2011-05-21 12:24:50 +00:00
|
|
|
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_Connect(DShowPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_Connect(%p, %p, %p)\n", this, pin, type);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* Input pins receive connections. */
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_ReceiveConnection(DShowPin *this, IPin *pin,
|
2011-05-21 12:24:50 +00:00
|
|
|
const AM_MEDIA_TYPE *type)
|
|
|
|
{
|
|
|
|
enum dshowDeviceType devtype = this->filter->type;
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_ReceiveConnection(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!pin)
|
|
|
|
return E_POINTER;
|
|
|
|
if (this->connectedto)
|
|
|
|
return VFW_E_ALREADY_CONNECTED;
|
|
|
|
|
|
|
|
ff_print_AM_MEDIA_TYPE(type);
|
|
|
|
if (devtype == VideoDevice) {
|
|
|
|
if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Video))
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
} else {
|
|
|
|
if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Audio))
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPin_AddRef(pin);
|
|
|
|
this->connectedto = pin;
|
|
|
|
|
|
|
|
ff_copy_dshow_media_type(&this->type, type);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_Disconnect(DShowPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_Disconnect(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (this->filter->state != State_Stopped)
|
|
|
|
return VFW_E_NOT_STOPPED;
|
|
|
|
if (!this->connectedto)
|
|
|
|
return S_FALSE;
|
2011-09-09 03:15:54 +00:00
|
|
|
IPin_Release(this->connectedto);
|
2011-05-21 12:24:50 +00:00
|
|
|
this->connectedto = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_ConnectedTo(DShowPin *this, IPin **pin)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_ConnectedTo(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!pin)
|
|
|
|
return E_POINTER;
|
|
|
|
if (!this->connectedto)
|
|
|
|
return VFW_E_NOT_CONNECTED;
|
|
|
|
IPin_AddRef(this->connectedto);
|
|
|
|
*pin = this->connectedto;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_ConnectionMediaType(DShowPin *this, AM_MEDIA_TYPE *type)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_ConnectionMediaType(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!type)
|
|
|
|
return E_POINTER;
|
|
|
|
if (!this->connectedto)
|
|
|
|
return VFW_E_NOT_CONNECTED;
|
|
|
|
|
|
|
|
return ff_copy_dshow_media_type(type, &this->type);
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_QueryPinInfo(DShowPin *this, PIN_INFO *info)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_QueryPinInfo(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (this->filter)
|
2021-01-21 22:45:48 +00:00
|
|
|
ff_dshow_filter_AddRef(this->filter);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
info->pFilter = (IBaseFilter *) this->filter;
|
|
|
|
info->dir = PINDIR_INPUT;
|
|
|
|
wcscpy(info->achName, L"Capture");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_QueryDirection(DShowPin *this, PIN_DIRECTION *dir)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_QueryDirection(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
if (!dir)
|
|
|
|
return E_POINTER;
|
|
|
|
*dir = PINDIR_INPUT;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_QueryId(DShowPin *this, wchar_t **id)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_QueryId(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!id)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*id = wcsdup(L"libAV Pin");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_QueryAccept(DShowPin *this, const AM_MEDIA_TYPE *type)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_QueryAccept(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_EnumMediaTypes(DShowPin *this, IEnumMediaTypes **enumtypes)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
|
|
|
const AM_MEDIA_TYPE *type = NULL;
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowEnumMediaTypes *new;
|
|
|
|
dshowdebug("ff_dshow_pin_EnumMediaTypes(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!enumtypes)
|
|
|
|
return E_POINTER;
|
2021-01-21 22:45:48 +00:00
|
|
|
new = ff_dshow_enummediatypes_Create(type);
|
2011-05-21 12:24:50 +00:00
|
|
|
if (!new)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*enumtypes = (IEnumMediaTypes *) new;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_QueryInternalConnections(DShowPin *this, IPin **pin,
|
2011-05-21 12:24:50 +00:00
|
|
|
unsigned long *npin)
|
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_QueryInternalConnections(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_EndOfStream(DShowPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_EndOfStream(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* I don't care. */
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_BeginFlush(DShowPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_BeginFlush(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* I don't care. */
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_EndFlush(DShowPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_EndFlush(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* I don't care. */
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_pin_NewSegment(DShowPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
|
2011-05-21 12:24:50 +00:00
|
|
|
double rate)
|
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_pin_NewSegment(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* I don't care. */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
static int ff_dshow_pin_Setup(DShowPin *this, DShowFilter *filter)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
|
|
|
IPinVtbl *vtbl = this->vtbl;
|
|
|
|
IMemInputPinVtbl *imemvtbl;
|
|
|
|
|
|
|
|
if (!filter)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
imemvtbl = av_malloc(sizeof(IMemInputPinVtbl));
|
|
|
|
if (!imemvtbl)
|
|
|
|
return 0;
|
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
SETVTBL(imemvtbl, meminputpin, QueryInterface);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, AddRef);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, Release);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, GetAllocator);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, NotifyAllocator);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, GetAllocatorRequirements);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, Receive);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, ReceiveMultiple);
|
|
|
|
SETVTBL(imemvtbl, meminputpin, ReceiveCanBlock);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
this->imemvtbl = imemvtbl;
|
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
SETVTBL(vtbl, pin, QueryInterface);
|
|
|
|
SETVTBL(vtbl, pin, AddRef);
|
|
|
|
SETVTBL(vtbl, pin, Release);
|
|
|
|
SETVTBL(vtbl, pin, Connect);
|
|
|
|
SETVTBL(vtbl, pin, ReceiveConnection);
|
|
|
|
SETVTBL(vtbl, pin, Disconnect);
|
|
|
|
SETVTBL(vtbl, pin, ConnectedTo);
|
|
|
|
SETVTBL(vtbl, pin, ConnectionMediaType);
|
|
|
|
SETVTBL(vtbl, pin, QueryPinInfo);
|
|
|
|
SETVTBL(vtbl, pin, QueryDirection);
|
|
|
|
SETVTBL(vtbl, pin, QueryId);
|
|
|
|
SETVTBL(vtbl, pin, QueryAccept);
|
|
|
|
SETVTBL(vtbl, pin, EnumMediaTypes);
|
|
|
|
SETVTBL(vtbl, pin, QueryInternalConnections);
|
|
|
|
SETVTBL(vtbl, pin, EndOfStream);
|
|
|
|
SETVTBL(vtbl, pin, BeginFlush);
|
|
|
|
SETVTBL(vtbl, pin, EndFlush);
|
|
|
|
SETVTBL(vtbl, pin, NewSegment);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
this->filter = filter;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2019-01-03 07:41:12 +00:00
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
static void ff_dshow_pin_Free(DShowPin *this)
|
2019-01-03 07:41:12 +00:00
|
|
|
{
|
|
|
|
if (!this)
|
|
|
|
return;
|
|
|
|
av_freep(&this->imemvtbl);
|
|
|
|
if (this->type.pbFormat) {
|
|
|
|
CoTaskMemFree(this->type.pbFormat);
|
|
|
|
this->type.pbFormat = NULL;
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 22:45:48 +00:00
|
|
|
DECLARE_CREATE(pin, DShowPin, ff_dshow_pin_Setup(this, filter), DShowFilter *filter)
|
|
|
|
DECLARE_DESTROY(pin, DShowPin, ff_dshow_pin_Free)
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2021-01-21 22:45:48 +00:00
|
|
|
* DShowMemInputPin
|
2011-05-21 12:24:50 +00:00
|
|
|
****************************************************************************/
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_QueryInterface(DShowMemInputPin *this, const GUID *riid,
|
2011-05-21 12:24:50 +00:00
|
|
|
void **ppvObject)
|
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
|
|
|
|
dshowdebug("ff_dshow_meminputpin_QueryInterface(%p)\n", this);
|
|
|
|
return ff_dshow_pin_QueryInterface(pin, riid, ppvObject);
|
2011-05-21 12:24:50 +00:00
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
unsigned long WINAPI ff_dshow_meminputpin_AddRef(DShowMemInputPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
|
|
|
|
dshowdebug("ff_dshow_meminputpin_AddRef(%p)\n", this);
|
|
|
|
return ff_dshow_pin_AddRef(pin);
|
2011-05-21 12:24:50 +00:00
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
unsigned long WINAPI ff_dshow_meminputpin_Release(DShowMemInputPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
|
|
|
|
dshowdebug("ff_dshow_meminputpin_Release(%p)\n", this);
|
|
|
|
return ff_dshow_pin_Release(pin);
|
2011-05-21 12:24:50 +00:00
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_GetAllocator(DShowMemInputPin *this, IMemAllocator **alloc)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_GetAllocator(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
return VFW_E_NO_ALLOCATOR;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_NotifyAllocator(DShowMemInputPin *this, IMemAllocator *alloc,
|
2012-09-07 12:16:30 +00:00
|
|
|
BOOL rdwr)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_NotifyAllocator(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *this,
|
2011-05-21 12:24:50 +00:00
|
|
|
ALLOCATOR_PROPERTIES *props)
|
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_GetAllocatorRequirements(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
|
2011-05-21 12:24:50 +00:00
|
|
|
enum dshowDeviceType devtype = pin->filter->type;
|
|
|
|
void *priv_data;
|
2015-07-30 21:55:19 +00:00
|
|
|
AVFormatContext *s;
|
2011-05-21 12:24:50 +00:00
|
|
|
uint8_t *buf;
|
2015-01-26 09:03:48 +00:00
|
|
|
int buf_size; /* todo should be a long? */
|
2011-05-21 12:24:50 +00:00
|
|
|
int index;
|
2021-12-21 13:53:29 +00:00
|
|
|
int64_t chosentime = 0;
|
|
|
|
int64_t sampletime = 0;
|
|
|
|
int64_t graphtime = 0;
|
2021-12-21 13:53:28 +00:00
|
|
|
int use_sample_time = 1;
|
2015-01-26 09:03:48 +00:00
|
|
|
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
|
|
|
|
IReferenceClock *clock = pin->filter->clock;
|
|
|
|
int64_t dummy;
|
2015-07-30 21:55:19 +00:00
|
|
|
struct dshow_ctx *ctx;
|
2021-12-21 13:53:29 +00:00
|
|
|
HRESULT hr;
|
2015-07-30 21:55:19 +00:00
|
|
|
|
2011-05-21 12:24:50 +00:00
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
if (!sample)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2021-12-21 13:53:27 +00:00
|
|
|
priv_data = pin->filter->priv_data;
|
|
|
|
s = priv_data;
|
|
|
|
ctx = s->priv_data;
|
|
|
|
|
2021-12-21 13:53:29 +00:00
|
|
|
hr = IMediaSample_GetTime(sample, &sampletime, &dummy);
|
2015-07-30 21:55:19 +00:00
|
|
|
IReferenceClock_GetTime(clock, &graphtime);
|
2021-12-21 13:53:27 +00:00
|
|
|
if (devtype == VideoDevice && !ctx->use_video_device_timestamps) {
|
2011-05-21 12:24:50 +00:00
|
|
|
/* PTS from video devices is unreliable. */
|
2021-12-21 13:53:28 +00:00
|
|
|
chosentime = graphtime;
|
|
|
|
use_sample_time = 0;
|
2011-05-21 12:24:50 +00:00
|
|
|
} else {
|
2021-12-21 13:53:29 +00:00
|
|
|
if (hr == VFW_E_SAMPLE_TIME_NOT_SET || sampletime == 0) {
|
|
|
|
chosentime = graphtime;
|
|
|
|
use_sample_time = 0;
|
|
|
|
av_log(s, AV_LOG_DEBUG,
|
|
|
|
"frame with missing sample timestamp encountered, falling back to graph timestamp\n");
|
|
|
|
}
|
|
|
|
else if (sampletime > 400000000000000000LL) {
|
2015-01-23 13:13:33 +00:00
|
|
|
/* initial frames sometimes start < 0 (shown as a very large number here,
|
2021-12-21 13:53:28 +00:00
|
|
|
like 437650244077016960 which FFmpeg doesn't like).
|
2015-01-23 13:13:33 +00:00
|
|
|
TODO figure out math. For now just drop them. */
|
2021-12-21 13:53:29 +00:00
|
|
|
av_log(s, AV_LOG_DEBUG,
|
|
|
|
"dropping initial (or ending) sample with odd PTS too high %"PRId64"\n", sampletime);
|
2015-01-23 13:13:33 +00:00
|
|
|
return S_OK;
|
2021-12-21 13:53:29 +00:00
|
|
|
} else
|
|
|
|
chosentime = sampletime;
|
2011-05-21 12:24:50 +00:00
|
|
|
}
|
2021-12-21 13:53:28 +00:00
|
|
|
// media sample time is relative to graph start time
|
|
|
|
sampletime += pin->filter->start_time;
|
|
|
|
if (use_sample_time)
|
|
|
|
chosentime += pin->filter->start_time;
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
buf_size = IMediaSample_GetActualDataLength(sample);
|
|
|
|
IMediaSample_GetPointer(sample, &buf);
|
|
|
|
index = pin->filter->stream_index;
|
|
|
|
|
2021-12-21 13:53:29 +00:00
|
|
|
av_log(s, AV_LOG_VERBOSE, "passing through packet of type %s size %8d "
|
2015-07-30 21:55:19 +00:00
|
|
|
"timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n",
|
2021-12-21 13:53:28 +00:00
|
|
|
devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime, ctx->device_name[devtype]);
|
|
|
|
pin->filter->callback(priv_data, index, buf, buf_size, chosentime, devtype);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_ReceiveMultiple(DShowMemInputPin *this,
|
2011-05-21 12:24:50 +00:00
|
|
|
IMediaSample **samples, long n, long *nproc)
|
|
|
|
{
|
|
|
|
int i;
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_ReceiveMultiple(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
2021-01-21 22:45:48 +00:00
|
|
|
ff_dshow_meminputpin_Receive(this, samples[i]);
|
2011-05-21 12:24:50 +00:00
|
|
|
|
|
|
|
*nproc = n;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2022-01-02 09:49:38 +00:00
|
|
|
long WINAPI ff_dshow_meminputpin_ReceiveCanBlock(DShowMemInputPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
dshowdebug("ff_dshow_meminputpin_ReceiveCanBlock(%p)\n", this);
|
2011-05-21 12:24:50 +00:00
|
|
|
/* I swear I will not block. */
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-21 22:45:48 +00:00
|
|
|
void ff_dshow_meminputpin_Destroy(DShowMemInputPin *this)
|
2011-05-21 12:24:50 +00:00
|
|
|
{
|
2021-01-21 22:45:48 +00:00
|
|
|
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
|
|
|
|
dshowdebug("ff_dshow_meminputpin_Destroy(%p)\n", this);
|
|
|
|
ff_dshow_pin_Destroy(pin);
|
2011-05-21 12:24:50 +00:00
|
|
|
}
|