src/3rdparty/phonon/ds9/backendnode.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     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             mediaObjectDestroyed();
       
    62         }
       
    63 
       
    64         void BackendNode::setMediaObject(MediaObject *mo)
       
    65         {
       
    66             if (m_mediaObject) {
       
    67                 disconnect(m_mediaObject, SIGNAL(destroyed()), this, SLOT(mediaObjectDestroyed()));
       
    68             }
       
    69             m_mediaObject = mo;
       
    70             connect(mo, SIGNAL(destroyed()), SLOT(mediaObjectDestroyed()));
       
    71         }
       
    72 
       
    73         void BackendNode::mediaObjectDestroyed()
       
    74         {
       
    75             //remove the filter from its graph
       
    76             FILTER_INFO info;
       
    77             for(int i = 0; i < FILTER_COUNT; ++i) {
       
    78                 const Filter &filter = m_filters[i];
       
    79                 if (!filter)
       
    80                     continue; 
       
    81                 filter->QueryFilterInfo(&info);
       
    82                 if (info.pGraph) {
       
    83                     HRESULT hr = info.pGraph->RemoveFilter(filter);
       
    84                     Q_ASSERT(SUCCEEDED(hr));
       
    85                     Q_UNUSED(hr);
       
    86                     info.pGraph->Release();
       
    87                 }
       
    88             }
       
    89             m_mediaObject = 0;
       
    90         }
       
    91 
       
    92         QList<InputPin> BackendNode::pins(const Filter &filter, PIN_DIRECTION wantedDirection)
       
    93         {
       
    94             QList<InputPin> ret;
       
    95             if (filter) {
       
    96                 ComPointer<IEnumPins> enumPin;
       
    97                 HRESULT hr = filter->EnumPins(enumPin.pparam());
       
    98                 Q_UNUSED(hr);
       
    99                 Q_ASSERT( SUCCEEDED(hr));
       
   100                 InputPin pin;
       
   101                 while (enumPin->Next(1, pin.pparam(), 0) == S_OK) {
       
   102                     PIN_DIRECTION dir;
       
   103                     hr = pin->QueryDirection(&dir);
       
   104                     Q_ASSERT( SUCCEEDED(hr));
       
   105                     if (dir == wantedDirection) {
       
   106                         ret.append(pin);
       
   107                     }
       
   108                 }
       
   109             }
       
   110             return ret;
       
   111         }
       
   112     }
       
   113 }
       
   114 
       
   115 QT_END_NAMESPACE
       
   116 
       
   117 #include "moc_backendnode.cpp"