Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amazon-ivs-web-broadcast

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amazon-ivs-web-broadcast - npm Package Compare versions

Comparing version 1.18.0 to 1.19.0

dist/src/stage/v2/stage-stream/__fixtures__/stage-layers.fixtures.d.ts

10

dist/src/client-common/override-config.d.ts

@@ -19,2 +19,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

disableTokenReuseMessage?: boolean;
enableInitialLayerOnSdp?: boolean;
dataPlaneEndpoint?: string;

@@ -129,1 +130,10 @@ }

export declare function isTokenReuseMessageDisabled(): boolean | undefined;
/**
* Internal API to enable sending the initial video layer preference on
* the SDP offer. This essentially enables simulcast controls from a critical
* path perspective, where as without the current impl is a no-op.
*
* @hidden
* @returns
*/
export declare function isInitialLayerOnSdpEnabled(): boolean | undefined;

3

dist/src/client-common/utils/test.utils.d.ts

@@ -60,2 +60,3 @@ /// <reference types="jest" />

declare function suppressConsoleLogsOnce(...types: Array<LogType>): void;
export { checkBasicEventProperties, makeBasicTestToken, makeTestToken, expectDifferentTraceId, expectSameTraceId, suppressConsoleLogs, suppressConsoleLogsOnce, };
declare function flushPromises(): Promise<void>;
export { checkBasicEventProperties, makeBasicTestToken, makeTestToken, expectDifferentTraceId, expectSameTraceId, suppressConsoleLogs, suppressConsoleLogsOnce, flushPromises, };

@@ -29,2 +29,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

in_band_messaging_enabled: boolean;
simulcast_initial_layer_preference: string;
};

@@ -31,0 +32,0 @@ export declare class MultihostSubscribeConfigurationEvent extends StageAnalyticsEvent {

@@ -7,3 +7,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

export declare class SimulcastLayerInfoEvent extends StageAnalyticsEvent {
constructor(token: StageToken, traceId: TraceId, rid: string, active: boolean, action?: Action, selected?: boolean);
constructor(token: StageToken, traceId: TraceId, rid: string, active: boolean, source?: Action, selected?: boolean, remoteParticipantId?: string);
}

@@ -76,3 +76,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

*/
constructor(token: StageToken, traceId: TraceId, remoteParticipantID: string, sfuResource: SfuResource, curStats?: RTCInboundRtpStreamStats, prevStats?: RTCInboundRtpStreamStats, iceCandidatePairStats?: RTCIceCandidatePairStats, codecStats?: RTCCodecStats, jitterBufferMinDelayInMs?: number);
constructor(token: StageToken, traceId: TraceId, remoteParticipantID: string, sfuResource: SfuResource, curStats?: RTCInboundRtpStreamStats, prevStats?: RTCInboundRtpStreamStats, iceCandidatePairStats?: RTCIceCandidatePairStats, codecStats?: RTCCodecStats, jitterBufferMinDelayInMs?: number, seiReadCnt?: number, seiBytesRead?: number);
}

@@ -79,0 +79,0 @@ /**

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { StreamType } from '../..';
import { TrackType as StreamType } from '../../../client-common/utils/media-track-helpers';
import { type StageToken } from '../token';

@@ -4,0 +4,0 @@ import { StageAnalyticsEvent } from './event';

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { DeepPartial, DeepReadonly } from '../utils/types';
import { InitialLayerPreference } from './schema';
/**

@@ -47,2 +48,8 @@ * Helper for bitrate conversion

export declare const createConfigCopy: <T>(config: T) => T;
/**
* Maps the initial layer preference enum into the outboudn server string.
*
* @param initialPref - Initial layer pref
*/
export declare const mapLayerPreferenceForRequest: (initialPref: InitialLayerPreference) => string;
export * from './tracks/tracks-helpers';

@@ -80,4 +80,15 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

/**
* Configuration property which dictates what layers are initially delivered to
* Subscribers when simulcast is sent by the Publisher.
*
* Default [[InitialLayerPreference.LOWEST_QUALITY]]
*/
export declare enum InitialLayerPreference {
LOWEST_QUALITY = "lowest_quality",
HIGHEST_QUALITY = "highest_quality"
}
/**
* Jitter buffer configuration, internal model
*
* @internal
* Jitter buffer configuration, internal model
*/

@@ -89,3 +100,2 @@ export interface InternalJitterBufferConfig {

/**
* @internal
* InBandMessaging subscribe configuration, internal model

@@ -97,4 +107,13 @@ */

/**
* Simulcast configuration, internal model
*
* @internal
*/
export interface InternalSimulcastSubscriberConfig {
initialLayerPreference: InitialLayerPreference;
}
/**
* Subscribe configuration, internal model
*
* @internal
*/

@@ -104,6 +123,7 @@ export interface InternalSubscribeConfig {

inBandMessaging: InternalInBandMessagingSubscribeConfig;
simulcast: InternalSimulcastSubscriberConfig;
}
/**
* Jitter buffer configuration
**/
*/
export interface JitterBufferConfiguration {

@@ -121,5 +141,8 @@ /**

}
export interface SimulcastSubscribeConfiguration {
initialLayerPreference?: InitialLayerPreference;
}
/**
* Subscribe configuration, applies to participants who are being subscribed to.
**/
*/
export interface SubscribeConfiguration {

@@ -134,2 +157,6 @@ /**

inBandMessaging?: InBandMessagingSubscribeConfiguration;
/**
* Optional configuration to apply specific simulcast, like initial layers
*/
simulcast?: SimulcastSubscribeConfiguration;
}

@@ -136,0 +163,0 @@ /****************************

@@ -604,2 +604,8 @@ import { BroadcastClientError } from '../../../client-common/errors';

};
readonly TRANSFORM_NOT_SUPPORTED_BY_PLATFORM: {
readonly code: 1482;
readonly message: "Transforms are not supported by this platform";
readonly fatal: false;
readonly nominal: false;
};
/** Multi-codec related errors */

@@ -606,0 +612,0 @@ readonly CODEC_HANDLE_INCOMPATIBLE_UNEXPECTED_ERROR: {

@@ -7,2 +7,3 @@ import { AnalyticsTracker } from '../../client-common/analytics/analytics-tracker';

import { InternalAudioTrackWithConfig, InternalVideoTrackWithConfig } from './configuration/schema';
import { VideoReceiverTransformer } from './peer-client/transceiver-transform';
/**

@@ -15,2 +16,3 @@ * TODO: This class currently depends on peer connection state being passed to it to determine what kinds

private analyticsTracker;
private receiveVideoTransformer;
traceId: TraceId;

@@ -36,3 +38,4 @@ private action;

private jitterBufferMinDelayInMs;
constructor(action: Action, token: StageToken, traceId: TraceId, identifier: string, analyticsTracker: AnalyticsTracker);
private prevVideoReceiverTransformerStats;
constructor(action: Action, token: StageToken, traceId: TraceId, identifier: string, analyticsTracker: AnalyticsTracker, receiveVideoTransformer: VideoReceiverTransformer);
private static defaultMultihostConfiguration;

@@ -62,2 +65,3 @@ /**

private uploadSubscriberStats;
private updateAndDiffSinceLastUpdate;
/**

@@ -64,0 +68,0 @@ * Returns the outbound and previous outbound stat report for audio

@@ -9,3 +9,3 @@ import { SfuResource } from '../../client-common/types';

import { type StageToken } from './token';
import { InternalTrackWithConfig, InternalJitterBufferConfig } from './configuration/schema';
import { InternalTrackWithConfig, InternalSubscribeConfig } from './configuration/schema';
import { IncompatibleCodec, StageConnection } from './stage-connection';

@@ -42,2 +42,3 @@ import { TypedEmitter } from './typed-emitter';

private inBandMessagingEnabled;
private simulcastSubscribeConfig?;
private mediaStream?;

@@ -69,5 +70,5 @@ private action;

*/
constructor(token: StageToken, logger: Logger, action: Action, tag: string, traceId: TraceId, analyticsTracker: AnalyticsTracker, subscriberId?: string, stageConnection?: StageConnection, jitterBufferConfig?: InternalJitterBufferConfig, inBandMessagingEnabled?: boolean);
constructor(token: StageToken, logger: Logger, action: Action, tag: string, traceId: TraceId, analyticsTracker: AnalyticsTracker, subscriberId?: string, stageConnection?: StageConnection, subscribeConfig?: InternalSubscribeConfig);
private toggleStageConnectionListeners;
updateJitterBufferConfig(config: InternalJitterBufferConfig): void;
updateSubscribeConfig(config: InternalSubscribeConfig): void;
connect: ({ audioOnly, traceId, iceRestartOptions, }: {

@@ -175,2 +176,3 @@ audioOnly?: boolean | undefined;

private createVideoReceiverTransformer;
private handleTransformNotSupported;
/**

@@ -210,2 +212,3 @@ * Emits Spade events with media track stats on [[ConnectionState]] changes.

onIncompatibleCodecs: (codecs: IncompatibleCodec[]) => Promise<void>;
sendSeiMessage(msg: ArrayBuffer): void;
}

@@ -21,2 +21,12 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

}
export declare type EnqueuedPayload = {
id: string;
payload: ArrayBuffer;
enqueuedAt: number;
};
export interface MessageQueue {
add: (payload: ArrayBuffer) => string;
poll: (sourceId: number) => EnqueuedPayload[];
}
export declare function createMessageQueue(layers: number): MessageQueue;
/**

@@ -31,3 +41,3 @@ * Transforms a frame being sent (i.e. published).

type: TransformType;
payload?: ArrayBuffer[];
payloads?: ArrayBuffer[];
}): RTCEncodedVideoFrame;

@@ -34,0 +44,0 @@ /**

@@ -18,3 +18,8 @@ import { SeiMessage } from '../../../client-common/types';

transformerId: string;
encodingLayers?: number;
};
export declare type VideoReceiverTransformStats = {
seiReadCnt: number;
seiBytesRead: number;
};
export declare type VideoReceiverTransformerEventMap = {

@@ -24,2 +29,7 @@ [VideoReceiverTransformerEvents.SEI_MESSAGE_RECEIVED]: (seiMessage: SeiMessage) => void;

};
export declare const enum TransformerState {
CREATED = "created",
INITIALIZED = "initialized",
DESTROYED = "destroyed"
}
/**

@@ -30,10 +40,18 @@ * Handles video receiver transforms (i.e. subscribe) and abstracts away the

export declare class VideoReceiverTransformer extends TypedEmitter<VideoReceiverTransformerEventMap> {
private transformSupport;
private state;
private transformerId;
private transceiver;
private transceiver?;
private worker?;
private isDestroyed;
private prevResultWasError;
private consecutiveErrorResults;
constructor(transceiver: RTCRtpTransceiver);
private seiReadCnt;
private seiBytesRead;
constructor({ enabled }: {
enabled: boolean;
});
private initializeInsertableStreams;
private initializeEncodedTransforms;
private initialize;
onTransceiverAdd(transceiver: RTCRtpTransceiver): boolean;
onTrackEvent(event: RTCTrackEvent): boolean;
/**

@@ -60,2 +78,4 @@ * Handles the message event from the worker.

private onTransformResult;
private updateReadStats;
getReceiverStats(): VideoReceiverTransformStats;
/**

@@ -71,2 +91,8 @@ * Emits an error event on unsuccessful results

destroy(): void;
/**
* Gets the transformer's state
*
* @returns the transformer's state
*/
getState(): TransformerState;
}

@@ -78,8 +104,30 @@ /**

export declare class VideoSenderTransformer {
private transformSupport;
private state;
private transformerId;
constructor(transceiver: RTCRtpTransceiver);
private transceiver?;
private worker?;
constructor({ enabled }: {
enabled: boolean;
});
/**
* Chrome Insertable Streams initialization
*/
private initializeInsertableStreams;
/**
* Safari/FF Encoded Transforms initialization
*/
private initializeEncodedTransforms;
private initialize;
static isSupported(transceiver: RTCRtpTransceiver): boolean;
sendMessage(payload: ArrayBuffer): void;
sendSeiMessage(payload: ArrayBuffer): void;
onTransceiverAdd(transceiver: RTCRtpTransceiver): boolean;
onTrackEvent(event: RTCTrackEvent): boolean;
destroy(): void;
/**
* Gets the transformer's state
*
* @returns the transformer's state
*/
getState(): TransformerState;
}
export {};

@@ -8,2 +8,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

import { StageToken } from '../token';
import { InitialLayerPreference } from '../configuration/schema';
import { BaseSdpExchanger } from './sdp-exchanger';

@@ -31,2 +32,3 @@ /**

abortController?: AbortController;
initialLayerPreference?: InitialLayerPreference;
}): Promise<WHIPServerResponse | undefined>;

@@ -33,0 +35,0 @@ private trackAttempt;

@@ -6,2 +6,3 @@ import { AnalyticsTracker } from '../../../client-common/analytics/analytics-tracker';

import { StageToken } from '../token';
import { InitialLayerPreference } from '../configuration/schema';
import { BaseSdpExchanger } from './sdp-exchanger';

@@ -23,2 +24,3 @@ export declare class HttpSdpExchanger extends BaseSdpExchanger {

abortController?: AbortController;
initialLayerPreference?: InitialLayerPreference;
}): Promise<WHIPServerResponse | undefined>;

@@ -25,0 +27,0 @@ /**

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { WHIPServerResponse } from '../../../client-common/types';
import { TraceId } from '../analytics/random.uuid';
import { InitialLayerPreference } from '../configuration/schema';
import { StageToken } from '../token';

@@ -14,2 +15,3 @@ export interface SdpExchanger {

abortController?: AbortController;
initialLayerPreference?: InitialLayerPreference;
}): Promise<WHIPServerResponse | undefined>;

@@ -29,4 +31,5 @@ getTransport(): string;

abortController?: AbortController;
initialLayerPreference?: InitialLayerPreference;
}): Promise<WHIPServerResponse | undefined>;
abstract getTransport(): string;
}

@@ -6,2 +6,3 @@ import { AnalyticsTracker } from '../../client-common/analytics/analytics-tracker';

import { StageToken } from './token';
import { InitialLayerPreference } from './configuration/schema';
export declare enum StageSocketMessageEvent {

@@ -84,3 +85,3 @@ MESSAGE = "message",

private beforeUnload;
sendSdpOffer: (sdpOffer: string, url: string, traceId: string, requestUUID: string, forceNode?: string, assignmentToken?: string, multiCodec?: boolean) => void;
sendSdpOffer: (sdpOffer: string, url: string, traceId: string, requestUUID: string, forceNode?: string, assignmentToken?: string, multiCodec?: boolean, initialLayerPref?: InitialLayerPreference) => void;
/**

@@ -87,0 +88,0 @@ * Get retry count based on total connection attempts.

@@ -9,2 +9,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

import { StagePeerClient } from './peer-client';
import { InitialLayerPreference } from './configuration/schema';
/**

@@ -252,4 +253,4 @@ * Participant Type

*/
exchangeSdp(sdpOffer: string, url: string, traceId: string, requestUUID: string, signal?: AbortSignal, forceNode?: string, assignmentToken?: string, multiCodec?: boolean): Promise<StageSdpAnswerMessage>;
exchangeSdp(sdpOffer: string, url: string, traceId: string, requestUUID: string, signal?: AbortSignal, forceNode?: string, assignmentToken?: string, multiCodec?: boolean, initialLayerPreference?: InitialLayerPreference): Promise<StageSdpAnswerMessage>;
}
export {};

@@ -123,2 +123,16 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

readonly TRANSFORM_ERROR: "transformError";
/**
* Indicates that the underlying subscription has started a reassignment to
* a new node.
*
*/
readonly REASSIGNMENT_STARTED: "reassignmentStarted";
/**
* Indicates that the underlying subscription has completed a reassignment.
*/
readonly REASSIGNMENT_SUCCESS: "reassignmentSuccess";
/**
* Indicates that the underlying reassignment has failed.
*/
readonly REASSIGNMENT_FAILED: "reassignmentFailed";
};

@@ -187,2 +201,5 @@ export declare const BroadcastStageSocketEvents: {

[BroadcastStageSubscriptionEvents.TRANSFORM_ERROR]: (error: StageClientError) => void;
[BroadcastStageSubscriptionEvents.REASSIGNMENT_STARTED]: () => void;
[BroadcastStageSubscriptionEvents.REASSIGNMENT_SUCCESS]: () => void;
[BroadcastStageSubscriptionEvents.REASSIGNMENT_FAILED]: () => void;
};

@@ -189,0 +206,0 @@ export declare type BroadcastStageSocketOpenPayload = {

@@ -17,3 +17,4 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

STATE_CHANGE = "stateChange",
ERROR = "error"
ERROR = "error",
TRANSFORM_ERROR = "transformError"
}

@@ -23,2 +24,3 @@ declare type PublicationEventMap = {

[StagePublicationEvents.ERROR]: (error: StageClientError) => void;
[StagePublicationEvents.TRANSFORM_ERROR]: (error: StageClientError) => void;
};

@@ -52,2 +54,3 @@ export declare class StagePublication extends TypedEmitter<PublicationEventMap> {

private onPeerClientConnectionStateChange;
private onPeerClientTransformError;
/**

@@ -60,3 +63,4 @@ * Receive notice of incompatible codec.

onIncompatibleCodecs: (codecs: IncompatibleCodec[]) => Promise<void>;
sendSeiMessage: (msg: ArrayBuffer) => void;
}
export {};

@@ -84,2 +84,3 @@ import { AnalyticsTracker } from '../../client-common/analytics/analytics-tracker';

private attemptToActualizeSubscribeType;
private applyVideoControlsBySubscribeType;
private onParticipantUpdated;

@@ -86,0 +87,0 @@ private onParticipantJoined;

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import type { RemoteLayerState } from '../remote-playback-controller-schema';
export declare type MockResponse = {

@@ -10,2 +11,3 @@ params: {

export declare const mockResponseOnce: ({ body, params }: MockResponse) => void;
export declare const mockResponse: ({ body, params }: MockResponse) => void;
export declare const mockRejectionOnce: ({ body, params }: MockResponse) => void;

@@ -17,1 +19,2 @@ export declare const GENERIC_SUCCESS_200: MockResponse;

export declare const LAYER_RESPONSE_200: MockResponse;
export declare const custom200LayerResponse: (layers: RemoteLayerState[]) => MockResponse;
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { AnalyticsTracker } from '../../../client-common/analytics/analytics-tracker';
import { Logger } from '../../../client-common/logger';
import { TraceId } from '../analytics/random.uuid';
import { StageToken } from '../token';
import * as R from '../utils/result';
import type { AnalyticsTracker } from '../../../client-common/analytics/analytics-tracker';
import type { Logger } from '../../../client-common/logger';
import type { TraceId } from '../analytics/random.uuid';
import type { StageToken } from '../token';
import type { Ok, Err } from '../utils/result';
export declare enum PlaybackControlAction {

@@ -29,2 +29,3 @@ PAUSE = "pause",

analyticsTracker: AnalyticsTracker;
remoteParticipantId: string;
};

@@ -45,4 +46,4 @@ export declare enum RemotePlaybackControllerState {

}
export declare type RemotePlaybackSuccess = R.Ok<RemotePlaybackSuccessOption>;
export declare type RemotePlaybackFailed = R.Err<RemotePlaybackErrorOption>;
export declare type RemotePlaybackSuccess = Ok<RemotePlaybackSuccessOption>;
export declare type RemotePlaybackFailed = Err<RemotePlaybackErrorOption>;
export declare type RemotePlaybackResult = RemotePlaybackSuccess | RemotePlaybackFailed;

@@ -57,5 +58,5 @@ export declare type RemoteLayerState = {

};
export declare type RemoteLayerRequestSuccess = R.Ok<RemotePlaybackSuccessOption>;
export declare type RemoteLayerRequestFailed = R.Err<RemotePlaybackErrorOption>;
export declare type RemoteLayerRequestSuccess = Ok<RemotePlaybackSuccessOption>;
export declare type RemoteLayerRequestFailed = Err<RemotePlaybackErrorOption>;
export declare type RemoteLayerRequestResult = RemoteLayerRequestSuccess | RemoteLayerRequestFailed;
export declare type RemoteLayerStateResults = R.Ok<RemoteLayerState[]> | RemoteLayerRequestFailed;
export declare type RemoteLayerStateResults = Ok<RemoteLayerState[]> | RemoteLayerRequestFailed;
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { TraceId } from '../analytics/random.uuid';
import { RemoteLayerRequestResult, RemoteLayerStateResults, RemotePlaybackControllerData, RemotePlaybackControllerEndpoints, RemotePlaybackControllerState, RemotePlaybackResult } from './remote-playback-controller-schema';
import { type RemoteLayerRequestResult, type RemoteLayerStateResults, type RemotePlaybackControllerData, type RemotePlaybackControllerEndpoints, RemotePlaybackControllerState, type RemotePlaybackResult } from './remote-playback-controller-schema';
/**

@@ -22,2 +22,3 @@ * Given an associated media ID corresponding to a Mercury session this

private layersEndpoint;
private remoteParticipantId;
/**

@@ -24,0 +25,0 @@ * Initialize controller with data

@@ -10,3 +10,4 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

export { StageStream } from './v2/stage-stream/stage-stream';
export { type StageAudioConfiguration, type StageVideoConfiguration, type SimulcastConfiguration, type JitterBufferConfiguration, type SubscribeConfiguration, type InBandMessagingSubscribeConfiguration, JitterBufferMinDelay, } from './core-api/configuration/schema';
export { RemoteStageStreamEvents, LocalStageStreamEvents, type StageStreamLayer, StageStreamLayerSelectedReason, } from './v2/stage-stream/stage-stream-schema';
export { type StageAudioConfiguration, type StageVideoConfiguration, type SimulcastConfiguration, type JitterBufferConfiguration, type SubscribeConfiguration, type InBandMessagingSubscribeConfiguration, type SimulcastSubscribeConfiguration, InitialLayerPreference, JitterBufferMinDelay, } from './core-api/configuration/schema';
export { type StageParticipantInfo, StageParticipantPublishState, StageParticipantSubscribeState, } from './v2/stage-participant/stage-participant';

@@ -13,0 +14,0 @@ export type { StageStrategy } from './v2/stage-strategy';

@@ -5,2 +5,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

import { LocalStageStream } from '../stage-stream/stage-stream-local';
import { StageStrategy } from '../stage-strategy';
export declare const defaultStrategy: {

@@ -57,1 +58,7 @@ stageStreamsToPublish(): never[];

};
export declare const defaultLayerStrategy: StageStrategy;
export declare const lowLayerStrategy: StageStrategy;
export declare const midLayerObjectStrategy: StageStrategy;
export declare const lowestQualityStrategy: StageStrategy;
export declare const highestQualityStrategy: StageStrategy;
export declare const hiInitialLayerStrategy: StageStrategy;

@@ -58,2 +58,25 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

/**
* Indicates that a stream's available layers state has been changed
*
* @param payload - [ StageParticipantInfo, StageStream, StageStreamLayer[] ]
* @event stageStreamLayersChanged
*/
STAGE_STREAM_LAYERS_CHANGED = "stageStreamLayersChanged",
/**
* Indicates that a stream layer has been selected based on the preferredLayerForStream strategy
*
* @param payload - [ StageParticipantInfo, StageStream, StageStreamLayer, StageStreamLayerSelectedReason ]
* @event stageStreamLayerSelected
*/
STAGE_STREAM_LAYER_SELECTED = "stageStreamLayerSelected",
/**
* Indicates that a stream's adaption state has changed, and whether it will automatically adapt
* based on network conditions, or be controlled manually based on the preferredLayerForStream
* values.
*
* @param payload - [ StageParticipantInfo, StageStream, Adaption ]
* @event stageStreamAdaptionChanged
*/
STAGE_STREAM_ADAPTION_CHANGED = "stageStreamAdaptionChanged",
/**
* Indicates a change to participant subscribtion state

@@ -85,5 +108,5 @@ *

* @event reason
* @internal
* @public
*/
STAGE_LEFT = "stageLeft"
}

@@ -51,2 +51,16 @@ import { IncompatibleCodec, StageConnection } from '../../core-api/stage-connection';

onIncompatibleCodecs: (codecs: IncompatibleCodec[]) => Promise<void>;
/**
* Send an SEI payload
*
* @param msg - The byte array to send
* @internal
*/
sendSeiMessage: (msg: ArrayBuffer) => void;
/**
* A internal helper function for sending SeiMessage strings more easily
*
* @param msg - The string payload to send
* @internal
*/
sendSeiMessageString: (msg: string) => void;
}

@@ -36,2 +36,4 @@ import { InternalSubscribeConfig } from '../../core-api/configuration/schema';

private onSubscriptionTransformError;
private onSubscriptionReassignmentStart;
private onSubscriptionReassignmentDone;
updateSubscribeStateIfNecessary: (newSubscribeType: SubscribeType, subscribeConfig?: InternalSubscribeConfig) => void;

@@ -38,0 +40,0 @@ updatePublishState: (isPublishing: boolean) => boolean;

@@ -9,11 +9,54 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

import { LocalStageStream } from './stage-stream/stage-stream-local';
import { RemoteStageStream } from './stage-stream/stage-stream-remote';
import { StageStreamLayer } from './stage-stream/stage-stream-schema';
/**
* Safely processes the defined strategy methods, and retrieves the necessary state
* returning the results into the internal Stage abstractions.
*/
export declare class StageStrategyWrapper {
private strategy;
private logger;
/**
* Create the wrapper strategy
*
* @param strategy - Customer defined strategy instance
* @param logger - logger
*/
constructor(strategy: StageStrategy, logger: ScopedLogger);
/**
* Updates the strategy
*
* @param strategy - New customer defined strategy instance
*/
setStrategy(strategy: StageStrategy): void;
/**
* Executes and returns a result containing the desired local stage streams
* the publishers wishes to send.
*/
stageStreamsToPublish(): Result<LocalStageStream[], Error>;
/**
* Executes and returns whether or not the publisher should automatically publish
*
* @param participantInfo - Publisher specific info for the local participant
*/
shouldPublishParticipant(participantInfo: StageParticipantInfo): Result<boolean, Error>;
/**
* Executes and returns how a subscriber should be subscribed to.
*
* @param participantInfo - Which remote participant to act on
*/
shouldSubscribeToParticipant(participantInfo: StageParticipantInfo): Result<SubscribeType, Error>;
/**
* Executs and returns the subscribe configuration for a specific participant
*
* @param participantInfo - Which remote participant to act on
*/
subscribeConfiguration(participantInfo: StageParticipantInfo): Result<SubscribeConfiguration | undefined, Error>;
/**
* Executes and return the preferrer layer for a particular remote participants stream.
*
* @param participantInfo - Which remote participant to act on
* @param remoteStream - Remote stream on which to apply the layer preferences
*/
preferredLayerForStream(participantInfo: StageParticipantInfo, remoteStream: RemoteStageStream): Result<StageStreamLayer | string | undefined>;
}
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { SubscribeConfiguration } from '../core-api/configuration/schema';
import { SubscribeType } from '../core-api/stage-subscription';
import { StageParticipantInfo } from './stage-participant/stage-participant';
import { LocalStageStream } from './stage-stream/stage-stream-local';
import type { SubscribeConfiguration } from '../core-api/configuration/schema';
import type { SubscribeType } from '../core-api/stage-subscription';
import type { StageParticipantInfo } from './stage-participant/stage-participant';
import type { LocalStageStream } from './stage-stream/stage-stream-local';
import type { RemoteStageStream } from './stage-stream/stage-stream-remote';
import type { StageStreamLayer } from './stage-stream/stage-stream-schema';
/**

@@ -32,2 +34,8 @@ * A StageStrategy dictates certain behavior on the [[Stage]]

subscribeConfiguration?(participant: StageParticipantInfo): SubscribeConfiguration;
/**
* Optionally return the preferred stream layer for a given participant. If defined, the returned [[StageStreamLayer]] will be used
* to change what video layer is delivered. This is used when a Publisher is sending Simulcast Layers, and allows the Subscriber
* to choose between those layers.
*/
preferredLayerForStream?(participant: StageParticipantInfo, stream: RemoteStageStream): StageStreamLayer | string | undefined;
}
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { TrackType as StreamType } from '../../../../client-common/utils/media-track-helpers';
import { AnalyticsTracker } from '../../../../client-common/analytics/analytics-tracker';
import { Logger } from '../../../../client-common/logger';
import { StageAudioConfiguration, StageVideoConfiguration } from '../../../core-api/configuration/schema';
import { RemotePlaybackController } from '../../../core-api/whep/remote-playback-controller';
import { InternalStageStream } from '../stage-stream-internal';
import { LocalStageStream } from '../stage-stream-local';
import { RemoteStageStream } from '../stage-stream-remote';
export declare function createInternalStream(track: MediaStreamTrack): InternalStageStream;
export declare function createInternalVideoStream(muted?: boolean): InternalStageStream;
export declare function createInternalStream(opts: {
track: MediaStreamTrack;
}): {
createStream: () => InternalStageStream;
logger: Logger;
analyticsTracker: AnalyticsTracker;
remotePlaybackController: RemotePlaybackController;
token: import("../../../core-api/token").StageToken;
};
export declare function createInternalVideoStream(opts?: {
muted?: boolean;
}): InternalStageStream;
export declare function createInternalStreamWithMocks(opts?: {
muted?: boolean;
streamType?: StreamType;
}): {
createStream: () => InternalStageStream;
logger: Logger;
analyticsTracker: AnalyticsTracker;
remotePlaybackController: RemotePlaybackController;
token: import("../../../core-api/token").StageToken;
};
export declare function createInternalAudioStream(muted?: boolean): InternalStageStream;

@@ -9,0 +33,0 @@ export declare function createRemoteStream(track: MediaStreamTrack): RemoteStageStream;

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { Result } from '../../core-api/utils/result';
import type { RemoteLayerState } from '../../core-api/whep/remote-playback-controller-schema';
import { InternalStageStream } from './stage-stream-internal';
import { RemoteStageStream } from './stage-stream-remote';
import { StageStreamLayer } from './stage-stream-schema';
export declare const DEFAULT_POLLING_DURATION = 3000;
/**

@@ -10,1 +14,24 @@ * Maps remote streams from internal ones

export declare function mapRemoteStreams(streams: InternalStageStream[]): RemoteStageStream[];
/**
* Converts the WHIP request layer state into our public layer state.
*
* @param layer - Remote layer state to convert to external state
*/
export declare function convertRemoteLayerToPublic(layer: RemoteLayerState): StageStreamLayer;
/**
* Sorts the layers array from lowest quality to highest quality. Quality here is defined
* as follows:
* https://tiny.amazon.com/56pw9hcn/docsgoogdocud12n5editkmn7
*
* @param layerA - First layer to compare
* @param layerB - Second layer to compare against the first layer
* @returns 1 if A is greater than B, 0 if the same, -1 if less than
*/
export declare function sortLayersByHighestQuality(layerA: StageStreamLayer, layerB: StageStreamLayer): number;
/**
* Converts an incoming layer request from either a string id or object, in the desired layer.
*
* @param preferredLayer - The target layer to select
* @param layers - The available layers to choose from
*/
export declare function coalesceCompositeLayerChoice(preferredLayer: StageStreamLayer | string | undefined, layers: StageStreamLayer[]): Result<StageStreamLayer | undefined, string>;
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { StageParticipantInfo } from '../stage-participant/stage-participant';
import { InternalStageStreamData, InternalStageStreamEventMap } from './stage-stream-schema';
import { type InternalStageStreamData, type InternalStageStreamEventMap, StageStreamLayer } from './stage-stream-schema';
import { StageStream } from './stage-stream';

@@ -13,6 +13,16 @@ import { RemoteStageStream } from './stage-stream-remote';

export declare class InternalStageStream extends StageStream<InternalStageStreamEventMap> {
private _isAdapting;
private _layers;
private _selectedLayer;
private state;
private prevState;
private token;
private analyticsTracker;
private info;
private remotePlaybackController;
private logger;
private layerPollingTimeoutId;
private weakRemoteMap;
private weakRemoteKey;
private commandMap;
/**

@@ -24,6 +34,94 @@ * Creates an instance of a StageStream

*/
constructor({ track, info, getStats, analyticsTracker, token }: InternalStageStreamData);
constructor({ track, info, getStats, remotePlaybackController, analyticsTracker, token }: InternalStageStreamData);
/**
* TODO: Implement FSM from shared web-std-lib here
*
* @param state - State to transition to
*/
private transitionStateTo;
/**
* Poll the layer endpoint for active layers and layer changes
*/
private initializeLayerPolling;
private startLayerPolling;
private stopLayerPolling;
/**
* Periodically requests layers from the remote endpoints
*/
private pollInternalLayers;
/**
* Converts the remote layer array from the WHEP control endpoint, into our
* internal (and eventually external API) layer state representation.
*
* @param remoteLayers - Remote layers from the WHEP endpoint
*/
private updateInternalLayersFromRemote;
/**
* When initializing the stream, any commands which arrive before we have our
* first meaningful state update may be thrown away due to invalid state, which
* is not necessarily true.
*
* The INITIALIZING state alongside the map ensures we replay setLayer and related
* commands while awaiting our first valid state from the media data plane. The
* most recent of the command invocations is kept to debounce potentially numerous calls.
*/
private flushCommandQueue;
/**
* Will queue manual updates if we're still initializing, as they may be valid once
* the initial layer state is received.
*
* Otherwise dynamic updates can pass through as existing stream state is maintained
* and awaits the next polled updates.
*
* @param nextLayer - Next layer to check for queueing, assumed to be immutable
*/
private queueLayerUpdateForValidState;
/**
* Transition into dynamic adaption mode. In this case we continue to persist
* selected layer state and will rely on the polled layer update for new state
*/
private handleDynamicUpdate;
private resetAdaptionStateOnError;
/**
* With a manual mode update, an explicit layer choice is being made which
* will disable dynamic adaption.
*
* @param nextLayer - Next layer to update as manually selected
*/
private handleManualUpdate;
/**
* Forces an state update depending on dynamic or manual adaption modes to
* ensure client state is in sync with server state.
*/
private applyExistingControlState;
private resetLayerOnError;
/**
* Map local layer state into the instance state in the interim while we
* await a state update from polling the remote layer state.
*
* @param nextLayer - Layer to update to
* @param prevLayer - Layer to update from
*/
private updateLocalLayerStateBeforeRemote;
/**
* Ensure metrics reflect the current state of the selected layers
*
* @param layer - Layer to emit tracking events for
*/
private trackLayerUpdate;
private isNextUpdateAdaptionOnly;
private isFirstLayerUpdate;
private isRepeatLayerSelection;
private isStateValidForLayerUpdates;
private isCommandQueueEmpty;
private emitLayerSelected;
private emitLayersChanged;
private emitAdaptionChanged;
/**
* Returns the remote facade which wraps the internal stage stream to prevent
* undesired mutations to events and state.
*
* We also utilize a WeakMap here to offer some consistency with regards to
* event listeners already applied, but not retaining memory if customers
* hand this around their application.
*/

@@ -36,2 +134,36 @@ get remote(): RemoteStageStream;

/**
* Returns whether the layer is currently dynamically adjusting the video layer
* based on network conditions, or relying on a manual selection.
*/
get isAdapting(): boolean;
/**
* Returns the list of all current Stage Stream Layers
*
*/
get layers(): StageStreamLayer[];
/**
* Returns the currently selected layer for the streams.
*
* @internal
*/
get selectedLayer(): StageStreamLayer | undefined;
/**
* Returns the highest quality layer for a particular stream.
*
* @internal
*/
get highestQualityLayer(): StageStreamLayer | undefined;
/**
* Returns the highest quality layer for a particular stream.
*
* @internal
*/
get lowestQualityLayer(): StageStreamLayer | undefined;
/**
* Returns the list of layers which matches the supplied constraints
*
* @param constraints - What the constraints should be to match for a layer
* @internal
*/
/**
* Mute or unmute a participant remotely

@@ -42,2 +174,20 @@ *

setMuted: (mute: boolean) => void;
/**
* Set or unset the target layer for the current stream.
*
* @param layer - Target layer to set or unset
*/
setLayer: (layer: StageStreamLayer | string | undefined) => void;
/**
* Aggregate command that pauses all outbound and inbound playback control operations.
* This is primarily useful during periods where the connection may be in a bad state, or
* other transition states where control requests are most likely invalid.
*/
pauseControls(): void;
/**
* Resumes layer control requests, and re-applies layer state to ensure that current
* local state is reflected in the remote server.
*/
resumeControls(): void;
cleanup(): void;
}
/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { TypedEmitter } from '../../core-api/typed-emitter';
import { RemoteStageStreamEventMap } from './stage-stream-schema';
import { InternalStageStream } from './stage-stream-internal';
import { type RemoteStageStreamEventMap, StageStreamLayer } from './stage-stream-schema';
import type { InternalStageStream } from './stage-stream-internal';
import { StageStream } from './stage-stream';

@@ -27,2 +27,3 @@ /**

set isMuted(muted: boolean);
get isAdapting(): boolean;
requestRTCStats: () => Promise<RTCStatsReport | undefined>;

@@ -42,2 +43,16 @@ /**

/**
* Returns the list of all current Stage Stream Layers
*
* @internal
*/
getLayers: () => StageStreamLayer[];
/**
* Returns the currently selected layer for the streams.
*
* @internal
*/
getSelectedLayer: () => StageStreamLayer | undefined;
getLowestQualityLayer: () => StageStreamLayer | undefined;
getHighestQualityLayer: () => StageStreamLayer | undefined;
/**
* Cleans up the Stage Stream so no additional events will fire.

@@ -44,0 +59,0 @@ */

/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */
import { AnalyticsTracker } from '../../../client-common/analytics/analytics-tracker';
import { StageToken } from '../../core-api/token';
import { EventMap } from '../../core-api/typed-emitter';
import { StageParticipantInfo } from '../stage-participant/stage-participant';
import type { AnalyticsTracker } from '../../../client-common/analytics/analytics-tracker';
import type { StageToken } from '../../core-api/token';
import type { RemotePlaybackController } from '../../core-api/whep/remote-playback-controller';
import type { StageParticipantInfo } from '../stage-participant/stage-participant';
export declare type GetStatsFunction = (track: MediaStreamTrack) => Promise<RTCStatsReport | undefined>;

@@ -11,13 +11,59 @@ export interface InternalStageStreamData {

getStats: GetStatsFunction;
remotePlaybackController: RemotePlaybackController;
analyticsTracker: AnalyticsTracker;
token: StageToken;
}
export declare enum InternalStageStreamState {
IDLE = "IDLE",
INITIALIZING = "INITIALIZING",
ACTIVE = "ACTIVE",
CONTROLS_PAUSED = "CONTROLS_PAUSED",
DESTROYED = "DESTROYED"
}
export declare enum InternalStageStreamEvents {
LAYERS_CHANGED = "LAYERS_CHANGED",
LAYER_SELECTED = "LAYER_SELECTED",
ADAPTION_CHANGED = "ADAPTION_CHANGED"
}
export declare type InternalStageStreamEventMap = EventMap;
export declare type InternalStageStreamEventMap = {
[InternalStageStreamEvents.LAYERS_CHANGED]: (layers: StageStreamLayer[]) => void;
[InternalStageStreamEvents.LAYER_SELECTED]: (layer: StageStreamLayer | undefined, reason: StageStreamLayerSelectedReason) => void;
[InternalStageStreamEvents.ADAPTION_CHANGED]: (adaption: boolean) => void;
};
export declare type InternalStageStreamCommand = () => void;
export declare type InternalStageStreamCommandKey = 'setLayer';
export declare enum RemoteStageStreamEvents {
LAYERS_CHANGED = "LAYERS_CHANGED",
LAYER_SELECTED = "LAYER_SELECTED",
ADAPTION_CHANGED = "ADAPTION_CHANGED"
}
export declare type RemoteStageStreamEventMap = EventMap;
export declare type RemoteStageStreamEventMap = {
[RemoteStageStreamEvents.LAYERS_CHANGED]: (layers: StageStreamLayer[]) => void;
[RemoteStageStreamEvents.LAYER_SELECTED]: (layer: StageStreamLayer | undefined, reason: StageStreamLayerSelectedReason) => void;
[RemoteStageStreamEvents.ADAPTION_CHANGED]: (adaption: boolean) => void;
};
export declare type StageStreamLayerConstraints = {
maxBitrateBps: number;
minBitrateBps: number;
maxFramerate: number;
minFramerate: number;
maxWidth: number;
minWidth: number;
maxHeight: number;
minHeight: number;
};
export declare type StageStreamLayer = {
label: string;
bitrateBps: number;
width: number;
height: number;
framesPerSecond: number;
selected: boolean;
};
export declare enum StageStreamLayerSelectedReason {
UNAVAILABLE = "unavailable",
SELECTED = "selected"
}
export declare enum LocalStageStreamEvents {
LOCAL_STREAM_MUTE_CHANGED = "localStreamMutedChanged"
}

@@ -41,3 +41,3 @@ /*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */

*/
cleanup: () => void;
cleanup(): void;
}

@@ -11,2 +11,4 @@ import { LogLevels } from '../../client-common/logger/logger.types';

import { StageEvents } from './stage-events';
import { StageStreamLayer, StageStreamLayerSelectedReason } from './stage-stream/stage-stream-schema';
import { RemoteStageStream } from './stage-stream/stage-stream-remote';
/** @hidden */

@@ -55,2 +57,3 @@ declare global {

private setupRemoteParticipantListeners;
private setupRemoteParticipantStreamEvents;
private onRemoteParticipantLeft;

@@ -89,2 +92,3 @@ private emitParticipantLeave;

private determineStreamUpdates;
private updateStreamLayerForParticipant;
/**

@@ -118,3 +122,3 @@ * Reads the StageDisconnectMessage code and handles the event.

*
* @internal
* @public
* @enum

@@ -159,4 +163,7 @@ */

[StageEvents.STAGE_STREAM_MUTE_CHANGED]: (participantInfo: StageParticipantInfo, stream: StageStream) => void;
[StageEvents.STAGE_STREAM_LAYERS_CHANGED]: (participantInfo: StageParticipantInfo, stream: RemoteStageStream, layers: StageStreamLayer[]) => void;
[StageEvents.STAGE_STREAM_LAYER_SELECTED]: (participantInfo: StageParticipantInfo, stream: RemoteStageStream, layer: StageStreamLayer | undefined, reason: StageStreamLayerSelectedReason) => void;
[StageEvents.STAGE_STREAM_ADAPTION_CHANGED]: (participantInfo: StageParticipantInfo, stream: RemoteStageStream, adaption: boolean) => void;
[StageEvents.ERROR]: (error: StageError) => void;
[StageEvents.STAGE_LEFT]: (reason: StageLeftReason) => void;
};
{
"name": "amazon-ivs-web-broadcast",
"version": "1.18.0",
"version": "1.19.0",
"description": "Amazon IVS Web Broadcast SDK",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc