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

Deliver video frames over WebSocket when JS is allowed #141

Open
4 of 7 tasks
ethanjli opened this issue Nov 2, 2022 · 0 comments
Open
4 of 7 tasks

Deliver video frames over WebSocket when JS is allowed #141

ethanjli opened this issue Nov 2, 2022 · 0 comments
Labels
stage: dev On/for a development version type: fix Iterations on existing features or infrastructure work: complicated The situation is complicated (known unknowns), good practices used

Comments

@ethanjli
Copy link
Member

ethanjli commented Nov 2, 2022

Refer to:

We can send msgpack blobs of frames (including annotation data/metadata) over a dedicated Action Cable connection. Refer to:

We should use a separate WebSocket connection for the underlying transport of the Action Cable connection because WebSocket is susceptible to head-of-line blocking (refer to https://hpbn.co/websocket/ ). So for example we'd have /cable for normal Action Cable channels, and then /video-cable for the video delivery Action Cable channels.

Probably the simplest approach is to deliver JPEG frames (along with all metadata) over an Action Cable connection, allowing flow control/feedback to be associated with the Action Cable channels used for video frame delivery. Then we'd put frames in a video player component or custom element (e.g. a canvas).

If we don't send the JPEG frames over Turbo Streams, maybe the stream player can be a custom HTML element which also displays accompanying timestamps and (optionally) metrics about dropped frames at ingress from the source and egress to the current browser. Refer to:

Tasks:

  • Make a canvas-based custom element which simply displays frames received over Action Cable (Use Action Cable with MessagePack encoding to deliver video stream frames #153)
  • Try out having one WebSocket connection per video stream, using Action Cable for CSRF and channel integrity (Use Action Cable with MessagePack encoding to deliver video stream frames #153)
  • Deliver video frames with metadata using the actioncable-v1-msgpack subprotocol and the Any Cable client (Use Action Cable with MessagePack encoding to deliver video stream frames #153)
  • If we must multiplex using Action Cable, improve fairness of the scheduling of video-cable utilization, to prevent any one stream from being starved - maybe with round-robin reading from each send channel for a given action cable connection? Not needed - having one WebSocket connection per connection works and is simpler, and it's more like the MJPEG-over-HTTP approach for no-JS browsers.
  • Confirm whether this works in iOS Safari with JS enabled (embedded MJPEG streams don't seem to work there)
  • Add toggle for showing frame timestamp in the stream player
  • Add a local buffer of most-recently-received frames in the stream player, with scrubbing
@ethanjli ethanjli added stage: dev On/for a development version type: fix Iterations on existing features or infrastructure work: complicated The situation is complicated (known unknowns), good practices used labels Nov 2, 2022
@ethanjli ethanjli moved this from 🔖 Ready to 🏗 In progress in pslive Video Delivery Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: dev On/for a development version type: fix Iterations on existing features or infrastructure work: complicated The situation is complicated (known unknowns), good practices used
Projects
Status: 🏗 In progress
Development

No branches or pull requests

1 participant