Distributors - Video Distributors
The Video Distributor module in HoloMIT SDK is designed to independently route, stream, and receive video feeds (either from a Webcam or a custom RenderTexture) outside the standard User Representation pipeline. This is highly useful for streaming external media, screens, or secondary cameras into a session.
Overview
The primary script driving this feature is VideoDistributor.cs, located at Assets\Distributors\Video\. It allows a GameObject to act as either a Producer (broadcasting video) or a Consumer (receiving video) based on a shared videoID.
Modes of Operation
-
Producer (
VideoDistributorMode.Producer)- Captures frames from a
VideoSourceType(eitherWebCamor a UnityRenderTexture). - Uses
VideoEncoder(with optional hardware acceleration like CUDA) to compress the video. - Pushes the stream to the network orchestrator via
MediaWriterusing the specificvideoID. - Automatically displays the local feed on the assigned
targetRenderer.
- Captures frames from a
-
Consumer (
VideoDistributorMode.Consumer)- Subscribes to a stream matching its configured
videoIDusingMediaReader. - Decompresses the incoming feed via
VideoDecoder. - Applies the resulting
Texture2Ddirectly onto itstargetRendererin theLateUpdate()loop.
- Subscribes to a stream matching its configured
Sample Scene Walkthrough
You can find an example implementation in Assets\DevelopmentTests\Distributors\. This scene demonstrates a closed-loop test of the distributor.
Step-by-step functionality of the sample:
-
Setup the Producer:
- A GameObject is equipped with the
VideoDistributorcomponent set toProducermode. - The
sourceTypeis configured (e.g.,RenderTextureplaying a sample video via aVideoPlayer, orWebCam). - A
targetRenderer(like a Plane or Quad) is assigned so you can see what is being broadcasted. - A unique
videoID(e.g.,123) is set.
- A GameObject is equipped with the
-
Setup the Consumer:
- Another GameObject in the scene has the
VideoDistributorcomponent, but set toConsumermode. - It is configured with the exact same
videoID(123) as the Producer. - A separate
targetRendereris assigned to display the incoming stream.
- Another GameObject in the scene has the
-
Runtime Execution:
- When you press Play, the Producer initializes its reader, encodes the frames, and sends them to the network layer (or loopback).
- Simultaneously, the Consumer connects, decodes the packets matching its ID, and dynamically updates its material to show the live video.
Example of the Video Distributor Producer and Consumer side-by-side in a scene.