QtGStreamer 1.2.0
Loading...
Searching...
No Matches
event.cpp
1/*
2 Copyright (C) 2010 Collabora Multimedia.
3 @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk>
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
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "caps.h"
19#include "event.h"
20#include "message.h"
21#include "object.h"
22#include "segment.h"
23#include <QtCore/QDebug>
24#include <gst/gst.h>
25
26namespace QGst {
27
28quint64 Event::timestamp() const
29{
30 return object<GstEvent>()->timestamp;
31}
32
33EventType Event::type() const
34{
35 return static_cast<EventType>(GST_EVENT_TYPE(object<GstEvent>()));
36}
37
38QString Event::typeName() const
39{
40 return QString::fromUtf8(GST_EVENT_TYPE_NAME(object<GstEvent>()));
41}
42
43StructureConstPtr Event::internalStructure()
44{
45 const GstStructure *structure = gst_event_get_structure(object<GstEvent>());
46 return SharedStructure::fromMiniObject(const_cast<GstStructure *>(structure), MiniObjectPtr(this));
47}
48
49bool Event::hasName(const char *name) const
50{
51 return gst_event_has_name(object<GstEvent>(), name);
52}
53
54quint32 Event::sequenceNumber() const
55{
56 return gst_event_get_seqnum(object<GstEvent>());
57}
58
59void Event::setSequenceNumber(quint32 num)
60{
61 gst_event_set_seqnum(object<GstEvent>(), num);
62}
63
64EventPtr Event::copy() const
65{
66 return EventPtr::wrap(gst_event_copy(object<GstEvent>()), false);
67}
68
69//********************************************************
70
71FlushStartEventPtr FlushStartEvent::create()
72{
73 return FlushStartEventPtr::wrap(gst_event_new_flush_start(), false);
74}
75
76//********************************************************
77
78FlushStopEventPtr FlushStopEvent::create(bool reset_time)
79{
80 return FlushStopEventPtr::wrap(gst_event_new_flush_stop(reset_time), false);
81}
82
83bool FlushStopEvent::resetTime() const
84{
85 gboolean r;
86 gst_event_parse_flush_stop(object<GstEvent>(), &r);
87 return r;
88}
89
90//********************************************************
91
92EosEventPtr EosEvent::create()
93{
94 return EosEventPtr::wrap(gst_event_new_eos(), false);
95}
96
97//********************************************************
98CapsEventPtr CapsEvent::create(const CapsPtr &caps)
99{
100 return CapsEventPtr::wrap(gst_event_new_caps(caps), false);
101}
102
103CapsPtr CapsEvent::caps() const
104{
105 GstCaps *c;
106 gst_event_parse_caps (object<GstEvent>(), &c);
107 return CapsPtr::wrap (c);
108}
109
110//********************************************************
111
112SegmentEventPtr SegmentEvent::create(const Segment & segment)
113{
114 return SegmentEventPtr::wrap(gst_event_new_segment(segment), false);
115}
116
117Segment SegmentEvent::segment() const
118{
119 const GstSegment *s;
120 gst_event_parse_segment(object<GstEvent>(), &s);
121
122 return Segment(s);
123}
124
125//********************************************************
126TagEventPtr TagEvent::create(const TagList & taglist)
127{
128 GstEvent * e = gst_event_new_tag(gst_tag_list_copy(&taglist));
129 return TagEventPtr::wrap(e, false);
130}
131
132TagList TagEvent::taglist() const
133{
134 GstTagList * t;
135 gst_event_parse_tag(object<GstEvent>(), &t);
136 TagList tl(t);
137 return tl;
138}
139
140//********************************************************
141
142BufferSizeEventPtr BufferSizeEvent::create(Format format, qint64 minSize, qint64 maxSize,
143 bool isAsync)
144{
145 GstEvent * e = gst_event_new_buffer_size(static_cast<GstFormat>(format), minSize, maxSize,
146 isAsync);
147
148 return BufferSizeEventPtr::wrap(e, false);
149}
150
151Format BufferSizeEvent::format() const
152{
153 GstFormat f;
154 gst_event_parse_buffer_size(object<GstEvent>(), &f, NULL, NULL, NULL);
155 return static_cast<Format>(f);
156}
157
158qint64 BufferSizeEvent::minSize() const
159{
160 gint64 s;
161 gst_event_parse_buffer_size(object<GstEvent>(), NULL, &s, NULL, NULL);
162 return s;
163}
164
165qint64 BufferSizeEvent::maxSize() const
166{
167 gint64 s;
168 gst_event_parse_buffer_size(object<GstEvent>(), NULL, NULL, &s, NULL);
169 return s;
170}
171
172bool BufferSizeEvent::isAsync() const
173{
174 gboolean u;
175 gst_event_parse_buffer_size(object<GstEvent>(), NULL, NULL, NULL, &u);
176 return u;
177}
178
179//********************************************************
180
181SinkMessageEventPtr SinkMessageEvent::create(const QString &name, const MessagePtr & msg)
182{
183 GstEvent * e = gst_event_new_sink_message(name.toUtf8().constData(), msg);
184 return SinkMessageEventPtr::wrap(e, false);
185}
186
187MessagePtr SinkMessageEvent::message() const
188{
189 GstMessage * msg;
190 gst_event_parse_sink_message(object<GstEvent>(), &msg);
191 //Wrap message (refcount was already increased), will unref() when MessagePtr is destroyed
192 return MessagePtr::wrap(msg, false);
193}
194
195//********************************************************
196
197QosEventPtr QosEvent::create(QosType qos, double proportion, ClockTimeDiff diff, ClockTime timeStamp)
198{
199 GstEvent * e = gst_event_new_qos(static_cast<GstQOSType>(qos), proportion, diff, static_cast<GstClockTime>(timeStamp));
200 return QosEventPtr::wrap(e, false);
201}
202
203QosType QosEvent::qosType() const
204{
205 GstQOSType t;
206 gst_event_parse_qos(object<GstEvent>(), &t, NULL, NULL, NULL);
207 return static_cast<QosType>(t);
208}
209
210double QosEvent::proportion() const
211{
212 double d;
213 gst_event_parse_qos(object<GstEvent>(), NULL, &d, NULL, NULL);
214 return d;
215}
216
217ClockTimeDiff QosEvent::diff() const
218{
219 GstClockTimeDiff c;
220 gst_event_parse_qos(object<GstEvent>(), NULL, NULL, &c, NULL);
221 return c;
222}
223
224ClockTime QosEvent::timestamp() const
225{
226 GstClockTime c;
227 gst_event_parse_qos(object<GstEvent>(), NULL, NULL, NULL, &c);
228 return c;
229}
230
231//********************************************************
232
233SeekEventPtr SeekEvent::create(double rate, Format format, SeekFlags flags, SeekType startType,
234 qint64 start, SeekType stopType, qint64 stop)
235{
236 GstEvent * e = gst_event_new_seek(rate, static_cast<GstFormat>(format),
237 static_cast<GstSeekFlags>(static_cast<int>(flags)),
238 static_cast<GstSeekType>(startType), start,
239 static_cast<GstSeekType>(stopType), stop );
240 return SeekEventPtr::wrap(e, false);
241}
242
243double SeekEvent::rate() const
244{
245 double d;
246 gst_event_parse_seek(object<GstEvent>(), &d, NULL, NULL, NULL, NULL, NULL, NULL);
247 return d;
248}
249
250Format SeekEvent::format() const
251{
252 GstFormat f;
253 gst_event_parse_seek(object<GstEvent>(), NULL, &f, NULL, NULL, NULL, NULL, NULL);
254 return static_cast<Format>(f);
255}
256
257SeekFlags SeekEvent::flags() const
258{
259 GstSeekFlags f;
260 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, &f, NULL, NULL, NULL, NULL);
261 return static_cast<SeekFlags>(f);
262}
263
264SeekType SeekEvent::startType() const
265{
266 GstSeekType t;
267 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, &t, NULL, NULL, NULL);
268 return static_cast<SeekType>(t);
269}
270
271qint64 SeekEvent::start() const
272{
273 gint64 s;
274 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, &s, NULL, NULL);
275 return s;
276}
277
278SeekType SeekEvent::stopType() const
279{
280 GstSeekType t;
281 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, &t, NULL);
282 return static_cast<SeekType>(t);
283}
284
285qint64 SeekEvent::stop() const
286{
287 gint64 s;
288 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, NULL, &s);
289 return s;
290}
291
292//********************************************************
293
294NavigationEventPtr NavigationEvent::create(const Structure & structure)
295{
296 GstStructure * s = structure.isValid() ? gst_structure_copy(structure) : NULL;
297 GstEvent * e = gst_event_new_navigation(s);
298 return NavigationEventPtr::wrap(e, false);
299}
300
301//********************************************************
302
303LatencyEventPtr LatencyEvent::create(ClockTime latency)
304{
305 GstEvent * e = gst_event_new_latency(latency);
306 return LatencyEventPtr::wrap(e, false);
307}
308
309ClockTime LatencyEvent::latency() const
310{
311 GstClockTime c;
312 gst_event_parse_latency(object<GstEvent>(), &c);
313 return c;
314}
315
316//********************************************************
317
318StepEventPtr StepEvent::create(Format format, quint64 amount, double rate, bool flush,
319 bool intermediate)
320{
321 GstEvent * e = gst_event_new_step(static_cast<GstFormat>(format), amount, rate, flush,
322 intermediate);
323 return StepEventPtr::wrap(e, false);
324}
325
326Format StepEvent::format() const
327{
328 GstFormat f;
329 gst_event_parse_step(object<GstEvent>(), &f, NULL, NULL, NULL, NULL);
330 return static_cast<Format>(f);
331}
332
333quint64 StepEvent::amount() const
334{
335 guint64 a;
336 gst_event_parse_step(object<GstEvent>(), NULL, &a, NULL, NULL, NULL);
337 return a;
338}
339
340double StepEvent::rate() const
341{
342 double d;
343 gst_event_parse_step(object<GstEvent>(), NULL, NULL, &d, NULL, NULL);
344 return d;
345
346}
347
348bool StepEvent::flush() const
349{
350 gboolean f;
351 gst_event_parse_step(object<GstEvent>(), NULL, NULL, NULL, &f, NULL);
352 return f;
353}
354
355bool StepEvent::intermediate() const
356{
357 gboolean i;
358 gst_event_parse_step(object<GstEvent>(), NULL, NULL, NULL, NULL, &i);
359 return i;
360}
361
362} //namespace QGst
static RefPointer< T > wrap(typename T::CType *nativePtr, bool increaseRef=true)
Definition refpointer.h:328
Wrappers for GStreamer classes.