fleeta-api-lib
Version:
A comprehensive library for fleet management applications - API, Auth, Device management
222 lines • 7.01 kB
TypeScript
/**
* Device Stream Manager
* 단일 디바이스의 모든 채널 스트림을 관리
* 채널 변경, 연결 풀, 상태 관리를 담당
*/
import type { CameraChannel, StreamQuality, ConnectionState, DeviceStats, DeviceManagerEvents, StreamCallback, VoiceCommState, TwoWayAudioStatus, VoiceCommCallback } from './types';
/**
* Device manager configuration interface
*/
export interface DeviceManagerConfig {
initialChannel: CameraChannel;
defaultQuality: StreamQuality;
enableConnectionPooling: boolean;
connectionTimeout: number;
enableVoiceCommSupport: boolean;
}
/**
* Device Stream Manager Class
* 단일 디바이스의 모든 채널과 스트림을 관리하는 매니저
*/
export declare class DeviceStreamManager {
private psn;
private config;
private currentChannel;
private availableChannels;
private connectionPool;
private activeConnection;
private previewConnections;
private currentStream;
private streamCallbacks;
private voiceCommState;
private voiceCommCallbacks;
private isInitialized;
private connectionStates;
private stats;
private lastChannelSwitch;
private totalChannelSwitches;
private events;
/**
* Create Device Stream Manager instance
* @param psn - Device PSN
* @param config - Device manager configuration
*/
constructor(psn: string, config: DeviceManagerConfig);
/**
* Initialize the device manager
* 디바이스 매니저 초기화
*/
initialize(): Promise<void>;
/**
* Connect main stream for current or specified channel
* 메인 스트림 연결 (고품질)
* @param channel - Channel to connect (default: current channel)
* @returns MediaStream for the connected channel
*/
connectMainStream(channel?: CameraChannel): Promise<MediaStream>;
/**
* Switch to a different channel
* 다른 채널로 변경
* @param newChannel - New channel to switch to
* @returns MediaStream for the new channel
*/
switchChannel(newChannel: CameraChannel): Promise<MediaStream>;
/**
* Add a preview stream for a different channel
* 다른 채널의 프리뷰 스트림 추가 (저품질)
* @param channel - Channel to add as preview
* @returns MediaStream for the preview channel
*/
addPreviewStream(channel: CameraChannel): Promise<MediaStream>;
/**
* Start voice communication
* 음성 통신 시작
*/
startVoiceComm(): Promise<TwoWayAudioStatus>;
/**
* Stop voice communication
* 음성 통신 중지
*/
stopVoiceComm(): Promise<TwoWayAudioStatus>;
/**
* Toggle local audio (microphone mute/unmute)
*/
setLocalAudioEnabled(enabled: boolean): void;
/**
* Set remote audio volume
*/
setRemoteAudioVolume(volume: number): void;
/**
* Get voice communication state
*/
getVoiceCommState(): VoiceCommState;
/**
* Disconnect from all streams
* 모든 스트림 연결 해제
*/
disconnect(): Promise<void>;
/**
* Get available channels for this device
* 이 디바이스의 사용 가능한 채널 목록
* @returns Array of available channels
*/
getAvailableChannels(): CameraChannel[];
/**
* Get current active channel
* 현재 활성 채널 조회
* @returns Current channel
*/
getCurrentChannel(): CameraChannel;
/**
* Get device PSN
* 디바이스 PSN 조회
* @returns Device PSN
*/
getPSN(): string;
/**
* Get connection state for a specific channel
* 특정 채널의 연결 상태 조회
* @param channel - Channel to check
* @returns Connection state
*/
getConnectionState(channel?: CameraChannel): ConnectionState;
/**
* Get current main stream
* 현재 메인 스트림 조회
* @returns Current MediaStream or null
*/
getCurrentStream(): MediaStream | null;
/**
* Get device statistics
* 디바이스 통계 조회
* @returns Device statistics
*/
getStats(): DeviceStats;
/**
* Register stream update callback
* 스트림 업데이트 콜백 등록
* @param callback - Stream update callback function
*/
onStreamUpdate(callback: StreamCallback): void;
/**
* Unregister stream update callback
* 스트림 업데이트 콜백 해제
* @param callback - Stream update callback function to remove
*/
offStreamUpdate(callback: StreamCallback): void;
/**
* Register voice communication callback
* 음성 통신 콜백 등록
* @param callback - Voice communication callback function
*/
onVoiceCommStateChange(callback: VoiceCommCallback): void;
/**
* Unregister voice communication callback
* 음성 통신 콜백 해제
* @param callback - Voice communication callback function to remove
*/
offVoiceCommStateChange(callback: VoiceCommCallback): void;
/**
* Set event callbacks
* 이벤트 콜백 설정
* @param events - Event callback functions
*/
setEvents(events: DeviceManagerEvents): void;
/**
* Destroy device manager and cleanup all resources
* 디바이스 매니저 파괴 및 모든 리소스 정리
*/
destroy(): Promise<void>;
/**
* Wait for MediaStream from a WebRTC connection
* WebRTC 연결에서 MediaStream 대기
* @param connection - WebRTC connection
* @returns Promise that resolves with MediaStream
*/
private waitForStream;
/**
* Demote main connection to preview
* 메인 연결을 프리뷰로 강등
*/
private demoteMainToPreview;
/**
* Update connection state for a channel
* 채널의 연결 상태 업데이트
* @param channel - Channel to update
* @param state - New connection state
*/
private updateConnectionState;
/**
* Update device statistics
* 디바이스 통계 업데이트
*/
private updateStats;
/**
* Calculate bandwidth usage
* 대역폭 사용량 계산
* @returns Estimated bandwidth usage in bytes/sec
*/
private calculateBandwidthUsage;
/**
* Calculate memory usage
* 메모리 사용량 계산
* @returns Estimated memory usage in bytes
*/
private calculateMemoryUsage;
/**
* Notify stream update to all callbacks
* 모든 콜백에 스트림 업데이트 알림
* @param channel - Updated channel
* @param stream - Updated MediaStream
* @param type - Stream type
* @param quality - Stream quality
*/
private notifyStreamUpdate;
/**
* Update voice communication state and notify callbacks
* 음성 통신 상태 업데이트 및 콜백 알림
* @param updates - Partial voice communication state updates
*/
private updateVoiceCommState;
}
//# sourceMappingURL=DeviceStreamManager.d.ts.map