@jambonz/mrf 0.1.3 → 0.1.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/lib/endpoint.js +16 -3
- package/package.json +1 -1
- package/test/support/mock-server.js +1 -1
package/lib/endpoint.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { EventEmitter } = require('events');
|
|
2
|
+
const { randomUUID } = require('crypto');
|
|
2
3
|
const { parseSdp, translatePlayUrl } = require('./utils');
|
|
3
4
|
|
|
4
5
|
// mediajam normalized wire events -> legacy ESL event names the
|
|
@@ -48,15 +49,27 @@ class Endpoint extends EventEmitter {
|
|
|
48
49
|
}
|
|
49
50
|
const files = Array.isArray(file) ? file : [file];
|
|
50
51
|
const urls = files.map(translatePlayUrl);
|
|
51
|
-
|
|
52
|
+
/* the client supplies the playId so _pendingPlays is populated BEFORE
|
|
53
|
+
* anything hits the wire — the server's play.start event can arrive in
|
|
54
|
+
* the same tcp chunk as the command response, which processes ahead of
|
|
55
|
+
* the awaiter's microtask; a lookup keyed on the response's playId
|
|
56
|
+
* misses that window (seen live: playback-start without file). */
|
|
57
|
+
const playId = randomUUID();
|
|
58
|
+
const data = { urls, playId };
|
|
52
59
|
if (seekOffset > 0) data.seekOffset = parseInt(seekOffset, 10);
|
|
53
|
-
const
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
60
|
+
const result = new Promise((resolve, reject) => {
|
|
55
61
|
// file (the caller's original, untranslated path) rides on the
|
|
56
62
|
// playback-start/stop events: FS parity — the say/play tasks match
|
|
57
63
|
// events to plays by evt.file when there is no tts playback id
|
|
58
64
|
this._pendingPlays.set(playId, { resolve, reject, file: files[0] });
|
|
59
65
|
});
|
|
66
|
+
try {
|
|
67
|
+
await this._request('play.start', data);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
this._pendingPlays.delete(playId);
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
/** fsmrf api() passthrough: translate the FS api commands in use. */
|
package/package.json
CHANGED
|
@@ -97,7 +97,7 @@ class MockMediajam {
|
|
|
97
97
|
case 'play.start': {
|
|
98
98
|
const ep = this.endpoints.get(frame.ep);
|
|
99
99
|
if (!ep) return fail('unknown_endpoint', frame.ep);
|
|
100
|
-
const playId = randomUUID().slice(0, 8);
|
|
100
|
+
const playId = frame.data?.playId || randomUUID().slice(0, 8);
|
|
101
101
|
res({ playId });
|
|
102
102
|
this.send(socket, { t: 'evt', ep: frame.ep, evt: 'play.start', data: { playId } });
|
|
103
103
|
const t = setTimeout(() => {
|