@livekit/rtc-node 0.3.0 → 0.4.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/Cargo.toml +2 -1
- package/dist/audio_frame.d.ts +2 -1
- 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_source.d.ts +2 -2
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +6 -9
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.d.ts +3 -3
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +6 -6
- package/dist/audio_stream.js.map +1 -1
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +16 -16
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.d.ts +4 -3
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +11 -11
- package/dist/ffi_client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/napi/native.cjs +9 -2
- package/dist/napi/native.d.ts +1 -0
- package/dist/napi/native.js +2 -2
- package/dist/participant.d.ts +5 -4
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +15 -15
- package/dist/participant.js.map +1 -1
- package/dist/room.d.ts +25 -22
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +58 -55
- package/dist/room.js.map +1 -1
- package/dist/track.d.ts +3 -3
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +5 -8
- package/dist/track.js.map +1 -1
- package/dist/track_publication.d.ts +3 -3
- package/dist/track_publication.d.ts.map +1 -1
- package/dist/track_publication.js +1 -1
- package/dist/track_publication.js.map +1 -1
- package/dist/video_frame.d.ts +2 -1
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +1 -1
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.d.ts +3 -2
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +3 -3
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.d.ts +3 -3
- package/dist/video_stream.d.ts.map +1 -1
- package/dist/video_stream.js +8 -8
- package/dist/video_stream.js.map +1 -1
- package/package.json +8 -8
- package/src/audio_frame.ts +5 -5
- package/src/audio_source.ts +13 -14
- package/src/audio_stream.ts +13 -17
- package/src/e2ee.ts +25 -24
- package/src/ffi_client.ts +15 -11
- package/src/index.ts +1 -3
- package/src/napi/native.cjs +9 -2
- package/src/napi/native.d.ts +1 -0
- package/src/napi/native.js +2 -2
- package/src/nodejs.rs +5 -0
- package/src/participant.ts +27 -29
- package/src/room.ts +94 -91
- package/src/track.ts +9 -11
- package/src/track_publication.ts +7 -7
- package/src/video_frame.ts +9 -16
- package/src/video_source.ts +10 -9
- package/src/video_stream.ts +17 -18
package/src/video_frame.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
import {
|
|
4
|
+
import { FfiClient, FfiRequest } from './ffi_client.js';
|
|
5
|
+
import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
|
|
6
6
|
import {
|
|
7
|
-
OwnedVideoBuffer,
|
|
8
7
|
VideoBufferInfo,
|
|
9
8
|
VideoBufferInfo_ComponentInfo,
|
|
10
9
|
VideoBufferType,
|
|
11
|
-
VideoConvertResponse,
|
|
12
10
|
} from './proto/video_frame_pb.js';
|
|
13
11
|
|
|
14
12
|
export class VideoFrame {
|
|
@@ -17,12 +15,7 @@ export class VideoFrame {
|
|
|
17
15
|
height: number;
|
|
18
16
|
type: VideoBufferType;
|
|
19
17
|
|
|
20
|
-
constructor(
|
|
21
|
-
data: Uint8Array,
|
|
22
|
-
width: number,
|
|
23
|
-
height: number,
|
|
24
|
-
type: VideoBufferType,
|
|
25
|
-
) {
|
|
18
|
+
constructor(data: Uint8Array, width: number, height: number, type: VideoBufferType) {
|
|
26
19
|
this.data = data;
|
|
27
20
|
this.width = width;
|
|
28
21
|
this.height = height;
|
|
@@ -31,7 +24,7 @@ export class VideoFrame {
|
|
|
31
24
|
|
|
32
25
|
/** @internal */
|
|
33
26
|
get dataPtr(): bigint {
|
|
34
|
-
return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer))
|
|
27
|
+
return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
|
|
35
28
|
}
|
|
36
29
|
|
|
37
30
|
/** @internal */
|
|
@@ -60,7 +53,7 @@ export class VideoFrame {
|
|
|
60
53
|
|
|
61
54
|
/** @internal */
|
|
62
55
|
static fromOwnedInfo(owned: OwnedVideoBuffer): VideoFrame {
|
|
63
|
-
|
|
56
|
+
const info = owned.info;
|
|
64
57
|
return new VideoFrame(
|
|
65
58
|
FfiClient.instance.copyBuffer(
|
|
66
59
|
info.dataPtr,
|
|
@@ -73,7 +66,7 @@ export class VideoFrame {
|
|
|
73
66
|
}
|
|
74
67
|
|
|
75
68
|
getPlane(planeNth: number): Uint8Array | void {
|
|
76
|
-
const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height)
|
|
69
|
+
const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
|
|
77
70
|
if (planeNth >= planeInfos.length) return;
|
|
78
71
|
|
|
79
72
|
const planeInfo = planeInfos[planeNth];
|
|
@@ -91,12 +84,12 @@ export class VideoFrame {
|
|
|
91
84
|
},
|
|
92
85
|
},
|
|
93
86
|
});
|
|
94
|
-
const resp = FfiClient.instance.request<VideoConvertResponse>(req)
|
|
87
|
+
const resp = FfiClient.instance.request<VideoConvertResponse>(req);
|
|
95
88
|
if (resp.error) {
|
|
96
|
-
throw resp.error
|
|
89
|
+
throw resp.error;
|
|
97
90
|
}
|
|
98
91
|
|
|
99
|
-
return VideoFrame.fromOwnedInfo(resp.buffer)
|
|
92
|
+
return VideoFrame.fromOwnedInfo(resp.buffer);
|
|
100
93
|
}
|
|
101
94
|
}
|
|
102
95
|
|
package/src/video_source.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
import {
|
|
4
|
+
import { FfiClient, FfiHandle } from './ffi_client.js';
|
|
5
|
+
import type {
|
|
6
|
+
CaptureVideoFrameResponse,
|
|
7
|
+
NewVideoSourceResponse,
|
|
8
|
+
VideoSourceInfo,
|
|
9
|
+
} from './proto/video_frame_pb.js';
|
|
6
10
|
import {
|
|
7
11
|
CaptureVideoFrameRequest,
|
|
8
|
-
CaptureVideoFrameResponse,
|
|
9
12
|
NewVideoSourceRequest,
|
|
10
|
-
NewVideoSourceResponse,
|
|
11
13
|
VideoRotation,
|
|
12
|
-
VideoSourceInfo,
|
|
13
14
|
VideoSourceType,
|
|
14
15
|
} from './proto/video_frame_pb.js';
|
|
15
|
-
import { VideoFrame } from './video_frame.js';
|
|
16
|
+
import type { VideoFrame } from './video_frame.js';
|
|
16
17
|
|
|
17
18
|
export class VideoSource {
|
|
18
19
|
/** @internal */
|
|
@@ -27,7 +28,7 @@ export class VideoSource {
|
|
|
27
28
|
this.width = width;
|
|
28
29
|
this.height = height;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
const req = new NewVideoSourceRequest({
|
|
31
32
|
type: VideoSourceType.VIDEO_SOURCE_NATIVE,
|
|
32
33
|
resolution: {
|
|
33
34
|
width: width,
|
|
@@ -35,7 +36,7 @@ export class VideoSource {
|
|
|
35
36
|
},
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
const res = FfiClient.instance.request<NewVideoSourceResponse>({
|
|
39
40
|
message: {
|
|
40
41
|
case: 'newVideoSource',
|
|
41
42
|
value: req,
|
|
@@ -47,7 +48,7 @@ export class VideoSource {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
captureFrame(frame: VideoFrame, timestampUs = 0n, rotation = VideoRotation.VIDEO_ROTATION_0) {
|
|
50
|
-
|
|
51
|
+
const req = new CaptureVideoFrameRequest({
|
|
51
52
|
sourceHandle: this.ffiHandle.handle,
|
|
52
53
|
buffer: frame.protoInfo(),
|
|
53
54
|
rotation,
|
package/src/video_stream.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client.js';
|
|
6
|
-
import { Track } from './track.js';
|
|
7
4
|
import EventEmitter from 'events';
|
|
8
|
-
import TypedEmitter from 'typed-emitter';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
5
|
+
import type TypedEmitter from 'typed-emitter';
|
|
6
|
+
import type { FfiEvent } from './ffi_client.js';
|
|
7
|
+
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
|
|
8
|
+
import type {
|
|
12
9
|
NewVideoStreamResponse,
|
|
13
10
|
VideoRotation,
|
|
14
11
|
VideoStreamInfo,
|
|
15
|
-
VideoStreamType,
|
|
16
12
|
} from './proto/video_frame_pb.js';
|
|
13
|
+
import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
|
|
14
|
+
import type { Track } from './track.js';
|
|
15
|
+
import { VideoFrame } from './video_frame.js';
|
|
17
16
|
|
|
18
17
|
export type VideoFrameEvent = {
|
|
19
|
-
frame: VideoFrame
|
|
20
|
-
timestampUs: bigint
|
|
21
|
-
rotation: VideoRotation
|
|
22
|
-
}
|
|
18
|
+
frame: VideoFrame;
|
|
19
|
+
timestampUs: bigint;
|
|
20
|
+
rotation: VideoRotation;
|
|
21
|
+
};
|
|
23
22
|
|
|
24
23
|
export type VideoStreamCallbacks = {
|
|
25
24
|
frameReceived: (evt: VideoFrameEvent) => void;
|
|
@@ -41,12 +40,12 @@ export class VideoStream extends (EventEmitter as new () => TypedEmitter<VideoSt
|
|
|
41
40
|
super();
|
|
42
41
|
this.track = track;
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
const req = new NewVideoStreamRequest({
|
|
45
44
|
type: VideoStreamType.VIDEO_STREAM_NATIVE,
|
|
46
45
|
trackHandle: track.ffi_handle.handle,
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
const res = FfiClient.instance.request<NewVideoStreamResponse>({
|
|
50
49
|
message: {
|
|
51
50
|
case: 'newVideoStream',
|
|
52
51
|
value: req,
|
|
@@ -67,12 +66,12 @@ export class VideoStream extends (EventEmitter as new () => TypedEmitter<VideoSt
|
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
const streamEvent = ev.message.value.message;
|
|
71
70
|
switch (streamEvent.case) {
|
|
72
71
|
case 'frameReceived':
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const rotation = streamEvent.value.rotation;
|
|
73
|
+
const timestampUs = streamEvent.value.timestampUs;
|
|
74
|
+
const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer);
|
|
76
75
|
this.emit(VideoStreamEvent.FrameReceived, { frame, timestampUs, rotation });
|
|
77
76
|
break;
|
|
78
77
|
case 'eos':
|