scratch-screen-share/notes.org

15 KiB

[2024-06-28 Fri]

well, i'm setting up sbcl and sly?

because i imagine using Common Lisp for my attempt at building screen sharing for the XR glasses

for the cool runtime access, right?

well, just flake shell and (use-package sly) is enough

for .lisp files to get stuff

yes, i'm still using C-M-f and stuff to move around sexps but things are fine

so, what's next? well, this is nice high level description dbus https://www.freedesktop.org/wiki/Software/dbus/

and here's something to start usage https://blog.macrolet.net/posts/DBus-and-PolicyKit-from-Common-Lisp.html from https://github.com/death/dbus

and even lots of examples, but i think i will need a big book on Common Lisp to learn new things?

[2024-06-29 Sat]

going through the dbus guide, sounds neat

https://develop.kde.org/docs/features/d-bus/introduction_to_dbus/

that qdbus and qdbus-viewer are in

$ nix shell nixpkgs#kdePackages.qttools

now let's read about calling methods

the receiving of the signals

all the different tabs i had

searching github for 'get-managed-objects usage

searchin github for 'define-singlan-handler usage examples

https://github.com/search?q=dbus%3Adefine-dbus-signal-handler&type=code

example in cl-notify of calling a method 'with-introspected-object

https://github.com/Lautaro-Garcia/cl-notify/blob/main/src/dbus-protocol.lisp#L27

  (defmacro with-dbus-method-inovaction ((result-var method &rest args) &body body)
  (alexandria:with-gensyms (bus notifications-object)
    `(dbus:with-open-bus (,bus (dbus:session-server-addresses))
       (dbus:with-introspected-object (,notifications-object ,bus "/org/freedesktop/Notifications" "org.freedesktop.Notifications")
         (let ((,result-var (,notifications-object "org.freedesktop.Notifications" ,method ,@args)))
          ,@body)))))

example in cl-notify of working with signals

https://github.com/Lautaro-Garcia/cl-notify/blob/main/src/signals.lisp

they register single handler, and add callbacks dynamically & call them from the registered function

dbus library example for publishing objects

my request for help with interactive async calls

old ticket on dbus repo about enabling introspection

big article about iolib

https://pages.cs.wisc.edu/~psilord/blog/data/iolib-tutorial/tutorial.html

it's the one that's used to create multiplexer for communication i tried to figure out what it means to have event-loops

docs on dbus type system

https://dbus.freedesktop.org/doc/dbus-specification.html#type-system

i.e how to understand types of methods and properties

  CL-USER> (dbus:sigexp "xsaysas")
(:INT64 :STRING (:ARRAY :BYTE) :STRING (:ARRAY :STRING))

function signature explanation can show what should lisp types be https://github.com/death/dbus/issues/17#issuecomment-418920440

repo for xdg-portal for wayland

the python snippet to check that ScreenCast via xdg-portal works

[2024-07-20 Sat]

and now i want to try to get display of stuff into gtk window, i guess

well, i guess i could go and try to read guide on pipewire with C examples

https://docs.pipewire.org/page_tutorial.html this is tutorial for the system

and here is example program that maybe does similar thing https://docs.pipewire.org/video-play_8c-example.html

[2024-07-28 Sun]

ok, now i'm trying to get frames from the pipewire 'out' node

and one option i'm exploring is gstreamer

which is a framework for creating applications that stream video / audio with some kind of ability to define \ declare pipeline and then start and then use api somehow

there's c api, and gobject accessibility layer so either c to common lisp, or gobject common lisp thingy maybe exist

more readin

gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink this is test for how it's installed

needed to add plugins

https://nixos.wiki/wiki/GStreamer

i guess i can try to go with the tutorials?

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

but with common lisp over gobject? i think i'm already using this in the gtk bindings playground? maybe not https://cl-gtk2.common-lisp.dev/doc/gobject/Creating-GObjects-classes-and-implementing-GInterfaces.html

GObject binding at the moment provides only limited scenarios of creating GObject classes.

[2024-08-15 Thu]

getting back after a long while.

so, i was at the creating a window, not knowing how to stream video from pipewire out node so. what to do, huh i think gtk3 bindings library was separate from gobject and glib

but maybe it doesn't matter? or maybe i should figure out glib bindings and use gtk3 though it?

well, there's something simple with opening a window

gtk-playground.lisp::defun example-window-simple (

and something extra simple with gstreamer opening separate window for test video source

maybe try to open gstreamer window with screen share?

ok, when i try example of pipewire window on screenshare source i get error that pipewiresrc is not found and that's right, i used system-wide gst-launch-1.0 and when i tried with one in flake shell - it also didn't work

so. tried removing all from shell env, then not found namespace Gst (defvar gstreamer (gir:require-namespace "Gst"))

so. yeah. maybe i need to install dev headers or something?

so. for moving the video around. chatgpt recommended something named 'videobox'

like i can declare it in the pipeline and then get reference to it and use to set video coordinates, huh? https://gstreamer.freedesktop.org/documentation/videobox/index.html?gi-language=python the thing exists but i have zero idea whether it's accessible in a way that's recommended

(defun for-screencast ()
  (gir:invoke (*gstreamer* 'init) '())
  (let* ((pipeline (gir:invoke (*gstreamer* 'parse-launch)
                                "pipewiresrc path=49 ! videoconvert ! videobox top=0 left=0 right=0 bottom=0 ! videoconvert ! autovideosink"
                                ))
         (videobox (gir:invoke (pipeline 'get-element-by-name) "videobox")))
    ;; Set the initial state to playing
    (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing))
    
    ;; Function to move the video
    (defun move-video (top left)
      (gir:invoke (videobox 'set-property) 'top top)
      (gir:invoke (videobox 'set-property) 'left left))

    ;; Example: Move the video 10 pixels down and 20 pixels to the right
    (move-video 10 20)))

and similar advice from claude, huh

(defun for-screencast ()
  (gir:invoke (*gstreamer* 'init) '())
  (let* ((pipeline (gir:invoke (*gstreamer* 'parse-launch)
                               "pipewiresrc path=49 ! videoconvert ! videobox name=move ! videoscale ! autovideosink"))
         (move-element (gir:invoke (pipeline 'get-by-name) "move")))
    (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing))
    (values pipeline move-element)))

(defun move-video (move-element left top)
  (gir:set-property move-element "left" left)
  (gir:set-property move-element "top" top))

;; Usage:
(multiple-value-bind (pipeline move-element) (for-screencast)
  ;; Move video 50 pixels to the right and 30 pixels down
  (move-video move-element 50 30)
  ;; Your main loop or other logic here
  )

let's try this out

[2024-08-16 Fri]

new day of the vacation

the experiment with moving the video, right?

could it be that both examples are fake? i don't seem to find both 'get-element things

trying to find anything about dynamism in gstreamer https://coaxion.net/blog/2014/01/gstreamer-dynamic-pipelines/ looks like this is about changing elements of the pipeline

and it's possible that parameters of the pipeline elements (pads?) are also static

options for transforming frames?

videotransform : A combination of scaling, 90-degree-step rotation,

https://github.com/Freescale/gstreamer-imx/blob/master/README.md horizontal/vertical flipping, and color space conversion operations. These elements are able to render video overlay compositions from GstVideoOverlayCompositionMeta data. They also implement the GstVideoDirection interface and have a "video-direction" property that handles rotation and flipping. Through this property, it is possible to configure these elements to auto-rotate images according to the information in image-orientation tags.

glimagesink

https://gstreamer.freedesktop.org/documentation/opengl/glimagesink.html?gi-language=python gst-launch-1.0 -v videotestsrc ! video/x-raw ! glimagesink has error ERROR: from element /GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLImageSink:sink: Failed to create EGLDisplay from native display Additional debug info: ../ext/gl/gstglimagesink.c(1136): _ensure_gl_setup (): /GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLImageSink:sink ERROR: pipeline doesn't want to preroll.

so maybe opengl is not available? how to check?

gltransformation

https://gstreamer.freedesktop.org/documentation/opengl/gltransformation.html?gi-language=python

here examples seem to be for images, not video and same error, let's figure out the opengl check

somewhat categorized things?

[2024-08-21 Wed]

visiting sister, returning back

last time i got stuck on video displaying frozen when i tried to add appsink

just re-checking my basic gstreamer pipeline and screencast start - thing works but i want to clean it up i guess, to allow for simpler retries?

so, for the appsnk there are signals

https://gstreamer.freedesktop.org/documentation/app/appsink.html?gi-language=python#appsink::new-sample

new-sample

def new_sample_callback (appsink, udata):
    #python callback for the 'new-sample' signal

Signal that a new sample is available.

but how do i connect to a callback from common lisp and gobject introspection https://github.com/andy128k/cl-gobject-introspection does the gitlab repo has info on callbacks?

can't seem to call method 'pull-sample' maybe article will help? https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html?gi-language=python#grabbing-data-with-appsink

well, this looks like method on gst namespace? "gst_app_sink_pull_sample()" https://gstreamer.freedesktop.org/documentation/applib/gstappsink.html?gi-language=python#gst_app_sink_pull_sample

there's article for python bindings https://lifestyletransfer.com/how-to-use-gstreamer-appsink-in-python/

[2024-08-22 Thu]

hey, i think this is progress

i am able to call appsink 'pull-sample after all (for some reason, i don't know what i was doing differently)

new error: >>> got to process sample with #<STRUCT-INSTANCE {10128D02F3}> but in the code for processing of the sample some type errors

Backtrace: 0: ((:METHOD GIR::THIS-OF (T)) T) [fast-method] 1: (GIR:PROPERTY T DATA) 2: (PROCESS-FRAME #<GIR::STRUCT-INSTANCE {100BCDAB73}>) 3: ((LAMBDA (APPSINK) :IN START-PROCESSING) #<GIR::OBJECT-INSTANCE {100BBE02D3}>)

ok, but when i have struct instance, how do i introspect it?

let's just go and read documentation for the type that's returned from pull-sample, sure

struggling, searching for answers

https://github.com/andy128k/cl-gobject-introspection/issues/73#issuecomment-755316735 Examples of inspection of a repository can be found in test files.

https://github.com/andy128k/cl-gobject-introspection/blob/master/test/test1.lisp

and i mean it's possible that referencing members of a structure is not implemented?

so, huh using internal functions

(data (gir:fields-dict-of (gir:struct-class-of map-info)))

i see >>>> and data has size NIL and buf ((memory . #<FIELD-INFO {100FEB4083}>) (flags . #<FIELD-INFO {100FEB4153}>) (data . #<FIELD-INFO {100FEB4223}>) (size . #<FIELD-INFO {100FEB42F3}>) (maxsize . #<FIELD-INFO {100FEB43C3}>) (user_data . #<FIELD-INFO {100FEB4493}>) (_gst_reserved . #<FIELD-INFO {100FEB4563}>)) ; Evaluation aborted on T CAPTURING-FRAMES>

so. there are data and size fields.