1
/* This file is part of the KDE project.
3
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
5
This library is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 2.1 or 3 of the License.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public License
15
along with this library. If not, see <http://www.gnu.org/licenses/>.
18
#include "fakesource.h"
23
#include <dvdmedia.h> // VIDEOINFOHEADER2
31
static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0};
32
static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, {0}, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} };
34
static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast<BYTE*>(&g_defaultWaveFormat)};
35
static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast<BYTE*>(&g_defaultVideoInfo)};
37
class FakePin : public QPin
40
FakePin(FakeSource *source, const AM_MEDIA_TYPE &mt) :
41
QPin(source, PINDIR_OUTPUT, QVector<AM_MEDIA_TYPE>() << mt), m_source(source)
51
STDMETHODIMP Disconnect()
53
HRESULT hr = QPin::Disconnect();
61
STDMETHODIMP Connect(IPin *pin, const AM_MEDIA_TYPE *type)
63
HRESULT hr = QPin::Connect(pin, type);
71
void setAvailable(bool avail)
73
if (mediaTypes().first().majortype == MEDIATYPE_Audio) {
75
m_source->addAvailableAudioPin(this);
77
m_source->removeAvailableAudioPin(this);
81
m_source->addAvailableVideoPin(this);
83
m_source->removeAvailableVideoPin(this);
93
FakeSource::FakeSource() : QBaseFilter(CLSID_NULL)
99
FakeSource::~FakeSource()
103
void FakeSource::addAvailableAudioPin(FakePin *pin)
105
availableAudioPins += pin;
108
void FakeSource::addAvailableVideoPin(FakePin *pin)
110
availableVideoPins += pin;
113
void FakeSource::removeAvailableAudioPin(FakePin *pin)
115
availableAudioPins -= pin;
117
if (availableAudioPins.isEmpty()) {
118
createFakeAudioPin();
122
void FakeSource::removeAvailableVideoPin(FakePin *pin)
124
availableVideoPins -= pin;
126
if (availableVideoPins.isEmpty()) {
127
createFakeVideoPin();
131
void FakeSource::createFakeAudioPin()
133
new FakePin(this, g_fakeAudioType);
136
void FakeSource::createFakeVideoPin()
138
new FakePin(this, g_fakeVideoType);