@clockworkdog/cogs-client 1.3.1 → 1.4.0
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 +10 -0
- package/dist/RtspStreamer.d.ts +21 -0
- package/dist/RtspStreamer.js +42 -0
- package/dist/browser/index.js +9259 -2763
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +3 -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);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Html5VideoPipeline as THtml5VideoPipeline } from 'media-stream-library';
|
|
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
|
+
}): THtml5VideoPipeline;
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// We need to require this rather than importing it to ensure Webpack picks the correct version of the library.
|
|
4
|
+
// We also then need to import the same class as a type so we can return the correct Typescript types.
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
/// @ts-ignore
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
const { Html5VideoPipeline, isRtcpBye } = require('media-stream-library/dist/browser-cjs.js');
|
|
9
|
+
const urls_1 = require("./helpers/urls");
|
|
10
|
+
/**
|
|
11
|
+
* Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
|
|
12
|
+
* feeds to the web.
|
|
13
|
+
*/
|
|
14
|
+
class RtspStreamer {
|
|
15
|
+
constructor({ hostname = document.location.hostname, port = urls_1.COGS_SERVER_PORT, path = '/tcp-proxy', } = {}) {
|
|
16
|
+
this._websocketUri = `ws://${hostname}:${port}${path}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Start an RTSP video stream on with the given URI on the given video element.
|
|
20
|
+
* @returns The playing HTML5 video pipeline.
|
|
21
|
+
*/
|
|
22
|
+
play(params) {
|
|
23
|
+
const { uri, videoElement } = params;
|
|
24
|
+
const pipeline = new Html5VideoPipeline({
|
|
25
|
+
ws: { uri: this._websocketUri },
|
|
26
|
+
rtsp: { uri: uri },
|
|
27
|
+
mediaElement: videoElement,
|
|
28
|
+
});
|
|
29
|
+
// Restart stream on RTCP BYE (stream ended)
|
|
30
|
+
pipeline.rtsp.onRtcp = (rtcp) => {
|
|
31
|
+
if (isRtcpBye(rtcp)) {
|
|
32
|
+
setTimeout(() => this.play(params), 0);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Start playback when ready
|
|
36
|
+
pipeline.ready.then(() => {
|
|
37
|
+
pipeline.rtsp.play();
|
|
38
|
+
});
|
|
39
|
+
return pipeline;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = RtspStreamer;
|