trtc-sdk-v5 5.14.2-beta.1 → 5.14.2-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "module": "./cdn-streaming.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/chorus",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x Chorus plugin",
5
5
  "main": "./chorus.esm.js",
6
6
  "module": "./chorus.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/custom-encryption",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "main": "./custom-encryption.esm.js",
5
5
  "module": "./custom-encryption.esm.js",
6
6
  "types": "./custom-encryption.esm.d.ts"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/device-detector",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x device detector plugin",
5
5
  "main": "./device-detector.esm.js",
6
6
  "module": "./device-detector.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/small-stream-auto-switcher",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "",
5
5
  "main": "./small-stream-auto-switcher.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-decoder",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/basic-beauty",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x basic-beauty plugin",
5
5
  "main": "./basic-beauty.esm.js",
6
6
  "module": "./basic-beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/beauty",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x beauty plugin",
5
5
  "main": "./beauty.esm.js",
6
6
  "module": "./beauty.esm.js",
@@ -0,0 +1,13 @@
1
+ export interface FaceDetectionOptions {
2
+ onFaceDetectionStateChanged: (hasFace: boolean) => void;
3
+ detectionInterval?: number;
4
+ minConfidence?: number;
5
+ missingTimeout?: number;
6
+ }
7
+
8
+ export interface UpdateFaceDetectionOptions {
9
+ onFaceDetectionStateChanged?: (hasFace: boolean) => void;
10
+ detectionInterval?: number;
11
+ minConfidence?: number;
12
+ missingTimeout?: number;
13
+ }
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__publicField=(e,t,i)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,i),BASE_FACE_DETECTION_RULES={detectionInterval:{type:"number",required:!1,min:100,max:5e3},minConfidence:{type:"number",required:!1,min:0,max:1},missingTimeout:{type:"number",required:!1,min:0,max:5e3}},faceDetectionOptions=__spreadValues({onFaceDetectionStateChanged:{required:!0}},BASE_FACE_DETECTION_RULES),updateFaceDetectionOptions=__spreadValues({onFaceDetectionStateChanged:{required:!1}},BASE_FACE_DETECTION_RULES);function startValidateRule(e){return{type:"object",required:!0,properties:faceDetectionOptions,validate(t,i,a,s){var o;const{RtcError:r,ErrorCode:n,ErrorCodeDictionary:c}=e.errorModule,{onFaceDetectionStateChanged:d}=t;if(d&&!e.utils.isFunction(d))throw new r({code:n.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,fnName:a,messageParams:{key:"onFaceDetectionStateChanged",value:typeof d,rule:{type:"Function"}}});if(!(null==(o=e.room.videoManager.cameraTrack)?void 0:o.mediaTrack))throw new r({code:n.INVALID_OPERATION,extraCode:c.INVALID_OPERATION_NEED_VIDEO,fnName:a})}}}function updateValidateRule(e){return{type:"object",required:!0,properties:updateFaceDetectionOptions,validate(t,i,a,s){var o;const{RtcError:r,ErrorCode:n,ErrorCodeDictionary:c}=e.errorModule,{onFaceDetectionStateChanged:d}=t;if(d&&!e.utils.isFunction(d))throw new r({code:n.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,fnName:a,messageParams:{key:"onFaceDetectionStateChanged",value:typeof d,rule:{type:"Function"}}});if(!(null==(o=e.room.videoManager.cameraTrack)?void 0:o.mediaTrack))throw new r({code:n.INVALID_OPERATION,extraCode:c.INVALID_OPERATION_NEED_VIDEO,fnName:a})}}}function stopValidateRule(e){return{name:"StopFaceDetectionOptions",required:!1}}var faceDetectionSeq=0,_FaceDetection=class e{constructor(e){this.core=e,__publicField(this,"seq"),__publicField(this,"log"),__publicField(this,"_core"),__publicField(this,"preLoadPromise"),__publicField(this,"_faceDetectorHash"),__publicField(this,"_visionTaskRegistry"),__publicField(this,"_faceStatus",!1),__publicField(this,"_startMissing"),__publicField(this,"_minConfidence",.8),__publicField(this,"_missingTimeout",1e3),__publicField(this,"_detectionInterval",300),__publicField(this,"_lastDetectTime",0),__publicField(this,"_videoFrameCallBackId"),__publicField(this,"_video"),__publicField(this,"_onFaceDetectionStateChanged"),faceDetectionSeq+=1,this.seq=faceDetectionSeq,this.log=e.log.createChild({id:`${this.getAlias()}${faceDetectionSeq}`}),this._core=e,this.log.info("created"),e.assetsPath&&(this.preLoadPromise=this.preload(e.assetsPath))}resetState(){this._faceStatus=!1,this._startMissing=null,this._lastDetectTime=0}async preload(e){try{await this._core.initVisionTaskRegistry(e,["FaceDetector"])}catch(e){const{RtcError:t,ErrorCode:i}=this._core.errorModule;throw new t({code:i.INVALID_OPERATION,message:`FaceDetection preload error, please redeploy the assets of the npm package. detail: ${e}`})}}getGroup(){return"fd"}getName(){return e.Name}getAlias(){return"fd"}getValidateRule(e){switch(e){case"start":return startValidateRule(this._core);case"update":return updateValidateRule(this._core);case"stop":return stopValidateRule(this._core)}}getCurrentStatus(){const e=this._visionTaskRegistry.getResult(this._faceDetectorHash).detections;this._visionTaskRegistry.resetHashResults();let t=e.length>0;if(t){const i=[];for(const t of e){const e=t.categories;for(const t of e)i.push(t.score)}t&&(t=!!i.find((e=>e>=this._minConfidence)))}return t}detectFace(){const e=this.getCurrentStatus();this._startMissing&&Date.now()-this._startMissing>=this._missingTimeout&&e!==this._faceStatus?(this._onFaceDetectionStateChanged(e),this._faceStatus=e,this._startMissing=null):Date.now()-this._lastDetectTime>=this._detectionInterval&&(this._faceStatus!==e&&(e||0===this._missingTimeout?(this._onFaceDetectionStateChanged(e),this._faceStatus=e):this._startMissing||(this._startMissing=Date.now())),this._lastDetectTime=Date.now()),this._videoFrameCallBackId=this._video.requestVideoFrameCallback(this.detectFace.bind(this))}async initFaceDetection(){this._visionTaskRegistry=await window.VisionTaskRegistry.getInstance();const e=await this._visionTaskRegistry.register(window.VisionTaskType.FaceDetector);e&&(this._faceDetectorHash=e,this._visionTaskRegistry.setVideo(this._faceDetectorHash,this._video))}updateOptions(e){e.onFaceDetectionStateChanged&&(this._onFaceDetectionStateChanged=e.onFaceDetectionStateChanged),e.detectionInterval&&(this._detectionInterval=e.detectionInterval),e.minConfidence&&(this._minConfidence=e.minConfidence),(0===e.missingTimeout||e.missingTimeout)&&(this._missingTimeout=e.missingTimeout)}async start(e){const{RtcError:t,ErrorCode:i}=this._core.errorModule;if(this.updateOptions(e),!this.preLoadPromise){if(!this._core.assetsPath)throw new t({code:i.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});this.preLoadPromise=this.preload(this._core.assetsPath)}await this.preLoadPromise;const a=this._core.room.videoManager.cameraTrack,s=null==a?void 0:a.player.element;if(!s)throw new t({code:i.DEVICE_ERROR,message:"please enable camera display to start detection"});this._video=s,await this.initFaceDetection().catch((e=>{throw new t({code:i.UNKNOWN_ERROR,message:e.message})})),this._videoFrameCallBackId=this._video.requestVideoFrameCallback(this.detectFace.bind(this)),a.on(this._core.enums.TrackEvent.MUTE,this.autoHandleMute,this)}autoHandleMute(){const e=this._core.room.videoManager.cameraTrack;this._faceStatus&&(this._faceStatus=!1,this._onFaceDetectionStateChanged(!1)),this._video.cancelVideoFrameCallback(this._videoFrameCallBackId),null==e||e.once(this._core.enums.TrackEvent.UNMUTE,(()=>{this._videoFrameCallBackId=this._video.requestVideoFrameCallback(this.detectFace.bind(this))}))}async update(e){this.updateOptions(e)}async stop(){var e;this.resetState(),this._video.cancelVideoFrameCallback(this._videoFrameCallBackId),null==(e=this._core.room.videoManager.cameraTrack)||e.off(this._core.enums.TrackEvent.MUTE,this.autoHandleMute,this)}destroy(){this.stop()}};__publicField(_FaceDetection,"Name","FaceDetection");var FaceDetection=_FaceDetection,index_default=FaceDetection;export{index_default as default};export{FaceDetection};
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).FaceDetection=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,s,"next",t)}function s(t){e(a,o,i,c,s,"throw",t)}c(void 0)}))}}function n(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var t=n.next();return c=t.done,t},e:function(t){s=!0,a=t},f:function(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}function i(){i=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new L(n||[]);return o(a,"_invoke",{value:I(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var d="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function g(){}function _(){}function w(){}var b={};h(b,c,(function(){return this}));var E=Object.getPrototypeOf,k=E&&E(E(O([])));k&&k!==r&&n.call(k,c)&&(b=k);var T=w.prototype=g.prototype=Object.create(b);function x(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function D(t,e){function r(o,i,a,c){var s=f(t[o],t,i);if("throw"!==s.type){var u=s.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function I(e,r,n){var o=d;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function F(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(F,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return _.prototype=w,o(T,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:_,configurable:!0}),_.displayName=h(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,u,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},x(D.prototype),h(D.prototype,s,(function(){return this})),e.AsyncIterator=D,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new D(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(T),h(T,u,"Generator"),h(T,c,(function(){return this})),h(T,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=O,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(S),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}var s=Object.defineProperty,u=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,f=function(t,e,r){return e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},d=function(t,e){for(var r in e||(e={}))h.call(e,r)&&f(t,r,e[r]);if(u){var n,i=o(u(e));try{for(i.s();!(n=i.n()).done;){r=n.value;l.call(e,r)&&f(t,r,e[r])}}catch(t){i.e(t)}finally{i.f()}}return t},p=function(t,e,r){return f(t,"symbol"!==c(e)?e+"":e,r)},v={detectionInterval:{type:"number",required:!1,min:100,max:5e3},minConfidence:{type:"number",required:!1,min:0,max:1},missingTimeout:{type:"number",required:!1,min:0,max:5e3}},y=d({onFaceDetectionStateChanged:{required:!0}},v),m=d({onFaceDetectionStateChanged:{required:!1}},v);var g=0,_=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.core=e,p(this,"seq"),p(this,"log"),p(this,"_core"),p(this,"preLoadPromise"),p(this,"_faceDetectorHash"),p(this,"_visionTaskRegistry"),p(this,"_faceStatus",!1),p(this,"_startMissing"),p(this,"_minConfidence",.8),p(this,"_missingTimeout",1e3),p(this,"_detectionInterval",300),p(this,"_lastDetectTime",0),p(this,"_videoFrameCallBackId"),p(this,"_video"),p(this,"_onFaceDetectionStateChanged"),g+=1,this.seq=g,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(g)}),this._core=e,this.log.info("created"),e.assetsPath&&(this.preLoadPromise=this.preload(e.assetsPath))}return n(t,[{key:"resetState",value:function(){this._faceStatus=!1,this._startMissing=null,this._lastDetectTime=0}},{key:"preload",value:(h=r(i().mark((function t(e){var r,n,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._core.initVisionTaskRegistry(e,["FaceDetector"]);case 3:t.next=9;break;case 5:throw t.prev=5,t.t0=t.catch(0),r=this._core.errorModule,n=r.RtcError,o=r.ErrorCode,new n({code:o.INVALID_OPERATION,message:"FaceDetection preload error, please redeploy the assets of the npm package. detail: ".concat(t.t0)});case 9:case"end":return t.stop()}}),t,this,[[0,5]])}))),function(t){return h.apply(this,arguments)})},{key:"getGroup",value:function(){return"fd"}},{key:"getName",value:function(){return t.Name}},{key:"getAlias",value:function(){return"fd"}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e=this._core,{type:"object",required:!0,properties:y,validate:function(t,r,n,o){var i,a=e.errorModule,s=a.RtcError,u=a.ErrorCode,h=a.ErrorCodeDictionary,l=t.onFaceDetectionStateChanged;if(l&&!e.utils.isFunction(l))throw new s({code:u.INVALID_PARAMETER,extraCode:h.INVALID_PARAMETER_TYPE,fnName:n,messageParams:{key:"onFaceDetectionStateChanged",value:c(l),rule:{type:"Function"}}});if(!(null==(i=e.room.videoManager.cameraTrack)?void 0:i.mediaTrack))throw new s({code:u.INVALID_OPERATION,extraCode:h.INVALID_OPERATION_NEED_VIDEO,fnName:n})}};case"update":return function(t){return{type:"object",required:!0,properties:m,validate:function(e,r,n,o){var i,a=t.errorModule,s=a.RtcError,u=a.ErrorCode,h=a.ErrorCodeDictionary,l=e.onFaceDetectionStateChanged;if(l&&!t.utils.isFunction(l))throw new s({code:u.INVALID_PARAMETER,extraCode:h.INVALID_PARAMETER_TYPE,fnName:n,messageParams:{key:"onFaceDetectionStateChanged",value:c(l),rule:{type:"Function"}}});if(!(null==(i=t.room.videoManager.cameraTrack)?void 0:i.mediaTrack))throw new s({code:u.INVALID_OPERATION,extraCode:h.INVALID_OPERATION_NEED_VIDEO,fnName:n})}}}(this._core);case"stop":return this._core,{name:"StopFaceDetectionOptions",required:!1}}var e}},{key:"getCurrentStatus",value:function(){var t=this,e=this._visionTaskRegistry.getResult(this._faceDetectorHash).detections;this._visionTaskRegistry.resetHashResults();var r=e.length>0;if(r){var n,i=[],a=o(e);try{for(a.s();!(n=a.n()).done;){var c,s=o(n.value.categories);try{for(s.s();!(c=s.n()).done;){var u=c.value;i.push(u.score)}}catch(t){s.e(t)}finally{s.f()}}}catch(t){a.e(t)}finally{a.f()}r&&(r=!!i.find((function(e){return e>=t._minConfidence})))}return r}},{key:"detectFace",value:function(){var t=this.getCurrentStatus();this._startMissing&&Date.now()-this._startMissing>=this._missingTimeout&&t!==this._faceStatus?(this._onFaceDetectionStateChanged(t),this._faceStatus=t,this._startMissing=null):Date.now()-this._lastDetectTime>=this._detectionInterval&&(this._faceStatus!==t&&(t||0===this._missingTimeout?(this._onFaceDetectionStateChanged(t),this._faceStatus=t):this._startMissing||(this._startMissing=Date.now())),this._lastDetectTime=Date.now()),this._videoFrameCallBackId=this._video.requestVideoFrameCallback(this.detectFace.bind(this))}},{key:"initFaceDetection",value:(u=r(i().mark((function t(){var e;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,window.VisionTaskRegistry.getInstance();case 2:return this._visionTaskRegistry=t.sent,t.next=5,this._visionTaskRegistry.register(window.VisionTaskType.FaceDetector);case 5:if(e=t.sent){t.next=8;break}return t.abrupt("return");case 8:this._faceDetectorHash=e,this._visionTaskRegistry.setVideo(this._faceDetectorHash,this._video);case 10:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"updateOptions",value:function(t){t.onFaceDetectionStateChanged&&(this._onFaceDetectionStateChanged=t.onFaceDetectionStateChanged),t.detectionInterval&&(this._detectionInterval=t.detectionInterval),t.minConfidence&&(this._minConfidence=t.minConfidence),(0===t.missingTimeout||t.missingTimeout)&&(this._missingTimeout=t.missingTimeout)}},{key:"start",value:(s=r(i().mark((function t(e){var r,n,o,a,c;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._core.errorModule,n=r.RtcError,o=r.ErrorCode,this.updateOptions(e),this.preLoadPromise){t.next=6;break}if(this._core.assetsPath){t.next=5;break}throw new n({code:o.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});case 5:this.preLoadPromise=this.preload(this._core.assetsPath);case 6:return t.next=8,this.preLoadPromise;case 8:if(a=this._core.room.videoManager.cameraTrack,c=null==a?void 0:a.player.element){t.next=12;break}throw new n({code:o.DEVICE_ERROR,message:"please enable camera display to start detection"});case 12:return this._video=c,t.next=15,this.initFaceDetection().catch((function(t){throw new n({code:o.UNKNOWN_ERROR,message:t.message})}));case 15:this._videoFrameCallBackId=this._video.requestVideoFrameCallback(this.detectFace.bind(this)),a.on(this._core.enums.TrackEvent.MUTE,this.autoHandleMute,this);case 17:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"autoHandleMute",value:function(){var t=this,e=this._core.room.videoManager.cameraTrack;this._faceStatus&&(this._faceStatus=!1,this._onFaceDetectionStateChanged(!1)),this._video.cancelVideoFrameCallback(this._videoFrameCallBackId),null==e||e.once(this._core.enums.TrackEvent.UNMUTE,(function(){t._videoFrameCallBackId=t._video.requestVideoFrameCallback(t.detectFace.bind(t))}))}},{key:"update",value:(a=r(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.updateOptions(e);case 1:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"stop",value:(e=r(i().mark((function t(){var e;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.resetState(),this._video.cancelVideoFrameCallback(this._videoFrameCallBackId),null==(e=this._core.room.videoManager.cameraTrack)||e.off(this._core.enums.TrackEvent.MUTE,this.autoHandleMute,this);case 3:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"destroy",value:function(){this.stop()}}]);var e,a,s,u,h}();return p(_,"Name","FaceDetection"),_}));
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@rtc-plugin/face-detection",
3
+ "version": "5.14.2-beta.2",
4
+ "description": "TRTC Web SDK 5.x face detection plugin",
5
+ "main": "./face-detection.esm.js",
6
+ "module": "./face-detection.esm.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git@github.com:LiteAVSDK/TRTC_Web.git"
10
+ },
11
+ "homepage": "https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/tutorial-40-advanced-face-detection.html",
12
+ "keywords": [
13
+ "webrtc",
14
+ "TRTC",
15
+ "rtc",
16
+ "call",
17
+ "video call",
18
+ "audio call",
19
+ "javascript",
20
+ "video",
21
+ "audio",
22
+ "camera",
23
+ "microphone",
24
+ "live streaming",
25
+ "real-time communication",
26
+ "face detection"
27
+ ],
28
+ "types": "./face-detection.esm.d.ts"
29
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-mixer",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x videoMixer plugin",
5
5
  "main": "./video-mixer.esm.js",
6
6
  "module": "./video-mixer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/virtual-background",
3
- "version": "5.14.2-beta.1",
3
+ "version": "5.14.2-beta.2",
4
4
  "description": "TRTC Web SDK 5.x virtual background plugin",
5
5
  "main": "./virtual-background.esm.js",
6
6
  "module": "./virtual-background.esm.js",