;(load (sb-ext:posix-getenv "ASDF")) (asdf:load-system 'cl-gobject-introspection) (defpackage :gstreamer-simple-pipeline (:use :cl) (:export cast-with-videobox)) (in-package :gstreamer-simple-pipeline) ;; name wildly from ;; https://stackoverflow.com/questions/36296165/python-bindings-for-gstreamer-how-to-import-typelib (defvar *gstreamer* (gir:require-namespace "Gst")) ;; 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 (setf (gir:property source 'path) (format nil "~A" 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