def set_env_variables()

in awstreamer/gst_pipeline/stream_client.py [0:0]


    def set_env_variables(self):
        '''
        Sets GStreamer environmental variables
        '''
        # Logging level
        if 'GST_DEBUG' not in os.environ:
            os.environ['GST_DEBUG'] = '2,splitmuxsink:4'

        # Plugin path
        plugin_path = "../gst_plugins"
        cwd_path = os.getcwd()
        file_path = os.path.abspath(os.path.dirname(__file__))
        if len(file_path) > len(cwd_path):
            diff_path = file_path.replace(cwd_path, '')
            diff_path = os.path.normpath(diff_path)
            plugin_path = os.path.join(diff_path, plugin_path)[1:]

        # Python bindings path
        plugin_path += ":/usr/lib/gstreamer-1.0/"

        logger.info("GST_PLUGIN_PATH: %s" % plugin_path)
        os.environ["GST_PLUGIN_PATH"] = plugin_path

        # Set LIB_GSTREAMER_PATH
        if 'LIB_GSTREAMER_PATH' not in os.environ:
            logger.info("Gstreamer version: {}.{}.{}.{}".format(*Gst.version()))
            lib_gst_path = None
            if sys.platform == "darwin":
                lib_gst_path = "/usr/local/Cellar/gstreamer/{}.{}.{}/lib/libgstreamer-1.0.dylib".format(*Gst.version())
            elif sys.platform == "win32":
                lib_gst_path = "C:\\msys64\\mingw64\\bin\\libgstreamer-1.0-0.dll"
            else:
                lib_gst_paths = [
                    "/usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0",
                    "/usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0"
                ]
                for path in lib_gst_paths:
                    if os.path.exists(path):
                        lib_gst_path = path
                        break

            if lib_gst_path is None:
                logger.warning("libgstreamer-1.0 not found! Please export LIB_GSTREAMER_PATH env var manually.")
            else:
                logger.info("LIB_GSTREAMER_PATH: %s" % lib_gst_path)
                os.environ['LIB_GSTREAMER_PATH'] = lib_gst_path