import carb.settings

import omni.ext
import omni.kit.renderer_capture


class Extension(omni.ext.IExt):
    def __init__(self):
        omni.ext.IExt.__init__(self)
        pass

    def on_startup(self):
        self._settings = carb.settings.get_settings()
        self._settings.set_default_bool("/exts/omni.kit.renderer.capture/autostartCapture", True)
        self._autostart = self._settings.get("/exts/omni.kit.renderer.capture/autostartCapture")
        if self._autostart:
            self._renderer_capture = omni.kit.renderer_capture.acquire_renderer_capture_interface()
            self._renderer_capture.startup()

    def on_shutdown(self):
        if self._autostart:
            self._renderer_capture.shutdown()
            self._renderer_capture = None
