00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "event.h"
00019 #include "message.h"
00020 #include "object.h"
00021 #include <QtCore/QDebug>
00022 #include <gst/gst.h>
00023
00024 namespace QGst {
00025
00026 ObjectPtr Event::source() const
00027 {
00028 return ObjectPtr::wrap(GST_EVENT_SRC(object<GstEvent>()));
00029 }
00030
00031 quint64 Event::timestamp() const
00032 {
00033 return object<GstEvent>()->timestamp;
00034 }
00035
00036 EventType Event::type() const
00037 {
00038 return static_cast<EventType>(GST_EVENT_TYPE(object<GstEvent>()));
00039 }
00040
00041 QString Event::typeName() const
00042 {
00043 return QString::fromUtf8(GST_EVENT_TYPE_NAME(object<GstQuery>()));
00044 }
00045
00046 StructurePtr Event::internalStructure()
00047 {
00048 return SharedStructure::fromMiniObject(object<GstEvent>()->structure, MiniObjectPtr(this));
00049 }
00050
00051 quint32 Event::sequenceNumber() const
00052 {
00053 return gst_event_get_seqnum(object<GstEvent>());
00054 }
00055
00056 void Event::setSequenceNumber(quint32 num)
00057 {
00058 gst_event_set_seqnum(object<GstEvent>(), num);
00059 }
00060
00061 EventPtr Event::copy() const
00062 {
00063 return EventPtr::wrap(gst_event_copy(object<GstEvent>()), false);
00064 }
00065
00066
00067
00068 FlushStartEventPtr FlushStartEvent::create()
00069 {
00070 return FlushStartEventPtr::wrap(gst_event_new_flush_start(), false);
00071 }
00072
00073
00074
00075 FlushStopEventPtr FlushStopEvent::create()
00076 {
00077 return FlushStopEventPtr::wrap(gst_event_new_flush_stop(), false);
00078 }
00079
00080
00081
00082 EosEventPtr EosEvent::create()
00083 {
00084 return EosEventPtr::wrap(gst_event_new_eos(), false);
00085 }
00086
00087
00088
00089 NewSegmentEventPtr NewSegmentEvent::create(bool update, double rate, double appliedRate,
00090 Format format, qint64 start, qint64 stop, qint64 position)
00091 {
00092 GstEvent * e = gst_event_new_new_segment_full(update, rate, appliedRate,
00093 static_cast<GstFormat>(format), start, stop,
00094 position);
00095
00096 return NewSegmentEventPtr::wrap(e, false);
00097 }
00098
00099 bool NewSegmentEvent::isUpdate() const
00100 {
00101 gboolean u;
00102 gst_event_parse_new_segment_full(object<GstEvent>(), &u, NULL, NULL, NULL, NULL, NULL, NULL);
00103 return u;
00104 }
00105
00106 double NewSegmentEvent::rate() const
00107 {
00108 double r;
00109 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, &r, NULL, NULL, NULL, NULL, NULL);
00110 return r;
00111 }
00112
00113 double NewSegmentEvent::appliedRate() const
00114 {
00115 double r;
00116 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, NULL, &r, NULL, NULL, NULL, NULL);
00117 return r;
00118 }
00119
00120 Format NewSegmentEvent::format() const
00121 {
00122 GstFormat f;
00123 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, NULL, NULL, &f, NULL, NULL, NULL);
00124 return static_cast<Format>(f);
00125 }
00126
00127 qint64 NewSegmentEvent::start() const
00128 {
00129 gint64 s;
00130 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, NULL, NULL, NULL, &s, NULL, NULL);
00131 return s;
00132 }
00133
00134 qint64 NewSegmentEvent::stop() const
00135 {
00136 gint64 s;
00137 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, &s, NULL);
00138 return s;
00139 }
00140
00141 qint64 NewSegmentEvent::position() const
00142 {
00143 gint64 p;
00144 gst_event_parse_new_segment_full(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, NULL, &p);
00145 return p;
00146 }
00147
00148
00149
00150 TagEventPtr TagEvent::create(const TagList & taglist)
00151 {
00152 GstEvent * e = gst_event_new_tag(gst_tag_list_copy(taglist));
00153 return TagEventPtr::wrap(e, false);
00154 }
00155
00156 TagList TagEvent::taglist() const
00157 {
00158 GstTagList * t;
00159 gst_event_parse_tag(object<GstEvent>(), &t);
00160 TagList tl(t);
00161 return tl;
00162 }
00163
00164
00165
00166 BufferSizeEventPtr BufferSizeEvent::create(Format format, qint64 minSize, qint64 maxSize,
00167 bool isAsync)
00168 {
00169 GstEvent * e = gst_event_new_buffer_size(static_cast<GstFormat>(format), minSize, maxSize,
00170 isAsync);
00171
00172 return BufferSizeEventPtr::wrap(e, false);
00173 }
00174
00175 Format BufferSizeEvent::format() const
00176 {
00177 GstFormat f;
00178 gst_event_parse_buffer_size(object<GstEvent>(), &f, NULL, NULL, NULL);
00179 return static_cast<Format>(f);
00180 }
00181
00182 qint64 BufferSizeEvent::minSize() const
00183 {
00184 gint64 s;
00185 gst_event_parse_buffer_size(object<GstEvent>(), NULL, &s, NULL, NULL);
00186 return s;
00187 }
00188
00189 qint64 BufferSizeEvent::maxSize() const
00190 {
00191 gint64 s;
00192 gst_event_parse_buffer_size(object<GstEvent>(), NULL, NULL, &s, NULL);
00193 return s;
00194 }
00195
00196 bool BufferSizeEvent::isAsync() const
00197 {
00198 gboolean u;
00199 gst_event_parse_buffer_size(object<GstEvent>(), NULL, NULL, NULL, &u);
00200 return u;
00201 }
00202
00203
00204
00205 SinkMessageEventPtr SinkMessageEvent::create(const MessagePtr & msg)
00206 {
00207 GstEvent * e = gst_event_new_sink_message(msg);
00208 return SinkMessageEventPtr::wrap(e, false);
00209 }
00210
00211 MessagePtr SinkMessageEvent::message() const
00212 {
00213 GstMessage * msg;
00214 gst_event_parse_sink_message(object<GstEvent>(), &msg);
00215
00216 return MessagePtr::wrap(msg, false);
00217 }
00218
00219
00220
00221 QosEventPtr QosEvent::create(double proportion, ClockTimeDiff diff, ClockTime timeStamp)
00222 {
00223 GstEvent * e = gst_event_new_qos(proportion, diff, static_cast<GstClockTime>(timeStamp));
00224 return QosEventPtr::wrap(e, false);
00225 }
00226
00227 double QosEvent::proportion() const
00228 {
00229 double d;
00230 gst_event_parse_qos(object<GstEvent>(), &d, NULL, NULL);
00231 return d;
00232 }
00233
00234 ClockTimeDiff QosEvent::diff() const
00235 {
00236 GstClockTimeDiff c;
00237 gst_event_parse_qos(object<GstEvent>(), NULL, &c, NULL);
00238 return c;
00239 }
00240
00241 ClockTime QosEvent::timestamp() const
00242 {
00243 GstClockTime c;
00244 gst_event_parse_qos(object<GstEvent>(), NULL, NULL, &c);
00245 return c;
00246 }
00247
00248
00249
00250 SeekEventPtr SeekEvent::create(double rate, Format format, SeekFlags flags, SeekType startType,
00251 qint64 start, SeekType stopType, qint64 stop)
00252 {
00253 GstEvent * e = gst_event_new_seek(rate, static_cast<GstFormat>(format),
00254 static_cast<GstSeekFlags>(static_cast<int>(flags)),
00255 static_cast<GstSeekType>(startType), start,
00256 static_cast<GstSeekType>(stopType), stop );
00257 return SeekEventPtr::wrap(e, false);
00258 }
00259
00260 double SeekEvent::rate() const
00261 {
00262 double d;
00263 gst_event_parse_seek(object<GstEvent>(), &d, NULL, NULL, NULL, NULL, NULL, NULL);
00264 return d;
00265 }
00266
00267 Format SeekEvent::format() const
00268 {
00269 GstFormat f;
00270 gst_event_parse_seek(object<GstEvent>(), NULL, &f, NULL, NULL, NULL, NULL, NULL);
00271 return static_cast<Format>(f);
00272 }
00273
00274 SeekFlags SeekEvent::flags() const
00275 {
00276 GstSeekFlags f;
00277 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, &f, NULL, NULL, NULL, NULL);
00278 return static_cast<SeekFlags>(f);
00279 }
00280
00281 SeekType SeekEvent::startType() const
00282 {
00283 GstSeekType t;
00284 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, &t, NULL, NULL, NULL);
00285 return static_cast<SeekType>(t);
00286 }
00287
00288 qint64 SeekEvent::start() const
00289 {
00290 gint64 s;
00291 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, &s, NULL, NULL);
00292 return s;
00293 }
00294
00295 SeekType SeekEvent::stopType() const
00296 {
00297 GstSeekType t;
00298 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, &t, NULL);
00299 return static_cast<SeekType>(t);
00300 }
00301
00302 qint64 SeekEvent::stop() const
00303 {
00304 gint64 s;
00305 gst_event_parse_seek(object<GstEvent>(), NULL, NULL, NULL, NULL, NULL, NULL, &s);
00306 return s;
00307 }
00308
00309
00310
00311 NavigationEventPtr NavigationEvent::create(const Structure & structure)
00312 {
00313 GstStructure * s = structure.isValid() ? gst_structure_copy(structure) : NULL;
00314 GstEvent * e = gst_event_new_navigation(s);
00315 return NavigationEventPtr::wrap(e, false);
00316 }
00317
00318
00319
00320 LatencyEventPtr LatencyEvent::create(ClockTime latency)
00321 {
00322 GstEvent * e = gst_event_new_latency(latency);
00323 return LatencyEventPtr::wrap(e, false);
00324 }
00325
00326 ClockTime LatencyEvent::latency() const
00327 {
00328 GstClockTime c;
00329 gst_event_parse_latency(object<GstEvent>(), &c);
00330 return c;
00331 }
00332
00333
00334
00335 StepEventPtr StepEvent::create(Format format, quint64 amount, double rate, bool flush,
00336 bool intermediate)
00337 {
00338 GstEvent * e = gst_event_new_step(static_cast<GstFormat>(format), amount, rate, flush,
00339 intermediate);
00340 return StepEventPtr::wrap(e, false);
00341 }
00342
00343 Format StepEvent::format() const
00344 {
00345 GstFormat f;
00346 gst_event_parse_step(object<GstEvent>(), &f, NULL, NULL, NULL, NULL);
00347 return static_cast<Format>(f);
00348 }
00349
00350 quint64 StepEvent::amount() const
00351 {
00352 guint64 a;
00353 gst_event_parse_step(object<GstEvent>(), NULL, &a, NULL, NULL, NULL);
00354 return a;
00355 }
00356
00357 double StepEvent::rate() const
00358 {
00359 double d;
00360 gst_event_parse_step(object<GstEvent>(), NULL, NULL, &d, NULL, NULL);
00361 return d;
00362
00363 }
00364
00365 bool StepEvent::flush() const
00366 {
00367 gboolean f;
00368 gst_event_parse_step(object<GstEvent>(), NULL, NULL, NULL, &f, NULL);
00369 return f;
00370 }
00371
00372 bool StepEvent::intermediate() const
00373 {
00374 gboolean i;
00375 gst_event_parse_step(object<GstEvent>(), NULL, NULL, NULL, NULL, &i);
00376 return i;
00377 }
00378
00379 }