[GStreamer] 常用内容积累

GST_OBJECT_NAME(GstObject *)         通过gst对象指针获取gst对象的name

GError *err;
gchar *debug_info;
gst_message_parse_error(msg,&err,&debug_info);
std::cout << "GST_MESSAGE_ERROR received , sender : " << GST_OBJECT_NAME(msg->src) 
				<< "error description : " << err->message << std::endl;

媒体数据的时长和当前进度

gst_element_query_position:获取某个element中当前数据在整个stream中的时间点或百分比

gst_element_query_duration:获取duration

gst_element_seek_simple:seek动作


gst_bus_add_signal_watch:观察信号

gst_bus_timed_pop_filtered:观察message


g_timeout_add_seconds:注册一个定时器和定时器超时函数


给sink element指定渲染窗口

static void realize_cb (GtkWidget *widget, CustomData *data) {
  GdkWindow *window = gtk_widget_get_window (widget);
  guintptr window_handle;

  if (!gdk_window_ensure_native (window))
    g_error ("Couldn't create native window needed for GstVideoOverlay!");

  /* Retrieve window handler from GDK */
#if defined (GDK_WINDOWING_WIN32)
  window_handle = (guintptr)GDK_WINDOW_HWND (window);
#elif defined (GDK_WINDOWING_QUARTZ)
  window_handle = gdk_quartz_window_get_nsview (window);
#elif defined (GDK_WINDOWING_X11)
  window_handle = GDK_WINDOW_XID (window);
#endif
  /* Pass it to playbin, which implements VideoOverlay and will forward it to the video sink */
  gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->playbin), window_handle);
}

GST_API
GstElement*             gst_element_factory_create              (GstElementFactory *factory,
                                                                 const gchar *name) G_GNUC_MALLOC;
GST_API
GstElement*             gst_element_factory_make                (const gchar *factoryname, const gchar *name) G_GNUC_MALLOC;

gst_element_factory_create使用factory指针创建,gst_element_factory_make使用factoryname创建,但是gst_element_factory_make内部会先遍历插件列表找到对应的factory,插件热插拔的时候考虑使用gst_element_factory_make,其他情况建议使用gst_element_factory_create,毕竟少了遍历的过程会快一点。


gst_bin_get_by_name ()

gst_bin_get_by_interface ()

gst_bin_iterate_elements ()


Tips:

  • All elements in GStreamer must typically be contained inside a pipeline before they can be used, because it takes care of some clocking and messaging functions.
  • All methods which apply to bins also apply to pipelines. What is all methods represent for?
  • Only elements residing in the same bin can be linked together, so remember to add them to the pipeline before trying to link them!
  • Keep in mind that, in order for the bus watches to work (be it a gst_bus_add_watch() or a gst_bus_add_signal_watch()), there must be GLib Main Loop running. In this case, it is hidden inside the GTK+ main loop.
  • Queues create new thread.
  • gst_element_link_many() can actually link elements with Request Pads. But it is needed to unref request pad when we don’t need it. In case that we forget to unref on request Pad, Stay out of trouble by always requesting Request Pads manually.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值