@livekit/rtc-node 0.12.2 → 0.13.0
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/dist/audio_frame.cjs +2 -2
- package/dist/audio_frame.cjs.map +1 -1
- package/dist/audio_frame.d.cts +2 -3
- package/dist/audio_frame.d.ts +2 -3
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +3 -3
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_resampler.cjs +10 -7
- package/dist/audio_resampler.cjs.map +1 -1
- package/dist/audio_resampler.d.cts +2 -3
- package/dist/audio_resampler.d.ts +2 -3
- package/dist/audio_resampler.d.ts.map +1 -1
- package/dist/audio_resampler.js +13 -10
- package/dist/audio_resampler.js.map +1 -1
- package/dist/audio_source.cjs +6 -4
- package/dist/audio_source.cjs.map +1 -1
- package/dist/audio_source.d.cts +3 -3
- package/dist/audio_source.d.ts +3 -3
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +9 -7
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.cjs +1 -2
- package/dist/audio_stream.cjs.map +1 -1
- package/dist/audio_stream.d.cts +2 -3
- package/dist/audio_stream.d.ts +2 -3
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +2 -3
- package/dist/audio_stream.js.map +1 -1
- package/dist/e2ee.cjs +19 -20
- package/dist/e2ee.cjs.map +1 -1
- package/dist/e2ee.d.cts +0 -1
- package/dist/e2ee.d.ts +0 -1
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +29 -30
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.cjs +6 -5
- package/dist/ffi_client.cjs.map +1 -1
- package/dist/ffi_client.d.cts +10 -10
- package/dist/ffi_client.d.ts +10 -10
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +6 -10
- package/dist/ffi_client.js.map +1 -1
- package/dist/index.cjs +16 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -35
- package/dist/index.d.ts +6 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -46
- package/dist/index.js.map +1 -1
- package/dist/napi/native.d.cjs.map +1 -1
- package/dist/napi/native.d.ts +5 -5
- package/dist/native.d.ts +5 -5
- package/dist/participant.cjs +57 -34
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +10 -10
- package/dist/participant.d.ts +10 -10
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +75 -50
- package/dist/participant.js.map +1 -1
- package/dist/proto/audio_frame_pb.cjs +977 -125
- package/dist/proto/audio_frame_pb.cjs.map +1 -1
- package/dist/proto/audio_frame_pb.d.cts +502 -417
- package/dist/proto/audio_frame_pb.d.ts +502 -417
- package/dist/proto/audio_frame_pb.d.ts.map +1 -1
- package/dist/proto/audio_frame_pb.js +943 -85
- package/dist/proto/audio_frame_pb.js.map +1 -1
- package/dist/proto/e2ee_pb.cjs +700 -85
- package/dist/proto/e2ee_pb.cjs.map +1 -1
- package/dist/proto/e2ee_pb.d.cts +331 -263
- package/dist/proto/e2ee_pb.d.ts +331 -263
- package/dist/proto/e2ee_pb.d.ts.map +1 -1
- package/dist/proto/e2ee_pb.js +675 -57
- package/dist/proto/e2ee_pb.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +369 -36
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +156 -109
- package/dist/proto/ffi_pb.d.ts +156 -109
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +364 -29
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/handle_pb.cjs +27 -7
- package/dist/proto/handle_pb.cjs.map +1 -1
- package/dist/proto/handle_pb.d.cts +13 -15
- package/dist/proto/handle_pb.d.ts +13 -15
- package/dist/proto/handle_pb.d.ts.map +1 -1
- package/dist/proto/handle_pb.js +26 -5
- package/dist/proto/handle_pb.js.map +1 -1
- package/dist/proto/participant_pb.cjs +112 -15
- package/dist/proto/participant_pb.cjs.map +1 -1
- package/dist/proto/participant_pb.d.cts +140 -52
- package/dist/proto/participant_pb.d.ts +140 -52
- package/dist/proto/participant_pb.d.ts.map +1 -1
- package/dist/proto/participant_pb.js +109 -11
- package/dist/proto/participant_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +2693 -302
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +1265 -862
- package/dist/proto/room_pb.d.ts +1265 -862
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +2603 -210
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/rpc_pb.cjs +302 -37
- package/dist/proto/rpc_pb.cjs.map +1 -1
- package/dist/proto/rpc_pb.d.cts +138 -108
- package/dist/proto/rpc_pb.d.ts +138 -108
- package/dist/proto/rpc_pb.d.ts.map +1 -1
- package/dist/proto/rpc_pb.js +291 -25
- package/dist/proto/rpc_pb.js.map +1 -1
- package/dist/proto/stats_pb.cjs +1253 -139
- package/dist/proto/stats_pb.cjs.map +1 -1
- package/dist/proto/stats_pb.d.cts +803 -692
- package/dist/proto/stats_pb.d.ts +803 -692
- package/dist/proto/stats_pb.d.ts.map +1 -1
- package/dist/proto/stats_pb.js +1216 -93
- package/dist/proto/stats_pb.js.map +1 -1
- package/dist/proto/track_pb.cjs +462 -64
- package/dist/proto/track_pb.cjs.map +1 -1
- package/dist/proto/track_pb.d.cts +250 -218
- package/dist/proto/track_pb.d.ts +250 -218
- package/dist/proto/track_pb.d.ts.map +1 -1
- package/dist/proto/track_pb.js +447 -45
- package/dist/proto/track_pb.js.map +1 -1
- package/dist/proto/track_publication_pb.cjs +130 -0
- package/dist/proto/track_publication_pb.cjs.map +1 -0
- package/dist/proto/track_publication_pb.d.cts +80 -0
- package/dist/proto/track_publication_pb.d.ts +80 -0
- package/dist/proto/track_publication_pb.d.ts.map +1 -0
- package/dist/proto/track_publication_pb.js +103 -0
- package/dist/proto/track_publication_pb.js.map +1 -0
- package/dist/proto/video_frame_pb.cjs +648 -88
- package/dist/proto/video_frame_pb.cjs.map +1 -1
- package/dist/proto/video_frame_pb.d.cts +371 -328
- package/dist/proto/video_frame_pb.d.ts +371 -328
- package/dist/proto/video_frame_pb.d.ts.map +1 -1
- package/dist/proto/video_frame_pb.js +626 -60
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +93 -125
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +6 -17
- package/dist/room.d.ts +6 -17
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +92 -122
- package/dist/room.js.map +1 -1
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +0 -1
- package/dist/rpc.d.ts +0 -1
- package/dist/rpc.js.map +1 -1
- package/dist/track.cjs +12 -8
- package/dist/track.cjs.map +1 -1
- package/dist/track.d.cts +8 -9
- package/dist/track.d.ts +8 -9
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +13 -9
- package/dist/track.js.map +1 -1
- package/dist/track_publication.cjs +21 -12
- package/dist/track_publication.cjs.map +1 -1
- package/dist/track_publication.d.cts +12 -13
- package/dist/track_publication.d.ts +12 -13
- package/dist/track_publication.d.ts.map +1 -1
- package/dist/track_publication.js +22 -13
- package/dist/track_publication.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +26 -45
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.cts +2 -3
- package/dist/video_frame.d.ts +2 -3
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +29 -48
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.cjs +7 -4
- package/dist/video_source.cjs.map +1 -1
- package/dist/video_source.d.cts +4 -4
- package/dist/video_source.d.ts +4 -4
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +9 -6
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.cjs +16 -5
- package/dist/video_stream.cjs.map +1 -1
- package/dist/video_stream.d.cts +3 -4
- package/dist/video_stream.d.ts +3 -4
- package/dist/video_stream.d.ts.map +1 -1
- package/dist/video_stream.js +17 -6
- package/dist/video_stream.js.map +1 -1
- package/package.json +9 -9
- package/src/audio_frame.ts +10 -10
- package/src/audio_resampler.ts +15 -13
- package/src/audio_source.ts +11 -8
- package/src/audio_stream.ts +3 -4
- package/src/e2ee.ts +36 -37
- package/src/ffi_client.ts +8 -16
- package/src/index.ts +5 -68
- package/src/napi/native.d.ts +5 -5
- package/src/participant.ts +100 -72
- package/src/proto/audio_frame_pb.ts +1220 -496
- package/src/proto/e2ee_pb.ts +858 -337
- package/src/proto/ffi_pb.ts +442 -135
- package/src/proto/handle_pb.ts +33 -19
- package/src/proto/participant_pb.ts +225 -60
- package/src/proto/room_pb.ts +3149 -1013
- package/src/proto/rpc_pb.ts +358 -129
- package/src/proto/stats_pb.ts +1891 -877
- package/src/proto/track_pb.ts +587 -253
- package/src/proto/track_publication_pb.ts +180 -0
- package/src/proto/video_frame_pb.ts +861 -394
- package/src/room.ts +143 -188
- package/src/rpc.ts +1 -1
- package/src/track.ts +16 -17
- package/src/track_publication.ts +25 -26
- package/src/version.ts +1 -1
- package/src/video_frame.ts +48 -72
- package/src/video_source.ts +11 -8
- package/src/video_stream.ts +18 -8
package/src/track_publication.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { create } from '@bufbuild/protobuf';
|
|
5
4
|
import { FfiClient } from './ffi_client.js';
|
|
6
5
|
import { FfiHandle } from './napi/native.js';
|
|
7
6
|
import type { EncryptionType } from './proto/e2ee_pb.js';
|
|
8
7
|
import type { SetSubscribedResponse } from './proto/room_pb.js';
|
|
9
|
-
import {
|
|
8
|
+
import { SetSubscribedRequest } from './proto/room_pb.js';
|
|
10
9
|
import type {
|
|
11
10
|
OwnedTrackPublication,
|
|
12
11
|
TrackKind,
|
|
@@ -20,52 +19,52 @@ export abstract class TrackPublication {
|
|
|
20
19
|
ffiHandle: FfiHandle;
|
|
21
20
|
|
|
22
21
|
/** @internal */
|
|
23
|
-
info
|
|
22
|
+
info?: TrackPublicationInfo;
|
|
24
23
|
track?: Track;
|
|
25
24
|
|
|
26
25
|
constructor(ownedInfo: OwnedTrackPublication) {
|
|
27
|
-
this.info = ownedInfo.info
|
|
28
|
-
this.ffiHandle = new FfiHandle(ownedInfo
|
|
26
|
+
this.info = ownedInfo.info;
|
|
27
|
+
this.ffiHandle = new FfiHandle(ownedInfo.handle!.id!);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
get sid(): string {
|
|
32
|
-
return this.info
|
|
30
|
+
get sid(): string | undefined {
|
|
31
|
+
return this.info?.sid;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
get name(): string {
|
|
36
|
-
return this.info
|
|
34
|
+
get name(): string | undefined {
|
|
35
|
+
return this.info?.name;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
get kind(): TrackKind {
|
|
40
|
-
return this.info
|
|
38
|
+
get kind(): TrackKind | undefined {
|
|
39
|
+
return this.info?.kind;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
get source(): TrackSource {
|
|
44
|
-
return this.info
|
|
42
|
+
get source(): TrackSource | undefined {
|
|
43
|
+
return this.info?.source;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
get simulcasted(): boolean {
|
|
48
|
-
return this.info
|
|
46
|
+
get simulcasted(): boolean | undefined {
|
|
47
|
+
return this.info?.simulcasted;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
get width(): number {
|
|
52
|
-
return this.info
|
|
50
|
+
get width(): number | undefined {
|
|
51
|
+
return this.info?.width;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
get height(): number {
|
|
56
|
-
return this.info
|
|
54
|
+
get height(): number | undefined {
|
|
55
|
+
return this.info?.height;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
get mimeType(): string {
|
|
60
|
-
return this.info
|
|
58
|
+
get mimeType(): string | undefined {
|
|
59
|
+
return this.info?.mimeType;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
get muted(): boolean {
|
|
64
|
-
return this.info
|
|
62
|
+
get muted(): boolean | undefined {
|
|
63
|
+
return this.info?.muted;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
get encryptionType(): EncryptionType {
|
|
68
|
-
return this.info
|
|
66
|
+
get encryptionType(): EncryptionType | undefined {
|
|
67
|
+
return this.info?.encryptionType;
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -101,7 +100,7 @@ export class RemoteTrackPublication extends TrackPublication {
|
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
setSubscribed(subscribed: boolean) {
|
|
104
|
-
const req =
|
|
103
|
+
const req = new SetSubscribedRequest({
|
|
105
104
|
subscribe: subscribed,
|
|
106
105
|
publicationHandle: this.ffiHandle.handle,
|
|
107
106
|
});
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.13.0";
|
package/src/video_frame.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
8
|
-
OwnedVideoBuffer,
|
|
4
|
+
import { FfiClient, FfiRequest } from './ffi_client.js';
|
|
5
|
+
import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
|
|
6
|
+
import {
|
|
9
7
|
VideoBufferInfo,
|
|
10
8
|
VideoBufferInfo_ComponentInfo,
|
|
11
|
-
VideoConvertResponse,
|
|
12
|
-
} from './proto/video_frame_pb.js';
|
|
13
|
-
import {
|
|
14
|
-
VideoBufferInfoSchema,
|
|
15
|
-
VideoBufferInfo_ComponentInfoSchema,
|
|
16
9
|
VideoBufferType,
|
|
17
10
|
} from './proto/video_frame_pb.js';
|
|
18
11
|
|
|
@@ -36,7 +29,7 @@ export class VideoFrame {
|
|
|
36
29
|
|
|
37
30
|
/** @internal */
|
|
38
31
|
protoInfo(): VideoBufferInfo {
|
|
39
|
-
const info =
|
|
32
|
+
const info = new VideoBufferInfo({
|
|
40
33
|
width: this.width,
|
|
41
34
|
height: this.height,
|
|
42
35
|
type: this.type,
|
|
@@ -65,12 +58,12 @@ export class VideoFrame {
|
|
|
65
58
|
const info = owned.info!;
|
|
66
59
|
return new VideoFrame(
|
|
67
60
|
FfiClient.instance.copyBuffer(
|
|
68
|
-
info.dataPtr
|
|
69
|
-
getPlaneLength(info.type
|
|
61
|
+
info.dataPtr!,
|
|
62
|
+
getPlaneLength(info.type!, info.width!, info.height!),
|
|
70
63
|
),
|
|
71
|
-
info.width
|
|
72
|
-
info.height
|
|
73
|
-
info.type
|
|
64
|
+
info.width!,
|
|
65
|
+
info.height!,
|
|
66
|
+
info.type!,
|
|
74
67
|
);
|
|
75
68
|
}
|
|
76
69
|
|
|
@@ -79,11 +72,11 @@ export class VideoFrame {
|
|
|
79
72
|
if (planeNth >= planeInfos.length) return;
|
|
80
73
|
|
|
81
74
|
const planeInfo = planeInfos[planeNth]!;
|
|
82
|
-
return FfiClient.instance.copyBuffer(planeInfo.dataPtr
|
|
75
|
+
return FfiClient.instance.copyBuffer(planeInfo.dataPtr!, planeInfo.size!);
|
|
83
76
|
}
|
|
84
77
|
|
|
85
78
|
convert(dstType: VideoBufferType, flipY = false): VideoFrame {
|
|
86
|
-
const req =
|
|
79
|
+
const req = new FfiRequest({
|
|
87
80
|
message: {
|
|
88
81
|
case: 'videoConvert',
|
|
89
82
|
value: {
|
|
@@ -94,11 +87,14 @@ export class VideoFrame {
|
|
|
94
87
|
},
|
|
95
88
|
});
|
|
96
89
|
const resp = FfiClient.instance.request<VideoConvertResponse>(req);
|
|
97
|
-
if (resp.message.case !== 'buffer') {
|
|
98
|
-
throw new Error(resp.message.value ?? 'Unknown Error');
|
|
99
|
-
}
|
|
100
90
|
|
|
101
|
-
|
|
91
|
+
switch (resp.message.case) {
|
|
92
|
+
case 'buffer':
|
|
93
|
+
return VideoFrame.fromOwnedInfo(resp.message.value);
|
|
94
|
+
case 'error':
|
|
95
|
+
default:
|
|
96
|
+
throw resp.message.value;
|
|
97
|
+
}
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
@@ -137,108 +133,88 @@ const getPlaneInfos = (
|
|
|
137
133
|
const chromaHeight = Math.trunc((height + 1) / 2);
|
|
138
134
|
switch (type) {
|
|
139
135
|
case VideoBufferType.I420: {
|
|
140
|
-
const y =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
size: width * height,
|
|
144
|
-
});
|
|
145
|
-
const u = create(VideoBufferInfo_ComponentInfoSchema, {
|
|
146
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
136
|
+
const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
|
|
137
|
+
const u = new VideoBufferInfo_ComponentInfo({
|
|
138
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
147
139
|
stride: chromaWidth,
|
|
148
140
|
size: chromaWidth * chromaHeight,
|
|
149
141
|
});
|
|
150
|
-
const v =
|
|
151
|
-
dataPtr: u.dataPtr + BigInt(u.size),
|
|
142
|
+
const v = new VideoBufferInfo_ComponentInfo({
|
|
143
|
+
dataPtr: u.dataPtr! + BigInt(u.size!),
|
|
152
144
|
stride: chromaWidth,
|
|
153
145
|
size: chromaWidth * chromaHeight,
|
|
154
146
|
});
|
|
155
147
|
return [y, u, v];
|
|
156
148
|
}
|
|
157
149
|
case VideoBufferType.I420A: {
|
|
158
|
-
const y =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
size: width * height,
|
|
162
|
-
});
|
|
163
|
-
const u = create(VideoBufferInfo_ComponentInfoSchema, {
|
|
164
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
150
|
+
const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
|
|
151
|
+
const u = new VideoBufferInfo_ComponentInfo({
|
|
152
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
165
153
|
stride: chromaWidth,
|
|
166
154
|
size: chromaWidth * chromaHeight,
|
|
167
155
|
});
|
|
168
|
-
const v =
|
|
169
|
-
dataPtr: u.dataPtr + BigInt(u.size),
|
|
156
|
+
const v = new VideoBufferInfo_ComponentInfo({
|
|
157
|
+
dataPtr: u.dataPtr! + BigInt(u.size!),
|
|
170
158
|
stride: chromaWidth,
|
|
171
159
|
size: chromaWidth * chromaHeight,
|
|
172
160
|
});
|
|
173
|
-
const a =
|
|
174
|
-
dataPtr: v.dataPtr + BigInt(v.size),
|
|
161
|
+
const a = new VideoBufferInfo_ComponentInfo({
|
|
162
|
+
dataPtr: v.dataPtr! + BigInt(v.size!),
|
|
175
163
|
stride: width,
|
|
176
164
|
size: width * height,
|
|
177
165
|
});
|
|
178
166
|
return [y, u, v, a];
|
|
179
167
|
}
|
|
180
168
|
case VideoBufferType.I422: {
|
|
181
|
-
const y =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
size: width * height,
|
|
185
|
-
});
|
|
186
|
-
const u = create(VideoBufferInfo_ComponentInfoSchema, {
|
|
187
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
169
|
+
const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
|
|
170
|
+
const u = new VideoBufferInfo_ComponentInfo({
|
|
171
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
188
172
|
stride: chromaWidth,
|
|
189
173
|
size: chromaWidth * height,
|
|
190
174
|
});
|
|
191
|
-
const v =
|
|
192
|
-
dataPtr: u.dataPtr + BigInt(u.size),
|
|
175
|
+
const v = new VideoBufferInfo_ComponentInfo({
|
|
176
|
+
dataPtr: u.dataPtr! + BigInt(u.size!),
|
|
193
177
|
stride: chromaWidth,
|
|
194
178
|
size: chromaWidth * height,
|
|
195
179
|
});
|
|
196
180
|
return [y, u, v];
|
|
197
181
|
}
|
|
198
182
|
case VideoBufferType.I444: {
|
|
199
|
-
const y =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
size: width * height,
|
|
203
|
-
});
|
|
204
|
-
const u = create(VideoBufferInfo_ComponentInfoSchema, {
|
|
205
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
183
|
+
const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
|
|
184
|
+
const u = new VideoBufferInfo_ComponentInfo({
|
|
185
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
206
186
|
stride: width,
|
|
207
187
|
size: width * height,
|
|
208
188
|
});
|
|
209
|
-
const v =
|
|
210
|
-
dataPtr: u.dataPtr + BigInt(u.size),
|
|
189
|
+
const v = new VideoBufferInfo_ComponentInfo({
|
|
190
|
+
dataPtr: u.dataPtr! + BigInt(u.size!),
|
|
211
191
|
stride: width,
|
|
212
192
|
size: width * height,
|
|
213
193
|
});
|
|
214
194
|
return [y, u, v];
|
|
215
195
|
}
|
|
216
196
|
case VideoBufferType.I010: {
|
|
217
|
-
const y =
|
|
197
|
+
const y = new VideoBufferInfo_ComponentInfo({
|
|
218
198
|
dataPtr,
|
|
219
199
|
stride: width * 2,
|
|
220
200
|
size: width * height * 2,
|
|
221
201
|
});
|
|
222
|
-
const u =
|
|
223
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
202
|
+
const u = new VideoBufferInfo_ComponentInfo({
|
|
203
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
224
204
|
stride: chromaWidth * 2,
|
|
225
205
|
size: chromaWidth * chromaHeight * 2,
|
|
226
206
|
});
|
|
227
|
-
const v =
|
|
228
|
-
dataPtr: u.dataPtr + BigInt(u.size),
|
|
207
|
+
const v = new VideoBufferInfo_ComponentInfo({
|
|
208
|
+
dataPtr: u.dataPtr! + BigInt(u.size!),
|
|
229
209
|
stride: chromaWidth * 2,
|
|
230
210
|
size: chromaWidth * chromaHeight * 2,
|
|
231
211
|
});
|
|
232
212
|
return [y, u, v];
|
|
233
213
|
}
|
|
234
214
|
case VideoBufferType.NV12: {
|
|
235
|
-
const y =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
size: width * height,
|
|
239
|
-
});
|
|
240
|
-
const uv = create(VideoBufferInfo_ComponentInfoSchema, {
|
|
241
|
-
dataPtr: y.dataPtr + BigInt(y.size),
|
|
215
|
+
const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
|
|
216
|
+
const uv = new VideoBufferInfo_ComponentInfo({
|
|
217
|
+
dataPtr: y.dataPtr! + BigInt(y.size!),
|
|
242
218
|
stride: chromaWidth * 2,
|
|
243
219
|
size: chromaWidth * chromaHeight * 2,
|
|
244
220
|
});
|
package/src/video_source.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { create } from '@bufbuild/protobuf';
|
|
5
4
|
import { FfiClient, FfiHandle } from './ffi_client.js';
|
|
6
5
|
import type {
|
|
7
6
|
CaptureVideoFrameResponse,
|
|
@@ -9,8 +8,8 @@ import type {
|
|
|
9
8
|
VideoSourceInfo,
|
|
10
9
|
} from './proto/video_frame_pb.js';
|
|
11
10
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
CaptureVideoFrameRequest,
|
|
12
|
+
NewVideoSourceRequest,
|
|
14
13
|
VideoRotation,
|
|
15
14
|
VideoSourceType,
|
|
16
15
|
} from './proto/video_frame_pb.js';
|
|
@@ -18,7 +17,7 @@ import type { VideoFrame } from './video_frame.js';
|
|
|
18
17
|
|
|
19
18
|
export class VideoSource {
|
|
20
19
|
/** @internal */
|
|
21
|
-
info
|
|
20
|
+
info?: VideoSourceInfo;
|
|
22
21
|
/** @internal */
|
|
23
22
|
ffiHandle: FfiHandle;
|
|
24
23
|
|
|
@@ -29,7 +28,7 @@ export class VideoSource {
|
|
|
29
28
|
this.width = width;
|
|
30
29
|
this.height = height;
|
|
31
30
|
|
|
32
|
-
const req =
|
|
31
|
+
const req = new NewVideoSourceRequest({
|
|
33
32
|
type: VideoSourceType.VIDEO_SOURCE_NATIVE,
|
|
34
33
|
resolution: {
|
|
35
34
|
width: width,
|
|
@@ -44,8 +43,8 @@ export class VideoSource {
|
|
|
44
43
|
},
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
this.info = res.source
|
|
48
|
-
this.ffiHandle = new FfiHandle(res.source!.handle!.id);
|
|
46
|
+
this.info = res.source?.info;
|
|
47
|
+
this.ffiHandle = new FfiHandle(res.source!.handle!.id!);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
captureFrame(
|
|
@@ -53,7 +52,7 @@ export class VideoSource {
|
|
|
53
52
|
timestampUs = BigInt(0),
|
|
54
53
|
rotation = VideoRotation.VIDEO_ROTATION_0,
|
|
55
54
|
) {
|
|
56
|
-
const req =
|
|
55
|
+
const req = new CaptureVideoFrameRequest({
|
|
57
56
|
sourceHandle: this.ffiHandle.handle,
|
|
58
57
|
buffer: frame.protoInfo(),
|
|
59
58
|
rotation,
|
|
@@ -64,4 +63,8 @@ export class VideoSource {
|
|
|
64
63
|
message: { case: 'captureVideoFrame', value: req },
|
|
65
64
|
});
|
|
66
65
|
}
|
|
66
|
+
|
|
67
|
+
async close() {
|
|
68
|
+
this.ffiHandle.dispose();
|
|
69
|
+
}
|
|
67
70
|
}
|
package/src/video_stream.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { create } from '@bufbuild/protobuf';
|
|
5
4
|
import { Mutex } from '@livekit/mutex';
|
|
6
5
|
import type { FfiEvent } from './ffi_client.js';
|
|
7
6
|
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
|
|
@@ -10,7 +9,7 @@ import type {
|
|
|
10
9
|
VideoRotation,
|
|
11
10
|
VideoStreamInfo,
|
|
12
11
|
} from './proto/video_frame_pb.js';
|
|
13
|
-
import {
|
|
12
|
+
import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
|
|
14
13
|
import type { Track } from './track.js';
|
|
15
14
|
import { VideoFrame } from './video_frame.js';
|
|
16
15
|
|
|
@@ -22,7 +21,7 @@ export type VideoFrameEvent = {
|
|
|
22
21
|
|
|
23
22
|
export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
|
|
24
23
|
/** @internal */
|
|
25
|
-
info
|
|
24
|
+
info?: VideoStreamInfo;
|
|
26
25
|
/** @internal */
|
|
27
26
|
ffiHandle: FfiHandle;
|
|
28
27
|
/** @internal */
|
|
@@ -37,7 +36,7 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
|
|
|
37
36
|
constructor(track: Track) {
|
|
38
37
|
this.track = track;
|
|
39
38
|
|
|
40
|
-
const req =
|
|
39
|
+
const req = new NewVideoStreamRequest({
|
|
41
40
|
type: VideoStreamType.VIDEO_STREAM_NATIVE,
|
|
42
41
|
trackHandle: track.ffi_handle.handle,
|
|
43
42
|
});
|
|
@@ -49,8 +48,8 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
|
|
|
49
48
|
},
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
this.info = res.stream
|
|
53
|
-
this.ffiHandle = new FfiHandle(res.stream!.handle!.id);
|
|
51
|
+
this.info = res.stream?.info;
|
|
52
|
+
this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);
|
|
54
53
|
|
|
55
54
|
FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);
|
|
56
55
|
}
|
|
@@ -71,9 +70,20 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
|
|
|
71
70
|
const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);
|
|
72
71
|
const value = { rotation, timestampUs, frame };
|
|
73
72
|
if (this.queueResolve) {
|
|
74
|
-
this.queueResolve({
|
|
73
|
+
this.queueResolve({
|
|
74
|
+
done: false,
|
|
75
|
+
value: {
|
|
76
|
+
frame: value.frame,
|
|
77
|
+
timestampUs: value.timestampUs!,
|
|
78
|
+
rotation: value.rotation!,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
75
81
|
} else {
|
|
76
|
-
this.eventQueue.push(
|
|
82
|
+
this.eventQueue.push({
|
|
83
|
+
frame: value.frame,
|
|
84
|
+
timestampUs: value.timestampUs!,
|
|
85
|
+
rotation: value.rotation!,
|
|
86
|
+
});
|
|
77
87
|
}
|
|
78
88
|
break;
|
|
79
89
|
case 'eos':
|