@basmilius/apple-rtsp 0.9.17 → 0.9.19
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/index.mjs +13 -6
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection, HTTP_TIMEOUT } from "@basmilius/apple-common";
|
|
1
|
+
import { Connection, ConnectionClosedError, ConnectionTimeoutError, HTTP_TIMEOUT, InvalidResponseError, TimeoutError } from "@basmilius/apple-common";
|
|
2
2
|
import { Plist } from "@basmilius/apple-encoding";
|
|
3
3
|
|
|
4
4
|
//#region src/encoding.ts
|
|
@@ -19,6 +19,7 @@ function buildResponse(options) {
|
|
|
19
19
|
}
|
|
20
20
|
function parseRequest(buffer) {
|
|
21
21
|
const headerLength = buffer.indexOf("\r\n\r\n");
|
|
22
|
+
if (headerLength === -1) return null;
|
|
22
23
|
const { headers, method, path } = parseRequestHeaders(buffer.subarray(0, headerLength));
|
|
23
24
|
let contentLength = headers["Content-Length"] ? Number(headers["Content-Length"]) : 0;
|
|
24
25
|
if (isNaN(contentLength)) contentLength = 0;
|
|
@@ -34,6 +35,7 @@ function parseRequest(buffer) {
|
|
|
34
35
|
}
|
|
35
36
|
function parseResponse(buffer) {
|
|
36
37
|
const headerLength = buffer.indexOf("\r\n\r\n");
|
|
38
|
+
if (headerLength === -1) return null;
|
|
37
39
|
const { headers, status, statusText } = parseResponseHeaders(buffer.subarray(0, headerLength));
|
|
38
40
|
let contentLength = headers["Content-Length"] ? Number(headers["Content-Length"]) : 0;
|
|
39
41
|
if (isNaN(contentLength)) contentLength = 0;
|
|
@@ -147,12 +149,12 @@ var RtspClient = class extends Connection {
|
|
|
147
149
|
return new Promise((resolve, reject) => {
|
|
148
150
|
const timer = setTimeout(() => {
|
|
149
151
|
this.#requests.delete(cseq);
|
|
150
|
-
reject(
|
|
152
|
+
reject(new TimeoutError(`No response to CSeq ${cseq} (${path})`));
|
|
151
153
|
}, timeout);
|
|
152
154
|
this.#requests.set(cseq, {
|
|
153
155
|
resolve: (response) => {
|
|
154
156
|
clearTimeout(timer);
|
|
155
|
-
if (!allowError && !response.ok) reject(
|
|
157
|
+
if (!allowError && !response.ok) reject(new InvalidResponseError(`RTSP error: ${response.status} ${response.statusText}`));
|
|
156
158
|
else resolve(response);
|
|
157
159
|
},
|
|
158
160
|
reject: (error) => {
|
|
@@ -166,7 +168,7 @@ var RtspClient = class extends Connection {
|
|
|
166
168
|
#onClose() {
|
|
167
169
|
this.#buffer = Buffer.alloc(0);
|
|
168
170
|
for (const [cseq, { reject }] of this.#requests) {
|
|
169
|
-
reject(
|
|
171
|
+
reject(new ConnectionClosedError("Connection closed."));
|
|
170
172
|
this.#requests.delete(cseq);
|
|
171
173
|
}
|
|
172
174
|
this.context.logger.net("[rtsp]", "#onClose()");
|
|
@@ -177,7 +179,12 @@ var RtspClient = class extends Connection {
|
|
|
177
179
|
if (this.#buffer.byteLength > MAX_BUFFER_SIZE) {
|
|
178
180
|
this.context.logger.error("[rtsp]", `Buffer exceeded max size (${this.#buffer.byteLength} bytes), resetting.`);
|
|
179
181
|
this.#buffer = Buffer.alloc(0);
|
|
180
|
-
|
|
182
|
+
const err = /* @__PURE__ */ new Error("Buffer overflow: exceeded maximum buffer size");
|
|
183
|
+
for (const [cseq, { reject }] of this.#requests) {
|
|
184
|
+
reject(err);
|
|
185
|
+
this.#requests.delete(cseq);
|
|
186
|
+
}
|
|
187
|
+
this.emit("error", err);
|
|
181
188
|
return;
|
|
182
189
|
}
|
|
183
190
|
const transformed = this.transformIncoming(this.#buffer);
|
|
@@ -208,7 +215,7 @@ var RtspClient = class extends Connection {
|
|
|
208
215
|
this.context.logger.error("[rtsp]", "#onError()", err);
|
|
209
216
|
}
|
|
210
217
|
#onTimeout() {
|
|
211
|
-
const err =
|
|
218
|
+
const err = new ConnectionTimeoutError();
|
|
212
219
|
for (const [cseq, { reject }] of this.#requests) {
|
|
213
220
|
reject(err);
|
|
214
221
|
this.#requests.delete(cseq);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/apple-rtsp",
|
|
3
3
|
"description": "RTSP protocol implementation for Apple Protocols.",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@basmilius/apple-common": "
|
|
46
|
-
"@basmilius/apple-encoding": "
|
|
45
|
+
"@basmilius/apple-common": "0.9.19",
|
|
46
|
+
"@basmilius/apple-encoding": "0.9.19"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/bun": "^1.3.11",
|