2013/03/18

[工作點滴] gstreamer from 0.10.x to 1.0.x in openwrt

I start to move the gstreamer version from 0.10.x to 1.0.x in openwrt. Two purpose, one is to get much more familiar with the gstreamer applications and plugins development, another one is to assist my colleagues for next schedule. Just make a quick note here.


Official gstreamer packages version I use is 1.0.5:
gstreamer core -> Modify Makefile and patch, compile ok.
- gst-plugins-base -> Modify Makefile and patch, compile ok.
- gst-plugins-good -> Modify Makefile and patch, compile ok.
- gst-plugins-ugly -> To be check if required.
- gst-plugins-bad -> Modify Makefile and patch, compile ok.
- gst-libav -> To be check if required.

Proprietary plugins
- package folder -> Modify the Makefile.
- gst-plugin foler -> Modify the configure.ac
- gst-plugin/src folder -> Modify the Makefile.am
- plugin source
  * GST_BOILERPLATE_FULL is gone, replace by G_DEFINE_TYPE_WITH_CODE
  * add the parent_class definition.
    #if 0
      GST_BOILERPLATE_FULL (GstA5sSrc, gst_a5s_src, GstBaseSrc, GST_TYPE_BASE_SRC, gst_a5s_src_init_interfaces);
    #else
      #define gst_a5s_src_parent_iclass parent_class
      G_DEFINE_TYPE_WITH_CODE (GstA5sSrc, gst_a5s_src, GST_TYPE_BASE_SRC, gst_a5s_src_init_interfaces);
    #endif
  * init funtion parameters is change.
    #if 0
      static void gst_a5s_src_init (GstA5sSrc * a5ssrc, GstA5sSrcClass * a5ssrc_class)
    #else
      static void gst_a5s_src_init (GstA5sSrc * a5ssrc)
    #endif
  * remove the gone already functions.
  * audio: Need lots of works to do.
  * buffer size: replace the GST_BUFFER_SIZE() to gst_buffer_get_size().
  * buffer data: replace the GST_BUFFER_DATA() by using the gst_buffer_map to access the data.

Audio plugins:
- GstRingBufferSpec -> GstAudioRingBufferSpec
- The GstAudioRingBufferSpec has big changes. Lots parameters are re-factored in the GstAudioInfo.
- The GstAudioInfo structure is as follow. The format part is in GstAudioFormatInfo.
  /**
  * GstAudioInfo:
  * @finfo: the format info of the audio
  * @flags: additional audio flags
  * @layout: audio layout
  * @rate: the audio sample rate
  * @channels: the number of channels
  * @bpf: the number of bytes for one frame, this is the size of one
  *         sample * @channels
  * @position: the positions for each channel
  *
  * Information describing audio properties. This information can be filled
  * in from GstCaps with gst_audio_info_from_caps().
  *
  * Use the provided macros to access the info in this structure.
  */
  struct _GstAudioInfo {
    const GstAudioFormatInfo *finfo;
    GstAudioFlags             flags;
    GstAudioLayout            layout;
    gint                      rate;
    gint                      channels;
    gint                      bpf;
    GstAudioChannelPosition   position[64];

    /*< private >*/
    gpointer _gst_reserved[GST_PADDING];
  };
- GstAudioFormatInfo
  /**
  * GstAudioFormatInfo:
  * @format: #GstAudioFormat
  * @name: string representation of the format
  * @description: user readable description of the format
  * @flags: #GstAudioFormatFlags
  * @endianness: the endianness
  * @width: amount of bits used for one sample
  * @depth: amount of valid bits in @width
  * @silence: @width/8 bytes with 1 silent sample
  * @unpack_format: the format of the unpacked samples
  * @unpack_func: function to unpack samples
  * @pack_func: function to pack samples
  *
  * Information for an audio format.
  */
  struct _GstAudioFormatInfo {
    GstAudioFormat format;
    const gchar *name;
    const gchar *description;
    GstAudioFormatFlags flags;
    gint endianness;
    gint width;
    gint depth;
    guint8 silence[8];

    GstAudioFormat unpack_format;
    GstAudioFormatUnpack unpack_func;
    GstAudioFormatPack pack_func;

    /*< private >*/
    gpointer _gst_reserved[GST_PADDING];
  };
- Change the audio/x-raw-int to audio/x-raw for pad template.
- To do list:
  * Check the timestamps mechanism in new alsa plugin example.
  * Check the audio GstAudioRingBufferSpec parameters.

Applications
- gst-rtsp-server
  * execute the autogen.sh and install the required tool to generate necessary files.
  * add the AC_PROG_CXX in configure.ac because our example is cpp based.
  * create patch to make gst-libs/gst/rtsp in gst-plugins-base to be the latest master version.
  * after above patch, the gst-rtsp-server's gst/rtsp-server library could be successfully built.
  * gst_debug_add_log_function() function parameters change from 2 to 3.
    gst_debug_add_log_function(gst_log_function_syslog, NULL, NULL);
  * buffer size: replace the GST_BUFFER_SIZE() to gst_buffer_get_size().
  * buffer data: replace the GST_BUFFER_DATA() by using the gst_buffer_map to access the data.
    GstBuffer *buffer = gst_app_sink_pull_preroll(sink);
    GstMapInfo mapinfo = {0, };
    gst_buffer_map(buffer, &mapinfo, GST_MAP_READ);
    /* access the buffer by mapinfo.data and mapinfo.size */
    gst_buffer_unmap(buffer, &mapinfo);
  * g_thread_create remove, use g_thread_new -> check further.
  * gst_app_sink_set_callbacks() -> callbacks structure is change.
  * ways change to handle sink callback functions.
    #if 0
      GstBuffer *buffer = gst_app_sink_pull_preroll(sink);
    #else
      GstSample *sample = gst_app_sink_pull_preroll(sink);
      GstBuffer *buffer = gst_sampe_get_buffer(sample);
    #endif
    #if 0
      GstBuffer *buffer = gst_app_sink_pull_buffer(sink);
    #else
      GstSample *sample = gst_app_sink_pull_sample(sink);
      GstBuffer *buffer = gst_sampe_get_buffer(sample);
    #endif
  * The GstRTSPMediaMapping rename to be GstRTSPMountPoints, we can compare by the examples.
  * gst_rtsp_server_get_media_mapping() become gst_rtsp_server_get_mount_points()
  * gst_rtsp_media_mapping_add_factory() become gst_rtsp_mount_points_add_factory()
  * In configure.ac, remove the WARNING_CFLAGS because some warnings would cause errors.
    #GST_OPTION_CFLAGS="\$(WARNING_CFLAGS) \$(ERROR_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
    GST_OPTION_CFLAGS="\$(ERROR_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"

沒有留言: