| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008-2016 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library 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 GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <gst/gst.h> |
| 21 |
#include <gstreamermm/message.h> |
| 22 |
#include <gstreamermm/structure.h> |
| 23 |
#include <gstreamermm/taglist.h> |
| 24 |
#include <gstreamermm/buffer.h> |
| 25 |
#include <gstreamermm/toc.h> |
| 26 |
_PINCLUDE(gstreamermm/private/miniobject_p.h) |
| 27 |
#include <iostream> |
| 28 |
|
| 29 |
namespace Gst |
| 30 |
{ |
| 31 |
|
| 32 |
namespace Enums |
| 33 |
{ |
| 34 |
|
| 35 |
Glib::ustring get_name(EventType t) |
| 36 |
{ |
| 37 |
return gst_event_type_get_name(GstEventType(t)); |
| 38 |
} |
| 39 |
|
| 40 |
Glib::QueryQuark get_quark(EventType t) |
| 41 |
{ |
| 42 |
return Glib::QueryQuark(gst_event_type_to_quark(GstEventType(t))); |
| 43 |
} |
| 44 |
|
| 45 |
EventTypeFlags get_flags(EventType t) |
| 46 |
{ |
| 47 |
return static_cast<EventTypeFlags>(gst_event_type_get_flags(static_cast<GstEventType>(t))); |
| 48 |
} |
| 49 |
|
| 50 |
} //namespace Enums |
| 51 |
|
| 52 |
Glib::RefPtr<Gst::Event> Event::create_writable() |
| 53 |
{ |
| 54 |
return Glib::RefPtr<Event>::cast_static(MiniObject::create_writable()); |
| 55 |
} |
| 56 |
|
| 57 |
bool Event::is_downstream() const |
| 58 |
{ |
| 59 |
return GST_EVENT_IS_DOWNSTREAM(gobj()); |
| 60 |
} |
| 61 |
|
| 62 |
bool Event::is_upstream() const |
| 63 |
{ |
| 64 |
return GST_EVENT_IS_UPSTREAM(gobj()); |
| 65 |
} |
| 66 |
|
| 67 |
bool Event::is_serialized() const |
| 68 |
{ |
| 69 |
return GST_EVENT_IS_SERIALIZED(gobj()); |
| 70 |
} |
| 71 |
|
| 72 |
bool EventFlushStop::parse_reset_time() const |
| 73 |
{ |
| 74 |
gboolean reset_time; |
| 75 |
gst_event_parse_flush_stop(const_cast<GstEvent*>(gobj()), &reset_time); |
| 76 |
return reset_time; |
| 77 |
} |
| 78 |
|
| 79 |
Gst::TagList EventTag::parse_tag_list() const |
| 80 |
{ |
| 81 |
GstTagList* gst_taglist = gst_tag_list_new_empty(); |
| 82 |
gst_event_parse_tag(const_cast<GstEvent*>(gobj()), &gst_taglist); |
| 83 |
return Gst::TagList(gst_taglist); |
| 84 |
} |
| 85 |
|
| 86 |
void EventBufferSize::parse(Format& format, gint64& minsize, gint64& maxsize, |
| 87 |
bool& async) const |
| 88 |
{ |
| 89 |
gboolean gst_async = FALSE; |
| 90 |
gst_event_parse_buffer_size(const_cast<GstEvent*>(gobj()), |
| 91 |
(GstFormat*)&format, &minsize, &maxsize, &gst_async); |
| 92 |
async = gst_async; |
| 93 |
} |
| 94 |
|
| 95 |
gint64 EventBufferSize::parse_min_size() const |
| 96 |
{ |
| 97 |
gint64 gst_minsize = 0; |
| 98 |
gst_event_parse_buffer_size(const_cast<GstEvent*>(gobj()), 0, &gst_minsize, |
| 99 |
nullptr, nullptr); |
| 100 |
return gst_minsize; |
| 101 |
} |
| 102 |
|
| 103 |
Gst::Format EventBufferSize::parse_format() const |
| 104 |
{ |
| 105 |
GstFormat gst_format = GST_FORMAT_UNDEFINED; |
| 106 |
gst_event_parse_buffer_size(const_cast<GstEvent*>(gobj()), |
| 107 |
reinterpret_cast<GstFormat*>(&gst_format), 0, 0, 0); |
| 108 |
return static_cast<Gst::Format>(gst_format); |
| 109 |
} |
| 110 |
|
| 111 |
gint64 EventBufferSize::parse_max_size() const |
| 112 |
{ |
| 113 |
gint64 gst_maxsize = 0; |
| 114 |
gst_event_parse_buffer_size(const_cast<GstEvent*>(gobj()), 0, 0, |
| 115 |
&gst_maxsize, 0); |
| 116 |
return gst_maxsize; |
| 117 |
} |
| 118 |
|
| 119 |
bool EventBufferSize::parse_async() const |
| 120 |
{ |
| 121 |
gboolean gst_async = FALSE; |
| 122 |
gst_event_parse_buffer_size(const_cast<GstEvent*>(gobj()), 0, 0, 0, &gst_async); |
| 123 |
return gst_async; |
| 124 |
} |
| 125 |
|
| 126 |
void EventQos::parse(Gst::QOSType& type, double& proportion, ClockTimeDiff& diff, |
| 127 |
ClockTime& timestamp) const |
| 128 |
{ |
| 129 |
gst_event_parse_qos(const_cast<GstEvent*>(gobj()), (GstQOSType*)&type, &proportion, &diff, |
| 130 |
×tamp); |
| 131 |
} |
| 132 |
|
| 133 |
QOSType EventQos::parse_type() const |
| 134 |
{ |
| 135 |
GstQOSType type; |
| 136 |
gst_event_parse_qos(const_cast<GstEvent*>(gobj()), &type, nullptr, nullptr, nullptr); |
| 137 |
return static_cast<Gst::QOSType>(type); |
| 138 |
} |
| 139 |
|
| 140 |
double EventQos::parse_proportion() const |
| 141 |
{ |
| 142 |
double gst_proportion = 0; |
| 143 |
gst_event_parse_qos(const_cast<GstEvent*>(gobj()), nullptr, &gst_proportion, nullptr, nullptr); |
| 144 |
return gst_proportion; |
| 145 |
} |
| 146 |
|
| 147 |
Gst::ClockTimeDiff EventQos::parse_diff() const |
| 148 |
{ |
| 149 |
GstClockTimeDiff gst_diff = 0; |
| 150 |
gst_event_parse_qos(const_cast<GstEvent*>(gobj()), nullptr, nullptr, &gst_diff, nullptr); |
| 151 |
return gst_diff; |
| 152 |
} |
| 153 |
|
| 154 |
Gst::ClockTime EventQos::parse_timestamp() const |
| 155 |
{ |
| 156 |
GstClockTime gst_timestamp = 0; |
| 157 |
gst_event_parse_qos(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, &gst_timestamp); |
| 158 |
return gst_timestamp; |
| 159 |
} |
| 160 |
|
| 161 |
void EventSeek::parse(double& rate, Format& format, SeekFlags& flags, |
| 162 |
SeekType& start_type, gint64& start, SeekType& stop_type, gint64& stop) const |
| 163 |
{ |
| 164 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), &rate, |
| 165 |
(GstFormat*)&format, (GstSeekFlags*)&flags, (GstSeekType*)&start_type, |
| 166 |
&start, (GstSeekType*)&stop_type, &stop); |
| 167 |
} |
| 168 |
|
| 169 |
gint64 EventSeek::parse_start() const |
| 170 |
{ |
| 171 |
gint64 gst_start = 0; |
| 172 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, nullptr, &gst_start, |
| 173 |
nullptr, nullptr); |
| 174 |
return gst_start; |
| 175 |
} |
| 176 |
|
| 177 |
double EventSeek::parse_rate() const |
| 178 |
{ |
| 179 |
double gst_rate = 0; |
| 180 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), &gst_rate, nullptr, nullptr, nullptr, nullptr, |
| 181 |
nullptr, nullptr); |
| 182 |
return gst_rate; |
| 183 |
} |
| 184 |
|
| 185 |
Gst::Format EventSeek::parse_format() const |
| 186 |
{ |
| 187 |
GstFormat gst_format = GST_FORMAT_UNDEFINED; |
| 188 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, &gst_format, nullptr, nullptr, nullptr, |
| 189 |
nullptr, nullptr); |
| 190 |
return static_cast<Gst::Format>(gst_format); |
| 191 |
} |
| 192 |
|
| 193 |
Gst::SeekFlags EventSeek::parse_flags() const |
| 194 |
{ |
| 195 |
GstSeekFlags gst_flags = GST_SEEK_FLAG_NONE; |
| 196 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, nullptr, &gst_flags, nullptr, nullptr, |
| 197 |
nullptr, nullptr); |
| 198 |
return static_cast<Gst::SeekFlags>(gst_flags); |
| 199 |
} |
| 200 |
|
| 201 |
Gst::SeekType EventSeek::parse_start_type() const |
| 202 |
{ |
| 203 |
GstSeekType gst_type = GST_SEEK_TYPE_NONE; |
| 204 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, &gst_type, nullptr, |
| 205 |
nullptr, nullptr); |
| 206 |
return static_cast<Gst::SeekType>(gst_type); |
| 207 |
} |
| 208 |
|
| 209 |
Gst::SeekType EventSeek::parse_stop_type() const |
| 210 |
{ |
| 211 |
GstSeekType gst_type = GST_SEEK_TYPE_NONE; |
| 212 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, nullptr, nullptr, &gst_type, |
| 213 |
nullptr); |
| 214 |
return static_cast<Gst::SeekType>(gst_type); |
| 215 |
} |
| 216 |
|
| 217 |
gint64 EventSeek::parse_stop() const |
| 218 |
{ |
| 219 |
gint64 gst_stop = 0; |
| 220 |
gst_event_parse_seek(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
| 221 |
&gst_stop); |
| 222 |
return gst_stop; |
| 223 |
} |
| 224 |
|
| 225 |
ClockTime EventLatency::parse_latency() const |
| 226 |
{ |
| 227 |
GstClockTime gst_latency = 0; |
| 228 |
gst_event_parse_latency(const_cast<GstEvent*>(gobj()), &gst_latency); |
| 229 |
return gst_latency; |
| 230 |
} |
| 231 |
|
| 232 |
void EventStep::parse(Gst::Format& format, guint64& amount, double& rate, |
| 233 |
bool& flush, bool& intermediate) const |
| 234 |
{ |
| 235 |
gboolean gst_flush = FALSE; |
| 236 |
gboolean gst_intermediate = FALSE; |
| 237 |
|
| 238 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), |
| 239 |
reinterpret_cast<GstFormat*>(&format), &amount, &rate, &gst_flush, |
| 240 |
&gst_intermediate); |
| 241 |
|
| 242 |
flush = gst_flush; |
| 243 |
intermediate = gst_intermediate; |
| 244 |
} |
| 245 |
|
| 246 |
guint64 EventStep::parse_amount() const |
| 247 |
{ |
| 248 |
guint64 gst_amount = 0; |
| 249 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), nullptr, &gst_amount, nullptr, nullptr, nullptr); |
| 250 |
return gst_amount; |
| 251 |
} |
| 252 |
|
| 253 |
Gst::Format EventStep::parse_format() const |
| 254 |
{ |
| 255 |
GstFormat gst_format = GST_FORMAT_UNDEFINED; |
| 256 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), &gst_format, nullptr, nullptr, nullptr, nullptr); |
| 257 |
return static_cast<Gst::Format>(gst_format); |
| 258 |
} |
| 259 |
|
| 260 |
double EventStep::parse_rate() const |
| 261 |
{ |
| 262 |
double gst_rate = 0; |
| 263 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), nullptr, nullptr, &gst_rate, nullptr, nullptr); |
| 264 |
return gst_rate; |
| 265 |
} |
| 266 |
|
| 267 |
bool EventStep::parse_flush() const |
| 268 |
{ |
| 269 |
gboolean gst_flush = FALSE; |
| 270 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, &gst_flush, nullptr); |
| 271 |
return gst_flush; |
| 272 |
} |
| 273 |
|
| 274 |
bool EventStep::parse_intermediate() const |
| 275 |
{ |
| 276 |
gboolean gst_intermediate = FALSE; |
| 277 |
gst_event_parse_step(const_cast<GstEvent*>(gobj()), nullptr, nullptr, nullptr, nullptr, |
| 278 |
&gst_intermediate); |
| 279 |
return gst_intermediate; |
| 280 |
} |
| 281 |
|
| 282 |
Glib::RefPtr<Gst::Message> EventSinkMessage::parse_message() |
| 283 |
{ |
| 284 |
GstMessage* gst_msg = nullptr; |
| 285 |
gst_event_parse_sink_message(gobj(), &gst_msg); |
| 286 |
return Glib::wrap(gst_msg); |
| 287 |
} |
| 288 |
|
| 289 |
Glib::RefPtr<const Gst::Message> EventSinkMessage::parse_message() const |
| 290 |
{ |
| 291 |
return const_cast<Gst::EventSinkMessage*>(this)->parse_message(); |
| 292 |
} |
| 293 |
|
| 294 |
void EventToc::parse(Glib::RefPtr<Gst::Toc>& toc, bool& updated) |
| 295 |
{ |
| 296 |
GstToc *gst_toc = nullptr; |
| 297 |
gboolean gst_updated; |
| 298 |
gst_event_parse_toc(gobj(), &gst_toc, &gst_updated); |
| 299 |
updated = gst_updated; |
| 300 |
toc = Glib::wrap(gst_toc); |
| 301 |
} |
| 302 |
|
| 303 |
void EventToc::parse(Glib::RefPtr<const Gst::Toc>& toc, bool& updated) const |
| 304 |
{ |
| 305 |
const_cast<EventToc*>(this)->parse(toc, updated); |
| 306 |
} |
| 307 |
|
| 308 |
Glib::RefPtr<Gst::Toc> EventToc::parse_toc() |
| 309 |
{ |
| 310 |
GstToc *gst_toc = nullptr; |
| 311 |
gst_event_parse_toc(gobj(), &gst_toc, nullptr); |
| 312 |
return Glib::wrap(gst_toc); |
| 313 |
} |
| 314 |
|
| 315 |
Glib::RefPtr<const Gst::Toc> EventToc::parse_toc() const |
| 316 |
{ |
| 317 |
return const_cast<EventToc*>(this)->parse_toc(); |
| 318 |
} |
| 319 |
|
| 320 |
bool EventToc::parse_updated() const |
| 321 |
{ |
| 322 |
gboolean gst_updated; |
| 323 |
gst_event_parse_toc(const_cast<GstEvent*>(gobj()), nullptr, &gst_updated); |
| 324 |
return gst_updated; |
| 325 |
} |
| 326 |
|
| 327 |
void EventProtection::parse(Glib::ustring& system_id, Glib::RefPtr<Gst::Buffer>& data, Glib::ustring& origin) const |
| 328 |
{ |
| 329 |
const gchar *gst_system_id = nullptr, *gst_origin = nullptr; |
| 330 |
GstBuffer *gst_buffer; |
| 331 |
gst_event_parse_protection(const_cast<GstEvent*>(gobj()), &gst_system_id, &gst_buffer, &gst_origin); |
| 332 |
system_id = gst_system_id; |
| 333 |
data = Glib::wrap(gst_buffer, true); |
| 334 |
origin = gst_origin; |
| 335 |
} |
| 336 |
|
| 337 |
Glib::ustring EventProtection::parse_system_id() const |
| 338 |
{ |
| 339 |
const gchar *gst_system_id = nullptr; |
| 340 |
gst_event_parse_protection(const_cast<GstEvent*>(gobj()), &gst_system_id, nullptr, nullptr); |
| 341 |
return Glib::ustring(gst_system_id); |
| 342 |
} |
| 343 |
|
| 344 |
Glib::RefPtr<Gst::Buffer> EventProtection::parse_data() |
| 345 |
{ |
| 346 |
GstBuffer* gst_data = nullptr; |
| 347 |
gst_event_parse_protection(const_cast<GstEvent*>(gobj()), nullptr, &gst_data, nullptr); |
| 348 |
return Glib::wrap(gst_data, true); |
| 349 |
} |
| 350 |
|
| 351 |
Glib::RefPtr<const Gst::Buffer> EventProtection::parse_data() const |
| 352 |
{ |
| 353 |
return const_cast<EventProtection*>(this)->parse_data(); |
| 354 |
} |
| 355 |
|
| 356 |
Glib::ustring EventProtection::parse_origin() const |
| 357 |
{ |
| 358 |
const gchar *gst_origin = nullptr; |
| 359 |
gst_event_parse_protection(const_cast<GstEvent*>(gobj()), nullptr, nullptr, &gst_origin); |
| 360 |
return Glib::ustring(gst_origin); |
| 361 |
} |
| 362 |
|
| 363 |
void EventSegmentDone::parse(Gst::Format& format, gint64& position) const |
| 364 |
{ |
| 365 |
GstFormat gst_format; |
| 366 |
gst_event_parse_segment_done(const_cast<GstEvent*>(gobj()), &gst_format, &position); |
| 367 |
format = static_cast<Gst::Format>(gst_format); |
| 368 |
} |
| 369 |
|
| 370 |
Gst::Format EventSegmentDone::parse_format() const |
| 371 |
{ |
| 372 |
GstFormat format; |
| 373 |
gst_event_parse_segment_done(const_cast<GstEvent*>(gobj()), &format, nullptr); |
| 374 |
return static_cast<Gst::Format>(format); |
| 375 |
} |
| 376 |
|
| 377 |
gint64 EventSegmentDone::parse_position() const |
| 378 |
{ |
| 379 |
gint64 position; |
| 380 |
gst_event_parse_segment_done(const_cast<GstEvent*>(gobj()), nullptr, &position); |
| 381 |
return position; |
| 382 |
} |
| 383 |
|
| 384 |
Gst::ClockTime EventGap::parse_timestamp() const |
| 385 |
{ |
| 386 |
GstClockTime timestamp; |
| 387 |
gst_event_parse_gap(const_cast<GstEvent*>(gobj()), ×tamp, nullptr); |
| 388 |
return timestamp; |
| 389 |
} |
| 390 |
|
| 391 |
Gst::ClockTime EventGap::parse_duration() const |
| 392 |
{ |
| 393 |
GstClockTime duration; |
| 394 |
gst_event_parse_gap(const_cast<GstEvent*>(gobj()), nullptr, &duration); |
| 395 |
return duration; |
| 396 |
} |
| 397 |
|
| 398 |
Glib::ustring EventStreamStart::parse_stream_id() const |
| 399 |
{ |
| 400 |
const gchar* gst_stream_id = nullptr; |
| 401 |
gst_event_parse_stream_start(const_cast<GstEvent*>(gobj()), &gst_stream_id); |
| 402 |
return Glib::ustring(gst_stream_id); |
| 403 |
} |
| 404 |
|
| 405 |
Gst::StreamFlags EventStreamStart::parse_stream_flags() const |
| 406 |
{ |
| 407 |
GstStreamFlags flags; |
| 408 |
gst_event_parse_stream_flags (const_cast<GstEvent*>(gobj()), &flags); |
| 409 |
return static_cast<Gst::StreamFlags>(flags); |
| 410 |
} |
| 411 |
|
| 412 |
Glib::RefPtr<Gst::Caps> EventCaps::parse_caps() |
| 413 |
{ |
| 414 |
GstCaps* gst_caps = nullptr; |
| 415 |
gst_event_parse_caps(gobj(), &gst_caps); |
| 416 |
return Glib::wrap(gst_caps, true); |
| 417 |
} |
| 418 |
|
| 419 |
Glib::RefPtr<const Gst::Caps> EventCaps::parse_caps() const |
| 420 |
{ |
| 421 |
return const_cast<EventCaps*>(this)->parse_caps(); |
| 422 |
} |
| 423 |
|
| 424 |
Gst::Segment EventSegment::copy_segment() const |
| 425 |
{ |
| 426 |
const GstSegment *gst_segment; |
| 427 |
gst_event_parse_segment(const_cast<GstEvent*>(gobj()), &gst_segment); |
| 428 |
return Gst::Segment(const_cast<GstSegment*>(gst_segment), true); |
| 429 |
|
| 430 |
} |
| 431 |
|
| 432 |
Glib::ustring EventTocSelect::parse_uid() const |
| 433 |
{ |
| 434 |
gchar *gst_uid; |
| 435 |
gst_event_parse_toc_select(const_cast<GstEvent*>(gobj()), &gst_uid); |
| 436 |
Glib::ustring uid = gst_uid; |
| 437 |
g_free(gst_uid); |
| 438 |
return uid; |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
} //namespace Gst |