2013-11-20 22:48:04 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Piotr Caban for 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 <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "dshow.h"
|
2014-02-25 12:22:53 +01:00
|
|
|
#include "vfw.h"
|
2014-02-25 12:22:30 +01:00
|
|
|
#include "aviriff.h"
|
2013-11-20 22:48:04 +01:00
|
|
|
|
|
|
|
#include "qcap_main.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
#define MAX_PIN_NO 128
|
2014-02-25 12:22:53 +01:00
|
|
|
#define AVISUPERINDEX_ENTRIES 2000
|
|
|
|
#define AVISTDINDEX_ENTRIES 4000
|
2014-02-25 12:22:30 +01:00
|
|
|
#define ALIGN(x) ((x+1)/2*2)
|
2013-11-25 16:25:06 +01:00
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
typedef struct {
|
|
|
|
BaseInputPin pin;
|
|
|
|
IAMStreamControl IAMStreamControl_iface;
|
|
|
|
IPropertyBag IPropertyBag_iface;
|
|
|
|
IQualityControl IQualityControl_iface;
|
2014-02-25 12:22:30 +01:00
|
|
|
|
2014-02-25 12:22:53 +01:00
|
|
|
REFERENCE_TIME avg_time_per_frame;
|
2014-02-25 12:23:31 +01:00
|
|
|
REFERENCE_TIME stop;
|
2014-02-25 12:22:53 +01:00
|
|
|
int stream_id;
|
2014-02-25 12:23:31 +01:00
|
|
|
LONGLONG stream_time;
|
2014-02-25 12:22:53 +01:00
|
|
|
|
2014-02-25 12:22:30 +01:00
|
|
|
/* strl chunk */
|
|
|
|
AVISTREAMHEADER strh;
|
|
|
|
struct {
|
|
|
|
FOURCC fcc;
|
|
|
|
DWORD cb;
|
|
|
|
BYTE data[1];
|
|
|
|
} *strf;
|
2014-02-25 12:22:53 +01:00
|
|
|
AVISUPERINDEX *indx;
|
|
|
|
BYTE indx_data[FIELD_OFFSET(AVISUPERINDEX, aIndex[AVISUPERINDEX_ENTRIES])];
|
|
|
|
|
|
|
|
/* movi chunk */
|
|
|
|
int ix_off;
|
|
|
|
AVISTDINDEX *ix;
|
|
|
|
BYTE ix_data[FIELD_OFFSET(AVISTDINDEX, aIndex[AVISTDINDEX_ENTRIES])];
|
2014-02-25 12:23:31 +01:00
|
|
|
|
|
|
|
IMediaSample *samples_head;
|
|
|
|
IMemAllocator *samples_allocator;
|
2013-11-25 16:29:04 +01:00
|
|
|
} AviMuxIn;
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
typedef struct {
|
|
|
|
BaseFilter filter;
|
|
|
|
IConfigAviMux IConfigAviMux_iface;
|
|
|
|
IConfigInterleaving IConfigInterleaving_iface;
|
|
|
|
IMediaSeeking IMediaSeeking_iface;
|
|
|
|
IPersistMediaPropertyBag IPersistMediaPropertyBag_iface;
|
|
|
|
ISpecifyPropertyPages ISpecifyPropertyPages_iface;
|
2013-11-25 16:25:06 +01:00
|
|
|
|
2014-02-24 12:11:12 +01:00
|
|
|
InterleavingMode mode;
|
2014-02-25 12:21:59 +01:00
|
|
|
REFERENCE_TIME interleave;
|
|
|
|
REFERENCE_TIME preroll;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
BaseOutputPin source;
|
|
|
|
IQualityControl IQualityControl_iface;
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
int input_pin_no;
|
|
|
|
AviMuxIn *in[MAX_PIN_NO-1];
|
2014-02-25 12:22:53 +01:00
|
|
|
|
|
|
|
REFERENCE_TIME start, stop;
|
|
|
|
AVIMAINHEADER avih;
|
|
|
|
|
|
|
|
int idx1_entries;
|
|
|
|
int idx1_size;
|
|
|
|
AVIINDEXENTRY *idx1;
|
2019-06-17 02:34:59 +02:00
|
|
|
|
|
|
|
int cur_stream;
|
|
|
|
LONGLONG cur_time;
|
|
|
|
|
|
|
|
int buf_pos;
|
|
|
|
BYTE buf[65536];
|
|
|
|
|
|
|
|
int movi_off;
|
|
|
|
int out_pos;
|
|
|
|
int size;
|
|
|
|
IStream *stream;
|
2013-11-20 22:48:04 +01:00
|
|
|
} AviMux;
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
static HRESULT create_input_pin(AviMux*);
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
static inline AviMux* impl_from_BaseFilter(BaseFilter *filter)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(filter, AviMux, filter);
|
|
|
|
}
|
|
|
|
|
2019-05-24 00:06:32 +02:00
|
|
|
static IPin *avi_mux_get_pin(BaseFilter *iface, unsigned int index)
|
2013-11-20 22:48:04 +01:00
|
|
|
{
|
2019-06-11 16:42:16 +02:00
|
|
|
AviMux *filter = impl_from_BaseFilter(iface);
|
2013-11-25 16:29:04 +01:00
|
|
|
|
2019-05-24 00:06:30 +02:00
|
|
|
if (!index)
|
2019-06-17 02:34:59 +02:00
|
|
|
return &filter->source.pin.IPin_iface;
|
2019-06-11 16:42:16 +02:00
|
|
|
else if (index <= filter->input_pin_no)
|
|
|
|
return &filter->in[index - 1]->pin.pin.IPin_iface;
|
2013-11-20 22:48:04 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-05-29 06:10:19 +02:00
|
|
|
static void avi_mux_destroy(BaseFilter *iface)
|
|
|
|
{
|
|
|
|
AviMux *filter = impl_from_BaseFilter(iface);
|
|
|
|
int i;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
strmbase_source_cleanup(&filter->source);
|
2019-05-29 06:10:19 +02:00
|
|
|
|
|
|
|
for (i = 0; i < filter->input_pin_no; ++i)
|
|
|
|
{
|
|
|
|
IPin_Disconnect(&filter->in[i]->pin.pin.IPin_iface);
|
|
|
|
IMemAllocator_Release(filter->in[i]->samples_allocator);
|
|
|
|
filter->in[i]->samples_allocator = NULL;
|
2019-06-14 01:09:18 +02:00
|
|
|
strmbase_sink_cleanup(&filter->in[i]->pin);
|
|
|
|
heap_free(filter->in[i]);
|
2019-05-29 06:10:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(filter->idx1);
|
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
heap_free(filter);
|
|
|
|
ObjectRefCount(FALSE);
|
|
|
|
}
|
|
|
|
|
2019-05-31 05:59:34 +02:00
|
|
|
static HRESULT avi_mux_query_interface(BaseFilter *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
AviMux *filter = impl_from_BaseFilter(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IConfigAviMux))
|
|
|
|
*out = &filter->IConfigAviMux_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IConfigInterleaving))
|
|
|
|
*out = &filter->IConfigInterleaving_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
|
|
|
*out = &filter->IMediaSeeking_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IPersistMediaPropertyBag))
|
|
|
|
*out = &filter->IPersistMediaPropertyBag_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_ISpecifyPropertyPages))
|
|
|
|
*out = &filter->ISpecifyPropertyPages_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
static const BaseFilterFuncTable filter_func_table = {
|
2019-05-24 00:06:31 +02:00
|
|
|
.filter_get_pin = avi_mux_get_pin,
|
2019-05-29 06:10:19 +02:00
|
|
|
.filter_destroy = avi_mux_destroy,
|
2019-05-31 05:59:34 +02:00
|
|
|
.filter_query_interface = avi_mux_query_interface,
|
2013-11-20 22:48:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_IBaseFilter(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
BaseFilter *filter = CONTAINING_RECORD(iface, BaseFilter, IBaseFilter_iface);
|
|
|
|
return impl_from_BaseFilter(filter);
|
|
|
|
}
|
|
|
|
|
2014-02-25 12:23:31 +01:00
|
|
|
static HRESULT out_flush(AviMux *This)
|
|
|
|
{
|
|
|
|
ULONG written;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if(!This->buf_pos)
|
2014-02-25 12:23:31 +01:00
|
|
|
return S_OK;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
hr = IStream_Write(This->stream, This->buf, This->buf_pos, &written);
|
2014-02-25 12:23:31 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
2019-06-17 02:34:59 +02:00
|
|
|
if (written != This->buf_pos)
|
2014-02-25 12:23:31 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->buf_pos = 0;
|
2014-02-25 12:23:31 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT out_seek(AviMux *This, int pos)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER li;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = out_flush(This);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
li.QuadPart = pos;
|
2019-06-17 02:34:59 +02:00
|
|
|
hr = IStream_Seek(This->stream, li, STREAM_SEEK_SET, NULL);
|
2014-02-25 12:23:31 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->out_pos = pos;
|
|
|
|
if(This->out_pos > This->size)
|
|
|
|
This->size = This->out_pos;
|
2014-02-25 12:23:31 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT out_write(AviMux *This, const void *data, int size)
|
|
|
|
{
|
|
|
|
int chunk_size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
while(1) {
|
2019-06-17 02:34:59 +02:00
|
|
|
if (size > sizeof(This->buf) - This->buf_pos)
|
|
|
|
chunk_size = sizeof(This->buf) - This->buf_pos;
|
2014-02-25 12:23:31 +01:00
|
|
|
else
|
|
|
|
chunk_size = size;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
memcpy(This->buf + This->buf_pos, data, chunk_size);
|
2014-02-25 12:23:31 +01:00
|
|
|
size -= chunk_size;
|
|
|
|
data = (const BYTE*)data + chunk_size;
|
2019-06-17 02:34:59 +02:00
|
|
|
This->buf_pos += chunk_size;
|
|
|
|
This->out_pos += chunk_size;
|
|
|
|
if (This->out_pos > This->size)
|
|
|
|
This->size = This->out_pos;
|
2014-02-25 12:23:31 +01:00
|
|
|
|
|
|
|
if(!size)
|
|
|
|
break;
|
|
|
|
hr = out_flush(This);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-25 12:22:53 +01:00
|
|
|
static inline HRESULT idx1_add_entry(AviMux *avimux, DWORD ckid, DWORD flags, DWORD off, DWORD len)
|
|
|
|
{
|
|
|
|
if(avimux->idx1_entries == avimux->idx1_size) {
|
|
|
|
AVIINDEXENTRY *new_idx = HeapReAlloc(GetProcessHeap(), 0, avimux->idx1,
|
|
|
|
sizeof(*avimux->idx1)*2*avimux->idx1_size);
|
|
|
|
if(!new_idx)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
avimux->idx1_size *= 2;
|
|
|
|
avimux->idx1 = new_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
avimux->idx1[avimux->idx1_entries].ckid = ckid;
|
|
|
|
avimux->idx1[avimux->idx1_entries].dwFlags = flags;
|
|
|
|
avimux->idx1[avimux->idx1_entries].dwChunkOffset = off;
|
|
|
|
avimux->idx1[avimux->idx1_entries].dwChunkLength = len;
|
|
|
|
avimux->idx1_entries++;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-25 12:23:31 +01:00
|
|
|
static HRESULT flush_queue(AviMux *avimux, AviMuxIn *avimuxin, BOOL closing)
|
|
|
|
{
|
|
|
|
IMediaSample *sample, **prev, **head_prev;
|
|
|
|
BYTE *data;
|
|
|
|
RIFFCHUNK rf;
|
|
|
|
DWORD size;
|
|
|
|
DWORD flags;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if (avimux->cur_stream != avimuxin->stream_id)
|
2014-02-25 12:23:31 +01:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
while(avimuxin->samples_head) {
|
|
|
|
hr = IMediaSample_GetPointer(avimuxin->samples_head, (BYTE**)&head_prev);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
head_prev--;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetPointer(*head_prev, (BYTE**)&prev);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
prev--;
|
|
|
|
|
|
|
|
sample = *head_prev;
|
|
|
|
size = IMediaSample_GetActualDataLength(sample);
|
|
|
|
hr = IMediaSample_GetPointer(sample, &data);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
flags = IMediaSample_IsDiscontinuity(sample)==S_OK ? AM_SAMPLE_TIMEDISCONTINUITY : 0;
|
|
|
|
if(IMediaSample_IsSyncPoint(sample) == S_OK)
|
|
|
|
flags |= AM_SAMPLE_SPLICEPOINT;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if (avimuxin->stream_time + (closing ? 0 : avimuxin->strh.dwScale) > avimux->cur_time
|
|
|
|
&& !(flags & AM_SAMPLE_TIMEDISCONTINUITY))
|
|
|
|
{
|
2014-02-25 12:23:31 +01:00
|
|
|
if(closing)
|
|
|
|
break;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
avimux->cur_stream++;
|
|
|
|
if(avimux->cur_stream >= avimux->input_pin_no-1) {
|
|
|
|
avimux->cur_time += avimux->interleave;
|
|
|
|
avimux->cur_stream = 0;
|
2014-02-25 12:23:31 +01:00
|
|
|
}
|
2019-06-17 02:34:59 +02:00
|
|
|
avimuxin = avimux->in[avimux->cur_stream];
|
2014-02-25 12:23:31 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(avimuxin->ix->nEntriesInUse == AVISTDINDEX_ENTRIES) {
|
|
|
|
/* TODO: use output pins Deliver/Receive method */
|
|
|
|
hr = out_seek(avimux, avimuxin->ix_off);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
hr = out_write(avimux, avimuxin->ix, sizeof(avimuxin->ix_data));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
avimuxin->indx->aIndex[avimuxin->indx->nEntriesInUse].qwOffset = avimuxin->ix_off;
|
|
|
|
avimuxin->indx->aIndex[avimuxin->indx->nEntriesInUse].dwSize = sizeof(avimuxin->ix_data);
|
|
|
|
avimuxin->indx->aIndex[avimuxin->indx->nEntriesInUse].dwDuration = AVISTDINDEX_ENTRIES;
|
|
|
|
avimuxin->indx->nEntriesInUse++;
|
|
|
|
|
|
|
|
memset(avimuxin->ix->aIndex, 0, sizeof(avimuxin->ix->aIndex)*avimuxin->ix->nEntriesInUse);
|
|
|
|
avimuxin->ix->nEntriesInUse = 0;
|
|
|
|
avimuxin->ix->qwBaseOffset = 0;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
avimuxin->ix_off = avimux->size;
|
|
|
|
avimux->size += sizeof(avimuxin->ix_data);
|
2014-02-25 12:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*head_prev == avimuxin->samples_head)
|
|
|
|
avimuxin->samples_head = NULL;
|
|
|
|
else
|
|
|
|
*head_prev = *prev;
|
|
|
|
|
|
|
|
avimuxin->stream_time += avimuxin->strh.dwScale;
|
|
|
|
avimuxin->strh.dwLength++;
|
|
|
|
if(!(flags & AM_SAMPLE_TIMEDISCONTINUITY)) {
|
|
|
|
if(!avimuxin->ix->qwBaseOffset)
|
2019-06-17 02:34:59 +02:00
|
|
|
avimuxin->ix->qwBaseOffset = avimux->size;
|
|
|
|
avimuxin->ix->aIndex[avimuxin->ix->nEntriesInUse].dwOffset =
|
|
|
|
avimux->size + sizeof(RIFFCHUNK) - avimuxin->ix->qwBaseOffset;
|
2014-02-25 12:23:31 +01:00
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
hr = out_seek(avimux, avimux->size);
|
2014-02-25 12:23:31 +01:00
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
avimuxin->ix->aIndex[avimuxin->ix->nEntriesInUse].dwSize = size |
|
|
|
|
(flags & AM_SAMPLE_SPLICEPOINT ? 0 : AVISTDINDEX_DELTAFRAME);
|
|
|
|
avimuxin->ix->nEntriesInUse++;
|
|
|
|
|
|
|
|
rf.fcc = FCC('0'+avimuxin->stream_id/10, '0'+avimuxin->stream_id%10,
|
|
|
|
'd', flags & AM_SAMPLE_SPLICEPOINT ? 'b' : 'c');
|
|
|
|
rf.cb = size;
|
|
|
|
hr = idx1_add_entry(avimux, rf.fcc, flags & AM_SAMPLE_SPLICEPOINT ? AVIIF_KEYFRAME : 0,
|
|
|
|
flags & AM_SAMPLE_TIMEDISCONTINUITY ?
|
2019-06-17 02:34:59 +02:00
|
|
|
avimux->idx1[avimux->idx1_entries-1].dwChunkOffset : avimux->size, size);
|
2014-02-25 12:23:31 +01:00
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(flags & AM_SAMPLE_TIMEDISCONTINUITY)) {
|
|
|
|
hr = out_write(avimux, &rf, sizeof(rf));
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
hr = out_write(avimux, data, size);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
flags = 0;
|
|
|
|
hr = out_write(avimux, &flags, ALIGN(rf.cb)-rf.cb);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT queue_sample(AviMux *avimux, AviMuxIn *avimuxin, IMediaSample *sample)
|
|
|
|
{
|
|
|
|
IMediaSample **prev, **head_prev;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetPointer(sample, (BYTE**)&prev);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
prev--;
|
|
|
|
|
|
|
|
if(avimuxin->samples_head) {
|
|
|
|
hr = IMediaSample_GetPointer(avimuxin->samples_head, (BYTE**)&head_prev);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
head_prev--;
|
|
|
|
|
|
|
|
*prev = *head_prev;
|
|
|
|
*head_prev = sample;
|
|
|
|
}else {
|
|
|
|
*prev = sample;
|
|
|
|
}
|
|
|
|
avimuxin->samples_head = sample;
|
|
|
|
IMediaSample_AddRef(sample);
|
|
|
|
|
|
|
|
return flush_queue(avimux, avimuxin, FALSE);
|
|
|
|
}
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
static HRESULT WINAPI AviMux_Stop(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IBaseFilter(iface);
|
2014-02-26 13:36:45 +01:00
|
|
|
HRESULT hr;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if(This->filter.state == State_Stopped)
|
|
|
|
return S_OK;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if (This->stream)
|
|
|
|
{
|
2014-02-26 13:36:45 +01:00
|
|
|
AVIEXTHEADER dmlh;
|
|
|
|
RIFFCHUNK rc;
|
|
|
|
RIFFLIST rl;
|
|
|
|
int idx1_off, empty_stream;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
empty_stream = This->cur_stream;
|
2014-02-26 13:36:45 +01:00
|
|
|
for(i=empty_stream+1; ; i++) {
|
|
|
|
if(i >= This->input_pin_no-1)
|
|
|
|
i = 0;
|
|
|
|
if(i == empty_stream)
|
|
|
|
break;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->cur_stream = i;
|
|
|
|
hr = flush_queue(This, This->in[This->cur_stream], TRUE);
|
2014-02-26 13:36:45 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
idx1_off = This->size;
|
2014-02-26 13:36:45 +01:00
|
|
|
rc.fcc = ckidAVIOLDINDEX;
|
|
|
|
rc.cb = This->idx1_entries * sizeof(*This->idx1);
|
|
|
|
hr = out_write(This, &rc, sizeof(rc));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
hr = out_write(This, This->idx1, This->idx1_entries * sizeof(*This->idx1));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
/* native writes 8 '\0' characters after the end of RIFF data */
|
|
|
|
i = 0;
|
|
|
|
hr = out_write(This, &i, sizeof(i));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
hr = out_write(This, &i, sizeof(i));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = out_seek(This, This->in[i]->ix_off);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
This->in[i]->indx->aIndex[This->in[i]->indx->nEntriesInUse].qwOffset = This->in[i]->ix_off;
|
|
|
|
This->in[i]->indx->aIndex[This->in[i]->indx->nEntriesInUse].dwSize = sizeof(This->in[i]->ix_data);
|
|
|
|
This->in[i]->indx->aIndex[This->in[i]->indx->nEntriesInUse].dwDuration = This->in[i]->strh.dwLength;
|
|
|
|
if(This->in[i]->indx->nEntriesInUse) {
|
|
|
|
This->in[i]->indx->aIndex[This->in[i]->indx->nEntriesInUse].dwDuration -=
|
|
|
|
This->in[i]->indx->aIndex[This->in[i]->indx->nEntriesInUse-1].dwDuration;
|
|
|
|
}
|
|
|
|
This->in[i]->indx->nEntriesInUse++;
|
|
|
|
hr = out_write(This, This->in[i]->ix, sizeof(This->in[i]->ix_data));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = out_seek(This, 0);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
rl.fcc = FCC('R','I','F','F');
|
2019-06-17 02:34:59 +02:00
|
|
|
rl.cb = This->size - sizeof(RIFFCHUNK) - 2 * sizeof(int);
|
2014-02-26 13:36:45 +01:00
|
|
|
rl.fccListType = FCC('A','V','I',' ');
|
|
|
|
hr = out_write(This, &rl, sizeof(rl));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
rl.fcc = FCC('L','I','S','T');
|
2019-06-17 02:34:59 +02:00
|
|
|
rl.cb = This->movi_off - sizeof(RIFFLIST) - sizeof(RIFFCHUNK);
|
2014-02-26 13:36:45 +01:00
|
|
|
rl.fccListType = FCC('h','d','r','l');
|
|
|
|
hr = out_write(This, &rl, sizeof(rl));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* FIXME: set This->avih.dwMaxBytesPerSec value */
|
|
|
|
This->avih.dwTotalFrames = (This->stop-This->start) / 10 / This->avih.dwMicroSecPerFrame;
|
|
|
|
hr = out_write(This, &This->avih, sizeof(This->avih));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rl.cb = sizeof(FOURCC) + sizeof(AVISTREAMHEADER) + sizeof(RIFFCHUNK) +
|
|
|
|
This->in[i]->strf->cb + sizeof(This->in[i]->indx_data);
|
|
|
|
rl.fccListType = ckidSTREAMLIST;
|
|
|
|
hr = out_write(This, &rl, sizeof(rl));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = out_write(This, &This->in[i]->strh, sizeof(AVISTREAMHEADER));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = out_write(This, This->in[i]->strf, sizeof(RIFFCHUNK) + This->in[i]->strf->cb);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = out_write(This, This->in[i]->indx, sizeof(This->in[i]->indx_data));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
rl.cb = sizeof(dmlh) + sizeof(FOURCC);
|
|
|
|
rl.fccListType = ckidODML;
|
|
|
|
hr = out_write(This, &rl, sizeof(rl));
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
memset(&dmlh, 0, sizeof(dmlh));
|
|
|
|
dmlh.fcc = ckidAVIEXTHEADER;
|
|
|
|
dmlh.cb = sizeof(dmlh) - sizeof(RIFFCHUNK);
|
|
|
|
dmlh.dwGrandFrames = This->in[0]->strh.dwLength;
|
|
|
|
hr = out_write(This, &dmlh, sizeof(dmlh));
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
rl.cb = idx1_off - This->movi_off - sizeof(RIFFCHUNK);
|
2014-02-26 13:36:45 +01:00
|
|
|
rl.fccListType = FCC('m','o','v','i');
|
|
|
|
out_write(This, &rl, sizeof(rl));
|
|
|
|
out_flush(This);
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
IStream_Release(This->stream);
|
|
|
|
This->stream = NULL;
|
2014-02-26 13:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
This->filter.state = State_Stopped;
|
|
|
|
return S_OK;
|
2013-11-20 22:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMux_Pause(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IBaseFilter(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMux_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IBaseFilter(iface);
|
2014-02-25 12:22:53 +01:00
|
|
|
HRESULT hr;
|
|
|
|
int i, stream_id;
|
|
|
|
|
2017-08-18 22:12:18 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_longlong(tStart));
|
2014-02-25 12:22:53 +01:00
|
|
|
|
|
|
|
if(This->filter.state == State_Running)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(This->mode != INTERLEAVE_FULL) {
|
|
|
|
FIXME("mode not supported (%d)\n", This->mode);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tStart)
|
|
|
|
FIXME("tStart parameter ignored\n");
|
|
|
|
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
IMediaSeeking *ms;
|
|
|
|
LONGLONG cur, stop;
|
|
|
|
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = IPin_QueryInterface(This->in[i]->pin.pin.pConnectedTo,
|
|
|
|
&IID_IMediaSeeking, (void**)&ms);
|
|
|
|
if(FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = IMediaSeeking_GetPositions(ms, &cur, &stop);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
IMediaSeeking_Release(ms);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Use IMediaSeeking to fill stream header\n");
|
|
|
|
IMediaSeeking_Release(ms);
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if (This->source.pMemInputPin)
|
|
|
|
{
|
|
|
|
hr = IMemInputPin_QueryInterface(This->source.pMemInputPin,
|
|
|
|
&IID_IStream, (void **)&This->stream);
|
2014-02-25 12:22:53 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->idx1_entries = 0;
|
|
|
|
if(!This->idx1_size) {
|
|
|
|
This->idx1_size = 1024;
|
|
|
|
This->idx1 = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->idx1)*This->idx1_size);
|
|
|
|
if(!This->idx1)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->size = 3*sizeof(RIFFLIST) + sizeof(AVIMAINHEADER) + sizeof(AVIEXTHEADER);
|
2014-02-25 12:22:53 +01:00
|
|
|
This->start = -1;
|
|
|
|
This->stop = -1;
|
|
|
|
memset(&This->avih, 0, sizeof(This->avih));
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
This->avih.dwStreams++;
|
2019-06-17 02:34:59 +02:00
|
|
|
This->size += sizeof(RIFFLIST) + sizeof(AVISTREAMHEADER) + sizeof(RIFFCHUNK)
|
|
|
|
+ This->in[i]->strf->cb + sizeof(This->in[i]->indx_data);
|
2014-02-25 12:22:53 +01:00
|
|
|
|
|
|
|
This->in[i]->strh.dwScale = MulDiv(This->in[i]->avg_time_per_frame, This->interleave, 10000000);
|
|
|
|
This->in[i]->strh.dwRate = This->interleave;
|
|
|
|
|
|
|
|
hr = IMemAllocator_Commit(This->in[i]->pin.pAllocator);
|
|
|
|
if(FAILED(hr)) {
|
2019-06-17 02:34:59 +02:00
|
|
|
if (This->stream)
|
|
|
|
{
|
|
|
|
IStream_Release(This->stream);
|
|
|
|
This->stream = NULL;
|
2014-02-25 12:22:53 +01:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->movi_off = This->size;
|
|
|
|
This->size += sizeof(RIFFLIST);
|
2014-02-25 12:22:53 +01:00
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
idx1_add_entry(This, FCC('7','F','x','x'), 0, This->movi_off + sizeof(RIFFLIST), 0);
|
2014-02-25 12:22:53 +01:00
|
|
|
|
|
|
|
stream_id = 0;
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->in[i]->ix_off = This->size;
|
|
|
|
This->size += sizeof(This->in[i]->ix_data);
|
2014-02-25 12:22:53 +01:00
|
|
|
This->in[i]->ix->fcc = FCC('i','x','0'+stream_id/10,'0'+stream_id%10);
|
|
|
|
This->in[i]->ix->cb = sizeof(This->in[i]->ix_data) - sizeof(RIFFCHUNK);
|
|
|
|
This->in[i]->ix->wLongsPerEntry = 2;
|
|
|
|
This->in[i]->ix->bIndexSubType = 0;
|
|
|
|
This->in[i]->ix->bIndexType = AVI_INDEX_OF_CHUNKS;
|
|
|
|
This->in[i]->ix->dwChunkId = FCC('0'+stream_id/10,'0'+stream_id%10,'d','b');
|
|
|
|
This->in[i]->ix->qwBaseOffset = 0;
|
|
|
|
|
|
|
|
This->in[i]->indx->fcc = ckidAVISUPERINDEX;
|
|
|
|
This->in[i]->indx->cb = sizeof(This->in[i]->indx_data) - sizeof(RIFFCHUNK);
|
|
|
|
This->in[i]->indx->wLongsPerEntry = 4;
|
|
|
|
This->in[i]->indx->bIndexSubType = 0;
|
|
|
|
This->in[i]->indx->bIndexType = AVI_INDEX_OF_INDEXES;
|
|
|
|
This->in[i]->indx->dwChunkId = This->in[i]->ix->dwChunkId;
|
|
|
|
This->in[i]->stream_id = stream_id++;
|
|
|
|
}
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
This->buf_pos = 0;
|
|
|
|
This->out_pos = 0;
|
2014-02-25 12:23:31 +01:00
|
|
|
|
2014-02-25 12:22:53 +01:00
|
|
|
This->avih.fcc = ckidMAINAVIHEADER;
|
|
|
|
This->avih.cb = sizeof(AVIMAINHEADER) - sizeof(RIFFCHUNK);
|
|
|
|
/* TODO: Use first video stream */
|
|
|
|
This->avih.dwMicroSecPerFrame = This->in[0]->avg_time_per_frame/10;
|
|
|
|
This->avih.dwPaddingGranularity = 1;
|
|
|
|
This->avih.dwFlags = AVIF_TRUSTCKTYPE | AVIF_HASINDEX;
|
|
|
|
This->avih.dwWidth = ((BITMAPINFOHEADER*)This->in[0]->strf->data)->biWidth;
|
|
|
|
This->avih.dwHeight = ((BITMAPINFOHEADER*)This->in[0]->strf->data)->biHeight;
|
|
|
|
|
|
|
|
This->filter.state = State_Running;
|
|
|
|
return S_OK;
|
2013-11-20 22:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl AviMuxVtbl = {
|
2019-05-31 05:59:34 +02:00
|
|
|
BaseFilterImpl_QueryInterface,
|
2013-11-20 22:48:04 +01:00
|
|
|
BaseFilterImpl_AddRef,
|
2019-05-29 06:10:19 +02:00
|
|
|
BaseFilterImpl_Release,
|
2013-11-20 22:48:04 +01:00
|
|
|
BaseFilterImpl_GetClassID,
|
|
|
|
AviMux_Stop,
|
|
|
|
AviMux_Pause,
|
|
|
|
AviMux_Run,
|
|
|
|
BaseFilterImpl_GetState,
|
|
|
|
BaseFilterImpl_SetSyncSource,
|
|
|
|
BaseFilterImpl_GetSyncSource,
|
2019-05-29 06:10:20 +02:00
|
|
|
BaseFilterImpl_EnumPins,
|
|
|
|
BaseFilterImpl_FindPin,
|
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
2013-11-20 22:48:04 +01:00
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
2019-05-29 06:10:20 +02:00
|
|
|
BaseFilterImpl_QueryVendorInfo
|
2013-11-20 22:48:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_IConfigAviMux(IConfigAviMux *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMux, IConfigAviMux_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigAviMux_QueryInterface(
|
|
|
|
IConfigAviMux *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConfigAviMux_AddRef(IConfigAviMux *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConfigAviMux_Release(IConfigAviMux *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigAviMux_SetMasterStream(IConfigAviMux *iface, LONG iStream)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
FIXME("(%p)->(%d)\n", This, iStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigAviMux_GetMasterStream(IConfigAviMux *iface, LONG *pStream)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigAviMux_SetOutputCompatibilityIndex(
|
|
|
|
IConfigAviMux *iface, BOOL fOldIndex)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, fOldIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigAviMux_GetOutputCompatibilityIndex(
|
|
|
|
IConfigAviMux *iface, BOOL *pfOldIndex)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigAviMux(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pfOldIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IConfigAviMuxVtbl ConfigAviMuxVtbl = {
|
|
|
|
ConfigAviMux_QueryInterface,
|
|
|
|
ConfigAviMux_AddRef,
|
|
|
|
ConfigAviMux_Release,
|
|
|
|
ConfigAviMux_SetMasterStream,
|
|
|
|
ConfigAviMux_GetMasterStream,
|
|
|
|
ConfigAviMux_SetOutputCompatibilityIndex,
|
|
|
|
ConfigAviMux_GetOutputCompatibilityIndex
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_IConfigInterleaving(IConfigInterleaving *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMux, IConfigInterleaving_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigInterleaving_QueryInterface(
|
|
|
|
IConfigInterleaving *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConfigInterleaving_AddRef(IConfigInterleaving *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConfigInterleaving_Release(IConfigInterleaving *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigInterleaving_put_Mode(
|
|
|
|
IConfigInterleaving *iface, InterleavingMode mode)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
2014-02-24 12:11:12 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, mode);
|
|
|
|
|
|
|
|
if(mode>INTERLEAVE_NONE_BUFFERED)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(This->mode != mode) {
|
2019-06-17 02:34:59 +02:00
|
|
|
if(This->source.pin.pConnectedTo) {
|
2014-02-25 12:21:43 +01:00
|
|
|
HRESULT hr = IFilterGraph_Reconnect(This->filter.filterInfo.pGraph,
|
2019-06-17 02:34:59 +02:00
|
|
|
&This->source.pin.IPin_iface);
|
2014-02-25 12:21:43 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
2014-02-24 12:11:12 +01:00
|
|
|
}
|
2014-02-25 12:21:43 +01:00
|
|
|
|
|
|
|
This->mode = mode;
|
2014-02-24 12:11:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2013-11-20 22:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigInterleaving_get_Mode(
|
|
|
|
IConfigInterleaving *iface, InterleavingMode *pMode)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pMode);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigInterleaving_put_Interleaving(IConfigInterleaving *iface,
|
|
|
|
const REFERENCE_TIME *prtInterleave, const REFERENCE_TIME *prtPreroll)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
2014-02-25 12:21:59 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, prtInterleave, prtPreroll);
|
|
|
|
|
|
|
|
if(prtInterleave)
|
|
|
|
This->interleave = *prtInterleave;
|
|
|
|
if(prtPreroll)
|
|
|
|
This->preroll = *prtPreroll;
|
|
|
|
return S_OK;
|
2013-11-20 22:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConfigInterleaving_get_Interleaving(IConfigInterleaving *iface,
|
|
|
|
REFERENCE_TIME *prtInterleave, REFERENCE_TIME *prtPreroll)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IConfigInterleaving(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, prtInterleave, prtPreroll);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IConfigInterleavingVtbl ConfigInterleavingVtbl = {
|
|
|
|
ConfigInterleaving_QueryInterface,
|
|
|
|
ConfigInterleaving_AddRef,
|
|
|
|
ConfigInterleaving_Release,
|
|
|
|
ConfigInterleaving_put_Mode,
|
|
|
|
ConfigInterleaving_get_Mode,
|
|
|
|
ConfigInterleaving_put_Interleaving,
|
|
|
|
ConfigInterleaving_get_Interleaving
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_IMediaSeeking(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMux, IMediaSeeking_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_QueryInterface(
|
|
|
|
IMediaSeeking *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MediaSeeking_AddRef(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MediaSeeking_Release(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetCapabilities(
|
|
|
|
IMediaSeeking *iface, DWORD *pCapabilities)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pCapabilities);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_CheckCapabilities(
|
|
|
|
IMediaSeeking *iface, DWORD *pCapabilities)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pCapabilities);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_IsFormatSupported(
|
|
|
|
IMediaSeeking *iface, const GUID *pFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_guid(pFormat));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_QueryPreferredFormat(
|
|
|
|
IMediaSeeking *iface, GUID *pFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pFormat);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetTimeFormat(
|
|
|
|
IMediaSeeking *iface, GUID *pFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pFormat);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_IsUsingTimeFormat(
|
|
|
|
IMediaSeeking *iface, const GUID *pFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_guid(pFormat));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_SetTimeFormat(
|
|
|
|
IMediaSeeking *iface, const GUID *pFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
2015-03-24 10:01:26 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_guid(pFormat));
|
2013-11-20 22:48:04 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetDuration(
|
|
|
|
IMediaSeeking *iface, LONGLONG *pDuration)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pDuration);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetStopPosition(
|
|
|
|
IMediaSeeking *iface, LONGLONG *pStop)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pStop);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetCurrentPosition(
|
|
|
|
IMediaSeeking *iface, LONGLONG *pCurrent)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pCurrent);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *pTarget,
|
|
|
|
const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p %s %s %s)\n", This, pTarget, debugstr_guid(pTargetFormat),
|
|
|
|
wine_dbgstr_longlong(Source), debugstr_guid(pSourceFormat));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface, LONGLONG *pCurrent,
|
|
|
|
DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p %x %p %x)\n", This, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetPositions(IMediaSeeking *iface,
|
|
|
|
LONGLONG *pCurrent, LONGLONG *pStop)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, pCurrent, pStop);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetAvailable(IMediaSeeking *iface,
|
|
|
|
LONGLONG *pEarliest, LONGLONG *pLatest)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, pEarliest, pLatest);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_SetRate(IMediaSeeking *iface, double dRate)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%lf)\n", This, dRate);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetRate(IMediaSeeking *iface, double *pdRate)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pdRate);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MediaSeeking_GetPreroll(IMediaSeeking *iface, LONGLONG *pllPreroll)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IMediaSeeking(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pllPreroll);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl MediaSeekingVtbl = {
|
|
|
|
MediaSeeking_QueryInterface,
|
|
|
|
MediaSeeking_AddRef,
|
|
|
|
MediaSeeking_Release,
|
|
|
|
MediaSeeking_GetCapabilities,
|
|
|
|
MediaSeeking_CheckCapabilities,
|
|
|
|
MediaSeeking_IsFormatSupported,
|
|
|
|
MediaSeeking_QueryPreferredFormat,
|
|
|
|
MediaSeeking_GetTimeFormat,
|
|
|
|
MediaSeeking_IsUsingTimeFormat,
|
|
|
|
MediaSeeking_SetTimeFormat,
|
|
|
|
MediaSeeking_GetDuration,
|
|
|
|
MediaSeeking_GetStopPosition,
|
|
|
|
MediaSeeking_GetCurrentPosition,
|
|
|
|
MediaSeeking_ConvertTimeFormat,
|
|
|
|
MediaSeeking_SetPositions,
|
|
|
|
MediaSeeking_GetPositions,
|
|
|
|
MediaSeeking_GetAvailable,
|
|
|
|
MediaSeeking_SetRate,
|
|
|
|
MediaSeeking_GetRate,
|
|
|
|
MediaSeeking_GetPreroll
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_IPersistMediaPropertyBag(IPersistMediaPropertyBag *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMux, IPersistMediaPropertyBag_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMediaPropertyBag_QueryInterface(
|
|
|
|
IPersistMediaPropertyBag *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistMediaPropertyBag_AddRef(IPersistMediaPropertyBag *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PersistMediaPropertyBag_Release(IPersistMediaPropertyBag *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMediaPropertyBag_GetClassID(
|
|
|
|
IPersistMediaPropertyBag *iface, CLSID *pClassID)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
return IBaseFilter_GetClassID(&This->filter.IBaseFilter_iface, pClassID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMediaPropertyBag_InitNew(IPersistMediaPropertyBag *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMediaPropertyBag_Load(IPersistMediaPropertyBag *iface,
|
|
|
|
IMediaPropertyBag *pPropBag, IErrorLog *pErrorLog)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistMediaPropertyBag_Save(IPersistMediaPropertyBag *iface,
|
|
|
|
IMediaPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_IPersistMediaPropertyBag(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPersistMediaPropertyBagVtbl PersistMediaPropertyBagVtbl = {
|
|
|
|
PersistMediaPropertyBag_QueryInterface,
|
|
|
|
PersistMediaPropertyBag_AddRef,
|
|
|
|
PersistMediaPropertyBag_Release,
|
|
|
|
PersistMediaPropertyBag_GetClassID,
|
|
|
|
PersistMediaPropertyBag_InitNew,
|
|
|
|
PersistMediaPropertyBag_Load,
|
|
|
|
PersistMediaPropertyBag_Save
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_ISpecifyPropertyPages(ISpecifyPropertyPages *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMux, ISpecifyPropertyPages_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SpecifyPropertyPages_QueryInterface(
|
|
|
|
ISpecifyPropertyPages *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_ISpecifyPropertyPages(iface);
|
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI SpecifyPropertyPages_AddRef(ISpecifyPropertyPages *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_ISpecifyPropertyPages(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI SpecifyPropertyPages_Release(ISpecifyPropertyPages *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_ISpecifyPropertyPages(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SpecifyPropertyPages_GetPages(
|
|
|
|
ISpecifyPropertyPages *iface, CAUUID *pPages)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_ISpecifyPropertyPages(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pPages);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISpecifyPropertyPagesVtbl SpecifyPropertyPagesVtbl = {
|
|
|
|
SpecifyPropertyPages_QueryInterface,
|
|
|
|
SpecifyPropertyPages_AddRef,
|
|
|
|
SpecifyPropertyPages_Release,
|
|
|
|
SpecifyPropertyPages_GetPages
|
|
|
|
};
|
|
|
|
|
2018-05-04 06:47:13 +02:00
|
|
|
static HRESULT WINAPI AviMuxOut_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *amt)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", base);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-09 17:12:33 +02:00
|
|
|
static HRESULT WINAPI AviMuxOut_AttemptConnection(BaseOutputPin *base,
|
2013-11-25 16:25:06 +01:00
|
|
|
IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
2013-11-26 14:36:19 +01:00
|
|
|
PIN_DIRECTION dir;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2013-11-25 16:25:06 +01:00
|
|
|
TRACE("(%p)->(%p AM_MEDIA_TYPE(%p))\n", base, pReceivePin, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
2013-11-26 14:36:19 +01:00
|
|
|
|
|
|
|
hr = IPin_QueryDirection(pReceivePin, &dir);
|
|
|
|
if(hr==S_OK && dir!=PINDIR_INPUT)
|
|
|
|
return VFW_E_INVALID_DIRECTION;
|
|
|
|
|
2013-11-25 16:25:06 +01:00
|
|
|
return BaseOutputPinImpl_AttemptConnection(base, pReceivePin, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_GetMediaType(BasePin *base, int iPosition, AM_MEDIA_TYPE *amt)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%d %p)\n", base, iPosition, amt);
|
|
|
|
|
|
|
|
if(iPosition < 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if(iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
|
|
|
|
amt->majortype = MEDIATYPE_Stream;
|
|
|
|
amt->subtype = MEDIASUBTYPE_Avi;
|
|
|
|
amt->bFixedSizeSamples = TRUE;
|
|
|
|
amt->bTemporalCompression = FALSE;
|
|
|
|
amt->lSampleSize = 1;
|
|
|
|
amt->formattype = GUID_NULL;
|
|
|
|
amt->pUnk = NULL;
|
|
|
|
amt->cbFormat = 0;
|
|
|
|
amt->pbFormat = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_DecideAllocator(BaseOutputPin *base,
|
|
|
|
IMemInputPin *pPin, IMemAllocator **pAlloc)
|
|
|
|
{
|
2013-11-26 14:36:19 +01:00
|
|
|
ALLOCATOR_PROPERTIES req, actual;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", base, pPin, pAlloc);
|
|
|
|
|
|
|
|
hr = BaseOutputPinImpl_InitAllocator(base, pAlloc);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IMemInputPin_GetAllocatorRequirements(pPin, &req);
|
|
|
|
if(FAILED(hr))
|
|
|
|
req.cbAlign = 1;
|
|
|
|
req.cBuffers = 32;
|
|
|
|
req.cbBuffer = 0;
|
|
|
|
req.cbPrefix = 0;
|
|
|
|
|
|
|
|
hr = IMemAllocator_SetProperties(*pAlloc, &req, &actual);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return IMemInputPin_NotifyAllocator(pPin, *pAlloc, TRUE);
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const BaseOutputPinFuncTable AviMuxOut_BaseOutputFuncTable = {
|
2014-01-06 17:54:13 +01:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
AviMuxOut_CheckMediaType,
|
2014-01-06 17:54:13 +01:00
|
|
|
AviMuxOut_GetMediaType
|
|
|
|
},
|
2019-05-09 17:12:33 +02:00
|
|
|
AviMuxOut_AttemptConnection,
|
2013-11-26 14:36:19 +01:00
|
|
|
NULL,
|
2013-11-25 16:25:06 +01:00
|
|
|
AviMuxOut_DecideAllocator,
|
|
|
|
};
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
static inline AviMux *impl_from_out_IPin(IPin *iface)
|
2013-11-25 16:25:06 +01:00
|
|
|
{
|
2019-06-17 02:34:59 +02:00
|
|
|
return CONTAINING_RECORD(iface, AviMux, source.pin.IPin_iface);
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryInterface(IPin *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin))
|
|
|
|
*ppv = iface;
|
|
|
|
else if(IsEqualIID(riid, &IID_IQualityControl))
|
2019-06-17 02:34:59 +02:00
|
|
|
*ppv = &This->IQualityControl_iface;
|
2013-11-25 16:25:06 +01:00
|
|
|
else {
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_Connect(IPin *iface,
|
|
|
|
IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
2013-11-26 14:36:19 +01:00
|
|
|
HRESULT hr;
|
|
|
|
int i;
|
|
|
|
|
2013-11-25 16:25:06 +01:00
|
|
|
TRACE("(%p)->(%p AM_MEDIA_TYPE(%p))\n", This, pReceivePin, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
2013-11-26 14:36:19 +01:00
|
|
|
|
|
|
|
hr = BaseOutputPinImpl_Connect(iface, pReceivePin, pmt);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
for(i=0; i<This->input_pin_no; i++) {
|
|
|
|
if(!This->in[i]->pin.pin.pConnectedTo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = IFilterGraph_Reconnect(This->filter.filterInfo.pGraph, &This->in[i]->pin.pin.IPin_iface);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
BaseOutputPinImpl_Disconnect(iface);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hr == S_OK)
|
|
|
|
IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
return hr;
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_ReceiveConnection(IPin *iface,
|
|
|
|
IPin *pConnector, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p AM_MEDIA_TYPE(%p)\n", This, pConnector, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
return BaseOutputPinImpl_ReceiveConnection(iface, pConnector, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_Disconnect(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
2013-11-26 14:36:19 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2013-11-25 16:25:06 +01:00
|
|
|
TRACE("(%p)\n", This);
|
2013-11-26 14:36:19 +01:00
|
|
|
|
|
|
|
hr = BaseOutputPinImpl_Disconnect(iface);
|
|
|
|
if(hr == S_OK)
|
|
|
|
IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
return hr;
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_ConnectedTo(IPin *iface, IPin **pPin)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pPin);
|
|
|
|
return BasePinImpl_ConnectedTo(iface, pPin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pmt);
|
|
|
|
return BasePinImpl_ConnectionMediaType(iface, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryPinInfo(IPin *iface, PIN_INFO *pInfo)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pInfo);
|
|
|
|
return BasePinImpl_QueryPinInfo(iface, pInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryDirection(IPin *iface, PIN_DIRECTION *pPinDir)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pPinDir);
|
|
|
|
return BasePinImpl_QueryDirection(iface, pPinDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryId(IPin *iface, LPWSTR *Id)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, Id);
|
|
|
|
return BasePinImpl_QueryId(iface, Id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(AM_MEDIA_TYPE(%p))\n", This, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
return BasePinImpl_QueryAccept(iface, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return BasePinImpl_EnumMediaTypes(iface, ppEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QueryInternalConnections(
|
|
|
|
IPin *iface, IPin **apPin, ULONG *nPin)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, apPin, nPin);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_EndOfStream(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return BaseOutputPinImpl_EndOfStream(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_BeginFlush(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return BaseOutputPinImpl_BeginFlush(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_EndFlush(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return BaseOutputPinImpl_EndFlush(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_NewSegment(IPin *iface, REFERENCE_TIME tStart,
|
|
|
|
REFERENCE_TIME tStop, double dRate)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IPin(iface);
|
2017-08-18 22:12:18 +02:00
|
|
|
TRACE("(%p)->(%s %s %f)\n", This, wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
|
2013-11-25 16:25:06 +01:00
|
|
|
return BasePinImpl_NewSegment(iface, tStart, tStop, dRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl AviMuxOut_PinVtbl = {
|
|
|
|
AviMuxOut_QueryInterface,
|
2019-06-19 03:17:37 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2013-11-25 16:25:06 +01:00
|
|
|
AviMuxOut_Connect,
|
|
|
|
AviMuxOut_ReceiveConnection,
|
|
|
|
AviMuxOut_Disconnect,
|
|
|
|
AviMuxOut_ConnectedTo,
|
|
|
|
AviMuxOut_ConnectionMediaType,
|
|
|
|
AviMuxOut_QueryPinInfo,
|
|
|
|
AviMuxOut_QueryDirection,
|
|
|
|
AviMuxOut_QueryId,
|
|
|
|
AviMuxOut_QueryAccept,
|
|
|
|
AviMuxOut_EnumMediaTypes,
|
|
|
|
AviMuxOut_QueryInternalConnections,
|
|
|
|
AviMuxOut_EndOfStream,
|
|
|
|
AviMuxOut_BeginFlush,
|
|
|
|
AviMuxOut_EndFlush,
|
|
|
|
AviMuxOut_NewSegment
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_out_IQualityControl(IQualityControl *iface)
|
|
|
|
{
|
2019-06-17 02:34:59 +02:00
|
|
|
return CONTAINING_RECORD(iface, AviMux, IQualityControl_iface);
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QualityControl_QueryInterface(
|
|
|
|
IQualityControl *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IQualityControl(iface);
|
2019-06-17 02:34:59 +02:00
|
|
|
return IPin_QueryInterface(&This->source.pin.IPin_iface, riid, ppv);
|
2013-11-25 16:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxOut_QualityControl_AddRef(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IQualityControl(iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxOut_QualityControl_Release(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IQualityControl(iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QualityControl_Notify(IQualityControl *iface,
|
|
|
|
IBaseFilter *pSelf, Quality q)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IQualityControl(iface);
|
2016-05-17 20:43:36 +02:00
|
|
|
FIXME("(%p)->(%p { 0x%x %u %s %s })\n", This, pSelf,
|
|
|
|
q.Type, q.Proportion,
|
|
|
|
wine_dbgstr_longlong(q.Late),
|
|
|
|
wine_dbgstr_longlong(q.TimeStamp));
|
2013-11-25 16:25:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxOut_QualityControl_SetSink(
|
|
|
|
IQualityControl *iface, IQualityControl *piqc)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_out_IQualityControl(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, piqc);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IQualityControlVtbl AviMuxOut_QualityControlVtbl = {
|
|
|
|
AviMuxOut_QualityControl_QueryInterface,
|
|
|
|
AviMuxOut_QualityControl_AddRef,
|
|
|
|
AviMuxOut_QualityControl_Release,
|
|
|
|
AviMuxOut_QualityControl_Notify,
|
|
|
|
AviMuxOut_QualityControl_SetSink
|
|
|
|
};
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
static HRESULT WINAPI AviMuxIn_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
2014-02-25 12:22:30 +01:00
|
|
|
TRACE("(%p:%s)->(AM_MEDIA_TYPE(%p))\n", base, debugstr_w(base->pinInfo.achName), pmt);
|
2013-11-25 16:29:04 +01:00
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
|
|
|
if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio) &&
|
|
|
|
IsEqualIID(&pmt->formattype, &FORMAT_WaveFormatEx))
|
|
|
|
return S_OK;
|
|
|
|
if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Interleaved) &&
|
|
|
|
IsEqualIID(&pmt->formattype, &FORMAT_DvInfo))
|
|
|
|
return S_OK;
|
|
|
|
if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) &&
|
|
|
|
(IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo) ||
|
|
|
|
IsEqualIID(&pmt->formattype, &FORMAT_DvInfo)))
|
|
|
|
return S_OK;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_GetMediaType(BasePin *base, int iPosition, AM_MEDIA_TYPE *amt)
|
|
|
|
{
|
2013-11-26 14:34:48 +01:00
|
|
|
return S_FALSE;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_Receive(BaseInputPin *base, IMediaSample *pSample)
|
|
|
|
{
|
2014-02-25 12:23:31 +01:00
|
|
|
AviMuxIn *avimuxin = CONTAINING_RECORD(base, AviMuxIn, pin);
|
|
|
|
AviMux *avimux = impl_from_IBaseFilter(base->pin.pinInfo.pFilter);
|
|
|
|
REFERENCE_TIME start, stop;
|
|
|
|
IMediaSample *sample;
|
|
|
|
int frames_no;
|
|
|
|
IMediaSample2 *ms2;
|
|
|
|
BYTE *frame, *buf;
|
|
|
|
DWORD max_size, size;
|
|
|
|
DWORD flags;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p)\n", base, debugstr_w(base->pin.pinInfo.achName), pSample);
|
|
|
|
|
|
|
|
hr = IMediaSample_QueryInterface(pSample, &IID_IMediaSample2, (void**)&ms2);
|
|
|
|
if(SUCCEEDED(hr)) {
|
|
|
|
AM_SAMPLE2_PROPERTIES props;
|
|
|
|
|
|
|
|
memset(&props, 0, sizeof(props));
|
|
|
|
hr = IMediaSample2_GetProperties(ms2, sizeof(props), (BYTE*)&props);
|
|
|
|
IMediaSample2_Release(ms2);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
flags = props.dwSampleFlags;
|
|
|
|
frame = props.pbBuffer;
|
|
|
|
size = props.lActual;
|
|
|
|
}else {
|
|
|
|
flags = IMediaSample_IsSyncPoint(pSample) == S_OK ? AM_SAMPLE_SPLICEPOINT : 0;
|
|
|
|
hr = IMediaSample_GetPointer(pSample, &frame);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
size = IMediaSample_GetActualDataLength(pSample);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!avimuxin->pin.pin.mtCurrent.bTemporalCompression)
|
|
|
|
flags |= AM_SAMPLE_SPLICEPOINT;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetTime(pSample, &start, &stop);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if(avimuxin->stop>stop)
|
|
|
|
return VFW_E_START_TIME_AFTER_END;
|
|
|
|
|
|
|
|
if(avimux->start == -1)
|
|
|
|
avimux->start = start;
|
|
|
|
if(avimux->stop < stop)
|
|
|
|
avimux->stop = stop;
|
|
|
|
|
|
|
|
if(avimux->avih.dwSuggestedBufferSize < ALIGN(size)+sizeof(RIFFCHUNK))
|
|
|
|
avimux->avih.dwSuggestedBufferSize = ALIGN(size) + sizeof(RIFFCHUNK);
|
|
|
|
if(avimuxin->strh.dwSuggestedBufferSize < ALIGN(size)+sizeof(RIFFCHUNK))
|
|
|
|
avimuxin->strh.dwSuggestedBufferSize = ALIGN(size) + sizeof(RIFFCHUNK);
|
|
|
|
|
|
|
|
frames_no = 1;
|
|
|
|
if(avimuxin->stop!=-1 && start > avimuxin->stop) {
|
|
|
|
frames_no += (double)(start - avimuxin->stop) / 10000000
|
|
|
|
* avimuxin->strh.dwRate / avimuxin->strh.dwScale + 0.5;
|
|
|
|
}
|
|
|
|
avimuxin->stop = stop;
|
|
|
|
|
|
|
|
while(--frames_no) {
|
|
|
|
/* TODO: store all control frames in one buffer */
|
|
|
|
hr = IMemAllocator_GetBuffer(avimuxin->samples_allocator, &sample, NULL, NULL, 0);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
hr = IMediaSample_SetActualDataLength(sample, 0);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMediaSample_SetDiscontinuity(sample, TRUE);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMediaSample_SetSyncPoint(sample, FALSE);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = queue_sample(avimux, avimuxin, sample);
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMemAllocator_GetBuffer(avimuxin->samples_allocator, &sample, NULL, NULL, 0);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
max_size = IMediaSample_GetSize(sample);
|
|
|
|
if(size > max_size)
|
|
|
|
size = max_size;
|
|
|
|
hr = IMediaSample_SetActualDataLength(sample, size);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMediaSample_SetDiscontinuity(sample, FALSE);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMediaSample_SetSyncPoint(sample, flags & AM_SAMPLE_SPLICEPOINT);
|
2014-09-28 23:53:46 +02:00
|
|
|
/* TODO: avoid unnecessary copying */
|
2014-02-25 12:23:31 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMediaSample_GetPointer(sample, &buf);
|
|
|
|
if(SUCCEEDED(hr)) {
|
|
|
|
memcpy(buf, frame, size);
|
|
|
|
hr = queue_sample(avimux, avimuxin, sample);
|
|
|
|
}
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
|
|
|
|
return hr;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const BaseInputPinFuncTable AviMuxIn_BaseInputFuncTable = {
|
2014-01-06 17:54:13 +01:00
|
|
|
{
|
|
|
|
AviMuxIn_CheckMediaType,
|
|
|
|
AviMuxIn_GetMediaType
|
|
|
|
},
|
2013-11-25 16:29:04 +01:00
|
|
|
AviMuxIn_Receive
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMux* impl_from_in_IPin(IPin *iface)
|
|
|
|
{
|
|
|
|
BasePin *bp = CONTAINING_RECORD(iface, BasePin, IPin_iface);
|
|
|
|
IBaseFilter *bf = bp->pinInfo.pFilter;
|
|
|
|
|
|
|
|
return impl_from_IBaseFilter(bf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline AviMuxIn* AviMuxIn_from_IPin(IPin *iface)
|
|
|
|
{
|
|
|
|
BasePin *bp = CONTAINING_RECORD(iface, BasePin, IPin_iface);
|
|
|
|
BaseInputPin *bip = CONTAINING_RECORD(bp, BaseInputPin, pin);
|
|
|
|
return CONTAINING_RECORD(bip, AviMuxIn, pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryInterface(IPin *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%s %p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
|
|
|
debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin))
|
|
|
|
*ppv = &avimuxin->pin.pin.IPin_iface;
|
|
|
|
else if(IsEqualIID(riid, &IID_IAMStreamControl))
|
|
|
|
*ppv = &avimuxin->IAMStreamControl_iface;
|
|
|
|
else if(IsEqualIID(riid, &IID_IMemInputPin))
|
2014-02-24 12:09:10 +01:00
|
|
|
*ppv = &avimuxin->pin.IMemInputPin_iface;
|
2013-11-25 16:29:04 +01:00
|
|
|
else if(IsEqualIID(riid, &IID_IPropertyBag))
|
|
|
|
*ppv = &avimuxin->IPropertyBag_iface;
|
|
|
|
else if(IsEqualIID(riid, &IID_IQualityControl))
|
|
|
|
*ppv = &avimuxin->IQualityControl_iface;
|
|
|
|
else {
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_Connect(IPin *iface,
|
|
|
|
IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p AM_MEDIA_TYPE(%p))\n", This,
|
|
|
|
debugstr_w(avimuxin->pin.pin.pinInfo.achName), pReceivePin, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
return BaseInputPinImpl_Connect(iface, pReceivePin, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface,
|
|
|
|
IPin *pConnector, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p AM_MEDIA_TYPE(%p))\n", This,
|
|
|
|
debugstr_w(avimuxin->pin.pin.pinInfo.achName), pConnector, pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
2013-11-26 14:35:08 +01:00
|
|
|
if(!pmt)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
hr = BaseInputPinImpl_ReceiveConnection(iface, pConnector, pmt);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2014-02-25 12:22:30 +01:00
|
|
|
if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) &&
|
|
|
|
IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
|
2014-02-25 12:23:31 +01:00
|
|
|
ALLOCATOR_PROPERTIES req, act;
|
2014-02-25 12:22:30 +01:00
|
|
|
VIDEOINFOHEADER *vih;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
vih = (VIDEOINFOHEADER*)pmt->pbFormat;
|
|
|
|
avimuxin->strh.fcc = ckidSTREAMHEADER;
|
|
|
|
avimuxin->strh.cb = sizeof(AVISTREAMHEADER) - FIELD_OFFSET(AVISTREAMHEADER, fccType);
|
|
|
|
avimuxin->strh.fccType = streamtypeVIDEO;
|
|
|
|
/* FIXME: fccHandler should be set differently */
|
|
|
|
avimuxin->strh.fccHandler = vih->bmiHeader.biCompression ?
|
|
|
|
vih->bmiHeader.biCompression : FCC('D','I','B',' ');
|
2014-02-25 12:23:31 +01:00
|
|
|
avimuxin->avg_time_per_frame = vih->AvgTimePerFrame;
|
|
|
|
avimuxin->stop = -1;
|
|
|
|
|
|
|
|
req.cBuffers = 32;
|
|
|
|
req.cbBuffer = vih->bmiHeader.biSizeImage;
|
|
|
|
req.cbAlign = 1;
|
|
|
|
req.cbPrefix = sizeof(void*);
|
|
|
|
hr = IMemAllocator_SetProperties(avimuxin->samples_allocator, &req, &act);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = IMemAllocator_Commit(avimuxin->samples_allocator);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
BasePinImpl_Disconnect(iface);
|
|
|
|
return hr;
|
|
|
|
}
|
2014-02-25 12:22:30 +01:00
|
|
|
|
|
|
|
size = pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
|
2014-02-26 13:36:58 +01:00
|
|
|
avimuxin->strf = CoTaskMemAlloc(sizeof(RIFFCHUNK) + ALIGN(FIELD_OFFSET(BITMAPINFO, bmiColors[vih->bmiHeader.biClrUsed])));
|
2014-02-25 12:22:30 +01:00
|
|
|
avimuxin->strf->fcc = ckidSTREAMFORMAT;
|
2014-02-26 13:36:58 +01:00
|
|
|
avimuxin->strf->cb = FIELD_OFFSET(BITMAPINFO, bmiColors[vih->bmiHeader.biClrUsed]);
|
2014-02-25 12:22:30 +01:00
|
|
|
if(size > avimuxin->strf->cb)
|
|
|
|
size = avimuxin->strf->cb;
|
|
|
|
memcpy(avimuxin->strf->data, &vih->bmiHeader, size);
|
|
|
|
}else {
|
|
|
|
FIXME("format not supported: %s %s\n", debugstr_guid(&pmt->majortype),
|
|
|
|
debugstr_guid(&pmt->formattype));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
return create_input_pin(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_Disconnect(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
2014-02-25 12:23:31 +01:00
|
|
|
IMediaSample **prev, *cur;
|
2014-02-25 12:22:30 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
TRACE("(%p:%s)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName));
|
2014-02-25 12:22:30 +01:00
|
|
|
|
|
|
|
hr = BasePinImpl_Disconnect(iface);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2014-02-25 12:23:31 +01:00
|
|
|
IMemAllocator_Decommit(avimuxin->samples_allocator);
|
|
|
|
while(avimuxin->samples_head) {
|
|
|
|
cur = avimuxin->samples_head;
|
|
|
|
hr = IMediaSample_GetPointer(cur, (BYTE**)&prev);
|
|
|
|
if(FAILED(hr))
|
|
|
|
break;
|
|
|
|
prev--;
|
|
|
|
|
|
|
|
cur = avimuxin->samples_head;
|
|
|
|
avimuxin->samples_head = *prev;
|
|
|
|
IMediaSample_Release(cur);
|
|
|
|
|
|
|
|
if(cur == avimuxin->samples_head)
|
|
|
|
avimuxin->samples_head = NULL;
|
|
|
|
}
|
2014-02-25 12:22:30 +01:00
|
|
|
CoTaskMemFree(avimuxin->strf);
|
|
|
|
avimuxin->strf = NULL;
|
|
|
|
return hr;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_ConnectedTo(IPin *iface, IPin **pPin)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pPin);
|
|
|
|
return BasePinImpl_ConnectedTo(iface, pPin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pmt);
|
|
|
|
return BasePinImpl_ConnectionMediaType(iface, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryPinInfo(IPin *iface, PIN_INFO *pInfo)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pInfo);
|
|
|
|
return BasePinImpl_QueryPinInfo(iface, pInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryDirection(IPin *iface, PIN_DIRECTION *pPinDir)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pPinDir);
|
|
|
|
return BasePinImpl_QueryDirection(iface, pPinDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryId(IPin *iface, LPWSTR *Id)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), Id);
|
|
|
|
return BasePinImpl_QueryId(iface, Id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(AM_MEDIA_TYPE(%p))\n", This,
|
|
|
|
debugstr_w(avimuxin->pin.pin.pinInfo.achName), pmt);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
return BasePinImpl_QueryAccept(iface, pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), ppEnum);
|
|
|
|
return BasePinImpl_EnumMediaTypes(iface, ppEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QueryInternalConnections(
|
|
|
|
IPin *iface, IPin **apPin, ULONG *nPin)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)->(%p %p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), apPin, nPin);
|
|
|
|
return BasePinImpl_QueryInternalConnections(iface, apPin, nPin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_EndOfStream(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName));
|
|
|
|
return BaseInputPinImpl_EndOfStream(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_BeginFlush(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName));
|
|
|
|
return BaseInputPinImpl_BeginFlush(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_EndFlush(IPin *iface)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
|
|
|
TRACE("(%p:%s)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName));
|
|
|
|
return BaseInputPinImpl_EndFlush(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_NewSegment(IPin *iface, REFERENCE_TIME tStart,
|
|
|
|
REFERENCE_TIME tStop, double dRate)
|
|
|
|
{
|
|
|
|
AviMux *This = impl_from_in_IPin(iface);
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
|
2017-08-18 22:12:18 +02:00
|
|
|
TRACE("(%p:%s)->(%s %s %f)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
|
|
|
wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
|
2013-11-25 16:29:04 +01:00
|
|
|
return BasePinImpl_NewSegment(iface, tStart, tStop, dRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl AviMuxIn_PinVtbl = {
|
|
|
|
AviMuxIn_QueryInterface,
|
2019-06-19 03:17:37 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2013-11-25 16:29:04 +01:00
|
|
|
AviMuxIn_Connect,
|
|
|
|
AviMuxIn_ReceiveConnection,
|
|
|
|
AviMuxIn_Disconnect,
|
|
|
|
AviMuxIn_ConnectedTo,
|
|
|
|
AviMuxIn_ConnectionMediaType,
|
|
|
|
AviMuxIn_QueryPinInfo,
|
|
|
|
AviMuxIn_QueryDirection,
|
|
|
|
AviMuxIn_QueryId,
|
|
|
|
AviMuxIn_QueryAccept,
|
|
|
|
AviMuxIn_EnumMediaTypes,
|
|
|
|
AviMuxIn_QueryInternalConnections,
|
|
|
|
AviMuxIn_EndOfStream,
|
|
|
|
AviMuxIn_BeginFlush,
|
|
|
|
AviMuxIn_EndFlush,
|
|
|
|
AviMuxIn_NewSegment
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMuxIn* AviMuxIn_from_IAMStreamControl(IAMStreamControl *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMuxIn, IAMStreamControl_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_AMStreamControl_QueryInterface(
|
|
|
|
IAMStreamControl *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
return IPin_QueryInterface(&avimuxin->pin.pin.IPin_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_AMStreamControl_AddRef(IAMStreamControl *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_AMStreamControl_Release(IAMStreamControl *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_AMStreamControl_StartAt(IAMStreamControl *iface,
|
|
|
|
const REFERENCE_TIME *ptStart, DWORD dwCookie)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%p %x)\n", This,
|
|
|
|
debugstr_w(avimuxin->pin.pin.pinInfo.achName), ptStart, dwCookie);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_AMStreamControl_StopAt(IAMStreamControl *iface,
|
|
|
|
const REFERENCE_TIME *ptStop, BOOL bSendExtra, DWORD dwCookie)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%p %x %x)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
|
|
|
ptStop, bSendExtra, dwCookie);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_AMStreamControl_GetInfo(
|
|
|
|
IAMStreamControl *iface, AM_STREAM_INFO *pInfo)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IAMStreamControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMStreamControlVtbl AviMuxIn_AMStreamControlVtbl = {
|
|
|
|
AviMuxIn_AMStreamControl_QueryInterface,
|
|
|
|
AviMuxIn_AMStreamControl_AddRef,
|
|
|
|
AviMuxIn_AMStreamControl_Release,
|
|
|
|
AviMuxIn_AMStreamControl_StartAt,
|
|
|
|
AviMuxIn_AMStreamControl_StopAt,
|
|
|
|
AviMuxIn_AMStreamControl_GetInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMuxIn* AviMuxIn_from_IMemInputPin(IMemInputPin *iface)
|
|
|
|
{
|
2014-02-24 12:09:10 +01:00
|
|
|
BaseInputPin *bip = CONTAINING_RECORD(iface, BaseInputPin, IMemInputPin_iface);
|
|
|
|
return CONTAINING_RECORD(bip, AviMuxIn, pin);
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_QueryInterface(
|
|
|
|
IMemInputPin *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
return IPin_QueryInterface(&avimuxin->pin.pin.IPin_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_MemInputPin_AddRef(IMemInputPin *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_MemInputPin_Release(IMemInputPin *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_GetAllocator(
|
|
|
|
IMemInputPin *iface, IMemAllocator **ppAllocator)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-24 12:10:27 +01:00
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), ppAllocator);
|
|
|
|
|
|
|
|
if(!ppAllocator)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
IMemAllocator_AddRef(avimuxin->pin.pAllocator);
|
|
|
|
*ppAllocator = avimuxin->pin.pAllocator;
|
|
|
|
return S_OK;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_NotifyAllocator(
|
|
|
|
IMemInputPin *iface, IMemAllocator *pAllocator, BOOL bReadOnly)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-24 12:10:46 +01:00
|
|
|
ALLOCATOR_PROPERTIES props;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p %x)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
2013-11-25 16:29:04 +01:00
|
|
|
pAllocator, bReadOnly);
|
2014-02-24 12:10:46 +01:00
|
|
|
|
|
|
|
if(!pAllocator)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
memset(&props, 0, sizeof(props));
|
|
|
|
hr = IMemAllocator_GetProperties(pAllocator, &props);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
props.cbAlign = 1;
|
|
|
|
props.cbPrefix = 8;
|
|
|
|
return IMemAllocator_SetProperties(avimuxin->pin.pAllocator, &props, &props);
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_GetAllocatorRequirements(
|
|
|
|
IMemInputPin *iface, ALLOCATOR_PROPERTIES *pProps)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-24 12:06:34 +01:00
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pProps);
|
|
|
|
|
|
|
|
if(!pProps)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
pProps->cbAlign = 1;
|
|
|
|
pProps->cbPrefix = 8;
|
|
|
|
return S_OK;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_Receive(
|
|
|
|
IMemInputPin *iface, IMediaSample *pSample)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-25 12:23:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pSample);
|
|
|
|
|
|
|
|
return avimuxin->pin.pFuncsTable->pfnReceive(&avimuxin->pin, pSample);
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_ReceiveMultiple(IMemInputPin *iface,
|
|
|
|
IMediaSample **pSamples, LONG nSamples, LONG *nSamplesProcessed)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-25 12:23:44 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p:%s)->(%p %d %p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
2013-11-25 16:29:04 +01:00
|
|
|
pSamples, nSamples, nSamplesProcessed);
|
2014-02-25 12:23:44 +01:00
|
|
|
|
|
|
|
for(*nSamplesProcessed=0; *nSamplesProcessed<nSamples; (*nSamplesProcessed)++)
|
|
|
|
{
|
|
|
|
hr = avimuxin->pin.pFuncsTable->pfnReceive(&avimuxin->pin, pSamples[*nSamplesProcessed]);
|
|
|
|
if(hr != S_OK)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_MemInputPin_ReceiveCanBlock(IMemInputPin *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IMemInputPin(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2014-02-24 12:11:26 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p:%s)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName));
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
if(!This->source.pMemInputPin)
|
2014-02-24 12:11:26 +01:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-06-17 02:34:59 +02:00
|
|
|
hr = IMemInputPin_ReceiveCanBlock(This->source.pMemInputPin);
|
2014-02-24 12:11:26 +01:00
|
|
|
return hr != S_FALSE ? S_OK : S_FALSE;
|
2013-11-25 16:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IMemInputPinVtbl AviMuxIn_MemInputPinVtbl = {
|
|
|
|
AviMuxIn_MemInputPin_QueryInterface,
|
|
|
|
AviMuxIn_MemInputPin_AddRef,
|
|
|
|
AviMuxIn_MemInputPin_Release,
|
|
|
|
AviMuxIn_MemInputPin_GetAllocator,
|
|
|
|
AviMuxIn_MemInputPin_NotifyAllocator,
|
|
|
|
AviMuxIn_MemInputPin_GetAllocatorRequirements,
|
|
|
|
AviMuxIn_MemInputPin_Receive,
|
|
|
|
AviMuxIn_MemInputPin_ReceiveMultiple,
|
|
|
|
AviMuxIn_MemInputPin_ReceiveCanBlock
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMuxIn* AviMuxIn_from_IPropertyBag(IPropertyBag *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMuxIn, IPropertyBag_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_PropertyBag_QueryInterface(
|
|
|
|
IPropertyBag *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPropertyBag(iface);
|
|
|
|
return IPin_QueryInterface(&avimuxin->pin.pin.IPin_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_PropertyBag_AddRef(IPropertyBag *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPropertyBag(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_PropertyBag_Release(IPropertyBag *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPropertyBag(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_PropertyBag_Read(IPropertyBag *iface,
|
|
|
|
LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPropertyBag(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%s %p %p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
|
|
|
debugstr_w(pszPropName), pVar, pErrorLog);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_PropertyBag_Write(IPropertyBag *iface,
|
|
|
|
LPCOLESTR pszPropName, VARIANT *pVar)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IPropertyBag(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%s %p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName),
|
|
|
|
debugstr_w(pszPropName), pVar);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPropertyBagVtbl AviMuxIn_PropertyBagVtbl = {
|
|
|
|
AviMuxIn_PropertyBag_QueryInterface,
|
|
|
|
AviMuxIn_PropertyBag_AddRef,
|
|
|
|
AviMuxIn_PropertyBag_Release,
|
|
|
|
AviMuxIn_PropertyBag_Read,
|
|
|
|
AviMuxIn_PropertyBag_Write
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline AviMuxIn* AviMuxIn_from_IQualityControl(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AviMuxIn, IQualityControl_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QualityControl_QueryInterface(
|
|
|
|
IQualityControl *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IQualityControl(iface);
|
|
|
|
return IPin_QueryInterface(&avimuxin->pin.pin.IPin_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_QualityControl_AddRef(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IQualityControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AviMuxIn_QualityControl_Release(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IQualityControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QualityControl_Notify(IQualityControl *iface,
|
|
|
|
IBaseFilter *pSelf, Quality q)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IQualityControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
2016-05-17 20:43:36 +02:00
|
|
|
FIXME("(%p:%s)->(%p { 0x%x %u %s %s })\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), pSelf,
|
|
|
|
q.Type, q.Proportion,
|
|
|
|
wine_dbgstr_longlong(q.Late),
|
|
|
|
wine_dbgstr_longlong(q.TimeStamp));
|
2013-11-25 16:29:04 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AviMuxIn_QualityControl_SetSink(
|
|
|
|
IQualityControl *iface, IQualityControl *piqc)
|
|
|
|
{
|
|
|
|
AviMuxIn *avimuxin = AviMuxIn_from_IQualityControl(iface);
|
|
|
|
AviMux *This = impl_from_in_IPin(&avimuxin->pin.pin.IPin_iface);
|
|
|
|
FIXME("(%p:%s)->(%p)\n", This, debugstr_w(avimuxin->pin.pin.pinInfo.achName), piqc);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IQualityControlVtbl AviMuxIn_QualityControlVtbl = {
|
|
|
|
AviMuxIn_QualityControl_QueryInterface,
|
|
|
|
AviMuxIn_QualityControl_AddRef,
|
|
|
|
AviMuxIn_QualityControl_Release,
|
|
|
|
AviMuxIn_QualityControl_Notify,
|
|
|
|
AviMuxIn_QualityControl_SetSink
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_input_pin(AviMux *avimux)
|
|
|
|
{
|
|
|
|
static const WCHAR name[] = {'I','n','p','u','t',' ','0','0',0};
|
2019-06-14 01:09:18 +02:00
|
|
|
AviMuxIn *object;
|
2013-11-25 16:29:04 +01:00
|
|
|
PIN_INFO info;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(avimux->input_pin_no >= MAX_PIN_NO-1)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
info.dir = PINDIR_INPUT;
|
|
|
|
info.pFilter = &avimux->filter.IBaseFilter_iface;
|
|
|
|
memcpy(info.achName, name, sizeof(name));
|
|
|
|
info.achName[7] = '0' + (avimux->input_pin_no+1) % 10;
|
|
|
|
info.achName[6] = '0' + (avimux->input_pin_no+1) / 10;
|
|
|
|
|
2019-06-14 01:09:18 +02:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
strmbase_sink_init(&object->pin, &AviMuxIn_PinVtbl, &info,
|
|
|
|
&AviMuxIn_BaseInputFuncTable, &avimux->filter.csFilter, NULL);
|
|
|
|
object->pin.IMemInputPin_iface.lpVtbl = &AviMuxIn_MemInputPinVtbl;
|
|
|
|
object->IAMStreamControl_iface.lpVtbl = &AviMuxIn_AMStreamControlVtbl;
|
|
|
|
object->IPropertyBag_iface.lpVtbl = &AviMuxIn_PropertyBagVtbl;
|
|
|
|
object->IQualityControl_iface.lpVtbl = &AviMuxIn_QualityControlVtbl;
|
2013-11-25 16:29:04 +01:00
|
|
|
|
2014-02-25 12:23:31 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
|
2019-06-14 01:09:18 +02:00
|
|
|
&IID_IMemAllocator, (void **)&object->samples_allocator);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
strmbase_sink_cleanup(&object->pin);
|
|
|
|
heap_free(object);
|
2014-02-25 12:23:31 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-02-24 12:10:27 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
|
2019-06-14 01:09:18 +02:00
|
|
|
&IID_IMemAllocator, (void **)&object->pin.pAllocator);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMemAllocator_Release(object->samples_allocator);
|
|
|
|
strmbase_sink_cleanup(&object->pin);
|
|
|
|
heap_free(object);
|
2014-02-24 12:10:27 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-06-14 01:09:18 +02:00
|
|
|
object->indx = (AVISUPERINDEX *)&object->indx_data;
|
|
|
|
object->ix = (AVISTDINDEX *)object->ix_data;
|
2014-02-25 12:22:30 +01:00
|
|
|
|
2019-06-14 01:09:18 +02:00
|
|
|
avimux->in[avimux->input_pin_no++] = object;
|
2013-11-25 16:29:04 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-06-04 17:01:17 +02:00
|
|
|
IUnknown * WINAPI QCAP_createAVIMux(IUnknown *outer, HRESULT *phr)
|
2013-11-20 22:48:04 +01:00
|
|
|
{
|
2013-11-25 16:29:04 +01:00
|
|
|
static const WCHAR output_name[] = {'A','V','I',' ','O','u','t',0};
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
AviMux *avimux;
|
2013-11-25 16:25:06 +01:00
|
|
|
PIN_INFO info;
|
|
|
|
HRESULT hr;
|
2013-11-20 22:48:04 +01:00
|
|
|
|
2014-02-25 12:21:59 +01:00
|
|
|
avimux = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(AviMux));
|
2013-11-20 22:48:04 +01:00
|
|
|
if(!avimux) {
|
|
|
|
*phr = E_OUTOFMEMORY;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-06-04 17:01:17 +02:00
|
|
|
strmbase_filter_init(&avimux->filter, &AviMuxVtbl, outer, &CLSID_AviDest,
|
2013-11-20 22:48:04 +01:00
|
|
|
(DWORD_PTR)(__FILE__ ": AviMux.csFilter"), &filter_func_table);
|
|
|
|
avimux->IConfigAviMux_iface.lpVtbl = &ConfigAviMuxVtbl;
|
|
|
|
avimux->IConfigInterleaving_iface.lpVtbl = &ConfigInterleavingVtbl;
|
|
|
|
avimux->IMediaSeeking_iface.lpVtbl = &MediaSeekingVtbl;
|
|
|
|
avimux->IPersistMediaPropertyBag_iface.lpVtbl = &PersistMediaPropertyBagVtbl;
|
|
|
|
avimux->ISpecifyPropertyPages_iface.lpVtbl = &SpecifyPropertyPagesVtbl;
|
|
|
|
|
2013-11-25 16:25:06 +01:00
|
|
|
info.dir = PINDIR_OUTPUT;
|
|
|
|
info.pFilter = &avimux->filter.IBaseFilter_iface;
|
|
|
|
lstrcpyW(info.achName, output_name);
|
2019-06-17 02:34:59 +02:00
|
|
|
strmbase_source_init(&avimux->source, &AviMuxOut_PinVtbl, &info,
|
|
|
|
&AviMuxOut_BaseOutputFuncTable, &avimux->filter.csFilter);
|
|
|
|
avimux->IQualityControl_iface.lpVtbl = &AviMuxOut_QualityControlVtbl;
|
|
|
|
avimux->cur_stream = 0;
|
|
|
|
avimux->cur_time = 0;
|
|
|
|
avimux->stream = NULL;
|
2013-11-25 16:25:06 +01:00
|
|
|
|
2013-11-25 16:29:04 +01:00
|
|
|
hr = create_input_pin(avimux);
|
|
|
|
if(FAILED(hr)) {
|
2019-06-17 02:34:59 +02:00
|
|
|
strmbase_source_cleanup(&avimux->source);
|
2019-05-22 07:02:16 +02:00
|
|
|
strmbase_filter_cleanup(&avimux->filter);
|
2013-11-25 16:29:04 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, avimux);
|
|
|
|
*phr = hr;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-25 12:21:59 +01:00
|
|
|
avimux->interleave = 10000000;
|
|
|
|
|
2013-11-20 22:48:04 +01:00
|
|
|
ObjectRefCount(TRUE);
|
|
|
|
*phr = S_OK;
|
2019-06-04 17:01:17 +02:00
|
|
|
return &avimux->filter.IUnknown_inner;
|
2013-11-20 22:48:04 +01:00
|
|
|
}
|