/tinyletter

The Programs of the Week of Labor Day

This Week’s Program: Sep 4 - Sep 8

Going to keep this week v brief. I took last week and Labor Day off from writing code, and jumped in for a few tiny but important commits.

8d15b54ca31fb54c70755e4bb47078e3d8064c0d

I write some contracts within the twitch module. These better define what is happening. The twitch-stream-key is a parameter that should be a string. The twitch-sink function accepts a boolean? with the #:test keyword and returns a GObject that is-a? GStreamer Element.

This is a small commit, but something that has me kind of stuck on this project is trying to understand how best to represent these different abstractions in Racket. Part of what helps me think through how the API should be shaped are Racket contracts. Which is unsurprising, considering how working within a statically typed system helps guide thinking (this is a no-dogma zone plz). As I’m shaping this code I’m thinking “well what would be better is, instead of saying this function returns something that is-a?/c element%, if it said something like gst-sink?. A small distinction, but one that helps guide the usage.

688ab2f5f09178169b1d7fe99b9926662368f748

This commit does just that. It defines two functions sink? and src? which return if a GStreamer element is a sink element (it consumes data) or a source element (it produces data).

What’s becoming clear to me as I’m writing this code and its documentation is that within the gstreamer module I’ll need to translate between the GObject interface and the racket/class interface. I made them look the same, but they serve different purposes with respect to user ergonomics.

The work continues.

– Mark