@clockworkdog/cogs-client 1.4.0 → 1.4.3

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.
@@ -175,7 +175,7 @@ function websocketParametersFromUrl(url) {
175
175
  const localClientId = pathParams.get('local_id');
176
176
  const isSimulator = pathParams.get('simulator') === 'true';
177
177
  const display = (_a = pathParams.get('display')) !== null && _a !== void 0 ? _a : '';
178
- const pluginId = parsedUrl.pathname.startsWith('/plugin/') ? parsedUrl.pathname.split('/')[2] : undefined;
178
+ const pluginId = parsedUrl.pathname.startsWith('/plugin/') ? decodeURIComponent(parsedUrl.pathname.split('/')[2]) : undefined;
179
179
  if (localClientId) {
180
180
  const type = (_b = pathParams.get('t')) !== null && _b !== void 0 ? _b : '';
181
181
  pathParams.delete('local_id');
@@ -1,4 +1,4 @@
1
- import type { Html5VideoPipeline as THtml5VideoPipeline } from 'media-stream-library';
1
+ import { Html5VideoPipeline } from '@clockworkdog/media-stream-library-browser';
2
2
  /**
3
3
  * Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
4
4
  * feeds to the web.
@@ -17,5 +17,6 @@ export default class RtspStreamer {
17
17
  play(params: {
18
18
  uri: string;
19
19
  videoElement: HTMLVideoElement;
20
- }): THtml5VideoPipeline;
20
+ playbackRate?: number;
21
+ }): Html5VideoPipeline;
21
22
  }
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
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');
3
+ const media_stream_library_browser_1 = require("@clockworkdog/media-stream-library-browser");
9
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;
10
8
  /**
11
9
  * Manages a websocket connection to the COGS TCP relay which can be used to send RTSP video
12
10
  * feeds to the web.
@@ -20,15 +18,16 @@ class RtspStreamer {
20
18
  * @returns The playing HTML5 video pipeline.
21
19
  */
22
20
  play(params) {
21
+ var _a;
23
22
  const { uri, videoElement } = params;
24
- const pipeline = new Html5VideoPipeline({
23
+ const pipeline = new media_stream_library_browser_1.Html5VideoPipeline({
25
24
  ws: { uri: this._websocketUri },
26
25
  rtsp: { uri: uri },
27
26
  mediaElement: videoElement,
28
27
  });
29
28
  // Restart stream on RTCP BYE (stream ended)
30
29
  pipeline.rtsp.onRtcp = (rtcp) => {
31
- if (isRtcpBye(rtcp)) {
30
+ if (media_stream_library_browser_1.isRtcpBye(rtcp)) {
32
31
  setTimeout(() => this.play(params), 0);
33
32
  }
34
33
  };
@@ -36,6 +35,11 @@ class RtspStreamer {
36
35
  pipeline.ready.then(() => {
37
36
  pipeline.rtsp.play();
38
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
+ });
39
43
  return pipeline;
40
44
  }
41
45
  }