@100mslive/hms-video-store 0.15.1-alpha.1 → 0.15.1-alpha.2

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.
@@ -40,6 +40,23 @@ export default class AnalyticsEventFactory {
40
40
  }): AnalyticsEvent;
41
41
  static hlsPlayerError(error: HMSException): AnalyticsEvent;
42
42
  static subscribeFail(error: Error): AnalyticsEvent;
43
+ /**
44
+ * An attempt went unanswered and is being retried. `sent` separates bytes the SFU ignored from
45
+ * an attempt that never reached the wire; `unproven` marks the channel-open race among the former.
46
+ */
47
+ static subscribeRequestRetry(properties: {
48
+ method: string;
49
+ trackId: string;
50
+ attempt: number;
51
+ unproven: boolean;
52
+ sent: boolean;
53
+ }): AnalyticsEvent;
54
+ /** no attempt was answered, so the SFU is left on a state nobody asked for */
55
+ static subscribeRequestUnanswered(properties: {
56
+ method: string;
57
+ trackId: string;
58
+ attempts: number;
59
+ }): AnalyticsEvent;
43
60
  static leave(): AnalyticsEvent;
44
61
  static autoplayError(): AnalyticsEvent;
45
62
  static audioPlaybackError(error: HMSException): AnalyticsEvent;
@@ -13,6 +13,11 @@ export interface PreferLayerResponse {
13
13
  code: number;
14
14
  message: string;
15
15
  };
16
+ /**
17
+ * Resolved locally without the SFU ever answering - the request was superseded, or skipped. The
18
+ * caller must not read it as the SFU having applied the state.
19
+ */
20
+ dropped?: boolean;
16
21
  }
17
22
  export interface PreferAudioLayerParams {
18
23
  params: {
@@ -1,10 +1,12 @@
1
1
  import ISubscribeConnectionObserver from './ISubscribeConnectionObserver';
2
+ import { EventBus } from '../../events/EventBus';
2
3
  import { InitFlags } from '../../signal/init/models';
3
4
  import JsonRpcSignal from '../../signal/jsonrpc';
4
5
  import { PreferAudioLayerParams, PreferLayerResponse, PreferVideoLayerParams } from '../channel-messages';
5
6
  import HMSConnection from '../HMSConnection';
6
7
  export default class HMSSubscribeConnection extends HMSConnection {
7
8
  private isFlagEnabled;
9
+ private eventBus?;
8
10
  private readonly TAG;
9
11
  private readonly remoteStreams;
10
12
  protected readonly observer: ISubscribeConnectionObserver;
@@ -17,6 +19,18 @@ export default class HMSSubscribeConnection extends HMSConnection {
17
19
  * apply stale desired state over a newer request.
18
20
  */
19
21
  private readonly RESPONSE_TIMEOUT;
22
+ /**
23
+ * The SFU creates this channel, so by DCEP the client's `open` fires a half-RTT before the SFU's
24
+ * and a request sent in that window is dropped before it arrives. Replies measure single-digit
25
+ * ms, so a request with no answer by now was lost rather than slow - and every ms spent waiting
26
+ * is a black tile. Applies only until the SFU has answered once; see `channelProven`.
27
+ */
28
+ private readonly UNPROVEN_CHANNEL_TIMEOUT;
29
+ /**
30
+ * Any reply proves the SFU's end of the channel is up, so the open race is behind us and a slow
31
+ * reply is the SFU being slow. Reset per channel: an SFU migration binds a new one.
32
+ */
33
+ private channelProven;
20
34
  readonly nativeConnection: RTCPeerConnection;
21
35
  private pendingMessageQueue;
22
36
  /** `${method}:${track_id}` -> the id of the newest request for it; older ones stop retrying */
@@ -32,14 +46,21 @@ export default class HMSSubscribeConnection extends HMSConnection {
32
46
  private apiChannel?;
33
47
  private eventEmitter;
34
48
  private initNativeConnectionCallbacks;
35
- constructor(signal: JsonRpcSignal, config: RTCConfiguration, isFlagEnabled: (flag: InitFlags) => boolean, observer: ISubscribeConnectionObserver);
49
+ constructor(signal: JsonRpcSignal, config: RTCConfiguration, isFlagEnabled: (flag: InitFlags) => boolean, observer: ISubscribeConnectionObserver, eventBus?: EventBus | undefined);
50
+ /**
51
+ * Drops the claim on one piece of subscription state, so anything still chasing it stops and
52
+ * resolves as dropped. The SFU telling us where it is overrules a request for somewhere else:
53
+ * without this the retries replay the overruled bytes and leave the SFU holding a preference
54
+ * the client has moved off, which the allocator restores to on the next bandwidth recovery.
55
+ */
56
+ cancelPendingRequest(method: string, trackId: string): void;
36
57
  sendOverApiDataChannel(message: string): void;
37
58
  /**
38
59
  * A retry replays the bytes serialised here, so a request still retrying after a newer one has
39
60
  * been made for the same track would re-apply state the caller has moved on from. Each request
40
61
  * claims its piece of subscription state, and stops once it no longer holds the claim.
41
62
  */
42
- sendOverApiDataChannelWithResponse<T extends PreferAudioLayerParams | PreferVideoLayerParams>(message: T, requestId?: string): Promise<PreferLayerResponse>;
63
+ sendOverApiDataChannelWithResponse<T extends PreferAudioLayerParams | PreferVideoLayerParams>(message: T): Promise<PreferLayerResponse>;
43
64
  close(): void;
44
65
  /**
45
66
  * Settles `wait` early if the connection is closed while it is parked on the api data channel.
@@ -49,11 +70,19 @@ export default class HMSSubscribeConnection extends HMSConnection {
49
70
  private abortOnClose;
50
71
  private handlePendingApiMessages;
51
72
  private sendMessage;
73
+ /** stateKey is `${method}:${track_id}`; the track id is the half that identifies the stuck track */
74
+ private publishRequestEvent;
52
75
  /**
53
76
  * Checked per attempt rather than once up front: 'open' is emitted from the channel's onopen, so
54
77
  * a channel that is closed or replaced never emits again and an unbounded wait here would hang
55
78
  * the caller for the rest of the session.
56
79
  */
57
80
  private waitForChannelOpen;
81
+ /**
82
+ * Only the first send on an unproven channel gets the short bound. A request dropped in the open
83
+ * window is answered by resending at once, but a link slow enough to miss 500ms twice is slow
84
+ * rather than dropping, and hard-failing it would strand the high-RTT clients the 10s bound
85
+ * exists for.
86
+ */
58
87
  private waitForResponse;
59
88
  }
@@ -68,7 +68,6 @@ export declare const ErrorFactory: {
68
68
  ProcessingFailed(action: HMSAction, description?: string): HMSException;
69
69
  AddAlreadyInProgress(action: HMSAction, description?: string): HMSException;
70
70
  DeviceNotSupported(action: HMSAction, description?: string): HMSException;
71
- NotAllowedForRoom(action: HMSAction, description?: string): HMSException;
72
71
  };
73
72
  PlaylistErrors: {
74
73
  NoEntryToPlay(action: HMSAction, description: string): HMSException;