werift 0.21.9 → 0.21.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.
- package/package.json +2 -3
- package/src/const.ts +0 -63
- package/src/dataChannel.ts +0 -156
- package/src/helper.ts +0 -44
- package/src/imports/common.ts +0 -1
- package/src/imports/dtls.ts +0 -1
- package/src/imports/ice.ts +0 -1
- package/src/imports/rtp.ts +0 -1
- package/src/imports/rtpExtra.ts +0 -1
- package/src/index.ts +0 -13
- package/src/media/codec.ts +0 -70
- package/src/media/extension/rtcpFeedback.ts +0 -11
- package/src/media/extension/rtpExtension.ts +0 -50
- package/src/media/index.ts +0 -9
- package/src/media/parameters.ts +0 -112
- package/src/media/receiver/nack.ts +0 -137
- package/src/media/receiver/receiverTwcc.ts +0 -154
- package/src/media/receiver/statistics.ts +0 -89
- package/src/media/router.ts +0 -193
- package/src/media/rtpReceiver.ts +0 -353
- package/src/media/rtpSender.ts +0 -500
- package/src/media/rtpTransceiver.ts +0 -121
- package/src/media/sender/cumulativeResult.ts +0 -61
- package/src/media/sender/senderBWE.ts +0 -129
- package/src/media/stats.ts +0 -1
- package/src/media/track.ts +0 -104
- package/src/nonstandard/index.ts +0 -5
- package/src/nonstandard/navigator.ts +0 -150
- package/src/nonstandard/recorder/index.ts +0 -103
- package/src/nonstandard/recorder/writer/index.ts +0 -19
- package/src/nonstandard/recorder/writer/webm.ts +0 -169
- package/src/nonstandard/userMedia.ts +0 -154
- package/src/peerConnection.ts +0 -1782
- package/src/sdp.ts +0 -735
- package/src/transport/dtls.ts +0 -389
- package/src/transport/ice.ts +0 -310
- package/src/transport/sctp.ts +0 -390
- package/src/types/domain.ts +0 -23
- package/src/types/util.ts +0 -7
- package/src/utils.ts +0 -155
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "werift",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.10",
|
|
4
4
|
"description": "WebRTC Implementation for TypeScript (Node.js)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"WebRTC",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"main": "lib/webrtc/src/index.js",
|
|
31
31
|
"types": "lib/webrtc/src/index.d.ts",
|
|
32
32
|
"files": [
|
|
33
|
-
"lib"
|
|
34
|
-
"src"
|
|
33
|
+
"lib"
|
|
35
34
|
],
|
|
36
35
|
"scripts": {
|
|
37
36
|
"build": "npm i && rm -rf lib && run-s format compile:*",
|
package/src/const.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { type HashAlgorithms, SignatureAlgorithm } from "./imports/dtls";
|
|
2
|
-
import {
|
|
3
|
-
ProtectionProfileAeadAes128Gcm,
|
|
4
|
-
ProtectionProfileAes128CmHmacSha1_80,
|
|
5
|
-
} from "./imports/rtp";
|
|
6
|
-
import type { DtlsRole } from "./transport/dtls";
|
|
7
|
-
|
|
8
|
-
// data channel export constants
|
|
9
|
-
export const DATA_CHANNEL_ACK = 2;
|
|
10
|
-
export const DATA_CHANNEL_OPEN = 3;
|
|
11
|
-
|
|
12
|
-
// 5.1. DATA_CHANNEL_OPEN Message
|
|
13
|
-
export const DATA_CHANNEL_RELIABLE = 0x00;
|
|
14
|
-
export const DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT = 0x01;
|
|
15
|
-
export const DATA_CHANNEL_PARTIAL_RELIABLE_TIMED = 0x02;
|
|
16
|
-
export const DATA_CHANNEL_RELIABLE_UNORDERED = 0x80;
|
|
17
|
-
export const DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT_UNORDERED = 0x81;
|
|
18
|
-
export const DATA_CHANNEL_PARTIAL_RELIABLE_TIMED_UNORDERED = 0x82;
|
|
19
|
-
|
|
20
|
-
export const WEBRTC_DCEP = 50;
|
|
21
|
-
export const WEBRTC_STRING = 51;
|
|
22
|
-
export const WEBRTC_BINARY = 53;
|
|
23
|
-
export const WEBRTC_STRING_EMPTY = 56;
|
|
24
|
-
export const WEBRTC_BINARY_EMPTY = 57;
|
|
25
|
-
|
|
26
|
-
export const DISCARD_HOST = "0.0.0.0";
|
|
27
|
-
export const DISCARD_PORT = 9;
|
|
28
|
-
export const MEDIA_KINDS = ["audio", "video"];
|
|
29
|
-
|
|
30
|
-
export const DIRECTIONS = ["inactive", "sendonly", "recvonly", "sendrecv"];
|
|
31
|
-
export const DTLS_ROLE_SETUP = {
|
|
32
|
-
auto: "actpass",
|
|
33
|
-
client: "active",
|
|
34
|
-
server: "passive",
|
|
35
|
-
};
|
|
36
|
-
export const DTLS_SETUP_ROLE: { [key: string]: DtlsRole } = Object.keys(
|
|
37
|
-
DTLS_ROLE_SETUP,
|
|
38
|
-
).reduce((acc, cur) => {
|
|
39
|
-
const key = (DTLS_ROLE_SETUP as any)[cur];
|
|
40
|
-
acc[key] = cur;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {} as any);
|
|
43
|
-
export const FMTP_INT_PARAMETERS = [
|
|
44
|
-
"apt",
|
|
45
|
-
"max-fr",
|
|
46
|
-
"max-fs",
|
|
47
|
-
"maxplaybackrate",
|
|
48
|
-
"minptime",
|
|
49
|
-
"stereo",
|
|
50
|
-
"useinbandfec",
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
export const SSRC_INFO_ATTRS = ["cname", "msid", "mslabel", "label"];
|
|
54
|
-
|
|
55
|
-
export const SRTP_PROFILE = {
|
|
56
|
-
SRTP_AES128_CM_HMAC_SHA1_80: ProtectionProfileAes128CmHmacSha1_80,
|
|
57
|
-
SRTP_AEAD_AES_128_GCM: ProtectionProfileAeadAes128Gcm,
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
export const SenderDirections = ["sendonly", "sendrecv"];
|
|
61
|
-
export const ReceiverDirection = ["sendrecv", "recvonly"];
|
|
62
|
-
|
|
63
|
-
export { type HashAlgorithms, SignatureAlgorithm };
|
package/src/dataChannel.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { Event, debug } from "./imports/common";
|
|
2
|
-
|
|
3
|
-
import { EventTarget } from "./helper";
|
|
4
|
-
import type { RTCSctpTransport } from "./transport/sctp";
|
|
5
|
-
import type { Callback, CallbackWithValue } from "./types/util";
|
|
6
|
-
|
|
7
|
-
const log = debug("werift:packages/webrtc/src/dataChannel.ts");
|
|
8
|
-
|
|
9
|
-
export class RTCDataChannel extends EventTarget {
|
|
10
|
-
readonly stateChanged = new Event<[DCState]>();
|
|
11
|
-
readonly onMessage = new Event<[string | Buffer]>();
|
|
12
|
-
// todo impl
|
|
13
|
-
readonly error = new Event<[Error]>();
|
|
14
|
-
readonly bufferedAmountLow = new Event();
|
|
15
|
-
onopen?: Callback;
|
|
16
|
-
onclose?: Callback;
|
|
17
|
-
onclosing?: Callback;
|
|
18
|
-
onmessage?: CallbackWithValue<MessageEvent>;
|
|
19
|
-
// todo impl
|
|
20
|
-
onerror?: CallbackWithValue<RTCErrorEvent>;
|
|
21
|
-
isCreatedByRemote = false;
|
|
22
|
-
id: number;
|
|
23
|
-
readyState: DCState = "connecting";
|
|
24
|
-
|
|
25
|
-
bufferedAmount = 0;
|
|
26
|
-
private _bufferedAmountLowThreshold = 0;
|
|
27
|
-
|
|
28
|
-
constructor(
|
|
29
|
-
private readonly transport: RTCSctpTransport,
|
|
30
|
-
private readonly parameters: RTCDataChannelParameters,
|
|
31
|
-
public readonly sendOpen = true,
|
|
32
|
-
) {
|
|
33
|
-
super();
|
|
34
|
-
|
|
35
|
-
this.id = this.parameters.id;
|
|
36
|
-
|
|
37
|
-
if (parameters.negotiated) {
|
|
38
|
-
if (this.id == undefined || this.id < 0 || this.id > 65534) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
"ID must be in range 0-65534 if data channel is negotiated out-of-band",
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
this.transport.dataChannelAddNegotiated(this);
|
|
44
|
-
} else {
|
|
45
|
-
if (sendOpen) {
|
|
46
|
-
this.sendOpen = false;
|
|
47
|
-
this.transport.dataChannelOpen(this);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get ordered() {
|
|
53
|
-
return this.parameters.ordered;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get maxRetransmits() {
|
|
57
|
-
return this.parameters.maxRetransmits;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get maxPacketLifeTime() {
|
|
61
|
-
return this.parameters.maxPacketLifeTime;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get label() {
|
|
65
|
-
return this.parameters.label;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get protocol() {
|
|
69
|
-
return this.parameters.protocol;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get negotiated() {
|
|
73
|
-
return this.parameters.negotiated;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get bufferedAmountLowThreshold() {
|
|
77
|
-
return this._bufferedAmountLowThreshold;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set bufferedAmountLowThreshold(value: number) {
|
|
81
|
-
if (value < 0 || value > 4294967295) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
"bufferedAmountLowThreshold must be in range 0 - 4294967295",
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
this._bufferedAmountLowThreshold = value;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setId(id: number) {
|
|
90
|
-
this.id = id;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setReadyState(state: DCState) {
|
|
94
|
-
if (state !== this.readyState) {
|
|
95
|
-
this.readyState = state;
|
|
96
|
-
this.stateChanged.execute(state);
|
|
97
|
-
|
|
98
|
-
switch (state) {
|
|
99
|
-
case "open":
|
|
100
|
-
if (this.onopen) this.onopen();
|
|
101
|
-
this.emit("open");
|
|
102
|
-
break;
|
|
103
|
-
case "closed":
|
|
104
|
-
if (this.onclose) this.onclose();
|
|
105
|
-
this.emit("close");
|
|
106
|
-
break;
|
|
107
|
-
case "closing":
|
|
108
|
-
if (this.onclosing) this.onclosing();
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
log("change state", state);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
addBufferedAmount(amount: number) {
|
|
116
|
-
const crossesThreshold =
|
|
117
|
-
this.bufferedAmount > this.bufferedAmountLowThreshold &&
|
|
118
|
-
this.bufferedAmount + amount <= this.bufferedAmountLowThreshold;
|
|
119
|
-
this.bufferedAmount += amount;
|
|
120
|
-
if (crossesThreshold) {
|
|
121
|
-
this.bufferedAmountLow.execute();
|
|
122
|
-
this.emit("bufferedamountlow");
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
send(data: Buffer | string) {
|
|
127
|
-
this.transport.datachannelSend(this, data);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
close() {
|
|
131
|
-
this.transport.dataChannelClose(this);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export type DCState = "open" | "closed" | "connecting" | "closing";
|
|
136
|
-
|
|
137
|
-
export class RTCDataChannelParameters {
|
|
138
|
-
label = "";
|
|
139
|
-
maxPacketLifeTime?: number; // sec
|
|
140
|
-
maxRetransmits?: number;
|
|
141
|
-
ordered = true;
|
|
142
|
-
protocol = "";
|
|
143
|
-
negotiated = false;
|
|
144
|
-
id!: number;
|
|
145
|
-
constructor(props: Partial<RTCDataChannelParameters> = {}) {
|
|
146
|
-
Object.assign(this, props);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export interface MessageEvent {
|
|
151
|
-
data: string | Buffer;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export interface RTCErrorEvent {
|
|
155
|
-
error: any;
|
|
156
|
-
}
|
package/src/helper.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "events";
|
|
2
|
-
|
|
3
|
-
export function enumerate<T>(arr: T[]): [number, T][] {
|
|
4
|
-
return arr.map((v, i) => [i, v]);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function divide(from: string, split: string): [string, string] {
|
|
8
|
-
const arr = from.split(split);
|
|
9
|
-
return [arr[0], arr.slice(1).join(split)];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class PromiseQueue {
|
|
13
|
-
queue: { promise: () => Promise<any>; done: () => void }[] = [];
|
|
14
|
-
running = false;
|
|
15
|
-
|
|
16
|
-
push = (promise: () => Promise<any>) =>
|
|
17
|
-
new Promise<void>((r) => {
|
|
18
|
-
this.queue.push({ promise, done: r });
|
|
19
|
-
if (!this.running) this.run();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
private async run() {
|
|
23
|
-
const task = this.queue.shift();
|
|
24
|
-
if (task) {
|
|
25
|
-
this.running = true;
|
|
26
|
-
await task.promise();
|
|
27
|
-
task.done();
|
|
28
|
-
|
|
29
|
-
this.run();
|
|
30
|
-
} else {
|
|
31
|
-
this.running = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class EventTarget extends EventEmitter {
|
|
37
|
-
addEventListener = (type: string, listener: (...args: any[]) => void) => {
|
|
38
|
-
this.addListener(type, listener);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
removeEventListener = (type: string, listener: (...args: any[]) => void) => {
|
|
42
|
-
this.removeListener(type, listener);
|
|
43
|
-
};
|
|
44
|
-
}
|
package/src/imports/common.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../common/src";
|
package/src/imports/dtls.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../dtls/src";
|
package/src/imports/ice.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../ice/src";
|
package/src/imports/rtp.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../rtp/src";
|
package/src/imports/rtpExtra.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../rtp/src/extra";
|
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./imports/common";
|
|
2
|
-
export * from "./imports/dtls";
|
|
3
|
-
export * from "./imports/ice";
|
|
4
|
-
export * from "./imports/rtp";
|
|
5
|
-
export * from "./dataChannel";
|
|
6
|
-
export * from "./media";
|
|
7
|
-
export * from "./peerConnection";
|
|
8
|
-
export * from "./sdp";
|
|
9
|
-
export * from "./transport/dtls";
|
|
10
|
-
export * from "./transport/ice";
|
|
11
|
-
export * from "./transport/sctp";
|
|
12
|
-
export * from "./types/domain";
|
|
13
|
-
export * from "./utils";
|
package/src/media/codec.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { useNACK, usePLI, useREMB } from "./extension/rtcpFeedback";
|
|
2
|
-
import { RTCRtpCodecParameters } from "./parameters";
|
|
3
|
-
|
|
4
|
-
export const useH264 = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
5
|
-
new RTCRtpCodecParameters({
|
|
6
|
-
mimeType: "video/h264",
|
|
7
|
-
clockRate: 90000,
|
|
8
|
-
rtcpFeedback: [useNACK(), usePLI(), useREMB()],
|
|
9
|
-
parameters:
|
|
10
|
-
"profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1",
|
|
11
|
-
...props,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export const useVP8 = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
15
|
-
new RTCRtpCodecParameters({
|
|
16
|
-
mimeType: "video/VP8",
|
|
17
|
-
clockRate: 90000,
|
|
18
|
-
rtcpFeedback: [useNACK(), usePLI(), useREMB()],
|
|
19
|
-
...props,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const useVP9 = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
23
|
-
new RTCRtpCodecParameters({
|
|
24
|
-
mimeType: "video/VP9",
|
|
25
|
-
clockRate: 90000,
|
|
26
|
-
rtcpFeedback: [useNACK(), usePLI(), useREMB()],
|
|
27
|
-
...props,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const useAV1X = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
31
|
-
new RTCRtpCodecParameters({
|
|
32
|
-
mimeType: "video/AV1X",
|
|
33
|
-
clockRate: 90000,
|
|
34
|
-
rtcpFeedback: [useNACK(), usePLI(), useREMB()],
|
|
35
|
-
...props,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export const useOPUS = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
39
|
-
new RTCRtpCodecParameters({
|
|
40
|
-
mimeType: "audio/OPUS",
|
|
41
|
-
clockRate: 48000,
|
|
42
|
-
channels: 2,
|
|
43
|
-
...props,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const usePCMU = (props: Partial<RTCRtpCodecParameters> = {}) =>
|
|
47
|
-
new RTCRtpCodecParameters({
|
|
48
|
-
mimeType: "audio/PCMU",
|
|
49
|
-
clockRate: 8000,
|
|
50
|
-
channels: 1,
|
|
51
|
-
payloadType: 0,
|
|
52
|
-
...props,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export const supportedCodecs = [
|
|
56
|
-
useAV1X(),
|
|
57
|
-
useVP9(),
|
|
58
|
-
useVP8(),
|
|
59
|
-
useH264(),
|
|
60
|
-
useOPUS(),
|
|
61
|
-
usePCMU(),
|
|
62
|
-
].map((codec) => codec.mimeType);
|
|
63
|
-
|
|
64
|
-
export const supportedVideoCodecs = supportedCodecs.filter((codec) =>
|
|
65
|
-
codec.toLowerCase().startsWith("video/"),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export const supportedAudioCodecs = supportedCodecs.filter((codec) =>
|
|
69
|
-
codec.toLowerCase().startsWith("audio/"),
|
|
70
|
-
);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RTCPFB } from "../parameters";
|
|
2
|
-
|
|
3
|
-
export const useFIR = (): RTCPFB => ({ type: "ccm", parameter: "fir" });
|
|
4
|
-
|
|
5
|
-
export const useNACK = (): RTCPFB => ({ type: "nack" });
|
|
6
|
-
|
|
7
|
-
export const usePLI = (): RTCPFB => ({ type: "nack", parameter: "pli" });
|
|
8
|
-
|
|
9
|
-
export const useREMB = (): RTCPFB => ({ type: "goog-remb" });
|
|
10
|
-
|
|
11
|
-
export const useTWCC = (): RTCPFB => ({ type: "transport-cc" });
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { RTP_EXTENSION_URI } from "../../imports/rtp";
|
|
2
|
-
import { RTCRtpHeaderExtensionParameters } from "../parameters";
|
|
3
|
-
|
|
4
|
-
export function useSdesMid() {
|
|
5
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
6
|
-
uri: RTP_EXTENSION_URI.sdesMid,
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useSdesRTPStreamId() {
|
|
11
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
12
|
-
uri: RTP_EXTENSION_URI.sdesRTPStreamID,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function useRepairedRtpStreamId() {
|
|
17
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
18
|
-
uri: RTP_EXTENSION_URI.repairedRtpStreamId,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useTransportWideCC() {
|
|
23
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
24
|
-
uri: RTP_EXTENSION_URI.transportWideCC,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useAbsSendTime() {
|
|
29
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
30
|
-
uri: RTP_EXTENSION_URI.absSendTime,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function useDependencyDescriptor() {
|
|
35
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
36
|
-
uri: RTP_EXTENSION_URI.dependencyDescriptor,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function useAudioLevelIndication() {
|
|
41
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
42
|
-
uri: RTP_EXTENSION_URI.audioLevelIndication,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function useVideoOrientation() {
|
|
47
|
-
return new RTCRtpHeaderExtensionParameters({
|
|
48
|
-
uri: RTP_EXTENSION_URI.videoOrientation,
|
|
49
|
-
});
|
|
50
|
-
}
|
package/src/media/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./codec";
|
|
2
|
-
export * from "./extension/rtcpFeedback";
|
|
3
|
-
export * from "./extension/rtpExtension";
|
|
4
|
-
export * from "./parameters";
|
|
5
|
-
export * from "./router";
|
|
6
|
-
export * from "./rtpReceiver";
|
|
7
|
-
export * from "./rtpSender";
|
|
8
|
-
export * from "./rtpTransceiver";
|
|
9
|
-
export * from "./track";
|
package/src/media/parameters.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { Direction } from "./rtpTransceiver";
|
|
2
|
-
|
|
3
|
-
export interface RTCRtpParameters {
|
|
4
|
-
codecs: RTCRtpCodecParameters[];
|
|
5
|
-
headerExtensions: RTCRtpHeaderExtensionParameters[];
|
|
6
|
-
muxId?: string;
|
|
7
|
-
rtpStreamId?: string;
|
|
8
|
-
repairedRtpStreamId?: string;
|
|
9
|
-
rtcp?: RTCRtcpParameters;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type RTCPFB = { type: string; parameter?: string };
|
|
13
|
-
|
|
14
|
-
export class RTCRtpCodecParameters {
|
|
15
|
-
/**
|
|
16
|
-
* When specifying a codec with a fixed payloadType such as PCMU,
|
|
17
|
-
* it is necessary to set the correct PayloadType in RTCRtpCodecParameters in advance.
|
|
18
|
-
*/
|
|
19
|
-
payloadType!: number;
|
|
20
|
-
mimeType!: string;
|
|
21
|
-
clockRate!: number;
|
|
22
|
-
channels?: number;
|
|
23
|
-
rtcpFeedback: RTCPFB[] = [];
|
|
24
|
-
parameters?: string;
|
|
25
|
-
direction: Direction | "all" = "all";
|
|
26
|
-
|
|
27
|
-
constructor(
|
|
28
|
-
props: Pick<RTCRtpCodecParameters, "mimeType" | "clockRate"> &
|
|
29
|
-
Partial<RTCRtpCodecParameters>,
|
|
30
|
-
) {
|
|
31
|
-
Object.assign(this, props);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get name() {
|
|
35
|
-
return this.mimeType.split("/")[1];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get contentType() {
|
|
39
|
-
return this.mimeType.split("/")[0];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get str() {
|
|
43
|
-
let s = `${this.name}/${this.clockRate}`;
|
|
44
|
-
if (this.channels === 2) s += "/2";
|
|
45
|
-
return s;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class RTCRtpHeaderExtensionParameters {
|
|
50
|
-
id!: number;
|
|
51
|
-
uri!: string;
|
|
52
|
-
|
|
53
|
-
constructor(
|
|
54
|
-
props: Partial<RTCRtpHeaderExtensionParameters> &
|
|
55
|
-
Pick<RTCRtpHeaderExtensionParameters, "uri">,
|
|
56
|
-
) {
|
|
57
|
-
Object.assign(this, props);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export class RTCRtcpParameters {
|
|
62
|
-
cname?: string;
|
|
63
|
-
mux = false;
|
|
64
|
-
ssrc?: number;
|
|
65
|
-
|
|
66
|
-
constructor(props: Partial<RTCRtcpParameters> = {}) {
|
|
67
|
-
Object.assign(this, props);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class RTCRtcpFeedback {
|
|
72
|
-
type!: string;
|
|
73
|
-
parameter?: string;
|
|
74
|
-
|
|
75
|
-
constructor(props: Partial<RTCRtcpFeedback> = {}) {
|
|
76
|
-
Object.assign(this, props);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export class RTCRtpRtxParameters {
|
|
80
|
-
ssrc!: number;
|
|
81
|
-
|
|
82
|
-
constructor(props: Partial<RTCRtpRtxParameters> = {}) {
|
|
83
|
-
Object.assign(this, props);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class RTCRtpCodingParameters {
|
|
88
|
-
ssrc!: number;
|
|
89
|
-
payloadType!: number;
|
|
90
|
-
rtx?: RTCRtpRtxParameters;
|
|
91
|
-
|
|
92
|
-
constructor(
|
|
93
|
-
props: Partial<RTCRtpCodingParameters> &
|
|
94
|
-
Pick<RTCRtpCodingParameters, "ssrc" | "payloadType">,
|
|
95
|
-
) {
|
|
96
|
-
Object.assign(this, props);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface RTCRtpReceiveParameters extends RTCRtpParameters {
|
|
101
|
-
encodings: RTCRtpCodingParameters[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export type RTCRtpSendParameters = RTCRtpParameters;
|
|
105
|
-
|
|
106
|
-
export class RTCRtpSimulcastParameters {
|
|
107
|
-
rid!: string;
|
|
108
|
-
direction!: "send" | "recv";
|
|
109
|
-
constructor(props: RTCRtpSimulcastParameters) {
|
|
110
|
-
Object.assign(this, props);
|
|
111
|
-
}
|
|
112
|
-
}
|