fleeta-api-lib
Version:
A comprehensive library for fleet management applications - API, Auth, Device management
121 lines • 5.8 kB
TypeScript
/**
* Live View API functions
* Handles live streaming commands and communication with devices
*/
import type { PlayLiveViewParams, PlayLiveViewResponse, StopLiveViewParams, StopLiveViewResponse, LiveDirectionParams, LiveDirectionResponse, LivePresignURLParams, LivePresignURLResponse, WebRTCConfig, LiveStreamStatus, LiveCameraChannel, TwoWayStartParams, TwoWayStartResponse, TwoWayStopParams, TwoWayStopResponse } from './types';
/**
* Start live view streaming for a specific device and camera channel
* Sends PlayLiveView command to the device
*
* @param params - Parameters for live view playback
* @returns Promise with live view response including stream status and name
*/
export declare function playLiveView(params: Omit<PlayLiveViewParams, 'email' | 'user_token'>): Promise<PlayLiveViewResponse>;
/**
* Stop live view streaming for a specific device
* Sends StopLiveView command to the device
*
* @param params - Parameters for stopping live view
* @returns Promise with stop live view response
*/
export declare function stopLiveView(params: Omit<StopLiveViewParams, 'email' | 'user_token'>): Promise<StopLiveViewResponse>;
/**
* Change live view camera direction for a specific device
* Sends LiveDirection command to switch between camera channels
* Used for multi-camera live view direction switching
*
* @param params - Parameters for camera direction change
* @returns Promise with direction change response including status and current direction
*/
export declare function changeLiveDirection(params: Omit<LiveDirectionParams, 'email' | 'user_token'>): Promise<LiveDirectionResponse>;
/**
* Change live direction with retry mechanism for busy status
* When status is 'busy', retries the direction change until it succeeds
* Used to handle multi-user live view scenarios where direction changes may conflict
*
* @param params - Parameters for camera direction change
* @param maxRetries - Maximum number of retry attempts (default: 5)
* @param retryInterval - Interval between retries in milliseconds (default: 1000ms)
* @returns Promise with final direction change response
*/
export declare function changeLiveDirectionWithRetry(params: Omit<LiveDirectionParams, 'email' | 'user_token'>, maxRetries?: number, retryInterval?: number): Promise<LiveDirectionResponse>;
/**
* Handle LiveClosing status with retry mechanism
* When device is in LiveClosing state, client should retry PlayLiveView
* with 1-2 second intervals until closing state ends
*
* @param params - Parameters for live view playback
* @param maxRetries - Maximum number of retry attempts (default: 8)
* @param retryInterval - Interval between retries in milliseconds (default: 2000ms)
* @returns Promise with final live view response
*/
export declare function playLiveViewWithRetry(params: Omit<PlayLiveViewParams, 'email' | 'user_token'>, maxRetries?: number, retryInterval?: number): Promise<PlayLiveViewResponse>;
/**
* Get WebRTC presigned URL for live streaming
* This function gets the presigned URL and WebRTC configuration needed for actual video streaming
* Should only be called when live view status is 'LiveStopped'
*
* @param params - Parameters for presigned URL request
* @returns Promise with WebRTC configuration for streaming
*/
export declare function getLivePresignURL(params: LivePresignURLParams): Promise<LivePresignURLResponse>;
/**
* Complete live streaming workflow
* Handles the full process: check status -> start live view -> get presigned URL
* Includes retry logic for LiveClosing status and busy conditions
* Stream name is generated as PSN + '_live' for presigned URL request
*
* @param psn - Device PSN
* @param channel - Camera channel
* @param clientId - Client identifier (usually PSN)
* @param role - WebRTC role (VIEWER or MASTER)
* @returns Promise with complete WebRTC configuration
*/
export declare function startLiveStreamingWorkflow(psn: string, channel?: LiveCameraChannel, clientId?: string, role?: 'VIEWER' | 'MASTER'): Promise<WebRTCConfig>;
/**
* Create custom signer for WebRTC SignalingClient
* Used to provide presigned URL to KVS WebRTC SignalingClient
*
* @param url - Presigned WebSocket URL
* @returns Custom signer object for SignalingClient
*/
export declare function createCustomSigner(url: string): {
getSignedURL: () => string;
};
/**
* Validate WebRTC configuration
* Checks if all required fields are present and valid
*
* @param config - WebRTC configuration to validate
* @returns Boolean indicating if configuration is valid
*/
export declare function validateWebRTCConfig(config: WebRTCConfig): boolean;
/**
* Get live stream status for a device
* Utility function to check current streaming status
*
* @param psn - Device PSN
* @param channel - Camera channel (optional, defaults to '1')
* @returns Promise with current live stream status
*/
export declare function getLiveStreamStatus(psn: string, channel?: LiveCameraChannel): Promise<{
status: LiveStreamStatus;
streamname?: string;
}>;
/**
* Start two-way audio communication with device
* Sends TwoWayStart command to enable bidirectional audio
*
* @param params - Parameters for starting two-way audio
* @returns Promise with two-way start response including status
*/
export declare function startTwoWayAudio(params: Omit<TwoWayStartParams, 'email' | 'user_token'>): Promise<TwoWayStartResponse>;
/**
* Stop two-way audio communication with device
* Sends TwoWayStop command to disable bidirectional audio
*
* @param params - Parameters for stopping two-way audio
* @returns Promise with two-way stop response including status
*/
export declare function stopTwoWayAudio(params: Omit<TwoWayStopParams, 'email' | 'user_token'>): Promise<TwoWayStopResponse>;
//# sourceMappingURL=api.d.ts.map