Home > database >  appsrc element is null on Android
appsrc element is null on Android

Time:11-24

I'm attempting to run an example appsrc application where the appsrc element is retrieved with

app->src = (GstAppSrc*)gst_get_element_factory_make("appsrc", "source")

However, this returns null and fails the assertion:

g_assert(app->src)

I've installed gstreamer-1.0-android-universal-1.21.2 binaries and my cmake file is this:

https://github.com/henkeldi/gstreamer-android/blob/master/app/src/main/cpp/CMakeLists.txt

Only difference is I've replaced ${ARCH} with the android abi. The application has no problems linking against the gstreamer headers. It's also been initialized properly (gst_init)

I'm developing on Windows for Android via Android studio. I'm not sure why appsrc isn't being found. Any ideas?

CodePudding user response:

I usually use Android.mk which simplify plugin initing. If appsrc is null this is because it is not registered as an element in gstreamer.

You probably need to register app plugin and all you need in this file : https://github.com/henkeldi/gstreamer-android/blob/master/app/src/main/cpp/gstreamer_android.cpp

add this

GST_PLUGIN_STATIC_REGISTER(app);

In this method

void gst_android_register_static_plugins() {
    // GST_PLUGIN_STATIC_REGISTER(audiotestsrc);
    // GST_PLUGIN_STATIC_REGISTER(audioconvert);
    // GST_PLUGIN_STATIC_REGISTER(audioresample);
}

You can also follow this tutorial if you prefer use the Android.mk file to build with gstreamer.

https://gstreamer.freedesktop.org/documentation/tutorials/android/index.html?gi-language=c

Best regards !

  • Related