summaryrefslogtreecommitdiff
path: root/src/QGst/query.h
blob: 33fd16654f5109ac9dc42461afa04231cd190830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
    Copyright (C) 2010  Collabora Multimedia.
      @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk>

    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 program 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 General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QGST_QUERY_H
#define QGST_QUERY_H

#include "miniobject.h"
#include "structure.h"

class QUrl;

namespace QGst {

    /*! \headerfile query.h <QGst/Query>
     * \brief Wrapper class for GstQuery
     *
     * Queries are lightweight objects that are sent from the application directly to elements
     * or pads using the query() methods. A typical usage is to find out the duration or current
     * position of media, or to display the status of a buffering operation.
     *
     * Queries are implemented as a subclass of MiniObject with a generic GstStructure as the
     * content. This allows for writing custom queries without requiring an API change while
     * allowing a wide range of different types of queries.
     *
     * QGst::Query is the common base class for all query types.
     *
     * In these bindings, for convenience, each query type has its own Query subclass. The create()
     * method in the subclasses should be used to create a query object. This does not reflect 1-1
     * the native C API, where there is only one Query class with tens of 'new_foo' and 'parse_foo'
     * methods.
     *
     * Note that the Query subclasses \em cannot be used with Value::get(), since a GValue
     * will actually contain a GstQuery (the subclasses do not exist in C) and Value::get()
     * is not able to do dynamic casts. As a result of that, Query subclasses also \em cannot be
     * used as arguments in slots connected to GObject signals, even though you may know that your
     * slot will only be called with that type of queries.
     */
class Query : public MiniObject
{
    QGST_WRAPPER(Query)
public:
    QString typeName() const;
    QueryType type() const;

    StructurePtr internalStructure();
    const StructurePtr internalStructure() const;

};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::PositionQuery
 */
class PositionQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(PositionQuery, Query)
public:
    static PositionQueryPtr create(Format format);

    Format format() const;
    qint64 position() const;
    void setValues(Format format, qint64 position);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::DurationQuery
 */
class DurationQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(DurationQuery, Query)
public:
    static DurationQueryPtr create(Format format);

    Format format() const;
    qint64 duration() const;
    void setValues(Format format, qint64 duration);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::LatencyQuery
 */
class LatencyQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(LatencyQuery, Query)
public:
    static LatencyQueryPtr create();

    bool hasLive() const;
    ClockTime minimumLatency() const;
    ClockTime maximumLatency() const;

    void setValues(bool live, ClockTime minimumLatency, ClockTime maximumLatency);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::SeekingQuery
 */
class SeekingQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(SeekingQuery, Query)
public:
    static SeekingQueryPtr create(Format format);

    Format format() const;
    bool seekable() const;
    qint64 segmentStart() const;
    qint64 segmentEnd() const;

    void setValues(Format format, bool seekable, qint64 segmentStart, qint64 segmentEnd);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::SegmentQuery
 */
class SegmentQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(SegmentQuery, Query)
public:
    static SegmentQueryPtr create(Format format);

    Format format() const;
    double rate() const;
    qint64 startValue() const;
    qint64 stopValue() const;

    void setValues(Format format, double rate, qint64 startValue, qint64 stopValue);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::ConvertQuery
 */
class ConvertQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(ConvertQuery, Query)
public:
    static ConvertQueryPtr create(Format sourceFormat, qint64 value, Format destinationFormat);

    Format sourceFormat() const;
    qint64 sourceValue() const;
    Format destinationFormat() const;
    qint64 destinationValue() const;

    void setValues(Format sourceFormat, qint64 sourcevalue, Format destinationFormat,
                    qint64 destinationValue);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::FormatsQuery
 */
class FormatsQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(FormatsQuery, Query)
public:
    static FormatsQueryPtr create();

    QList<Format> formats() const;

    void setValue(const QList<Format> & formats);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::BufferingQuery
 */
class BufferingQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(BufferingQuery, Query)
public:
    static BufferingQueryPtr create(Format format);

    bool isBusy() const;
    int percent() const;

    void setValues(bool busy, int percent);

    BufferingMode mode() const;
    int averageIn() const;
    int averageOut() const;
    qint64 bufferingLeft() const;

    void setValues(BufferingMode mode, int averageIn, int averageOut, qint64 bufferingLeft);

    Format format() const;
    qint64 rangeStart() const;
    qint64 rangeStop() const;
    qint64 estimatedTotal() const;

    void setValues(Format rangeFormat, qint64 rangeStart, qint64 rangeStop, qint64 estimatedTotal);
};

/*! \headerfile query.h <QGst/Query>
 * \brief Wrapper class for queries of type QGst::UriQuery
 */
class UriQuery : public Query
{
    QGST_WRAPPER_DIFFERENT_C_CLASS(UriQuery, Query)
public:
    static UriQueryPtr create();

    QUrl uri() const;

    void setValue(const QUrl & uri);
};

} //namespace QGst

QGLIB_REGISTER_TYPE(QGst::Query)
QGST_REGISTER_SUBCLASS(Query, Position)
QGST_REGISTER_SUBCLASS(Query, Duration)
QGST_REGISTER_SUBCLASS(Query, Latency)
QGST_REGISTER_SUBCLASS(Query, Seeking)
QGST_REGISTER_SUBCLASS(Query, Segment)
QGST_REGISTER_SUBCLASS(Query, Convert)
QGST_REGISTER_SUBCLASS(Query, Formats)
QGST_REGISTER_SUBCLASS(Query, Buffering)
QGST_REGISTER_SUBCLASS(Query, Uri)

#endif