(load (sb-ext:posix-getenv "ASDF")) (asdf:load-system 'cl-cffi-gtk) (asdf:load-system 'cl-gobject-introspection) (defpackage :tutorial-hello-world (:use :cl)) (in-package :tutorial-hello-world) (gir:require-namespace "GLib") (defvar *gtk* (gir:require-namespace "Gtk" "3.0")) (gir:nget *gtk* "WindowType" :toplevel) ; get enum value ;; name wildly from ;; https://stackoverflow.com/questions/36296165/python-bindings-for-gstreamer-how-to-import-typelib (defvar *gstreamer* (gir:require-namespace "Gst")) ;; overall capacities of this Glib bindings ;; https://github.com/andy128k/cl-gobject-introspection ;; back to hello-world ;; how'd i figure out what are the names to call, sad (gir:nget *gstreamer* 'init ) (gir:nget *gstreamer* 'parse-launch) (gir:nget *gstreamer* "State" :playing) (gir:nget *gstreamer* "Element" 'set-state) (gir:nget *gstreamer* "Element") (progn (gir:invoke (*gstreamer* 'init) '()) (let ((pipeline (gir:invoke (*gstreamer* 'parse-launch) "playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm" ))) (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)))) ;; from here? ;; https://github.com/irsbugs/GStreaming?tab=readme-ov-file#gstparse_launch ;; and docs searched with underscore ;; https://gstreamer.freedesktop.org/documentation/gstreamer/gstparse.html?gi-language=python#gst_parse_launch (defun tutorial-main () (gir:invoke (*gstreamer* 'init) '()) (let ((pipeline (gir:invoke (*gstreamer* 'parse-launch) "videotestsrc ! videoconvert ! autovideosink" ;"playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm" ))) (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) ;; (let* ((bus (gir:invoke (pipeline 'get-bus))) ;; (msg (gir:invoke (bus 'timed-pop-filtered) ;; (gir:nget *gstreamer* :clock-time-none) ;; (list ;; (gir:nget *gstreamer* "MessageType" :error) ;; (gir:nget *gstreamer* "MessageType" :eos)))))) (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :paused)))) ;; call ;; so, it's only uri stuff didn't work ;; videotestsc worked ;; and error i got was from trying to set :null ? but it should be correct enum ;; oh well, ok (defun for-screencast (stream-num) (gir:invoke (*gstreamer* 'init) '()) (let* ((pipeline (gir:invoke (*gstreamer* 'parse-launch) (format nil "pipewiresrc path=~A ! videoconvert ! videobox name=move ! autovideosink" stream-num) ;"playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm" )) (move-element (gir:invoke (pipeline 'get-by-name) "move"))) (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) (values pipeline move-element))) ;; well, pipewire is not part of what's added to env ;; not sure if i can add it ;; trying to run without env gstreamer doesn't work, installing ;; $ sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev ;; still results in error for (defvar *gstreamer* (gir:require-namespace "Gst")) ;; i can try to add pipewire, but then would it work with the screen share running on system server? ;; it did work. wowy. ok ;; cool. now i'm kind of at the point of python example :D ;; huh. how the heck can i check all valid functions to call? ;; i don't understand. let's try creation of pipeline "by element" (gir:invoke (*gstreamer* 'pipeline-new)) (gir:nget *gstreamer* 'init) ; this directly exists (gir:nget *gstreamer* 'pipeline-new) ; doesn't work (gir:nget *gstreamer* "Pipeline" 'new) ;; https://gstreamer.freedesktop.org/documentation/gstreamer/gstpipeline.html?gi-language=python#gst_pipeline_new ;; well, i guess it should be in namespace "Pipeline", so, huh ;;https://gstreamer.freedesktop.org/documentation/gstreamer/gstelementfactory.html?gi-language=python (gir:nget *gstreamer* 'element-factory-make) (gir:nget *gstreamer* "ElementFactory" 'make) ; and now this exists ;; OKOK ;; let's generalize, when stream is not passed, use the testsrc (defun cast-with-videobox (&optional stream-num) (gir:invoke (*gstreamer* 'init) '()) (let* ((pipeline (gir:invoke (*gstreamer* "Pipeline" 'new) "video-pipeline")) (source (gir:invoke (*gstreamer* "ElementFactory" 'make) (if stream-num "pipewiresrc" "videotestsrc") "source")) (convert (gir:invoke (*gstreamer* "ElementFactory" 'make) "videoconvert" "convert")) (box (gir:invoke (*gstreamer* "ElementFactory" 'make) "videobox" "box")) (sink (gir:invoke (*gstreamer* "ElementFactory" 'make) "autovideosink" "sink"))) (when stream-num ;; Set pipewiresrc properties, such as the path (gir:invoke (source 'set-property) 'path stream-num)) ;; Add and link elements in the pipeline (gir:invoke (pipeline 'add) source) (gir:invoke (pipeline 'add) convert) (gir:invoke (pipeline 'add) box) (gir:invoke (pipeline 'add) sink) (gir:invoke (source 'link) convert) (gir:invoke (convert 'link) box) (gir:invoke (box 'link) sink) (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) ;(format t ">> arhg ~A" (gir:property box 'top)) (defun move-video (top left) (setf (gir:property box 'top) top (gir:property box 'left) left)) ;; Example: Move the video 10 pixels down and 20 pixels to the right (move-video 100 200) pipeline)) ;; now this works, but padding is symmetrical