Class VideoStreamSender
Component for sending video streams.
Implements
Inherited Members
Namespace: Unity.RenderStreaming
Assembly: Unity.RenderStreaming.dll
Syntax
[AddComponentMenu("Render Streaming/Video Stream Sender")]
public class VideoStreamSender : StreamSenderBase, IStreamSender
Properties
autoRequestUserAuthorization
Whether request permission to use any video input sources.
Declaration
public bool autoRequestUserAuthorization { get; set; }
Property Value
Type | Description |
---|---|
bool |
codec
Gets the codec information for the video stream.
Declaration
public VideoCodecInfo codec { get; }
Property Value
Type | Description |
---|---|
VideoCodecInfo |
frameRate
Gets the frame rate of the video stream.
Declaration
public float frameRate { get; }
Property Value
Type | Description |
---|---|
float |
height
Gets or sets the height of the frame buffer used for streaming.
Declaration
public uint height { get; set; }
Property Value
Type | Description |
---|---|
uint |
maxBitrate
Gets the maximum bitrate of the video stream.
Declaration
public uint maxBitrate { get; }
Property Value
Type | Description |
---|---|
uint |
minBitrate
Gets the minimum bitrate of the video stream.
Declaration
public uint minBitrate { get; }
Property Value
Type | Description |
---|---|
uint |
scaleResolutionDown
The scale factor by which to reduce the video resolution to conserve bandwidth.
Declaration
public float scaleResolutionDown { get; }
Property Value
Type | Description |
---|---|
float |
source
Gets or sets the source of the video stream.
Declaration
public VideoStreamSource source { get; set; }
Property Value
Type | Description |
---|---|
VideoStreamSource |
sourceCamera
Gets or sets the camera used as the video stream source.
Declaration
public Camera sourceCamera { get; set; }
Property Value
Type | Description |
---|---|
Camera |
sourceDeviceIndex
The index of WebCamTexture.devices.
Declaration
public int sourceDeviceIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
sourceTexture
Gets or sets the texture used as the video stream source.
Declaration
public Texture sourceTexture { get; set; }
Property Value
Type | Description |
---|---|
Texture |
sourceWebCamTexture
Gets the WebCamTexture used as the video stream source.
Declaration
public WebCamTexture sourceWebCamTexture { get; }
Property Value
Type | Description |
---|---|
WebCamTexture |
width
Gets or sets the width of the frame buffer used for streaming.
Declaration
public uint width { get; set; }
Property Value
Type | Description |
---|---|
uint |
Methods
GetAvailableCodecs()
Declaration
public static IEnumerable<VideoCodecInfo> GetAvailableCodecs()
Returns
Type | Description |
---|---|
IEnumerable<VideoCodecInfo> |
SetBitrate(uint, uint)
Sets the bitrate range for the video stream.
Declaration
public void SetBitrate(uint minBitrate, uint maxBitrate)
Parameters
Type | Name | Description |
---|---|---|
uint | minBitrate | The minimum bitrate in kbps. Must be greater than zero. |
uint | maxBitrate | The maximum bitrate in kbps. Must be greater than or equal to the minimum bitrate. |
Examples
videoStreamSender.SetBitrate(1000, 2500);
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the maximum bitrate is less than the minimum bitrate. |
SetCodec(VideoCodecInfo)
Sets the codec for the video stream.
Declaration
public void SetCodec(VideoCodecInfo codec)
Parameters
Type | Name | Description |
---|---|---|
VideoCodecInfo | codec | The codec information to set. |
Examples
var codec = VideoStreamSender.GetAvailableCodecs().FirstOrDefault(x => x.mimeType.Contains("VP9"));
videoStreamSender.SetCodec(codec);
SetFrameRate(float)
Sets the frame rate for the video stream.
Declaration
public void SetFrameRate(float frameRate)
Parameters
Type | Name | Description |
---|---|---|
float | frameRate | The new frame rate. Must be greater than zero. |
Examples
videoStreamSender.SetFrameRate(30.0f);
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the frame rate is less than or equal to zero. |
SetScaleResolutionDown(float)
Sets the scale factor by which to reduce the video resolution to conserve bandwidth.
Declaration
public void SetScaleResolutionDown(float scaleFactor)
Parameters
Type | Name | Description |
---|---|---|
float | scaleFactor | The scale factor by which to reduce the resolution. Must be greater than 1.0f. |
Examples
videoStreamSender.SetScaleResolutionDown(2.0f);
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the scale factor is less than or equal to 1.0f. |
SetTextureSize(Vector2Int)
Sets the size of the frame buffer used for streaming.
Declaration
public void SetTextureSize(Vector2Int size)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | size | The new size of the texture as a Vector2Int. |
Examples
SetTextureSize(new Vector2Int(1920, 1080));