A gstreamermm Gst::Bus example.
#include <gstreamermm.h>
#include <glibmm/main.h>
Glib::RefPtr<Glib::MainLoop> main_loop;
bool bus_message_watch(const Glib::RefPtr<Gst::Bus>& , const Glib::RefPtr<Gst::Message>& message)
{
  
  if (message->get_source())
  {
    std::cout << 
"Source object: " << message->get_source()->get_name() << 
std::endl;
  }
  switch (message->get_message_type())
  {
  
  {
    auto error_msg = Glib::RefPtr<Gst::MessageError>::cast_static(message);
    std::cout << 
"Error: " << error_msg->parse_error().what() << 
std::endl;
    std::cout << 
"Debug: " << error_msg->parse_debug() << 
std::endl;
    break;
  }
  
    main_loop->quit();
    break;
  
  {
    auto state_changed_msg = Glib::RefPtr<Gst::MessageStateChanged>::cast_static(message);
    break;
  }
  
  default:
    break;
  }
  return true;
}
int main(int argc, char *argv[])
{
  
  
  
  try
  {
    pipeline->add(source)->add(sink);
  }
  {
    std::cerr << 
"Exception while adding: " << ex.what() << 
std::endl;
     return 1;
  }
  
  try
  {
    source->link(sink);
  }
  {
    std::cerr << 
"Exception while linking: " << ex.what() << 
std::endl;
  }
  
  Glib::RefPtr<Gst::Bus> bus = pipeline->get_bus();
  
  
  main_loop = Glib::MainLoop::create();
  main_loop->run();
  
  return 0;
}