| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 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. |
| 8 |
|
| 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. |
| 13 |
|
| 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/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "backendnode.h" |
| 19 |
#include "mediaobject.h" |
| 20 |
|
| 21 |
#include <ocidl.h> // ISpecifyPropertyPages |
| 22 |
#include <olectl.h> // OleCreatePropertyFrame |
| 23 |
|
| 24 |
QT_BEGIN_NAMESPACE |
| 25 |
|
| 26 |
namespace Phonon |
| 27 |
{ |
| 28 |
namespace DS9 |
| 29 |
{ |
| 30 |
// Displays a property dialog for a filter (experimental but should be put into main |
| 31 |
/*static void showPropertyDialog(const Filter &filter) |
| 32 |
{ |
| 33 |
ComPointer<ISpecifyPropertyPages> prop(filter, IID_ISpecifyPropertyPages); |
| 34 |
if (prop != 0) { |
| 35 |
IUnknown *iunk[] = {filter}; |
| 36 |
// Show the page. |
| 37 |
CAUUID caGUID; |
| 38 |
prop->GetPages(&caGUID); |
| 39 |
OleCreatePropertyFrame( |
| 40 |
0, // Parent window |
| 41 |
0, 0, // (Reserved) |
| 42 |
0, // Caption for the dialog box |
| 43 |
1, // Number of objects (just the filter) |
| 44 |
iunk, // Array of object pointers. |
| 45 |
caGUID.cElems, // Number of property pages |
| 46 |
caGUID.pElems, // Array of property page CLSIDs |
| 47 |
0, // Locale identifier |
| 48 |
0, 0 // Reserved |
| 49 |
); |
| 50 |
} |
| 51 |
}*/ |
| 52 |
|
| 53 |
//for now we have 2 graphs that do the same |
| 54 |
BackendNode::BackendNode(QObject *parent) : QObject(parent), m_mediaObject(0) |
| 55 |
{ |
| 56 |
} |
| 57 |
|
| 58 |
BackendNode::~BackendNode() |
| 59 |
{ |
| 60 |
//this will remove the filter from the graph |
| 61 |
FILTER_INFO info; |
| 62 |
for(int i = 0; i < FILTER_COUNT; ++i) { |
| 63 |
const Filter &filter = m_filters[i]; |
| 64 |
if (!filter) |
| 65 |
continue; |
| 66 |
filter->QueryFilterInfo(&info); |
| 67 |
if (info.pGraph) { |
| 68 |
HRESULT hr = info.pGraph->RemoveFilter(filter); |
| 69 |
|
| 70 |
if (FAILED(hr) && m_mediaObject) { |
| 71 |
m_mediaObject->ensureStopped(); |
| 72 |
|
| 73 |
hr = info.pGraph->RemoveFilter(filter); |
| 74 |
} |
| 75 |
Q_ASSERT(SUCCEEDED(hr)); |
| 76 |
info.pGraph->Release(); |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
void BackendNode::setMediaObject(MediaObject *mo) |
| 82 |
{ |
| 83 |
if (m_mediaObject) { |
| 84 |
disconnect(m_mediaObject, SIGNAL(destroyed()), this, SLOT(mediaObjectDestroyed())); |
| 85 |
} |
| 86 |
m_mediaObject = mo; |
| 87 |
connect(mo, SIGNAL(destroyed()), SLOT(mediaObjectDestroyed())); |
| 88 |
} |
| 89 |
|
| 90 |
void BackendNode::mediaObjectDestroyed() |
| 91 |
{ |
| 92 |
//remove the filter from its graph |
| 93 |
FILTER_INFO info; |
| 94 |
for(int i = 0; i < FILTER_COUNT; ++i) { |
| 95 |
const Filter &filter = m_filters[i]; |
| 96 |
if (!filter) |
| 97 |
continue; |
| 98 |
filter->QueryFilterInfo(&info); |
| 99 |
if (info.pGraph) { |
| 100 |
HRESULT hr = info.pGraph->RemoveFilter(filter); |
| 101 |
Q_ASSERT(SUCCEEDED(hr)); |
| 102 |
Q_UNUSED(hr); |
| 103 |
info.pGraph->Release(); |
| 104 |
} |
| 105 |
} |
| 106 |
m_mediaObject = 0; |
| 107 |
} |
| 108 |
|
| 109 |
QList<InputPin> BackendNode::pins(const Filter &filter, PIN_DIRECTION wantedDirection) |
| 110 |
{ |
| 111 |
QList<InputPin> ret; |
| 112 |
if (filter) { |
| 113 |
ComPointer<IEnumPins> enumPin; |
| 114 |
HRESULT hr = filter->EnumPins(enumPin.pparam()); |
| 115 |
Q_UNUSED(hr); |
| 116 |
Q_ASSERT( SUCCEEDED(hr)); |
| 117 |
InputPin pin; |
| 118 |
while (enumPin->Next(1, pin.pparam(), 0) == S_OK) { |
| 119 |
PIN_DIRECTION dir; |
| 120 |
hr = pin->QueryDirection(&dir); |
| 121 |
Q_ASSERT( SUCCEEDED(hr)); |
| 122 |
if (dir == wantedDirection) { |
| 123 |
ret.append(pin); |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
return ret; |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
QT_END_NAMESPACE |
| 133 |
|
| 134 |
#include "moc_backendnode.cpp" |