@besovideo/webrtc-player 0.10.28 → 0.10.29

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/README.md CHANGED
@@ -484,10 +484,16 @@ instance.open()
484
484
 
485
485
  **水印配置**
486
486
 
487
- `PuPlayer` 和 `PlayBack` 支持水印层。水印是播放窗口上的 DOM/CSS 叠层,不会写入本地录像文件。
487
+ `PuPlayer`、`PlayBack`、`CreateCallEndPoint` 和 `callEndPointUtils.pushLocalMedia` 支持水印层。水印是播放窗口上的 DOM/CSS 叠层,不会写入本地录像文件。
488
488
 
489
489
  ```typescript
490
- import { globalConfigHandler, PuPlayer, PlayBack } from "@besovideo/webrtc-player";
490
+ import {
491
+ globalConfigHandler,
492
+ PuPlayer,
493
+ PlayBack,
494
+ CreateCallEndPoint,
495
+ callEndPointUtils,
496
+ } from "@besovideo/webrtc-player";
491
497
 
492
498
  interface IWatermarkConfig {
493
499
  // 是否启用水印
@@ -520,7 +526,7 @@ interface IWatermarkConfig {
520
526
  zIndex?: number;
521
527
  }
522
528
 
523
- // 全局配置:影响之后创建的 PuPlayer 和 PlayBack 实例
529
+ // 全局配置:影响之后创建的播放器、回放、通话和推流预览实例
524
530
  globalConfigHandler.setDefaultProps({
525
531
  watermark: {
526
532
  // 支持 string 或 string[],数组会按多行显示
@@ -571,6 +577,22 @@ PlayBack({
571
577
  enable: false,
572
578
  },
573
579
  });
580
+
581
+ // 通话端点窗口覆盖全局配置,本地和远端视频区域都会显示水印
582
+ CreateCallEndPoint({
583
+ // ...
584
+ watermark: {
585
+ text: "通话水印",
586
+ },
587
+ });
588
+
589
+ // 推送本地媒体流预览覆盖全局配置
590
+ callEndPointUtils.pushLocalMedia({
591
+ // ...
592
+ watermark: {
593
+ text: "推流预览水印",
594
+ },
595
+ });
574
596
  ```
575
597
 
576
598
  水印间距会根据播放窗口大小自动调整。`gapX` / `gapY` 表示最小间距,`maxColumns` / `maxRows` 用于限制大屏下最多显示的水印密度:
@@ -588,6 +610,8 @@ const callEndPointUtils: {
588
610
  token: string;
589
611
  // div 用于渲染
590
612
  container?: HTMLDivElement;
613
+ // 播放窗口水印配置,支持全局配置和实例覆盖
614
+ watermark?: IWatermarkConfig;
591
615
  // 是否获取视频
592
616
  video?: boolean;
593
617
  // 是否获取音频
@@ -124,7 +124,7 @@ var bvPlayerCore = (() => {
124
124
  var define_processenv_default;
125
125
  var init_define_processenv = __esm({
126
126
  "<define:processenv>"() {
127
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.10.28", PROJECT_NAMESPACE: "bvplayer" };
127
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.10.29", PROJECT_NAMESPACE: "bvplayer" };
128
128
  }
129
129
  });
130
130
 
@@ -35743,6 +35743,17 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
35743
35743
  dialogPanelHandle.setZIndex(createParams.zIndex);
35744
35744
  }
35745
35745
  const { myVideo, remoteVideo } = dialogPanelHandle;
35746
+ const watermarkConfig = mergeWatermarkConfig(
35747
+ globalConfigHandler.getDefaultProps().watermark,
35748
+ createParams.watermark
35749
+ );
35750
+ const addWatermark = (container) => {
35751
+ const watermark = new watermark_default(watermarkConfig);
35752
+ core_default.dom.append(container, watermark.init());
35753
+ processHandle.reg(() => {
35754
+ watermark.destroy();
35755
+ });
35756
+ };
35746
35757
  const intervalDestoryHandle = GenProcessDestoryHandle();
35747
35758
  const open = (openParams) => __async(this, null, function* () {
35748
35759
  var _a2, _b, _c;
@@ -35793,6 +35804,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
35793
35804
  }
35794
35805
  throw openMedia.message;
35795
35806
  }
35807
+ addWatermark(myVideo);
35796
35808
  const openResult = yield openMedia == null ? void 0 : openMedia.push();
35797
35809
  if (openResult.code != "SUCCESS") {
35798
35810
  throw openResult.message;
@@ -35842,6 +35854,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
35842
35854
  hasVideo: !!waitRemoteResult.data.video,
35843
35855
  events: dialogPanelHandle.closeHandle
35844
35856
  }, dialogPanelHandle.pcSink);
35857
+ addWatermark(remoteVideo);
35845
35858
  processHandle.reg(() => {
35846
35859
  var _a3;
35847
35860
  (_a3 = remoteOpenResult.close) == null ? void 0 : _a3.call(remoteOpenResult);
@@ -35860,6 +35873,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
35860
35873
  hasVideo: avCall2.video,
35861
35874
  events: dialogPanelHandle.closeHandle
35862
35875
  }, dialogPanelHandle.pcSink);
35876
+ addWatermark(remoteVideo);
35863
35877
  processHandle.reg(() => {
35864
35878
  var _a3;
35865
35879
  (_a3 = remoteOpenResult.close) == null ? void 0 : _a3.call(remoteOpenResult);
@@ -35975,7 +35989,8 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
35975
35989
  playerConfig: {
35976
35990
  disabledControls: (params == null ? void 0 : params.disabledControls) ? [...params == null ? void 0 : params.disabledControls, "ptzControl", "mike"] : ["ptzControl", "mike"],
35977
35991
  enableController: !!(params == null ? void 0 : params.enableController)
35978
- }
35992
+ },
35993
+ watermark: params == null ? void 0 : params.watermark
35979
35994
  });
35980
35995
  const videoEle = player.video.getVideoEl();
35981
35996
  let firstTime = 0;
@@ -36061,7 +36076,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
36061
36076
  // src/components/callEndPointUtils.ts
36062
36077
  function pushLocalMedia(params) {
36063
36078
  return __async(this, null, function* () {
36064
- var _a, _b, _c, _d, _e, _f;
36079
+ var _a, _b, _c, _d, _e, _f, _g;
36065
36080
  i18n_default(params.locale || "zh");
36066
36081
  const processHandle = GenProcessDestoryHandle();
36067
36082
  let container = null;
@@ -36071,7 +36086,13 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
36071
36086
  container.style.width = "100%";
36072
36087
  container.style.position = "relative";
36073
36088
  core_default.dom.append(params.container, container);
36074
- container.player = CreatePlayerPlugin(container, params.renderParams);
36089
+ container.player = CreatePlayerPlugin(container, __spreadProps(__spreadValues({}, params.renderParams), {
36090
+ watermark: mergeWatermarkConfig(
36091
+ globalConfigHandler.getDefaultProps().watermark,
36092
+ (_a = params.renderParams) == null ? void 0 : _a.watermark,
36093
+ params.watermark
36094
+ )
36095
+ }));
36075
36096
  }
36076
36097
  processHandle.reg(() => {
36077
36098
  if (container) {
@@ -36086,7 +36107,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
36086
36107
  });
36087
36108
  const resultResult = yield mediaEndPoint.open({
36088
36109
  container,
36089
- videoEle: (_a = container == null ? void 0 : container.player) == null ? void 0 : _a.getVideoEle(),
36110
+ videoEle: (_b = container == null ? void 0 : container.player) == null ? void 0 : _b.getVideoEle(),
36090
36111
  call: {
36091
36112
  videoCall: !!params.video,
36092
36113
  name: "",
@@ -36114,7 +36135,7 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
36114
36135
  }
36115
36136
  const pushResult = yield resultResult.push();
36116
36137
  if (pushResult.code != "SUCCESS") {
36117
- (_b = resultResult.close) == null ? void 0 : _b.call(resultResult);
36138
+ (_c = resultResult.close) == null ? void 0 : _c.call(resultResult);
36118
36139
  return pushResult;
36119
36140
  }
36120
36141
  const close = () => __async(this, null, function* () {
@@ -36123,20 +36144,20 @@ a=fmtp:${pt} x-google-start-bitrate=${bitrate}`
36123
36144
  (_b2 = resultResult.close) == null ? void 0 : _b2.call(resultResult);
36124
36145
  processHandle.invoke();
36125
36146
  });
36126
- if ((_c = pushResult.streamIdInfo) == null ? void 0 : _c.mediaStream) {
36127
- const mediaStream = (_d = pushResult.streamIdInfo) == null ? void 0 : _d.mediaStream;
36147
+ if ((_d = pushResult.streamIdInfo) == null ? void 0 : _d.mediaStream) {
36148
+ const mediaStream = (_e = pushResult.streamIdInfo) == null ? void 0 : _e.mediaStream;
36128
36149
  const configHandle = GetInnerConfig(callEndPointConfig).pushMediaStream({
36129
36150
  stream: mediaStream,
36130
36151
  isShare: !!params.displayMedia
36131
36152
  });
36132
36153
  if (params.container) {
36133
- (_e = container == null ? void 0 : container.player) == null ? void 0 : _e.setMediaStream(mediaStream);
36154
+ (_f = container == null ? void 0 : container.player) == null ? void 0 : _f.setMediaStream(mediaStream);
36134
36155
  }
36135
36156
  processHandle.reg(() => {
36136
36157
  configHandle.remove();
36137
36158
  });
36138
36159
  }
36139
- if ((_f = pushResult.streamIdInfo) == null ? void 0 : _f.duration) {
36160
+ if ((_g = pushResult.streamIdInfo) == null ? void 0 : _g.duration) {
36140
36161
  let containerTrialShow2 = function() {
36141
36162
  if (container && !params.customDisTrial) {
36142
36163
  const ele = document.createElement("div");
package/dist/main.es.js CHANGED
@@ -118,7 +118,7 @@ var __async = (__this, __arguments, generator) => {
118
118
  var define_processenv_default;
119
119
  var init_define_processenv = __esm({
120
120
  "<define:processenv>"() {
121
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.10.28", PROJECT_NAMESPACE: "bvplayer" };
121
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.10.29", PROJECT_NAMESPACE: "bvplayer" };
122
122
  }
123
123
  });
124
124
 
@@ -35725,6 +35725,17 @@ function CreateCallEndPoint(createParams) {
35725
35725
  dialogPanelHandle.setZIndex(createParams.zIndex);
35726
35726
  }
35727
35727
  const { myVideo, remoteVideo } = dialogPanelHandle;
35728
+ const watermarkConfig = mergeWatermarkConfig(
35729
+ globalConfigHandler.getDefaultProps().watermark,
35730
+ createParams.watermark
35731
+ );
35732
+ const addWatermark = (container) => {
35733
+ const watermark = new watermark_default(watermarkConfig);
35734
+ core_default.dom.append(container, watermark.init());
35735
+ processHandle.reg(() => {
35736
+ watermark.destroy();
35737
+ });
35738
+ };
35728
35739
  const intervalDestoryHandle = GenProcessDestoryHandle();
35729
35740
  const open = (openParams) => __async(this, null, function* () {
35730
35741
  var _a2, _b, _c;
@@ -35775,6 +35786,7 @@ function CreateCallEndPoint(createParams) {
35775
35786
  }
35776
35787
  throw openMedia.message;
35777
35788
  }
35789
+ addWatermark(myVideo);
35778
35790
  const openResult = yield openMedia == null ? void 0 : openMedia.push();
35779
35791
  if (openResult.code != "SUCCESS") {
35780
35792
  throw openResult.message;
@@ -35824,6 +35836,7 @@ function CreateCallEndPoint(createParams) {
35824
35836
  hasVideo: !!waitRemoteResult.data.video,
35825
35837
  events: dialogPanelHandle.closeHandle
35826
35838
  }, dialogPanelHandle.pcSink);
35839
+ addWatermark(remoteVideo);
35827
35840
  processHandle.reg(() => {
35828
35841
  var _a3;
35829
35842
  (_a3 = remoteOpenResult.close) == null ? void 0 : _a3.call(remoteOpenResult);
@@ -35842,6 +35855,7 @@ function CreateCallEndPoint(createParams) {
35842
35855
  hasVideo: avCall2.video,
35843
35856
  events: dialogPanelHandle.closeHandle
35844
35857
  }, dialogPanelHandle.pcSink);
35858
+ addWatermark(remoteVideo);
35845
35859
  processHandle.reg(() => {
35846
35860
  var _a3;
35847
35861
  (_a3 = remoteOpenResult.close) == null ? void 0 : _a3.call(remoteOpenResult);
@@ -35957,7 +35971,8 @@ function CreatePlayerPlugin(container, params) {
35957
35971
  playerConfig: {
35958
35972
  disabledControls: (params == null ? void 0 : params.disabledControls) ? [...params == null ? void 0 : params.disabledControls, "ptzControl", "mike"] : ["ptzControl", "mike"],
35959
35973
  enableController: !!(params == null ? void 0 : params.enableController)
35960
- }
35974
+ },
35975
+ watermark: params == null ? void 0 : params.watermark
35961
35976
  });
35962
35977
  const videoEle = player.video.getVideoEl();
35963
35978
  let firstTime = 0;
@@ -36043,7 +36058,7 @@ function CreatePlayerPlugin(container, params) {
36043
36058
  // src/components/callEndPointUtils.ts
36044
36059
  function pushLocalMedia(params) {
36045
36060
  return __async(this, null, function* () {
36046
- var _a, _b, _c, _d, _e, _f;
36061
+ var _a, _b, _c, _d, _e, _f, _g;
36047
36062
  i18n_default(params.locale || "zh");
36048
36063
  const processHandle = GenProcessDestoryHandle();
36049
36064
  let container = null;
@@ -36053,7 +36068,13 @@ function pushLocalMedia(params) {
36053
36068
  container.style.width = "100%";
36054
36069
  container.style.position = "relative";
36055
36070
  core_default.dom.append(params.container, container);
36056
- container.player = CreatePlayerPlugin(container, params.renderParams);
36071
+ container.player = CreatePlayerPlugin(container, __spreadProps(__spreadValues({}, params.renderParams), {
36072
+ watermark: mergeWatermarkConfig(
36073
+ globalConfigHandler.getDefaultProps().watermark,
36074
+ (_a = params.renderParams) == null ? void 0 : _a.watermark,
36075
+ params.watermark
36076
+ )
36077
+ }));
36057
36078
  }
36058
36079
  processHandle.reg(() => {
36059
36080
  if (container) {
@@ -36068,7 +36089,7 @@ function pushLocalMedia(params) {
36068
36089
  });
36069
36090
  const resultResult = yield mediaEndPoint.open({
36070
36091
  container,
36071
- videoEle: (_a = container == null ? void 0 : container.player) == null ? void 0 : _a.getVideoEle(),
36092
+ videoEle: (_b = container == null ? void 0 : container.player) == null ? void 0 : _b.getVideoEle(),
36072
36093
  call: {
36073
36094
  videoCall: !!params.video,
36074
36095
  name: "",
@@ -36096,7 +36117,7 @@ function pushLocalMedia(params) {
36096
36117
  }
36097
36118
  const pushResult = yield resultResult.push();
36098
36119
  if (pushResult.code != "SUCCESS") {
36099
- (_b = resultResult.close) == null ? void 0 : _b.call(resultResult);
36120
+ (_c = resultResult.close) == null ? void 0 : _c.call(resultResult);
36100
36121
  return pushResult;
36101
36122
  }
36102
36123
  const close = () => __async(this, null, function* () {
@@ -36105,20 +36126,20 @@ function pushLocalMedia(params) {
36105
36126
  (_b2 = resultResult.close) == null ? void 0 : _b2.call(resultResult);
36106
36127
  processHandle.invoke();
36107
36128
  });
36108
- if ((_c = pushResult.streamIdInfo) == null ? void 0 : _c.mediaStream) {
36109
- const mediaStream = (_d = pushResult.streamIdInfo) == null ? void 0 : _d.mediaStream;
36129
+ if ((_d = pushResult.streamIdInfo) == null ? void 0 : _d.mediaStream) {
36130
+ const mediaStream = (_e = pushResult.streamIdInfo) == null ? void 0 : _e.mediaStream;
36110
36131
  const configHandle = GetInnerConfig(callEndPointConfig).pushMediaStream({
36111
36132
  stream: mediaStream,
36112
36133
  isShare: !!params.displayMedia
36113
36134
  });
36114
36135
  if (params.container) {
36115
- (_e = container == null ? void 0 : container.player) == null ? void 0 : _e.setMediaStream(mediaStream);
36136
+ (_f = container == null ? void 0 : container.player) == null ? void 0 : _f.setMediaStream(mediaStream);
36116
36137
  }
36117
36138
  processHandle.reg(() => {
36118
36139
  configHandle.remove();
36119
36140
  });
36120
36141
  }
36121
- if ((_f = pushResult.streamIdInfo) == null ? void 0 : _f.duration) {
36142
+ if ((_g = pushResult.streamIdInfo) == null ? void 0 : _g.duration) {
36122
36143
  let containerTrialShow2 = function() {
36123
36144
  if (container && !params.customDisTrial) {
36124
36145
  const ele = document.createElement("div");
@@ -2,6 +2,7 @@ import { AvCallPayload } from "src/api/call";
2
2
  import initI18n from "../locales/i18n";
3
3
  import { ICommandWsGetter } from "./callComponents/commandWsManager";
4
4
  import { CallEndPointConfigManagerUser } from "./callComponents/callEndPointConfig";
5
+ import { IWatermarkConfig } from "../plugins/watermark";
5
6
  declare enum ECallSteps {
6
7
  "GET_USER_INFO" = "GET_USER_INFO",
7
8
  "START_CALL" = "START_CALL",
@@ -24,6 +25,7 @@ type TCreateEndPointParams = ICommandWsGetter & {
24
25
  onClose?: () => void;
25
26
  zIndex?: number;
26
27
  locale?: Parameters<typeof initI18n>[0];
28
+ watermark?: IWatermarkConfig;
27
29
  };
28
30
  export declare function CreateProcessHandle<T extends string, TData = void>(): {
29
31
  reg(handle: (data: TData) => void | Promise<void>): {
@@ -1,6 +1,7 @@
1
1
  import { IOpenResult } from "./callComponents/mediaEndPoint";
2
2
  import { IOpenParams } from "./callEndPoint";
3
3
  import { CreatePlayerPlugin } from "./callEndPointUtilsPlayer";
4
+ import { IWatermarkConfig } from "../plugins/watermark";
4
5
  export type IPushLocalMediaResult = IOpenResult & {
5
6
  streamIdInfo?: {
6
7
  id: string;
@@ -15,6 +16,7 @@ declare function pushLocalMedia(params: {
15
16
  locale?: "zh" | "en";
16
17
  container?: HTMLDivElement;
17
18
  renderParams?: Parameters<typeof CreatePlayerPlugin>[1];
19
+ watermark?: IWatermarkConfig;
18
20
  video?: boolean;
19
21
  audio?: boolean;
20
22
  displayMedia?: IOpenParams["displayMedia"];
@@ -1,7 +1,9 @@
1
1
  import { IControlPluginMap } from "../plugins/controller";
2
+ import { IWatermarkConfig } from "../plugins/watermark";
2
3
  export declare function CreatePlayerPlugin(container: HTMLDivElement, params?: {
3
- disabledControls: (keyof IControlPluginMap)[];
4
- enableController: boolean;
4
+ disabledControls?: (keyof IControlPluginMap)[];
5
+ enableController?: boolean;
6
+ watermark?: IWatermarkConfig;
5
7
  }): {
6
8
  setMediaStream(stream: MediaStream): void;
7
9
  destory(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@besovideo/webrtc-player",
3
- "version": "0.10.28",
3
+ "version": "0.10.29",
4
4
  "description": "@besovideo/webrtc-player desc",
5
5
  "type": "module",
6
6
  "types": "./dist/types/main.d.ts",