| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | |
| 3 | |
| 4 | #include <glibmm.h> |
| 5 | |
| 6 | #include <gstreamermm/bus.h> |
| 7 | #include <gstreamermm/private/bus_p.h> |
| 8 | |
| 9 | |
| 10 | /* gstreamermm - a C++ wrapper for gstreamer |
| 11 | * |
| 12 | * Copyright 2008-2016 The gstreamermm Development Team |
| 13 | * |
| 14 | * This library is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU Lesser General Public |
| 16 | * License as published by the Free Software Foundation; either |
| 17 | * version 2.1 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This library is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * Lesser General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Lesser General Public |
| 25 | * License along with this library; if not, write to the Free |
| 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | */ |
| 28 | |
| 29 | |
| 30 | namespace |
| 31 | { |
| 32 | |
| 33 | extern "C" |
| 34 | { |
| 35 | |
| 36 | static gboolean Bus_Message_gstreamermm_callback(GstBus* bus, GstMessage* message, void* data) |
| 37 | { |
| 38 | Gst::Bus::SlotMessage* the_slot = static_cast<Gst::Bus::SlotMessage*>(data); |
| 39 | |
| 40 | try |
| 41 | { |
| 42 | return (*the_slot)(Glib::wrap(bus, true), Glib::wrap(message, true)); |
| 43 | } |
| 44 | catch(...) |
| 45 | { |
| 46 | Glib::exception_handlers_invoke(); |
| 47 | } |
| 48 | |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | static void Bus_Message_gstreamermm_callback_destroy(void* data) |
| 53 | { |
| 54 | delete static_cast<Gst::Bus::SlotMessage*>(data); |
| 55 | } |
| 56 | |
| 57 | static GstBusSyncReply Bus_Message_Sync_gstreamermm_callback(GstBus* bus, GstMessage* message, void* data) |
| 58 | { |
| 59 | Gst::Bus::SlotMessageSync* the_slot = static_cast<Gst::Bus::SlotMessageSync*>(data); |
| 60 | |
| 61 | try |
| 62 | { |
| 63 | return static_cast<GstBusSyncReply>((*the_slot)(Glib::wrap(bus, true), Glib::wrap(message, true))); |
| 64 | } |
| 65 | catch(...) |
| 66 | { |
| 67 | Glib::exception_handlers_invoke(); |
| 68 | } |
| 69 | |
| 70 | return GST_BUS_PASS; |
| 71 | } |
| 72 | |
| 73 | } // extern "C" |
| 74 | |
| 75 | } // anonymous namespace |
| 76 | |
| 77 | namespace Gst |
| 78 | { |
| 79 | |
| 80 | guint Bus::add_watch(const SlotMessage& slot, int priority) |
| 81 | { |
| 82 | //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter. |
| 83 | //It will be deleted when Bus_Message_gstreamermm_callback_destroy() is called. |
| 84 | SlotMessage* slot_copy = new SlotMessage(slot); |
| 85 | return gst_bus_add_watch_full(gobj(), priority, |
| 86 | &Bus_Message_gstreamermm_callback, slot_copy, |
| 87 | &Bus_Message_gstreamermm_callback_destroy); |
| 88 | } |
| 89 | |
| 90 | bool Bus::remove_watch(guint id) |
| 91 | { |
| 92 | return g_source_remove(id); |
| 93 | } |
| 94 | |
| 95 | void Bus::set_sync_handler(const SlotMessageSync& slot) |
| 96 | { |
| 97 | // Clear a possibly existing sync handler by calling with 0 before setting |
| 98 | // a new one (see gst_bus_set_sync_handler docs) |
| 99 | gst_bus_set_sync_handler(gobj(), 0, 0, 0); |
| 100 | |
| 101 | SlotMessageSync* slot_copy = new SlotMessageSync(slot); |
| 102 | gst_bus_set_sync_handler(gobj(), &Bus_Message_Sync_gstreamermm_callback, slot_copy, &Bus_Message_gstreamermm_callback_destroy); |
| 103 | } |
| 104 | |
| 105 | } //namespace Gst |
| 106 | |
| 107 | namespace |
| 108 | { |
| 109 | |
| 110 | |
| 111 | static void Bus_signal_message_callback(GstBus* self, GstMessage* p0,void* data) |
| 112 | { |
| 113 | using namespace Gst; |
| 114 | using SlotType = sigc::slot< void,const Glib::RefPtr<Gst::Message>& >; |
| 115 | |
| 116 | auto obj = dynamic_cast<Bus*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self)); |
| 117 | // Do not try to call a signal on a disassociated wrapper. |
| 118 | if(obj) |
| 119 | { |
| 120 | try |
| 121 | { |
| 122 | if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) |
| 123 | (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true) |
| 124 | ); |
| 125 | } |
| 126 | catch(...) |
| 127 | { |
| 128 | Glib::exception_handlers_invoke(); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | static const Glib::SignalProxyInfo Bus_signal_message_info = |
| 134 | { |
| 135 | "message", |
| 136 | (GCallback) &Bus_signal_message_callback, |
| 137 | (GCallback) &Bus_signal_message_callback |
| 138 | }; |
| 139 | |
| 140 | |
| 141 | static void Bus_signal_sync_message_callback(GstBus* self, GstMessage* p0,void* data) |
| 142 | { |
| 143 | using namespace Gst; |
| 144 | using SlotType = sigc::slot< void,const Glib::RefPtr<Gst::Message>& >; |
| 145 | |
| 146 | auto obj = dynamic_cast<Bus*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self)); |
| 147 | // Do not try to call a signal on a disassociated wrapper. |
| 148 | if(obj) |
| 149 | { |
| 150 | try |
| 151 | { |
| 152 | if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) |
| 153 | (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true) |
| 154 | ); |
| 155 | } |
| 156 | catch(...) |
| 157 | { |
| 158 | Glib::exception_handlers_invoke(); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static const Glib::SignalProxyInfo Bus_signal_sync_message_info = |
| 164 | { |
| 165 | "sync-message", |
| 166 | (GCallback) &Bus_signal_sync_message_callback, |
| 167 | (GCallback) &Bus_signal_sync_message_callback |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | } // anonymous namespace |
| 172 | |
| 173 | // static |
| 174 | GType Glib::Value<Gst::BusFlags>::value_type() |
| 175 | { |
| 176 | return gst_bus_flags_get_type(); |
| 177 | } |
| 178 | |
| 179 | // static |
| 180 | GType Glib::Value<Gst::BusSyncReply>::value_type() |
| 181 | { |
| 182 | return gst_bus_sync_reply_get_type(); |
| 183 | } |
| 184 | |
| 185 | |
| 186 | namespace Glib |
| 187 | { |
| 188 | |
| 189 | Glib::RefPtr<Gst::Bus> wrap(GstBus* object, bool take_copy) |
| 190 | { |
| 191 | return Glib::RefPtr<Gst::Bus>( dynamic_cast<Gst::Bus*> (Glib::wrap_auto ((GObject*)(object), take_copy)) ); |
| 192 | //We use dynamic_cast<> in case of multiple inheritance. |
| 193 | } |
| 194 | |
| 195 | } /* namespace Glib */ |
| 196 | |
| 197 | |
| 198 | namespace Gst |
| 199 | { |
| 200 | |
| 201 | |
| 202 | /* The *_Class implementation: */ |
| 203 | |
| 204 | const Glib::Class& Bus_Class::init() |
| 205 | { |
| 206 | if(!gtype_) // create the GType if necessary |
| 207 | { |
| 208 | // Glib::Class has to know the class init function to clone custom types. |
| 209 | class_init_func_ = &Bus_Class::class_init_function; |
| 210 | |
| 211 | // This is actually just optimized away, apparently with no harm. |
| 212 | // Make sure that the parent type has been created. |
| 213 | //CppClassParent::CppObjectType::get_type(); |
| 214 | |
| 215 | // Create the wrapper type, with the same class/instance size as the base type. |
| 216 | register_derived_type(gst_bus_get_type()); |
| 217 | |
| 218 | // Add derived versions of interfaces, if the C type implements any interfaces: |
| 219 | |
| 220 | } |
| 221 | |
| 222 | return *this; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | void Bus_Class::class_init_function(void* g_class, void* class_data) |
| 227 | { |
| 228 | const auto klass = static_cast<BaseClassType*>(g_class); |
| 229 | CppClassParent::class_init_function(klass, class_data); |
| 230 | |
| 231 | |
| 232 | klass->message = &message_callback; |
| 233 | klass->sync_message = &sync_message_callback; |
| 234 | } |
| 235 | |
| 236 | |
| 237 | void Bus_Class::message_callback(GstBus* self, GstMessage* p0) |
| 238 | { |
| 239 | const auto obj_base = static_cast<Glib::ObjectBase*>( |
| 240 | Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 241 | |
| 242 | // Non-gtkmmproc-generated custom classes implicitly call the default |
| 243 | // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 244 | // generated classes can use this optimisation, which avoids the unnecessary |
| 245 | // parameter conversions if there is no possibility of the virtual function |
| 246 | // being overridden: |
| 247 | if(obj_base && obj_base->is_derived_()) |
| 248 | { |
| 249 | const auto obj = dynamic_cast<CppObjectType* const>(obj_base); |
| 250 | if(obj) // This can be NULL during destruction. |
| 251 | { |
| 252 | try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 253 | { |
| 254 | // Call the virtual member method, which derived classes might override. |
| 255 | obj->on_message(Glib::wrap(p0, true) |
| 256 | ); |
| 257 | return; |
| 258 | } |
| 259 | catch(...) |
| 260 | { |
| 261 | Glib::exception_handlers_invoke(); |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | const auto base = static_cast<BaseClassType*>( |
| 267 | g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 268 | ); |
| 269 | |
| 270 | // Call the original underlying C function: |
| 271 | if(base && base->message) |
| 272 | (*base->message)(self, p0); |
| 273 | } |
| 274 | void Bus_Class::sync_message_callback(GstBus* self, GstMessage* p0) |
| 275 | { |
| 276 | const auto obj_base = static_cast<Glib::ObjectBase*>( |
| 277 | Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 278 | |
| 279 | // Non-gtkmmproc-generated custom classes implicitly call the default |
| 280 | // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 281 | // generated classes can use this optimisation, which avoids the unnecessary |
| 282 | // parameter conversions if there is no possibility of the virtual function |
| 283 | // being overridden: |
| 284 | if(obj_base && obj_base->is_derived_()) |
| 285 | { |
| 286 | const auto obj = dynamic_cast<CppObjectType* const>(obj_base); |
| 287 | if(obj) // This can be NULL during destruction. |
| 288 | { |
| 289 | try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 290 | { |
| 291 | // Call the virtual member method, which derived classes might override. |
| 292 | obj->on_sync_message(Glib::wrap(p0, true) |
| 293 | ); |
| 294 | return; |
| 295 | } |
| 296 | catch(...) |
| 297 | { |
| 298 | Glib::exception_handlers_invoke(); |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | const auto base = static_cast<BaseClassType*>( |
| 304 | g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 305 | ); |
| 306 | |
| 307 | // Call the original underlying C function: |
| 308 | if(base && base->sync_message) |
| 309 | (*base->sync_message)(self, p0); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | Glib::ObjectBase* Bus_Class::wrap_new(GObject* object) |
| 314 | { |
| 315 | return new Bus((GstBus*)object); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | /* The implementation: */ |
| 320 | |
| 321 | GstBus* Bus::gobj_copy() |
| 322 | { |
| 323 | reference(); |
| 324 | return gobj(); |
| 325 | } |
| 326 | |
| 327 | Bus::Bus(const Glib::ConstructParams& construct_params) |
| 328 | : |
| 329 | Object(construct_params) |
| 330 | { |
| 331 | |
| 332 | } |
| 333 | |
| 334 | Bus::Bus(GstBus* castitem) |
| 335 | : |
| 336 | Object((GstObject*)(castitem)) |
| 337 | {} |
| 338 | |
| 339 | |
| 340 | Bus::Bus(Bus&& src) noexcept |
| 341 | : Object(std::move(src)) |
| 342 | {} |
| 343 | |
| 344 | Bus& Bus::operator=(Bus&& src) noexcept |
| 345 | { |
| 346 | Object::operator=(std::move(src)); |
| 347 | return *this; |
| 348 | } |
| 349 | |
| 350 | |
| 351 | Bus::~Bus() noexcept |
| 352 | {} |
| 353 | |
| 354 | |
| 355 | Bus::CppClassType Bus::bus_class_; // initialize static member |
| 356 | |
| 357 | GType Bus::get_type() |
| 358 | { |
| 359 | return bus_class_.init().get_type(); |
| 360 | } |
| 361 | |
| 362 | |
| 363 | GType Bus::get_base_type() |
| 364 | { |
| 365 | return gst_bus_get_type(); |
| 366 | } |
| 367 | |
| 368 | |
| 369 | Bus::Bus() |
| 370 | : |
| 371 | // Mark this class as non-derived to allow C++ vfuncs to be skipped. |
| 372 | Glib::ObjectBase(nullptr), |
| 373 | Object(Glib::ConstructParams(bus_class_.init())) |
| 374 | { |
| 375 | |
| 376 | |
| 377 | } |
| 378 | |
| 379 | Glib::RefPtr<Bus> Bus::create() |
| 380 | { |
| 381 | return Glib::RefPtr<Bus>( new Bus() ); |
| 382 | } |
| 383 | |
| 384 | bool Bus::post(Glib::RefPtr<Gst::Message>&& message) |
| 385 | { |
| 386 | return gst_bus_post(gobj(), (message) ? message.release()->gobj() : nullptr); |
| 387 | } |
| 388 | |
| 389 | bool Bus::have_pending() const |
| 390 | { |
| 391 | return gst_bus_have_pending(const_cast<GstBus*>(gobj())); |
| 392 | } |
| 393 | |
| 394 | Glib::RefPtr<Gst::Message> Bus::peek() |
| 395 | { |
| 396 | return Glib::wrap(gst_bus_peek(gobj())); |
| 397 | } |
| 398 | |
| 399 | Glib::RefPtr<const Gst::Message> Bus::peek() const |
| 400 | { |
| 401 | return Glib::wrap(gst_bus_peek(const_cast<GstBus*>(gobj()))); |
| 402 | } |
| 403 | |
| 404 | Glib::RefPtr<Gst::Message> Bus::pop() |
| 405 | { |
| 406 | return Glib::wrap(gst_bus_pop(gobj())); |
| 407 | } |
| 408 | |
| 409 | Glib::RefPtr<Gst::Message> Bus::pop(MessageType message_type) |
| 410 | { |
| 411 | return Glib::wrap(gst_bus_pop_filtered(gobj(), ((GstMessageType)(message_type)))); |
| 412 | } |
| 413 | |
| 414 | Glib::RefPtr<Gst::Message> Bus::pop(ClockTime timeout) |
| 415 | { |
| 416 | return Glib::wrap(gst_bus_timed_pop(gobj(), ((GstClockTime)(timeout)))); |
| 417 | } |
| 418 | |
| 419 | Glib::RefPtr<Gst::Message> Bus::pop(ClockTime timeout, MessageType message_type) |
| 420 | { |
| 421 | return Glib::wrap(gst_bus_timed_pop_filtered(gobj(), ((GstClockTime)(timeout)), ((GstMessageType)(message_type)))); |
| 422 | } |
| 423 | |
| 424 | void Bus::set_flushing(bool flushing) |
| 425 | { |
| 426 | gst_bus_set_flushing(gobj(), static_cast<int>(flushing)); |
| 427 | } |
| 428 | |
| 429 | void Bus::disable_sync_message_emission() |
| 430 | { |
| 431 | gst_bus_disable_sync_message_emission(gobj()); |
| 432 | } |
| 433 | |
| 434 | void Bus::enable_sync_message_emission() |
| 435 | { |
| 436 | gst_bus_enable_sync_message_emission(gobj()); |
| 437 | } |
| 438 | |
| 439 | void Bus::add_signal_watch(int priority) |
| 440 | { |
| 441 | gst_bus_add_signal_watch_full(gobj(), priority); |
| 442 | } |
| 443 | |
| 444 | void Bus::remove_signal_watch() |
| 445 | { |
| 446 | gst_bus_remove_signal_watch(gobj()); |
| 447 | } |
| 448 | |
| 449 | Glib::RefPtr<Gst::Message> Bus::poll(MessageType message_type, ClockTime timeout) |
| 450 | { |
| 451 | return Glib::wrap(gst_bus_poll(gobj(), ((GstMessageType)(message_type)), ((GstClockTime)(timeout)))); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | Glib::SignalProxy< void,const Glib::RefPtr<Gst::Message>& > Bus::signal_message() |
| 456 | { |
| 457 | return Glib::SignalProxy< void,const Glib::RefPtr<Gst::Message>& >(this, &Bus_signal_message_info); |
| 458 | } |
| 459 | |
| 460 | |
| 461 | Glib::SignalProxy< void,const Glib::RefPtr<Gst::Message>& > Bus::signal_sync_message() |
| 462 | { |
| 463 | return Glib::SignalProxy< void,const Glib::RefPtr<Gst::Message>& >(this, &Bus_signal_sync_message_info); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | void Gst::Bus::on_message(const Glib::RefPtr<Gst::Message>& message) |
| 468 | { |
| 469 | const auto base = static_cast<BaseClassType*>( |
| 470 | g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 471 | ); |
| 472 | |
| 473 | if(base && base->message) |
| 474 | (*base->message)(gobj(),Glib::unwrap(message)); |
| 475 | } |
| 476 | void Gst::Bus::on_sync_message(const Glib::RefPtr<Gst::Message>& message) |
| 477 | { |
| 478 | const auto base = static_cast<BaseClassType*>( |
| 479 | g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 480 | ); |
| 481 | |
| 482 | if(base && base->sync_message) |
| 483 | (*base->sync_message)(gobj(),Glib::unwrap(message)); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | } // namespace Gst |
| 488 | |
| 489 |