@lox-audioserver/node-airplay-sender 0.4.6 → 0.4.7
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.
|
@@ -297,8 +297,7 @@ AirTunesDevice.prototype.doHandshake = function () {
|
|
|
297
297
|
this.rtsp.on('ready', () => {
|
|
298
298
|
this.status = 'playing';
|
|
299
299
|
this.emit('status', 'playing');
|
|
300
|
-
|
|
301
|
-
this.relayAudio();
|
|
300
|
+
this.relayAudio();
|
|
302
301
|
});
|
|
303
302
|
this.rtsp.on('need_password', () => {
|
|
304
303
|
this.emit('status', 'need_password');
|
|
@@ -328,6 +327,9 @@ AirTunesDevice.prototype.doHandshake = function () {
|
|
|
328
327
|
AirTunesDevice.prototype.relayAudio = function () {
|
|
329
328
|
this.status = 'ready';
|
|
330
329
|
this.emit('status', 'ready');
|
|
330
|
+
let packetCount = 0;
|
|
331
|
+
let byteCount = 0;
|
|
332
|
+
let lastLogAt = 0;
|
|
331
333
|
this.audioCallback = (packet) => {
|
|
332
334
|
const airTunes = makeAirTunesPacket(packet, this.encoder, this.requireEncryption, this.alacEncoding, this.credentials, this.inputCodec);
|
|
333
335
|
// if (self.credentials) {
|
|
@@ -335,8 +337,37 @@ AirTunesDevice.prototype.relayAudio = function () {
|
|
|
335
337
|
// }
|
|
336
338
|
if (this.audioSocket == null) {
|
|
337
339
|
this.audioSocket = node_dgram_1.default.createSocket('udp4');
|
|
340
|
+
this.audioSocket.on('error', (err) => {
|
|
341
|
+
this.logLine?.('audio socket error', {
|
|
342
|
+
host: this.host,
|
|
343
|
+
port: this.serverPort,
|
|
344
|
+
message: err instanceof Error ? err.message : String(err),
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
this.audioSocket.send(airTunes, 0, airTunes.length, this.serverPort, this.host, (err) => {
|
|
349
|
+
if (err) {
|
|
350
|
+
this.logLine?.('audio packet send failed', {
|
|
351
|
+
host: this.host,
|
|
352
|
+
port: this.serverPort,
|
|
353
|
+
message: err instanceof Error ? err.message : String(err),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
packetCount += 1;
|
|
358
|
+
byteCount += airTunes.length;
|
|
359
|
+
const now = Date.now();
|
|
360
|
+
if (now - lastLogAt > 5000) {
|
|
361
|
+
lastLogAt = now;
|
|
362
|
+
if (this.options?.debug) {
|
|
363
|
+
this.logLine?.('audio packet send stats', {
|
|
364
|
+
host: this.host,
|
|
365
|
+
port: this.serverPort,
|
|
366
|
+
packets: packetCount,
|
|
367
|
+
bytes: byteCount,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
338
370
|
}
|
|
339
|
-
this.audioSocket.send(airTunes, 0, airTunes.length, this.serverPort, this.host);
|
|
340
371
|
};
|
|
341
372
|
// this.sendAirTunesPacket = function(airTunes) {
|
|
342
373
|
// try{
|
|
@@ -297,8 +297,7 @@ AirTunesDevice.prototype.doHandshake = function () {
|
|
|
297
297
|
this.rtsp.on('ready', () => {
|
|
298
298
|
this.status = 'playing';
|
|
299
299
|
this.emit('status', 'playing');
|
|
300
|
-
|
|
301
|
-
this.relayAudio();
|
|
300
|
+
this.relayAudio();
|
|
302
301
|
});
|
|
303
302
|
this.rtsp.on('need_password', () => {
|
|
304
303
|
this.emit('status', 'need_password');
|
|
@@ -328,6 +327,9 @@ AirTunesDevice.prototype.doHandshake = function () {
|
|
|
328
327
|
AirTunesDevice.prototype.relayAudio = function () {
|
|
329
328
|
this.status = 'ready';
|
|
330
329
|
this.emit('status', 'ready');
|
|
330
|
+
let packetCount = 0;
|
|
331
|
+
let byteCount = 0;
|
|
332
|
+
let lastLogAt = 0;
|
|
331
333
|
this.audioCallback = (packet) => {
|
|
332
334
|
const airTunes = makeAirTunesPacket(packet, this.encoder, this.requireEncryption, this.alacEncoding, this.credentials, this.inputCodec);
|
|
333
335
|
// if (self.credentials) {
|
|
@@ -335,8 +337,37 @@ AirTunesDevice.prototype.relayAudio = function () {
|
|
|
335
337
|
// }
|
|
336
338
|
if (this.audioSocket == null) {
|
|
337
339
|
this.audioSocket = node_dgram_1.default.createSocket('udp4');
|
|
340
|
+
this.audioSocket.on('error', (err) => {
|
|
341
|
+
this.logLine?.('audio socket error', {
|
|
342
|
+
host: this.host,
|
|
343
|
+
port: this.serverPort,
|
|
344
|
+
message: err instanceof Error ? err.message : String(err),
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
this.audioSocket.send(airTunes, 0, airTunes.length, this.serverPort, this.host, (err) => {
|
|
349
|
+
if (err) {
|
|
350
|
+
this.logLine?.('audio packet send failed', {
|
|
351
|
+
host: this.host,
|
|
352
|
+
port: this.serverPort,
|
|
353
|
+
message: err instanceof Error ? err.message : String(err),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
packetCount += 1;
|
|
358
|
+
byteCount += airTunes.length;
|
|
359
|
+
const now = Date.now();
|
|
360
|
+
if (now - lastLogAt > 5000) {
|
|
361
|
+
lastLogAt = now;
|
|
362
|
+
if (this.options?.debug) {
|
|
363
|
+
this.logLine?.('audio packet send stats', {
|
|
364
|
+
host: this.host,
|
|
365
|
+
port: this.serverPort,
|
|
366
|
+
packets: packetCount,
|
|
367
|
+
bytes: byteCount,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
338
370
|
}
|
|
339
|
-
this.audioSocket.send(airTunes, 0, airTunes.length, this.serverPort, this.host);
|
|
340
371
|
};
|
|
341
372
|
// this.sendAirTunesPacket = function(airTunes) {
|
|
342
373
|
// try{
|
package/package.json
CHANGED