Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/layer-max-dimensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@millicast/sdk': minor
---

Add `maxWidth` and `maxHeight` resolution constraints to `LayerInfo`, so `View.select()`, `View.project()` and `View.connect({ layer })` can limit the resolution of a video track (0 resets the restriction). Supplying only the dimension limits keeps server side ABR active within those limits; supplying `encodingId`, `spatialLayerId` or `temporalLayerId` still fixes the track to that layer. Matches the `maxWidth`/`maxHeight` constraints already available in the native SDKs.
9 changes: 9 additions & 0 deletions packages/millicast-sdk/src/Signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ export const signalingEvents = {
}

/**
* Layer selection and resolution constraints for a video track.
*
* Supplying only `maxWidth` and/or `maxHeight` does not pin the track to a layer: server side ABR
* stays active and selects the highest layer whose resolution fits within the given limits.
* Supplying `encodingId`, `spatialLayerId` or `temporalLayerId` fixes the track to that layer and
* bypasses ABR.
*
* @typedef {Object} LayerInfo
* @property {String} encodingId - rid value of the simulcast encoding of the track (default: automatic selection)
* @property {Number} spatialLayerId - The spatial layer id to send to the outgoing stream (default: max layer available)
* @property {Number} temporalLayerId - The temporaral layer id to send to the outgoing stream (default: max layer available)
* @property {Number} maxSpatialLayerId - Max spatial layer id (default: unlimited)
* @property {Number} maxTemporalLayerId - Max temporal layer id (default: unlimited)
* @property {Number} [maxWidth] - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
* @property {Number} [maxHeight] - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/millicast-sdk/src/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ export default class View extends BaseWebRTC {
}

/**
* Layer selection and resolution constraints for a video track.
*
* Supplying only `maxWidth` and/or `maxHeight` does not pin the track to a layer: server side ABR
* stays active and selects the highest layer whose resolution fits within the given limits.
* Supplying `encodingId`, `spatialLayerId` or `temporalLayerId` fixes the track to that layer and
* bypasses ABR.
*
* @typedef {Object} LayerInfo
* @property {String} encodingId - rid value of the simulcast encoding of the track (default: automatic selection)
* @property {Number} spatialLayerId - The spatial layer id to send to the outgoing stream (default: max layer available)
* @property {Number} temporalLayerId - The temporaral layer id to send to the outgoing stream (default: max layer available)
* @property {Number} maxSpatialLayerId - Max spatial layer id (default: unlimited)
* @property {Number} maxTemporalLayerId - Max temporal layer id (default: unlimited)
* @property {Number} [maxWidth] - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
* @property {Number} [maxHeight] - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/

/**
Expand Down
42 changes: 42 additions & 0 deletions packages/millicast-sdk/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,21 @@ declare module "@millicast/sdk" {
}

/**
* Layer selection and resolution constraints for a video track.
*
* Supplying only `maxWidth` and/or `maxHeight` does not pin the track to a layer: server side ABR
* stays active and selects the highest layer whose resolution fits within the given limits.
* Supplying `encodingId`, `spatialLayerId` or `temporalLayerId` fixes the track to that layer and
* bypasses ABR.
*
* @typedef {Object} LayerInfo
* @property {String} encodingId - rid value of the simulcast encoding of the track (default: automatic selection)
* @property {Number} spatialLayerId - The spatial layer id to send to the outgoing stream (default: max layer available)
* @property {Number} temporalLayerId - The temporaral layer id to send to the outgoing stream (default: max layer available)
* @property {Number} maxSpatialLayerId - Max spatial layer id (default: unlimited)
* @property {Number} maxTemporalLayerId - Max temporal layer id (default: unlimited)
* @property {Number} [maxWidth] - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
* @property {Number} [maxHeight] - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/
/**
* @typedef {Object} SignalingSubscribeOptions
Expand Down Expand Up @@ -663,6 +672,14 @@ declare module "@millicast/sdk" {
*/
cmd(cmd: string, data?: any): Promise<any>
}
/**
* Layer selection and resolution constraints for a video track.
*
* Supplying only `maxWidth` and/or `maxHeight` does not pin the track to a layer: server side ABR
* stays active and selects the highest layer whose resolution fits within the given limits.
* Supplying `encodingId`, `spatialLayerId` or `temporalLayerId` fixes the track to that layer and
* bypasses ABR.
*/
export type LayerInfo = {
/**
* - rid value of the simulcast encoding of the track (default: automatic selection)
Expand All @@ -684,6 +701,14 @@ declare module "@millicast/sdk" {
* - Max temporal layer id (default: unlimited)
*/
maxTemporalLayerId: number
/**
* - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
*/
maxWidth?: number
/**
* - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/
maxHeight?: number
}
export type SignalingSubscribeOptions = {
/**
Expand Down Expand Up @@ -1203,6 +1228,14 @@ declare module "@millicast/sdk" {
* - Max temporal layer id (default: unlimited)
*/
maxTemporalLayerId: number
/**
* - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
*/
maxWidth?: number
/**
* - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/
maxHeight?: number
}
/**
* - Ask the server to use the playout delay header extension.
Expand Down Expand Up @@ -1511,12 +1544,21 @@ declare module "@millicast/sdk" {
export class View extends BaseWebRTC {
constructor(streamName: string, tokenGenerator: TokenGeneratorCallback, mediaElement?: HTMLVideoElement, autoReconnect?: boolean)
/**
* Layer selection and resolution constraints for a video track.
*
* Supplying only `maxWidth` and/or `maxHeight` does not pin the track to a layer: server side ABR
* stays active and selects the highest layer whose resolution fits within the given limits.
* Supplying `encodingId`, `spatialLayerId` or `temporalLayerId` fixes the track to that layer and
* bypasses ABR.
*
* @typedef {Object} LayerInfo
* @property {String} encodingId - rid value of the simulcast encoding of the track (default: automatic selection)
* @property {Number} spatialLayerId - The spatial layer id to send to the outgoing stream (default: max layer available)
* @property {Number} temporalLayerId - The temporaral layer id to send to the outgoing stream (default: max layer available)
* @property {Number} maxSpatialLayerId - Max spatial layer id (default: unlimited)
* @property {Number} maxTemporalLayerId - Max temporal layer id (default: unlimited)
* @property {Number} [maxWidth] - Max width, in pixels, of the layer to receive. ABR stays active and selects the highest layer not wider than this value (default: unlimited, 0 resets the restriction)
* @property {Number} [maxHeight] - Max height, in pixels, of the layer to receive. ABR stays active and selects the highest layer not taller than this value (default: unlimited, 0 resets the restriction)
*/
/**
* Connects to an active stream as subscriber.
Expand Down
Loading