@clockworkdog/cogs-client 1.3.1 → 1.4.2
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/CogsConnection.d.ts +6 -0
- package/dist/CogsConnection.js +11 -1
- package/dist/RtspStreamer.d.ts +22 -0
- package/dist/RtspStreamer.js +46 -0
- package/dist/browser/index.js +2448 -150
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +2 -1
package/dist/CogsConnection.d.ts
CHANGED
|
@@ -74,6 +74,12 @@ export default class CogsConnection<CustomTypes extends {
|
|
|
74
74
|
sendInitialMediaClipStates(allMediaClipStates: AllMediaClipStatesMessage): void;
|
|
75
75
|
sendMediaClipState(mediaClipState: MediaClipStateMessage): void;
|
|
76
76
|
sendAudioOutputs(audioOutputs: MediaDeviceInfo[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Show or hide the plugin window.
|
|
79
|
+
* @param visible Whether to show or hide the window
|
|
80
|
+
* This is only relevant for plugins, not for Media Master content.
|
|
81
|
+
*/
|
|
82
|
+
setPluginWindowVisible(visible: boolean): void;
|
|
77
83
|
addEventListener<EventName extends keyof ConnectionEventListeners<CustomTypes>, EventValue extends ConnectionEventListeners<CustomTypes>[EventName]>(type: EventName, listener: (ev: CustomEvent<EventValue>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
78
84
|
removeEventListener<EventName extends keyof ConnectionEventListeners<CustomTypes>, EventValue extends ConnectionEventListeners<CustomTypes>[EventName]>(type: EventName, listener: (ev: CustomEvent<EventValue>) => void, options?: boolean | EventListenerOptions): void;
|
|
79
85
|
private dispatchEvent;
|
package/dist/CogsConnection.js
CHANGED
|
@@ -146,6 +146,16 @@ class CogsConnection {
|
|
|
146
146
|
this.websocket.send(JSON.stringify({ audioOutputs }));
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Show or hide the plugin window.
|
|
151
|
+
* @param visible Whether to show or hide the window
|
|
152
|
+
* This is only relevant for plugins, not for Media Master content.
|
|
153
|
+
*/
|
|
154
|
+
setPluginWindowVisible(visible) {
|
|
155
|
+
if (this.isConnected) {
|
|
156
|
+
this.websocket.send(JSON.stringify({ window: { visible } }));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
149
159
|
// Type-safe wrapper around EventTarget
|
|
150
160
|
addEventListener(type, listener, options) {
|
|
151
161
|
this.eventTarget.addEventListener(type, listener, options);
|
|
@@ -165,7 +175,7 @@ function websocketParametersFromUrl(url) {
|
|
|
165
175
|
const localClientId = pathParams.get('local_id');
|
|
166
176
|
const isSimulator = pathParams.get('simulator') === 'true';
|
|
167
177
|
const display = (_a = pathParams.get('display')) !== null && _a !== void 0 ? _a : '';
|
|
168
|
-
const pluginId = parsedUrl.pathname.startsWith('/plugin/') ? parsedUrl.pathname.split('/')[2] : undefined;
|
|
178
|
+
const pluginId = parsedUrl.pathname.startsWith('/plugin/') ? decodeURIComponent(parsedUrl.pathname.split('/')[2]) : undefined;
|
|
169
179
|
if (localClientId) {
|
|
170
180
|
const type = (_b = pathParams.get('t')) !== null && _b !== void 0 ? _b : '';
|
|
171
181
|
pathParams.delete('local_id');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Html5VideoPipeline } from '@clockworkdog/media-stream-library-browser';
|
|
2
|
+
/**
|
|
3
|
+
* Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
|
|
4
|
+
* feeds to the web.
|
|
5
|
+
*/
|
|
6
|
+
export default class RtspStreamer {
|
|
7
|
+
private _websocketUri;
|
|
8
|
+
constructor({ hostname, port, path, }?: {
|
|
9
|
+
hostname?: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
path?: string;
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Start an RTSP video stream on with the given URI on the given video element.
|
|
15
|
+
* @returns The playing HTML5 video pipeline.
|
|
16
|
+
*/
|
|
17
|
+
play(params: {
|
|
18
|
+
uri: string;
|
|
19
|
+
videoElement: HTMLVideoElement;
|
|
20
|
+
playbackRate?: number;
|
|
21
|
+
}): Html5VideoPipeline;
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const media_stream_library_browser_1 = require("@clockworkdog/media-stream-library-browser");
|
|
4
|
+
const urls_1 = require("./helpers/urls");
|
|
5
|
+
// Use a faster-than-realtime playback rate by default
|
|
6
|
+
// so that it keeps up with a realtime stream in case of video buffering
|
|
7
|
+
const DEFAULT_VIDEO_PLAYBACK_RATE = 1.1;
|
|
8
|
+
/**
|
|
9
|
+
* Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
|
|
10
|
+
* feeds to the web.
|
|
11
|
+
*/
|
|
12
|
+
class RtspStreamer {
|
|
13
|
+
constructor({ hostname = document.location.hostname, port = urls_1.COGS_SERVER_PORT, path = '/tcp-proxy', } = {}) {
|
|
14
|
+
this._websocketUri = `ws://${hostname}:${port}${path}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Start an RTSP video stream on with the given URI on the given video element.
|
|
18
|
+
* @returns The playing HTML5 video pipeline.
|
|
19
|
+
*/
|
|
20
|
+
play(params) {
|
|
21
|
+
var _a;
|
|
22
|
+
const { uri, videoElement } = params;
|
|
23
|
+
const pipeline = new media_stream_library_browser_1.Html5VideoPipeline({
|
|
24
|
+
ws: { uri: this._websocketUri },
|
|
25
|
+
rtsp: { uri: uri },
|
|
26
|
+
mediaElement: videoElement,
|
|
27
|
+
});
|
|
28
|
+
// Restart stream on RTCP BYE (stream ended)
|
|
29
|
+
pipeline.rtsp.onRtcp = (rtcp) => {
|
|
30
|
+
if (media_stream_library_browser_1.isRtcpBye(rtcp)) {
|
|
31
|
+
setTimeout(() => this.play(params), 0);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
// Start playback when ready
|
|
35
|
+
pipeline.ready.then(() => {
|
|
36
|
+
pipeline.rtsp.play();
|
|
37
|
+
});
|
|
38
|
+
videoElement.playbackRate = (_a = params.playbackRate) !== null && _a !== void 0 ? _a : DEFAULT_VIDEO_PLAYBACK_RATE;
|
|
39
|
+
videoElement.addEventListener('play', () => {
|
|
40
|
+
var _a;
|
|
41
|
+
videoElement.playbackRate = (_a = params.playbackRate) !== null && _a !== void 0 ? _a : DEFAULT_VIDEO_PLAYBACK_RATE;
|
|
42
|
+
});
|
|
43
|
+
return pipeline;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = RtspStreamer;
|