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
#ifndef PHONON_QPIN_H
19
#define PHONON_QPIN_H
20
21
#include "phononds9_namespace.h"
22
23
#include <QtCore/QString>
24
#include <QtCore/QVector>
25
#include <QtCore/QMutex>
26
27
#include <dshow.h>
28
29
QT_BEGIN_NAMESPACE
30
31
namespace Phonon
32
{
33
    namespace DS9
34
    {
35
        class QBaseFilter;
36
37
        //this is the base class for our self-implemented Pins
38
        class QPin : public IPin
39
        {
40
        public:
41
            QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector<AM_MEDIA_TYPE> &mt);
42
            virtual ~QPin();
43
44
            //reimplementation from IUnknown
45
            STDMETHODIMP QueryInterface(REFIID iid, void** out);
46
            STDMETHODIMP_(ULONG) AddRef();
47
            STDMETHODIMP_(ULONG) Release();
48
49
            //reimplementation from IPin
50
            STDMETHODIMP Connect(IPin *,const AM_MEDIA_TYPE *);
51
            STDMETHODIMP ReceiveConnection(IPin *,const AM_MEDIA_TYPE *);
52
            STDMETHODIMP Disconnect();
53
            STDMETHODIMP ConnectedTo(IPin **);
54
            STDMETHODIMP ConnectionMediaType(AM_MEDIA_TYPE *);
55
            STDMETHODIMP QueryPinInfo(PIN_INFO *);
56
            STDMETHODIMP QueryDirection(PIN_DIRECTION *);
57
            STDMETHODIMP QueryId(LPWSTR*);
58
            STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE*);
59
            STDMETHODIMP EnumMediaTypes(IEnumMediaTypes **);
60
            STDMETHODIMP QueryInternalConnections(IPin **, ULONG*);
61
            STDMETHODIMP EndOfStream();
62
            STDMETHODIMP BeginFlush();
63
            STDMETHODIMP EndFlush();
64
            STDMETHODIMP NewSegment(REFERENCE_TIME, REFERENCE_TIME, double);
65
66
            QVector<AM_MEDIA_TYPE> mediaTypes() const;
67
68
            HRESULT setAcceptedMediaType(const AM_MEDIA_TYPE &);
69
70
            bool isFlushing() const;
71
            void setConnectedType(const AM_MEDIA_TYPE &type);
72
            const AM_MEDIA_TYPE &connectedType() const;
73
            void setConnected(IPin *pin);
74
            IPin *connected(bool = false) const;
75
            void setMemoryAllocator(IMemAllocator *alloc);
76
            IMemAllocator *memoryAllocator(bool = false) const;
77
            void createDefaultMemoryAllocator(ALLOCATOR_PROPERTIES * = 0);
78
            PIN_DIRECTION direction() const;
79
80
            FILTER_STATE filterState() const;
81
82
            static AM_MEDIA_TYPE copyMediaType(const AM_MEDIA_TYPE &type);
83
            static void freeMediaType(AM_MEDIA_TYPE *type);
84
            static void freeMediaType(const AM_MEDIA_TYPE &type);
85
86
        protected:
87
            //this can be used by sub-classes
88
            mutable QMutex m_mutex;
89
            QBaseFilter * const m_parent;
90
            bool m_flushing;
91
92
        private:
93
            HRESULT checkOutputMediaTypesConnection(IPin *pin);
94
            HRESULT checkOwnMediaTypesConnection(IPin *pin);
95
96
            LONG m_refCount;
97
            IPin *m_connected;
98
            const PIN_DIRECTION m_direction;
99
            QVector<AM_MEDIA_TYPE> m_mediaTypes; //accepted media types
100
            AM_MEDIA_TYPE m_connectedType;
101
            IMemAllocator *m_memAlloc;
102
        };
103
104
        //utility function
105
        class QAMMediaType : public AM_MEDIA_TYPE
106
        {
107
        public:
108
            ~QAMMediaType() 
109
            {
110
                QPin::freeMediaType(*this);
111
            }
112
113
        };
114
115
    }
116
}
117
118
QT_END_NAMESPACE
119
120
#endif //PHONON_QPIN_H