Skip to main content

Video Distributor

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 component driving this feature is VideoDistributor. 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

  1. Producer (VideoDistributorMode.Producer)

    • Captures frames from a VideoSourceType (either WebCam or a Unity RenderTexture).
    • Uses VideoEncoder (with optional hardware acceleration like CUDA) to compress the video.
    • Pushes the stream to the network orchestrator via MediaWriter using the specific videoID.
    • Automatically displays the local feed on the assigned targetRenderer.
  2. Consumer (VideoDistributorMode.Consumer)

    • Subscribes to a stream matching its configured videoID using MediaReader.
    • Decompresses the incoming feed via VideoDecoder.
    • Applies the resulting Texture2D directly onto its targetRenderer in the LateUpdate() loop.

Sample Scene Walkthrough

The SDK provides an example implementation to demonstrate a closed-loop test of the distributor. For a more detailed breakdown of the specific scripts and setup used, please refer to the Distributors Sample Documentation.

Step-by-step functionality of the sample:

  1. Setup the Producer:

    • A GameObject is equipped with the VideoDistributor component set to Producer mode.
    • The sourceType is configured (e.g., RenderTexture playing a sample video via a VideoPlayer, or WebCam).
    • 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.
  2. Setup the Consumer:

    • Another GameObject in the scene has the VideoDistributor component, but set to Consumer mode.
    • It is configured with the exact same videoID (123) as the Producer.
    • A separate targetRenderer is assigned to display the incoming stream.
  3. 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.