Search code examples
gstreamer

androidmedia plugin pad templates?


This isn't documented so maybe someone has an answer.

In android, I'm wondering if you can use androidmedia in a custom appsrc pipeline in place of the x264 plugin which is currently broken on Android. Does anyone know androidmedia's src/sink availability?

The pipeline is: appsrc->androidmedia->h264parse


Solution

  • AndroidMedia registers codecs that are suffixed by the hardware you have. As an exemple if you use a qualcom based hardware encoder you can use this pipeline :

    videotestsrc is-live=true ! amcvidenc-omxqcomvideoencoderavc bitrate=6000000 i-frame-interval=2 ! h264parse ...
    

    To know which hardware encoder is present on your system you can use this kotlin sample code :

        var mediaCodecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
        var codecName = "amcvidenc-"+mediaCodecList.findEncoderForFormat(MediaFormat.createVideoFormat("video/avc", 1920, 1080)).replace(".","").replace("-","").lowercase()
    

    I think most of androids codecs are register with higher rank in the registry, so maybe you can use encodebin.

    You can get more information here: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/androidmedia/gstamc.c

    Sink and Src are pad templates for amcvidenc-...

      templ =
          gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
      gst_element_class_add_pad_template (element_class, templ);
      gst_caps_unref (sink_caps);
    
      templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
      gst_element_class_add_pad_template (element_class, templ);
      gst_caps_unref (src_caps);
    

    Best regards