Filesrc source code analysis

Summary

according to Last blog In the introduction, we know that for the filesrc class, we only need to complete its static method, and the invocation logic is completed by pipeline/bin. What's more, filesrc inherits basesrc. Basesrc is a template for all src type element s. Its interface completes a series of logic, such as state switching management, Pad negotiation, memory allocator negotiation, etc. filesrc only overloads part of the interface of basesrc. If you don't want to use the default logic provided by basesrc, you can replace it by overloading yourself.

code analysis

For an introduction to the members and methods of the filesrc class, see: Official introduction to filesrc The functions of each attribute and interface are described in detail in the official introduction. Additional call logic for each interface is added here so that the whole code logic can be seen at a glance.

The following is the author's call sequence by adding the printed filesrc function. With this call timing, we can peek into what Pipeline needs to be prepared for at all stages.

  • [NULL] to [READY] Stage: Create instances of elements.
  • [READY] to [PAUSED] stage: Open the file handle to obtain file flow information.
  • [PAUSED] to [PREROLL] stage: The data of the first buffer was successfully read.
  • PLAYING: Read file data continuously and fill it in the specified buffer until the data is read and returned to GST_FLOW_EOS.
  • PLAYING to PAUSED: The implementation is transparent to filesrc.
  • [PAUSED] to [READY] phase: the specific implementation is transparent to filesrc.
  • [READY] to [NULL] phase: Close the file handle
$ gst-launch-1.0 filesrc location=/oem/200frames_count.h264 ! filesink location=/tmp/flc.h264

FLC-DBG:[GstFileSrc] <gst_file_src_class_init> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_init> is called!
Setting pipeline to PAUSED ...
FLC-DBG:[GstFileSrc] <gst_file_src_start> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_get_size> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_is_seekable> is called!
Pipeline is PREROLLING ...
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_get_size> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_fill> is called!
FLC-DBG:[GstFileSrc] <gst_file_src_get_size> is called!
Got EOS from element "pipeline0".
Execution ended after 0:00:00.009744000
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
FLC-DBG:[GstFileSrc] <gst_file_src_stop> is called!
Setting pipeline to NULL ...
Freeing pipeline ...
FLC-DBG:[GstFileSrc] <gst_file_src_finalize> is called!

Tags: Attribute

Posted on Tue, 10 Sep 2019 20:06:49 -0700 by gljaber