Skip to main content
The getIngest function is designed to handle multiple input types and processes them into a unified WHIP URL format for the broadcast. It supports inputs such as stream keys, URLs, Cloudflare stream data, Cloudflare URL data, or Livepeer stream data.

Overview

Functionality

getIngest is crafted to facilitate the integration of different ingest sources into the broadcast by providing a standardized output format.

Input Types

The function can process the following input types:
  • ingest: The ingest information to be parsed.
    • string: If the string is a valid URL (starting with http/https), it’s returned directly. If not, it’s treated as a stream key and a WHIP URL is constructed using a provided base URL.
    • LivepeerStream: Extracts the streamKey and constructs a WHIP URL using the provided base URL from options.
    • CloudflareStreamData: Retrieves the URL from the Cloudflare data object.
  • opts: Optional parameters including:

Output Format

The output is a WHIP URL string or null if the input is invalid, empty, or the necessary information to construct a WHIP URL is not provided.

Usage

The function is typically used in scenarios where different types of ingest sources need to be parsed and provided to a broadcaster in a standardized WHIP URL format.

Implementation

const whipUrl = getIngest(streamKey, {
  baseUrl: "https://playback.livepeer.studio/webrtc",
});
In this example, ingestInfo can be any supported type of ingest source information. The function processes this input and returns a WHIP URL, which can then be used by the broadcaster for media broadcasting.