stream-doctor 0.1.0 → 0.2.0-alpha.1
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/stream_doctor.d.ts +149 -5
- package/dist/stream_doctor.js +3 -3
- package/package.json +4 -4
package/dist/stream_doctor.d.ts
CHANGED
|
@@ -1,9 +1,73 @@
|
|
|
1
1
|
import { type ChildProcess } from "node:child_process";
|
|
2
2
|
/** Lifecycle state of a streamer or viewer. */
|
|
3
3
|
export type Status = "streaming" | "receiving" | "waiting_for_playlist" | "ended" | "failed" | "stopped";
|
|
4
|
+
/** H.264 profiles the generator encodes to; the generator emits 8-bit I420, so 10-bit and 4:2:2 are out. */
|
|
5
|
+
export type VideoProfile = "baseline" | "main" | "high";
|
|
6
|
+
/** x264 presets, from fastest to smallest. */
|
|
7
|
+
export type Preset = "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" | "placebo";
|
|
8
|
+
/** x264 tunings. */
|
|
9
|
+
export type Tune = "film" | "animation" | "grain" | "stillimage" | "fastdecode" | "zerolatency";
|
|
10
|
+
/** AAC profiles the generator encodes to. */
|
|
11
|
+
export type AudioProfile = "mpeg4_lc" | "mpeg2_lc";
|
|
12
|
+
/** Sample rates the AAC encoder accepts. */
|
|
13
|
+
export type SampleRate = 12000 | 16000 | 24000 | 32000 | 44100 | 48000 | 64000 | 88200;
|
|
14
|
+
/** Settings for a synthetic source; anything left out keeps the daemon default. */
|
|
15
|
+
export interface SyntheticSource {
|
|
16
|
+
video?: {
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
/** A whole number of frames per second, or [numerator, denominator] for rates like 30000/1001. */
|
|
20
|
+
fps?: number | [number, number];
|
|
21
|
+
gop_size?: number;
|
|
22
|
+
preset?: Preset;
|
|
23
|
+
tune?: Tune;
|
|
24
|
+
profile?: VideoProfile;
|
|
25
|
+
crf?: number;
|
|
26
|
+
bitrate?: number;
|
|
27
|
+
};
|
|
28
|
+
audio?: {
|
|
29
|
+
sample_rate?: SampleRate;
|
|
30
|
+
bitrate?: number;
|
|
31
|
+
profile?: AudioProfile;
|
|
32
|
+
};
|
|
33
|
+
/** Seconds to stream; omitted means the stream never ends. */
|
|
34
|
+
duration?: number;
|
|
35
|
+
}
|
|
36
|
+
/** A synthetic source as the daemon resolved it, with every default filled in. */
|
|
37
|
+
export interface ResolvedSyntheticSource {
|
|
38
|
+
video: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
fps: [number, number];
|
|
42
|
+
gop_size: number;
|
|
43
|
+
preset: Preset;
|
|
44
|
+
tune: Tune;
|
|
45
|
+
profile: VideoProfile | null;
|
|
46
|
+
crf: number | null;
|
|
47
|
+
bitrate: number | null;
|
|
48
|
+
};
|
|
49
|
+
audio: {
|
|
50
|
+
sample_rate: SampleRate;
|
|
51
|
+
bitrate: number | null;
|
|
52
|
+
profile: AudioProfile;
|
|
53
|
+
};
|
|
54
|
+
duration: number | null;
|
|
55
|
+
}
|
|
56
|
+
/** What a streamer should send: a file the daemon reads, or a source it generates. */
|
|
57
|
+
export type PublishInput = {
|
|
58
|
+
file: string;
|
|
59
|
+
synthetic?: never;
|
|
60
|
+
} | {
|
|
61
|
+
file?: never;
|
|
62
|
+
synthetic: SyntheticSource;
|
|
63
|
+
};
|
|
4
64
|
/** State of the publisher, as reported by the daemon. */
|
|
5
65
|
export interface StreamerStatus {
|
|
6
|
-
input:
|
|
66
|
+
input: {
|
|
67
|
+
file: string;
|
|
68
|
+
} | {
|
|
69
|
+
synthetic: ResolvedSyntheticSource;
|
|
70
|
+
};
|
|
7
71
|
rtmp_url: string;
|
|
8
72
|
status: Status;
|
|
9
73
|
error: string | null;
|
|
@@ -15,17 +79,99 @@ export interface AvDrift {
|
|
|
15
79
|
frame_duration_ms: number | null;
|
|
16
80
|
latest_samples: number[];
|
|
17
81
|
}
|
|
82
|
+
/** Time from the streamer starting to the first segment appearing; needs `watch()` before `publish()`. */
|
|
83
|
+
export interface TimeToFirstFrame {
|
|
84
|
+
status: "waiting" | "measured" | "missed_first_frame" | "no_streamer";
|
|
85
|
+
ms: number | null;
|
|
86
|
+
}
|
|
87
|
+
/** One frame number, or an inclusive run of them. */
|
|
88
|
+
export type FrameGap = [number] | [number, number];
|
|
89
|
+
/** A frame number and how many extra times it arrived. */
|
|
90
|
+
export type FrameRepeat = [number, number];
|
|
91
|
+
export interface FrameFaults {
|
|
92
|
+
reordered: {
|
|
93
|
+
count: number | null;
|
|
94
|
+
max_depth: number | null;
|
|
95
|
+
permutations: number[][];
|
|
96
|
+
};
|
|
97
|
+
missing: {
|
|
98
|
+
count: number | null;
|
|
99
|
+
gaps: FrameGap[];
|
|
100
|
+
};
|
|
101
|
+
duplicated: {
|
|
102
|
+
count: number | null;
|
|
103
|
+
repeats: FrameRepeat[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface TrackFrameFaults {
|
|
107
|
+
video: FrameFaults;
|
|
108
|
+
audio: FrameFaults;
|
|
109
|
+
}
|
|
110
|
+
/** How long a frame takes to become downloadable. */
|
|
111
|
+
export interface AvailabilityLatency {
|
|
112
|
+
status: "waiting" | "measured";
|
|
113
|
+
ms: number | null;
|
|
114
|
+
latest_samples: number[];
|
|
115
|
+
}
|
|
18
116
|
/** Metrics collected by a viewer. */
|
|
19
117
|
export interface Metrics {
|
|
20
118
|
av_drift?: AvDrift;
|
|
119
|
+
time_to_first_frame?: TimeToFirstFrame;
|
|
120
|
+
frames?: TrackFrameFaults;
|
|
121
|
+
availability_latency?: AvailabilityLatency;
|
|
21
122
|
error?: string;
|
|
22
123
|
}
|
|
124
|
+
/** A track a variant declares in its CODECS attribute. */
|
|
125
|
+
export type Track = VideoTrack | AudioTrack | UnknownTrack;
|
|
126
|
+
export interface VideoTrack {
|
|
127
|
+
type: "video";
|
|
128
|
+
codec: "h264";
|
|
129
|
+
profile: string | null;
|
|
130
|
+
level: string | null;
|
|
131
|
+
}
|
|
132
|
+
export interface AudioTrack {
|
|
133
|
+
type: "audio";
|
|
134
|
+
codec: "aac";
|
|
135
|
+
profile: string | null;
|
|
136
|
+
level: null;
|
|
137
|
+
}
|
|
138
|
+
/** A codec string this SDK does not parse, kept verbatim. */
|
|
139
|
+
export interface UnknownTrack {
|
|
140
|
+
type: "unknown";
|
|
141
|
+
raw: string;
|
|
142
|
+
}
|
|
143
|
+
/** Frame size a variant declares, in pixels. */
|
|
144
|
+
export interface Resolution {
|
|
145
|
+
width: number;
|
|
146
|
+
height: number;
|
|
147
|
+
}
|
|
148
|
+
/** One variant of an HLS stream, as declared by the packager. */
|
|
149
|
+
export interface Variant {
|
|
150
|
+
id: number;
|
|
151
|
+
uri: string;
|
|
152
|
+
container: "mpeg_ts" | "cmaf" | null;
|
|
153
|
+
bandwidth: number | null;
|
|
154
|
+
average_bandwidth: number | null;
|
|
155
|
+
resolution: Resolution | null;
|
|
156
|
+
frame_rate: number | null;
|
|
157
|
+
name: string | null;
|
|
158
|
+
codecs: string | null;
|
|
159
|
+
/** Read from the media when the playlist declares no CODECS attribute, "unknown" when that fails too. */
|
|
160
|
+
tracks: Track[] | "unknown";
|
|
161
|
+
}
|
|
162
|
+
/** What a stream declares about itself in its playlists, read once the playlist appears. */
|
|
163
|
+
export interface PlaylistDescription {
|
|
164
|
+
variants: Variant[];
|
|
165
|
+
error: string | null;
|
|
166
|
+
}
|
|
23
167
|
/** State of a viewer, as reported by the daemon. */
|
|
24
168
|
export interface ViewerStatus {
|
|
25
169
|
id: string;
|
|
26
170
|
hls_url: string;
|
|
27
171
|
status: Status;
|
|
28
172
|
error: string | null;
|
|
173
|
+
/** Null until the playlist has been read. */
|
|
174
|
+
playlist: PlaylistDescription | null;
|
|
29
175
|
metrics: Metrics;
|
|
30
176
|
}
|
|
31
177
|
/** State of the whole daemon. */
|
|
@@ -47,10 +193,8 @@ declare class Session {
|
|
|
47
193
|
child: ChildProcess | null;
|
|
48
194
|
logFile: string | null;
|
|
49
195
|
constructor(daemonUrl: string, child: ChildProcess | null, logFile?: string | null);
|
|
50
|
-
/** Starts publishing `file` to `rtmpUrl`. */
|
|
51
|
-
publish(rtmpUrl: string,
|
|
52
|
-
file?: string;
|
|
53
|
-
}): Streamer;
|
|
196
|
+
/** Starts publishing `file`, or a `synthetic` source generated by the daemon, to `rtmpUrl`. */
|
|
197
|
+
publish(rtmpUrl: string, input: PublishInput): Streamer;
|
|
54
198
|
/** Starts a viewer collecting metrics from the HLS playlist at `hlsUrl`. */
|
|
55
199
|
watch(hlsUrl: string): Promise<Viewer>;
|
|
56
200
|
/** Current state of the daemon. */
|
package/dist/stream_doctor.js
CHANGED
|
@@ -55,9 +55,9 @@ class Session {
|
|
|
55
55
|
this.child = child;
|
|
56
56
|
this.logFile = logFile;
|
|
57
57
|
}
|
|
58
|
-
/** Starts publishing `file` to `rtmpUrl`. */
|
|
59
|
-
publish(rtmpUrl,
|
|
60
|
-
const ready = api("POST", "/streamer", { input
|
|
58
|
+
/** Starts publishing `file`, or a `synthetic` source generated by the daemon, to `rtmpUrl`. */
|
|
59
|
+
publish(rtmpUrl, input) {
|
|
60
|
+
const ready = api("POST", "/streamer", { input, rtmp_url: rtmpUrl }, this.daemonUrl);
|
|
61
61
|
return new Streamer(this.daemonUrl, ready);
|
|
62
62
|
}
|
|
63
63
|
/** Starts a viewer collecting metrics from the HLS playlist at `hlsUrl`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
4
4
|
"description": "Automated end-to-end testing for video infrastructure (early proof of concept)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"typescript-eslint": "^8.70.0"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@stream-doctor/darwin-arm64": "0.
|
|
37
|
-
"@stream-doctor/linux-arm64": "0.
|
|
38
|
-
"@stream-doctor/linux-x64": "0.
|
|
36
|
+
"@stream-doctor/darwin-arm64": "0.2.0-alpha.1",
|
|
37
|
+
"@stream-doctor/linux-arm64": "0.2.0-alpha.1",
|
|
38
|
+
"@stream-doctor/linux-x64": "0.2.0-alpha.1"
|
|
39
39
|
}
|
|
40
40
|
}
|