Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Action Cable with MessagePack encoding to deliver video stream frames #153

Merged
merged 13 commits into from
Nov 29, 2022

Conversation

ethanjli
Copy link
Member

@ethanjli ethanjli commented Nov 28, 2022

This PR completes part of #141, closes #149, and refactors some internal code.

Breaking changes:

Additions:

  • When Javascript is enabled, the web browser will open camera streams using a new custom HTML element (<video-cable-player>), which opens a new custom Turbo Streams-inspired Action Cable channel (Video::StreamsChannel) over WebSockets, instead of opening the camera stream as MJPEG-over-HTTP. This fixes Turbo Drive continues loading MJPEG stream even after navigating to a different page #149. Video::StreamsChannel integrates with the videostreams Broker in the same way that Turbo::StreamsChannel integrates with the godest framework's turbostreams Broker.
  • There is a new /video-cable route which serves Action Cable connections with Video::Streams channels. Each camera stream on an instrument opens a separate WebSocket connection to this route (by attaching a per-camera value on a HTTP GET query param) in order to prevent any camera from being starved from writing data on the WebSocket connection.
  • Now all Action Cable connections are served using MessagePack encoding instead of JSON encoding. This allows us to avoid base64-encoding each video stream frame, which would incur a significant network overhead, since JSON can't hold raw bytes.

This PR also upgrades dependencies, both to implement the above additions and to keep dependencies up-to-date.

@ethanjli ethanjli added stage: dev On/for a development version type: feature Brand new functionality, features, pages, workflows, endpoints, etc. labels Nov 28, 2022
@ethanjli ethanjli added the breaking Introduces a breaking change label Nov 29, 2022
@ethanjli ethanjli merged commit b165b97 into main Nov 29, 2022
@ethanjli ethanjli deleted the feature/websocket-video-streaming branch November 29, 2022 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Introduces a breaking change stage: dev On/for a development version type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Turbo Drive continues loading MJPEG stream even after navigating to a different page
1 participant