Skip to main content

Module video

Module video 

Source
Expand description

Videos notes link to, played where the link was: in the note’s row.

Nothing of a video is fetched until its reader presses play: the server it is on sees that request, a video is large, and it has sound. Then GStreamer does the work. A playbin fetches the address and decodes what it finds, the sound goes to the system’s output, and the pictures come here, each scaled to what a row can show and converted to RGBA, through an appsink. The app looks for a new one thirty times a second while a video plays (see TICK_PLAYING) and shows the latest.

flowchart LR
    url["An https address"] --> playbin["playbin: fetches, demuxes, decodes"]
    playbin -->|"sound"| audio["The system's audio output"]
    playbin -->|"pictures"| convert["videoconvert, videoscale: RGBA, no side over the limit"]
    convert --> sink["appsink: keeps the latest frame, drops the rest"]
    sink -->|"taken at each tick"| playback["Playback: the frame as an image, where it is, how long it is"]
    playback --> row["The row's video box"]

One video plays at a time, and it plays while it is on screen. The rows of a list are built anew each time the popup is, and only those in view: so Videos counts the times the popup is built, a row that shows the video says so as it is built, and a video no row has shown through a few builds of the popup, and for a moment, is held. That is one rule for a row scrolled out of view and for another view shown in the list’s place. A closed popup is not built at all, and holds its video as it closes.

Whether a video’s sound is off, and how loud it is, is asked of what plays it, not kept here (see SOUND_EVERY): where the system remembers how an app’s sound was left, as PipeWire and PulseAudio do, a video starts as the last one ended, muted if that was and as loud as that was, and the mute button and its slider say so.

A video plays at the speed its reader chose (see Speed), which holds for the next one too until the applet is started again. A speed is a seek: to where the video is, to play on from there at another rate. Its sound keeps its pitch, where GStreamer has the element for that (scaletempo).

The room a video takes in its row is settled before anything of it is known (box_size): as wide as the row, in the proportions the note says it has, or those of most videos if it doesn’t say. What plays is fitted inside, so a row is the same height before, while and after.

A link to YouTube is to a page, and what there is to play of it has to be found first (see crate::youtube). Its Playback is there from the press, saying it is on its way, and gets its player when the stream is found.

The address comes from whoever wrote the note. Only https is played, and it is GStreamer that fetches it: its decoders read what a stranger sent, which is one more reason nothing plays unasked.

Structs§

Frame 🔒
One picture of a video: RGBA, row after row, with nothing between the rows.
Playback
The video that plays, or did last, as the model keeps it and its row shows it.
Player 🔒
One video, being played by GStreamer. Dropping it stops it.
Speed
How fast a video plays: 1 is as it was made. One of Speed::ALL.
Videos
The videos of the notes on show, as the model keeps them.

Enums§

Happened 🔒
What a player has to say for itself, when it is asked.
Loudness
How loud a video is, as its button says it at a glance.

Constants§

FRAME_MAX_SIDE 🔒
The most pixels a frame has on either side when it is handed over: more than the popup shows at any scale, and far fewer than a video may have. Frames are copied thirty times a second.
SOUND_EVERY 🔒
How often a video is asked whether its sound is off, and how loud it is. That is not the mute button’s alone to say: the system may start a video’s sound as it left this app’s last, off included, and a mixer can turn it off, on, up or down at any time. The button and its slider show what is so, a moment later at most.
STREAM_BITRATE_MAX 🔒
The most bits a second taken of a video that comes in several sizes to choose from, as the playlist of a live one lists them: about what one 720 lines tall takes. Its pictures are shown no larger than FRAME_MAX_SIDE, so the sizes over that would be fetched and decoded to be scaled down.
TICK_PAUSED
TICK_PLAYING
How often a video that plays is looked at for a new frame, and how often one that doesn’t, while the popup is open: it may still have a frame to show after a seek, or something to say.
UNSEEN 🔒
How long a video plays on with no row showing it, and through how many builds of the popup, before it is held. Both, because neither says it alone: a popup that took its time to draw has let a moment go by without being built again, and one that is built several times before it is drawn once has not been long about it.
UNSEEN_VIEWS 🔒
USUAL_ASPECT 🔒
The proportions a video is given room for when its note doesn’t say its own: what most videos have.

Functions§

amplitude 🔒
The amplitude that is shown as shown (see shown_volume).
box_size
The room a video takes in a row width wide, when its note says it is size pixels, or doesn’t say: the whole width, as tall as its proportions make that, and never taller than it is wide. A video taller than that plays between bars, with its controls still in view.
clock
seconds as a player says it: 0:07, 12:34, 1:02:03.
frame_of 🔒
The picture sample carries, copied out row by row: a row may be longer in the buffer than the pixels it holds.
picture_sink 🔒
Where a video’s pictures go: converted to RGBA with square pixels, scaled down until neither side is over FRAME_MAX_SIDE, and the latest kept in latest for whoever takes it. A frame nobody took is dropped for the next: what is shown is what is current.
ready 🔒
GStreamer, started once. What it said if it could not be: there is no second try in one run.
shown_volume 🔒
How loud a video is, as its reader is shown it and sets it: from 0.0 to 1.0, on the scale a system’s mixer shows, where half way sounds about half as loud. What plays it counts in amplitude, which is that cubed: half way there is an eighth.