@livekit/rtc-node 0.0.2 → 0.0.4
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 +21 -0
- package/build.rs +5 -0
- package/dist/audio_frame.d.ts +14 -0
- package/dist/audio_frame.d.ts.map +1 -0
- package/dist/audio_frame.js +36 -0
- package/dist/audio_frame.js.map +1 -0
- package/dist/audio_source.d.ts +14 -0
- package/dist/audio_source.d.ts.map +1 -0
- package/dist/audio_source.js +42 -0
- package/dist/audio_source.js.map +1 -0
- package/dist/audio_stream.d.ts +24 -0
- package/dist/audio_stream.d.ts.map +1 -0
- package/dist/audio_stream.js +54 -0
- package/dist/audio_stream.js.map +1 -0
- package/dist/e2ee.d.ts +44 -0
- package/dist/e2ee.d.ts.map +1 -0
- package/dist/e2ee.js +232 -0
- package/dist/e2ee.js.map +1 -0
- package/dist/ffi_client.d.ts +23 -0
- package/dist/ffi_client.d.ts.map +1 -0
- package/dist/ffi_client.js +57 -0
- package/dist/ffi_client.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/native.d.ts +14 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +297 -0
- package/dist/native.js.map +1 -0
- package/dist/participant.d.ts +30 -0
- package/dist/participant.d.ts.map +1 -0
- package/dist/participant.js +120 -0
- package/dist/participant.js.map +1 -0
- package/dist/proto/audio_frame_pb.d.ts +556 -0
- package/dist/proto/audio_frame_pb.d.ts.map +1 -0
- package/dist/proto/audio_frame_pb.js +861 -0
- package/dist/proto/audio_frame_pb.js.map +1 -0
- package/dist/proto/e2ee_pb.d.ts +652 -0
- package/dist/proto/e2ee_pb.d.ts.map +1 -0
- package/dist/proto/e2ee_pb.js +906 -0
- package/dist/proto/e2ee_pb.js.map +1 -0
- package/dist/proto/ffi_pb.d.ts +672 -0
- package/dist/proto/ffi_pb.d.ts.map +1 -0
- package/dist/proto/ffi_pb.js +459 -0
- package/dist/proto/ffi_pb.js.map +1 -0
- package/dist/proto/handle_pb.d.ts +30 -0
- package/dist/proto/handle_pb.d.ts.map +1 -0
- package/dist/proto/handle_pb.js +59 -0
- package/dist/proto/handle_pb.js.map +1 -0
- package/dist/proto/participant_pb.d.ts +54 -0
- package/dist/proto/participant_pb.d.ts.map +1 -0
- package/dist/proto/participant_pb.js +93 -0
- package/dist/proto/participant_pb.js.map +1 -0
- package/dist/proto/room_pb.d.ts +1480 -0
- package/dist/proto/room_pb.d.ts.map +1 -0
- package/dist/proto/room_pb.js +2172 -0
- package/dist/proto/room_pb.js.map +1 -0
- package/dist/proto/stats_pb.d.ts +1713 -0
- package/dist/proto/stats_pb.d.ts.map +1 -0
- package/dist/proto/stats_pb.js +2238 -0
- package/dist/proto/stats_pb.js.map +1 -0
- package/dist/proto/track_pb.d.ts +353 -0
- package/dist/proto/track_pb.d.ts.map +1 -0
- package/dist/proto/track_pb.js +550 -0
- package/dist/proto/track_pb.js.map +1 -0
- package/dist/proto/video_frame_pb.d.ts +855 -0
- package/dist/proto/video_frame_pb.d.ts.map +1 -0
- package/dist/proto/video_frame_pb.js +1214 -0
- package/dist/proto/video_frame_pb.js.map +1 -0
- package/dist/room.d.ts +95 -0
- package/dist/room.d.ts.map +1 -0
- package/dist/room.js +285 -0
- package/dist/room.js.map +1 -0
- package/dist/track.d.ts +35 -0
- package/dist/track.d.ts.map +1 -0
- package/dist/track.js +72 -0
- package/dist/track.js.map +1 -0
- package/dist/track_publication.d.ts +31 -0
- package/dist/track_publication.d.ts.map +1 -0
- package/dist/track_publication.js +66 -0
- package/dist/track_publication.js.map +1 -0
- package/dist/video_frame.d.ts +111 -0
- package/dist/video_frame.d.ts.map +1 -0
- package/dist/video_frame.js +364 -0
- package/dist/video_frame.js.map +1 -0
- package/dist/video_source.d.ts +14 -0
- package/dist/video_source.d.ts.map +1 -0
- package/dist/video_source.js +44 -0
- package/dist/video_source.js.map +1 -0
- package/dist/video_stream.d.ts +24 -0
- package/dist/video_stream.d.ts.map +1 -0
- package/dist/video_stream.js +56 -0
- package/dist/video_stream.js.map +1 -0
- package/package.json +19 -14
- package/src/audio_frame.ts +45 -0
- package/src/audio_source.ts +64 -0
- package/src/audio_stream.ts +74 -0
- package/src/e2ee.ts +311 -0
- package/src/ffi_client.ts +68 -0
- package/src/index.ts +52 -0
- package/src/lib.rs +5 -0
- package/src/native.d.ts +14 -0
- package/src/native.js +269 -0
- package/src/nodejs.rs +115 -0
- package/src/participant.ts +171 -0
- package/src/proto/audio_frame_pb.ts +1121 -0
- package/src/proto/e2ee_pb.ts +1231 -0
- package/src/proto/ffi_pb.ts +969 -0
- package/src/proto/handle_pb.ts +69 -0
- package/src/proto/participant_pb.ts +121 -0
- package/src/proto/room_pb.ts +2843 -0
- package/src/proto/stats_pb.ts +2955 -0
- package/src/proto/track_pb.ts +683 -0
- package/src/proto/video_frame_pb.ts +1568 -0
- package/src/room.ts +370 -0
- package/src/track.ts +101 -0
- package/src/track_publication.ts +90 -0
- package/src/video_frame.ts +620 -0
- package/src/video_source.ts +61 -0
- package/src/video_stream.ts +76 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FfiClient, FfiClientEvent, FfiEvent, FfiHandle, FfiRequest } from './ffi_client';
|
|
2
|
+
import { Track } from './track';
|
|
3
|
+
import EventEmitter from 'events';
|
|
4
|
+
import TypedEmitter from 'typed-emitter';
|
|
5
|
+
import { VideoFrame, VideoFrameBuffer } from './video_frame';
|
|
6
|
+
import {
|
|
7
|
+
NewVideoStreamRequest,
|
|
8
|
+
NewVideoStreamResponse,
|
|
9
|
+
VideoStreamInfo,
|
|
10
|
+
VideoStreamType,
|
|
11
|
+
} from './proto/video_frame_pb';
|
|
12
|
+
|
|
13
|
+
export type VideoStreamCallbacks = {
|
|
14
|
+
frameReceived: (frame: VideoFrame) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export enum VideoStreamEvent {
|
|
18
|
+
FrameReceived = 'frameReceived',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class VideoStream extends (EventEmitter as new () => TypedEmitter<VideoStreamCallbacks>) {
|
|
22
|
+
/** @internal */
|
|
23
|
+
info: VideoStreamInfo;
|
|
24
|
+
/** @internal */
|
|
25
|
+
ffiHandle: FfiHandle;
|
|
26
|
+
|
|
27
|
+
track: Track;
|
|
28
|
+
|
|
29
|
+
constructor(track: Track) {
|
|
30
|
+
super();
|
|
31
|
+
this.track = track;
|
|
32
|
+
|
|
33
|
+
let req = new NewVideoStreamRequest({
|
|
34
|
+
type: VideoStreamType.VIDEO_STREAM_NATIVE,
|
|
35
|
+
trackHandle: track.ffi_handle.handle,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let res = FfiClient.instance.request<NewVideoStreamResponse>({
|
|
39
|
+
message: {
|
|
40
|
+
case: 'newVideoStream',
|
|
41
|
+
value: req,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.info = res.stream.info;
|
|
46
|
+
this.ffiHandle = new FfiHandle(res.stream.handle.id);
|
|
47
|
+
|
|
48
|
+
FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private onEvent(ev: FfiEvent) {
|
|
52
|
+
if (
|
|
53
|
+
ev.message.case != 'videoStreamEvent' ||
|
|
54
|
+
ev.message.value.streamHandle != this.ffiHandle.handle
|
|
55
|
+
) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let streamEvent = ev.message.value.message;
|
|
60
|
+
switch (streamEvent.case) {
|
|
61
|
+
case 'frameReceived':
|
|
62
|
+
let frameInfo = streamEvent.value.frame;
|
|
63
|
+
let buffer = VideoFrameBuffer.fromOwnedInfo(streamEvent.value.buffer);
|
|
64
|
+
let frame = new VideoFrame(Number(frameInfo.timestampUs), frameInfo.rotation, buffer);
|
|
65
|
+
this.emit(VideoStreamEvent.FrameReceived, frame);
|
|
66
|
+
break;
|
|
67
|
+
case 'eos':
|
|
68
|
+
FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
close() {
|
|
74
|
+
this.ffiHandle.dispose();
|
|
75
|
+
}
|
|
76
|
+
}
|