[GStreamer] Bus && Message

前言:

Bus 里的 message 有两种被消费的方法:同步轮训,回调通知。

同步轮训:

可以在代码中调用  gst_bus_poll 

GstMessage *
gst_bus_poll (GstBus * bus,
              GstMessageType events,
              GstClockTime timeout)

以阻塞 timeout 时间等待指定 GstMessageType 类型的 Message 到达。超时或者有对应Message到达时,此函数返回。还可以使用 gst_bus_timed_pop_filtered  等其他函数,具体见官方文档GstBusicon-default.png?t=N7T8https://gstreamer.freedesktop.org/documentation/gstreamer/gstbus.html#gst_bus_poll

回调通知

 [Gstreamer] 消息处理handler的设置-CSDN博客

Build-in Message Type:

  • Error, warning and information notifications: those are used by elements if a message should be shown to the user about the state of the pipeline. Error messages are fatal and terminate the data-passing. The error should be repaired to resume pipeline activity. Warnings are not fatal, but imply a problem nevertheless. Information messages are for non-problem notifications. All those messages contain a GError with the main error type and message, and optionally a debug string. Both can be extracted using gst_message_parse_error()_parse_warning () and _parse_info (). Both error and debug strings should be freed after use.

  • End-of-stream notification: this is emitted when the stream has ended. The state of the pipeline will not change, but further media handling will stall. Applications can use this to skip to the next song in their playlist. After end-of-stream, it is also possible to seek back in the stream. Playback will then continue automatically. This message has no specific arguments.

  • Tags: emitted when metadata was found in the stream. This can be emitted multiple times for a pipeline (e.g. once for descriptive metadata such as artist name or song title, and another one for stream-information, such as samplerate and bitrate). Applications should cache metadata internally. gst_message_parse_tag() should be used to parse the taglist, which should be gst_tag_list_unref ()'ed when no longer needed.

  • State-changes: emitted after a successful state change. gst_message_parse_state_changed () can be used to parse the old and new state of this transition.

  • Buffering: emitted during caching of network-streams. One can manually extract the progress (in percent) from the message by extracting the “buffer-percent” property from the structure returned by gst_message_get_structure(). See also Buffering

  • Element messages: these are special messages that are unique to certain elements and usually represent additional features. The element's documentation should mention in detail which element messages a particular element may send. As an example, the 'qtdemux' QuickTime demuxer element may send a 'redirect' element message on certain occasions if the stream contains a redirect instruction.

  • Application-specific messages: any information on those can be extracted by getting the message structure (see above) and reading its fields. Usually these messages can safely be ignored.

    Application messages are primarily meant for internal use in applications in case the application needs to marshal information from some thread into the main thread. This is particularly useful when the application is making use of element signals (as those signals will be emitted in the context of the streaming thread).

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值