whepts 1.1.8 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,17 +6,65 @@ export interface ConnectionManagerOptions {
6
6
  emitter: EventEmitter;
7
7
  getNonAdvertisedCodecs: () => string[];
8
8
  }
9
+ /**
10
+ * WebRTC 连接管理器
11
+ *
12
+ * 负责管理 RTCPeerConnection 的生命周期和事件处理。
13
+ */
9
14
  export declare class ConnectionManager {
10
15
  private options;
11
16
  private pc?;
12
17
  private offerData?;
13
18
  constructor(options: ConnectionManagerOptions);
19
+ /**
20
+ * 创建并配置 PeerConnection
21
+ */
14
22
  setupPeerConnection(iceServers: RTCIceServer[]): Promise<string>;
23
+ /**
24
+ * 设置远程 SDP Answer
25
+ */
15
26
  setAnswer(answer: string): Promise<void>;
16
27
  getPeerConnection(): RTCPeerConnection | undefined;
17
28
  getOfferData(): ParsedOffer | undefined;
18
29
  close(): void;
19
- private onLocalCandidate;
20
- private onConnectionState;
21
- private onIceConnectionState;
30
+ /**
31
+ * 处理本地 ICE 候选事件
32
+ */
33
+ private handleIceCandidate;
34
+ /**
35
+ * 处理连接状态变化
36
+ *
37
+ * connectionState 可能的值:
38
+ * - 'new': 刚创建,还未连接
39
+ * 'connecting': 正在连接中
40
+ * 'connected': 已连接
41
+ * - 'disconnected': 已断开(可能短暂)
42
+ * - 'failed': 连接失败
43
+ * - 'closed': 已关闭
44
+ *
45
+ * 连接失败或关闭属于流断开,触发 flow:stalled 事件进行恢复。
46
+ */
47
+ private handleConnectionState;
48
+ /**
49
+ * 处理 ICE 连接状态变化
50
+ *
51
+ * iceConnectionState 可能的值:
52
+ * - 'new': 刚创建,还未检查
53
+ * - 'checking': 正在检查
54
+ * 'connected': ICE 连接成功
55
+ * 'completed': ICE 连接完成
56
+ * 'failed': ICE 连接失败
57
+ * 'disconnected': ICE 连接断开(可能短暂)
58
+ */
59
+ private handleIceConnectionState;
60
+ /**
61
+ * 处理媒体轨道事件
62
+ */
63
+ private handleTrack;
64
+ /**
65
+ * 重启 ICE 连接
66
+ *
67
+ * 当 ICE 连接失败时,尝试重启 ICE 以恢复连接
68
+ */
69
+ private restartIceConnection;
22
70
  }
@@ -1,16 +1,22 @@
1
1
  import type { EventEmitter } from 'eventemitter3';
2
+ import type { MonitorScheduler } from '~/monitors/scheduler';
2
3
  export declare class TrackManager {
3
4
  private container;
5
+ private eventEmitter;
4
6
  private lazyLoad;
5
7
  private stream?;
6
8
  private observer?;
7
9
  private showStore;
8
10
  private playMonitor;
9
11
  private flowMonitor;
10
- constructor(container: HTMLMediaElement, eventEmitter: EventEmitter, lazyLoad?: boolean);
12
+ constructor(container: HTMLMediaElement, eventEmitter: EventEmitter, lazyLoad: boolean | undefined, scheduler: MonitorScheduler);
11
13
  onTrack(evt: RTCTrackEvent, pc?: RTCPeerConnection): void;
12
14
  get paused(): boolean;
13
15
  pause(): void;
14
16
  resume(): void;
15
17
  stop(): void;
18
+ /**
19
+ * 永久销毁(仅在 WebRTCWhep.close() 时调用)
20
+ */
21
+ destroy(): void;
16
22
  }
package/dist/errors.d.ts CHANGED
@@ -4,14 +4,20 @@
4
4
  export type ErrorType = string;
5
5
  /**
6
6
  * 错误类型常量
7
+ *
8
+ * 错误分类:
9
+ * - SIGNAL_ERROR: 信令异常(SDP、ICE 服务器)
10
+ * - STATE_ERROR: 状态异常(播放器已关闭等)
11
+ * - REQUEST_ERROR: 请求异常(400、406 等错误状态码)
12
+ * - NOT_FOUND_ERROR: 资源未找到(404)
13
+ *
14
+ * 注意:流连接断开已由 `flow:stalled` 事件独立处理,不作为错误类型。
7
15
  */
8
16
  export declare const ErrorTypes: {
9
17
  SIGNAL_ERROR: string;
10
18
  STATE_ERROR: string;
11
19
  REQUEST_ERROR: string;
12
20
  NOT_FOUND_ERROR: string;
13
- CONNECT_ERROR: string;
14
- MEDIA_ERROR: string;
15
21
  OTHER_ERROR: string;
16
22
  };
17
23
  /**