@microsoft/teams-js 2.14.0-beta.1 → 2.14.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.
@@ -824,6 +824,7 @@ __webpack_require__.d(__webpack_exports__, {
824
824
  "appEntity": () => (/* reexport */ appEntity),
825
825
  "appInitialization": () => (/* reexport */ appInitialization),
826
826
  "appInstallDialog": () => (/* reexport */ appInstallDialog),
827
+ "appNotification": () => (/* reexport */ appNotification),
827
828
  "authentication": () => (/* reexport */ authentication),
828
829
  "barCode": () => (/* reexport */ barCode),
829
830
  "calendar": () => (/* reexport */ calendar),
@@ -2089,7 +2090,7 @@ var _minRuntimeConfigToUninitialize = {
2089
2090
  * @hidden
2090
2091
  * Package version.
2091
2092
  */
2092
- var version = "2.14.0-beta.1";
2093
+ var version = "2.14.0";
2093
2094
 
2094
2095
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
2095
2096
 
@@ -5709,6 +5710,135 @@ var appInstallDialog;
5709
5710
  appInstallDialog.isSupported = isSupported;
5710
5711
  })(appInstallDialog || (appInstallDialog = {}));
5711
5712
 
5713
+ ;// CONCATENATED MODULE: ./src/public/appNotification.ts
5714
+
5715
+
5716
+
5717
+
5718
+ /**
5719
+ * Namespace to interact with the appNotification specific part of the SDK
5720
+ * @beta
5721
+ */
5722
+ var appNotification;
5723
+ (function (appNotification) {
5724
+ /**
5725
+ * @internal
5726
+ *
5727
+ * @hidden
5728
+ *
5729
+ * @beta
5730
+ *
5731
+ * This converts the notifcationActionUrl from a URL type to a string type for proper flow across the iframe
5732
+ * @param notificationDisplayParam - appNotification display parameter with the notificationActionUrl as a URL type
5733
+ * @returns a serialized object that can be sent to the host SDK
5734
+ */
5735
+ function serializeParam(notificationDisplayParam) {
5736
+ var _a;
5737
+ return {
5738
+ title: notificationDisplayParam.title,
5739
+ content: notificationDisplayParam.content,
5740
+ notificationIconAsSring: (_a = notificationDisplayParam.icon) === null || _a === void 0 ? void 0 : _a.href,
5741
+ displayDurationInSeconds: notificationDisplayParam.displayDurationInSeconds,
5742
+ notificationActionUrlAsString: notificationDisplayParam.notificationActionUrl.href,
5743
+ };
5744
+ }
5745
+ /**
5746
+ * Checks the valididty of the URL passed
5747
+ *
5748
+ * @param url
5749
+ * @returns True if a valid url was passed
5750
+ *
5751
+ * @beta
5752
+ */
5753
+ function isValidUrl(url) {
5754
+ var validProtocols = ['https:'];
5755
+ return validProtocols.includes(url.protocol);
5756
+ }
5757
+ /**
5758
+ * Validates that the input string is of property length
5759
+ *
5760
+ * @param inputString and maximumLength
5761
+ * @returns True if string length is within specified limit
5762
+ *
5763
+ * @beta
5764
+ */
5765
+ function isValidLength(inputString, maxLength) {
5766
+ return inputString.length <= maxLength;
5767
+ }
5768
+ /**
5769
+ * Validates that all the required appNotification display parameters are either supplied or satisfy the required checks
5770
+ * @param notificationDisplayParam
5771
+ * @throws Error if any of the required parameters aren't supplied
5772
+ * @throws Error if content or title length is beyond specific limit
5773
+ * @throws Error if invalid url is passed
5774
+ * @returns void
5775
+ *
5776
+ * @beta
5777
+ */
5778
+ function validateNotificationDisplayParams(notificationDisplayParam) {
5779
+ var maxTitleLength = 75;
5780
+ var maxContentLength = 1500;
5781
+ if (!notificationDisplayParam.title) {
5782
+ throw new Error('Must supply notification title');
5783
+ }
5784
+ if (!isValidLength(notificationDisplayParam.title, maxTitleLength)) {
5785
+ throw new Error("Invalid notification title length: Maximum title length ".concat(maxTitleLength, ", title length supplied ").concat(notificationDisplayParam.title.length));
5786
+ }
5787
+ if (!notificationDisplayParam.content) {
5788
+ throw new Error('Must supply notification content');
5789
+ }
5790
+ if (!isValidLength(notificationDisplayParam.content, maxContentLength)) {
5791
+ throw new Error("Invalid notification content length: Maximum content length ".concat(maxContentLength, ", content length supplied ").concat(notificationDisplayParam.content.length));
5792
+ }
5793
+ if (!notificationDisplayParam.notificationActionUrl) {
5794
+ throw new Error('Must supply notification url');
5795
+ }
5796
+ if (!isValidUrl(notificationDisplayParam.notificationActionUrl)) {
5797
+ throw new Error('Invalid notificationAction url');
5798
+ }
5799
+ if ((notificationDisplayParam === null || notificationDisplayParam === void 0 ? void 0 : notificationDisplayParam.icon) !== undefined && !isValidUrl(notificationDisplayParam === null || notificationDisplayParam === void 0 ? void 0 : notificationDisplayParam.icon)) {
5800
+ throw new Error('Invalid icon url');
5801
+ }
5802
+ if (!notificationDisplayParam.displayDurationInSeconds) {
5803
+ throw new Error('Must supply notification display duration in seconds');
5804
+ }
5805
+ if (notificationDisplayParam.displayDurationInSeconds < 0) {
5806
+ throw new Error('Notification display time must be greater than zero');
5807
+ }
5808
+ }
5809
+ /**
5810
+ * Displays appNotification after making a validiity check on all of the required parameters, by calling the validateNotificationDisplayParams helper function
5811
+ * An interface object containing all the required parameters to be displayed on the notification would be passed in here
5812
+ * The notificationDisplayParam would be serialized before passing across to the message handler to ensure all objects passed contain simple parameters that would properly pass across the Iframe
5813
+ * @param notificationdisplayparam - Interface object with all the parameters required to display an appNotificiation
5814
+ * @returns a promise resolution upon conclusion
5815
+ * @throws Error if appNotification capability is not supported
5816
+ * @throws Error if notficationDisplayParam was not validated successfully
5817
+ *
5818
+ * @beta
5819
+ */
5820
+ function displayInAppNotification(notificationDisplayParam) {
5821
+ ensureInitialized(runtime, FrameContexts.content, FrameContexts.stage, FrameContexts.sidePanel, FrameContexts.meetingStage);
5822
+ if (!isSupported()) {
5823
+ throw errorNotSupportedOnPlatform;
5824
+ }
5825
+ validateNotificationDisplayParams(notificationDisplayParam);
5826
+ return sendAndHandleSdkError('appNotification.displayNotification', serializeParam(notificationDisplayParam));
5827
+ }
5828
+ appNotification.displayInAppNotification = displayInAppNotification;
5829
+ /**
5830
+ * Checks if appNotification is supported by the host
5831
+ * @returns boolean to represent whether the appNotification capability is supported
5832
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
5833
+ *
5834
+ * @beta
5835
+ */
5836
+ function isSupported() {
5837
+ return ensureInitialized(runtime) && runtime.supports.appNotification ? true : false;
5838
+ }
5839
+ appNotification.isSupported = isSupported;
5840
+ })(appNotification || (appNotification = {}));
5841
+
5712
5842
  ;// CONCATENATED MODULE: ./src/public/media.ts
5713
5843
  /* eslint-disable @typescript-eslint/explicit-member-accessibility */
5714
5844
  var __extends = (undefined && undefined.__extends) || (function () {
@@ -7891,6 +8021,274 @@ var profile;
7891
8021
  profile.isSupported = isSupported;
7892
8022
  })(profile || (profile = {}));
7893
8023
 
8024
+ ;// CONCATENATED MODULE: ./src/internal/videoFrameTick.ts
8025
+
8026
+ var VideoFrameTick = /** @class */ (function () {
8027
+ function VideoFrameTick() {
8028
+ }
8029
+ VideoFrameTick.setTimeout = function (callback, timeoutInMs) {
8030
+ var startedAtInMs = performance.now();
8031
+ var id = generateGUID();
8032
+ VideoFrameTick.setTimeoutCallbacks[id] = {
8033
+ callback: callback,
8034
+ timeoutInMs: timeoutInMs,
8035
+ startedAtInMs: startedAtInMs,
8036
+ };
8037
+ return id;
8038
+ };
8039
+ VideoFrameTick.clearTimeout = function (id) {
8040
+ delete VideoFrameTick.setTimeoutCallbacks[id];
8041
+ };
8042
+ VideoFrameTick.setInterval = function (callback, intervalInMs) {
8043
+ VideoFrameTick.setTimeout(function next() {
8044
+ callback();
8045
+ VideoFrameTick.setTimeout(next, intervalInMs);
8046
+ }, intervalInMs);
8047
+ };
8048
+ /**
8049
+ * Call this function whenever a frame comes in, it will check if any timeout is due and call the callback
8050
+ */
8051
+ VideoFrameTick.tick = function () {
8052
+ var now = performance.now();
8053
+ var timeoutIds = [];
8054
+ // find all the timeouts that are due,
8055
+ // not to invoke them in the loop to avoid modifying the collection while iterating
8056
+ for (var key in VideoFrameTick.setTimeoutCallbacks) {
8057
+ var callback = VideoFrameTick.setTimeoutCallbacks[key];
8058
+ var start = callback.startedAtInMs;
8059
+ if (now - start >= callback.timeoutInMs) {
8060
+ timeoutIds.push(key);
8061
+ }
8062
+ }
8063
+ // invoke the callbacks
8064
+ for (var _i = 0, timeoutIds_1 = timeoutIds; _i < timeoutIds_1.length; _i++) {
8065
+ var id = timeoutIds_1[_i];
8066
+ var callback = VideoFrameTick.setTimeoutCallbacks[id];
8067
+ callback.callback();
8068
+ delete VideoFrameTick.setTimeoutCallbacks[id];
8069
+ }
8070
+ };
8071
+ VideoFrameTick.setTimeoutCallbacks = {};
8072
+ return VideoFrameTick;
8073
+ }());
8074
+
8075
+
8076
+ ;// CONCATENATED MODULE: ./src/internal/videoPerformanceStatistics.ts
8077
+
8078
+ var VideoPerformanceStatistics = /** @class */ (function () {
8079
+ function VideoPerformanceStatistics(distributionBinSize,
8080
+ /**
8081
+ * Function to report the statistics result
8082
+ */
8083
+ reportStatisticsResult) {
8084
+ this.reportStatisticsResult = reportStatisticsResult;
8085
+ this.sampleCount = 0;
8086
+ this.distributionBins = new Uint32Array(distributionBinSize);
8087
+ }
8088
+ /**
8089
+ * Call this function before processing every frame
8090
+ */
8091
+ VideoPerformanceStatistics.prototype.processStarts = function (effectId, frameWidth, frameHeight, effectParam) {
8092
+ VideoFrameTick.tick();
8093
+ if (!this.suitableForThisSession(effectId, frameWidth, frameHeight, effectParam)) {
8094
+ this.reportAndResetSession(this.getStatistics(), effectId, effectParam, frameWidth, frameHeight);
8095
+ }
8096
+ this.start();
8097
+ };
8098
+ VideoPerformanceStatistics.prototype.processEnds = function () {
8099
+ // calculate duration of the process and record it
8100
+ var durationInMillisecond = performance.now() - this.frameProcessingStartedAt;
8101
+ var binIndex = Math.floor(Math.max(0, Math.min(this.distributionBins.length - 1, durationInMillisecond)));
8102
+ this.distributionBins[binIndex] += 1;
8103
+ this.sampleCount += 1;
8104
+ };
8105
+ VideoPerformanceStatistics.prototype.getStatistics = function () {
8106
+ if (!this.currentSession) {
8107
+ return null;
8108
+ }
8109
+ return {
8110
+ effectId: this.currentSession.effectId,
8111
+ effectParam: this.currentSession.effectParam,
8112
+ frameHeight: this.currentSession.frameHeight,
8113
+ frameWidth: this.currentSession.frameWidth,
8114
+ duration: performance.now() - this.currentSession.startedAtInMs,
8115
+ sampleCount: this.sampleCount,
8116
+ distributionBins: this.distributionBins.slice(),
8117
+ };
8118
+ };
8119
+ VideoPerformanceStatistics.prototype.start = function () {
8120
+ this.frameProcessingStartedAt = performance.now();
8121
+ };
8122
+ VideoPerformanceStatistics.prototype.suitableForThisSession = function (effectId, frameWidth, frameHeight, effectParam) {
8123
+ return (this.currentSession &&
8124
+ this.currentSession.effectId === effectId &&
8125
+ this.currentSession.effectParam === effectParam &&
8126
+ this.currentSession.frameWidth === frameWidth &&
8127
+ this.currentSession.frameHeight === frameHeight);
8128
+ };
8129
+ VideoPerformanceStatistics.prototype.reportAndResetSession = function (result, effectId, effectParam, frameWidth, frameHeight) {
8130
+ var _this = this;
8131
+ result && this.reportStatisticsResult(result);
8132
+ this.resetCurrentSession(this.getNextTimeout(effectId, this.currentSession), effectId, effectParam, frameWidth, frameHeight);
8133
+ if (this.timeoutId) {
8134
+ VideoFrameTick.clearTimeout(this.timeoutId);
8135
+ }
8136
+ this.timeoutId = VideoFrameTick.setTimeout((function () { return _this.reportAndResetSession(_this.getStatistics(), effectId, effectParam, frameWidth, frameHeight); }).bind(this), this.currentSession.timeoutInMs);
8137
+ };
8138
+ VideoPerformanceStatistics.prototype.resetCurrentSession = function (timeoutInMs, effectId, effectParam, frameWidth, frameHeight) {
8139
+ this.currentSession = {
8140
+ startedAtInMs: performance.now(),
8141
+ timeoutInMs: timeoutInMs,
8142
+ effectId: effectId,
8143
+ effectParam: effectParam,
8144
+ frameWidth: frameWidth,
8145
+ frameHeight: frameHeight,
8146
+ };
8147
+ this.sampleCount = 0;
8148
+ this.distributionBins.fill(0);
8149
+ };
8150
+ // send the statistics result every n second, where n starts from 1, 2, 4...and finally stays at every 30 seconds.
8151
+ VideoPerformanceStatistics.prototype.getNextTimeout = function (effectId, currentSession) {
8152
+ // only reset timeout when new session or effect changed
8153
+ if (!currentSession || currentSession.effectId !== effectId) {
8154
+ return VideoPerformanceStatistics.initialSessionTimeoutInMs;
8155
+ }
8156
+ return Math.min(VideoPerformanceStatistics.maxSessionTimeoutInMs, currentSession.timeoutInMs * 2);
8157
+ };
8158
+ VideoPerformanceStatistics.initialSessionTimeoutInMs = 1000;
8159
+ VideoPerformanceStatistics.maxSessionTimeoutInMs = 1000 * 30;
8160
+ return VideoPerformanceStatistics;
8161
+ }());
8162
+
8163
+
8164
+ ;// CONCATENATED MODULE: ./src/internal/videoPerformanceMonitor.ts
8165
+
8166
+
8167
+ /**
8168
+ * This class is used to monitor the performance of video processing, and report performance events.
8169
+ */
8170
+ var VideoPerformanceMonitor = /** @class */ (function () {
8171
+ function VideoPerformanceMonitor(reportPerformanceEvent) {
8172
+ var _this = this;
8173
+ this.reportPerformanceEvent = reportPerformanceEvent;
8174
+ this.isFirstFrameProcessed = false;
8175
+ this.frameProcessTimeLimit = 100;
8176
+ this.frameProcessingStartedAt = 0;
8177
+ this.frameProcessingTimeCost = 0;
8178
+ this.processedFrameCount = 0;
8179
+ this.performanceStatistics = new VideoPerformanceStatistics(VideoPerformanceMonitor.distributionBinSize, function (result) {
8180
+ return _this.reportPerformanceEvent('video.performance.performanceDataGenerated', [result]);
8181
+ });
8182
+ }
8183
+ /**
8184
+ * Start to check frame processing time intervally
8185
+ * and report performance event if the average frame processing time is too long.
8186
+ */
8187
+ VideoPerformanceMonitor.prototype.startMonitorSlowFrameProcessing = function () {
8188
+ var _this = this;
8189
+ VideoFrameTick.setInterval(function () {
8190
+ if (_this.processedFrameCount === 0) {
8191
+ return;
8192
+ }
8193
+ var averageFrameProcessingTime = _this.frameProcessingTimeCost / _this.processedFrameCount;
8194
+ if (averageFrameProcessingTime > _this.frameProcessTimeLimit) {
8195
+ _this.reportPerformanceEvent('video.performance.frameProcessingSlow', [averageFrameProcessingTime]);
8196
+ }
8197
+ _this.frameProcessingTimeCost = 0;
8198
+ _this.processedFrameCount = 0;
8199
+ }, VideoPerformanceMonitor.calculateFPSInterval);
8200
+ };
8201
+ /**
8202
+ * Define the time limit of frame processing.
8203
+ * When the average frame processing time is longer than the time limit, a "video.performance.frameProcessingSlow" event will be reported.
8204
+ * @param timeLimit
8205
+ */
8206
+ VideoPerformanceMonitor.prototype.setFrameProcessTimeLimit = function (timeLimit) {
8207
+ this.frameProcessTimeLimit = timeLimit;
8208
+ };
8209
+ /**
8210
+ * Call this function when the app starts to switch to the new video effect
8211
+ */
8212
+ VideoPerformanceMonitor.prototype.reportApplyingVideoEffect = function (effectId, effectParam) {
8213
+ var _a, _b;
8214
+ if (((_a = this.applyingEffect) === null || _a === void 0 ? void 0 : _a.effectId) === effectId && ((_b = this.applyingEffect) === null || _b === void 0 ? void 0 : _b.effectParam) === effectParam) {
8215
+ return;
8216
+ }
8217
+ this.applyingEffect = {
8218
+ effectId: effectId,
8219
+ effectParam: effectParam,
8220
+ };
8221
+ this.appliedEffect = undefined;
8222
+ };
8223
+ /**
8224
+ * Call this function when the new video effect is ready
8225
+ */
8226
+ VideoPerformanceMonitor.prototype.reportVideoEffectChanged = function (effectId, effectParam) {
8227
+ if (this.applyingEffect === undefined ||
8228
+ (this.applyingEffect.effectId !== effectId && this.applyingEffect.effectParam !== effectParam)) {
8229
+ // don't handle obsoleted event
8230
+ return;
8231
+ }
8232
+ this.appliedEffect = {
8233
+ effectId: effectId,
8234
+ effectParam: effectParam,
8235
+ };
8236
+ this.applyingEffect = undefined;
8237
+ this.isFirstFrameProcessed = false;
8238
+ };
8239
+ /**
8240
+ * Call this function when the app starts to process a video frame
8241
+ */
8242
+ VideoPerformanceMonitor.prototype.reportStartFrameProcessing = function (frameWidth, frameHeight) {
8243
+ VideoFrameTick.tick();
8244
+ if (!this.appliedEffect) {
8245
+ return;
8246
+ }
8247
+ this.frameProcessingStartedAt = performance.now();
8248
+ this.performanceStatistics.processStarts(this.appliedEffect.effectId, frameWidth, frameHeight, this.appliedEffect.effectParam);
8249
+ };
8250
+ /**
8251
+ * Call this function when the app finishes successfully processing a video frame
8252
+ */
8253
+ VideoPerformanceMonitor.prototype.reportFrameProcessed = function () {
8254
+ var _a;
8255
+ if (!this.appliedEffect) {
8256
+ return;
8257
+ }
8258
+ this.processedFrameCount++;
8259
+ this.frameProcessingTimeCost += performance.now() - this.frameProcessingStartedAt;
8260
+ this.performanceStatistics.processEnds();
8261
+ if (!this.isFirstFrameProcessed) {
8262
+ this.isFirstFrameProcessed = true;
8263
+ this.reportPerformanceEvent('video.performance.firstFrameProcessed', [
8264
+ Date.now(),
8265
+ this.appliedEffect.effectId,
8266
+ (_a = this.appliedEffect) === null || _a === void 0 ? void 0 : _a.effectParam,
8267
+ ]);
8268
+ }
8269
+ };
8270
+ /**
8271
+ * Call this function when the app starts to get the texture stream
8272
+ */
8273
+ VideoPerformanceMonitor.prototype.reportGettingTextureStream = function (streamId) {
8274
+ this.gettingTextureStreamStartedAt = performance.now();
8275
+ this.currentStreamId = streamId;
8276
+ };
8277
+ /**
8278
+ * Call this function when the app finishes successfully getting the texture stream
8279
+ */
8280
+ VideoPerformanceMonitor.prototype.reportTextureStreamAcquired = function () {
8281
+ if (this.gettingTextureStreamStartedAt !== undefined) {
8282
+ var timeTaken = performance.now() - this.gettingTextureStreamStartedAt;
8283
+ this.reportPerformanceEvent('video.performance.textureStreamAcquired', [this.currentStreamId, timeTaken]);
8284
+ }
8285
+ };
8286
+ VideoPerformanceMonitor.distributionBinSize = 1000;
8287
+ VideoPerformanceMonitor.calculateFPSInterval = 1000;
8288
+ return VideoPerformanceMonitor;
8289
+ }());
8290
+
8291
+
7894
8292
  ;// CONCATENATED MODULE: ./src/internal/videoUtils.ts
7895
8293
  var videoUtils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
7896
8294
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -7937,14 +8335,14 @@ var videoUtils_generator = (undefined && undefined.__generator) || function (thi
7937
8335
  * @hidden
7938
8336
  * Create a MediaStreamTrack from the media stream with the given streamId and processed by videoFrameHandler.
7939
8337
  */
7940
- function processMediaStream(streamId, videoFrameHandler, notifyError) {
8338
+ function processMediaStream(streamId, videoFrameHandler, notifyError, videoPerformanceMonitor) {
7941
8339
  return videoUtils_awaiter(this, void 0, void 0, function () {
7942
8340
  var _a;
7943
8341
  return videoUtils_generator(this, function (_b) {
7944
8342
  switch (_b.label) {
7945
8343
  case 0:
7946
8344
  _a = createProcessedStreamGenerator;
7947
- return [4 /*yield*/, getInputVideoTrack(streamId, notifyError)];
8345
+ return [4 /*yield*/, getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor)];
7948
8346
  case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new DefaultTransformer(notifyError, videoFrameHandler)])];
7949
8347
  }
7950
8348
  });
@@ -7958,14 +8356,14 @@ function processMediaStream(streamId, videoFrameHandler, notifyError) {
7958
8356
  * @internal
7959
8357
  * Limited to Microsoft-internal use
7960
8358
  */
7961
- function processMediaStreamWithMetadata(streamId, videoFrameHandler, notifyError) {
8359
+ function processMediaStreamWithMetadata(streamId, videoFrameHandler, notifyError, videoPerformanceMonitor) {
7962
8360
  return videoUtils_awaiter(this, void 0, void 0, function () {
7963
8361
  var _a;
7964
8362
  return videoUtils_generator(this, function (_b) {
7965
8363
  switch (_b.label) {
7966
8364
  case 0:
7967
8365
  _a = createProcessedStreamGenerator;
7968
- return [4 /*yield*/, getInputVideoTrack(streamId, notifyError)];
8366
+ return [4 /*yield*/, getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor)];
7969
8367
  case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), new TransformerWithMetadata(notifyError, videoFrameHandler)])];
7970
8368
  }
7971
8369
  });
@@ -7974,7 +8372,7 @@ function processMediaStreamWithMetadata(streamId, videoFrameHandler, notifyError
7974
8372
  /**
7975
8373
  * Get the video track from the media stream gotten from chrome.webview.getTextureStream(streamId).
7976
8374
  */
7977
- function getInputVideoTrack(streamId, notifyError) {
8375
+ function getInputVideoTrack(streamId, notifyError, videoPerformanceMonitor) {
7978
8376
  return videoUtils_awaiter(this, void 0, void 0, function () {
7979
8377
  var chrome, mediaStream, tracks, error_1, errorMsg;
7980
8378
  return videoUtils_generator(this, function (_a) {
@@ -7987,6 +8385,7 @@ function getInputVideoTrack(streamId, notifyError) {
7987
8385
  _a.label = 1;
7988
8386
  case 1:
7989
8387
  _a.trys.push([1, 3, , 4]);
8388
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportGettingTextureStream(streamId);
7990
8389
  return [4 /*yield*/, chrome.webview.getTextureStream(streamId)];
7991
8390
  case 2:
7992
8391
  mediaStream = _a.sent();
@@ -7994,6 +8393,7 @@ function getInputVideoTrack(streamId, notifyError) {
7994
8393
  if (tracks.length === 0) {
7995
8394
  throw new Error("No video track in stream ".concat(streamId));
7996
8395
  }
8396
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportTextureStreamAcquired();
7997
8397
  return [2 /*return*/, tracks[0]];
7998
8398
  case 3:
7999
8399
  error_1 = _a.sent();
@@ -8319,10 +8719,12 @@ var TransformerWithMetadata = /** @class */ (function () {
8319
8719
  /**
8320
8720
  * @hidden
8321
8721
  */
8322
- function createEffectParameterChangeCallback(callback) {
8722
+ function createEffectParameterChangeCallback(callback, videoPerformanceMonitor) {
8323
8723
  return function (effectId, effectParam) {
8724
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportApplyingVideoEffect(effectId || '', effectParam);
8324
8725
  callback(effectId, effectParam)
8325
8726
  .then(function () {
8727
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportVideoEffectChanged(effectId || '', effectParam);
8326
8728
  sendMessageToParent('video.videoEffectReadiness', [true, effectId, undefined, effectParam]);
8327
8729
  })
8328
8730
  .catch(function (reason) {
@@ -8398,12 +8800,16 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
8398
8800
 
8399
8801
 
8400
8802
 
8803
+
8401
8804
  /**
8402
8805
  * Namespace to video extensibility of the SDK
8403
8806
  * @beta
8404
8807
  */
8405
8808
  var video;
8406
8809
  (function (video) {
8810
+ var videoPerformanceMonitor = inServerSideRenderingEnvironment()
8811
+ ? undefined
8812
+ : new VideoPerformanceMonitor(sendMessageToParent);
8407
8813
  /**
8408
8814
  * Video frame format enum, currently only support NV12
8409
8815
  * @beta
@@ -8489,6 +8895,9 @@ var video;
8489
8895
  if (!parameters.videoFrameHandler || !parameters.videoBufferHandler) {
8490
8896
  throw new Error('Both videoFrameHandler and videoBufferHandler must be provided');
8491
8897
  }
8898
+ registerHandler('video.setFrameProcessTimeLimit', function (timeLimitInfo) {
8899
+ return videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.setFrameProcessTimeLimit(timeLimitInfo.timeLimit);
8900
+ }, false);
8492
8901
  if (doesSupportMediaStream()) {
8493
8902
  registerForMediaStream(parameters.videoFrameHandler, parameters.config);
8494
8903
  }
@@ -8499,6 +8908,7 @@ var video;
8499
8908
  // should not happen if isSupported() is true
8500
8909
  throw errorNotSupportedOnPlatform;
8501
8910
  }
8911
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.startMonitorSlowFrameProcessing();
8502
8912
  }
8503
8913
  video.registerForVideoFrame = registerForVideoFrame;
8504
8914
  /**
@@ -8527,7 +8937,7 @@ var video;
8527
8937
  if (!isSupported()) {
8528
8938
  throw errorNotSupportedOnPlatform;
8529
8939
  }
8530
- registerHandler('video.effectParameterChange', createEffectParameterChangeCallback(callback), false);
8940
+ registerHandler('video.effectParameterChange', createEffectParameterChangeCallback(callback, videoPerformanceMonitor), false);
8531
8941
  sendMessageToParent('video.registerForVideoEffect');
8532
8942
  }
8533
8943
  video.registerForVideoEffect = registerForVideoEffect;
@@ -8569,13 +8979,14 @@ var video;
8569
8979
  throw errorNotSupportedOnPlatform;
8570
8980
  }
8571
8981
  registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return video_awaiter(_this, void 0, void 0, function () {
8572
- var streamId, generator;
8982
+ var streamId, monitoredVideoFrameHandler, generator;
8573
8983
  var _a, _b;
8574
8984
  return video_generator(this, function (_c) {
8575
8985
  switch (_c.label) {
8576
8986
  case 0:
8577
8987
  streamId = mediaStreamInfo.streamId;
8578
- return [4 /*yield*/, processMediaStream(streamId, videoFrameHandler, notifyError)];
8988
+ monitoredVideoFrameHandler = createMonitoredVideoFrameHandler(videoFrameHandler, videoPerformanceMonitor);
8989
+ return [4 /*yield*/, processMediaStream(streamId, monitoredVideoFrameHandler, notifyError, videoPerformanceMonitor)];
8579
8990
  case 1:
8580
8991
  generator = _c.sent();
8581
8992
  // register the video track with processed frames back to the stream:
@@ -8586,6 +8997,24 @@ var video;
8586
8997
  }); }, false);
8587
8998
  sendMessageToParent('video.mediaStream.registerForVideoFrame', [config]);
8588
8999
  }
9000
+ function createMonitoredVideoFrameHandler(videoFrameHandler, videoPerformanceMonitor) {
9001
+ var _this = this;
9002
+ return function (videoFrameData) { return video_awaiter(_this, void 0, void 0, function () {
9003
+ var originalFrame, processedFrame;
9004
+ return video_generator(this, function (_a) {
9005
+ switch (_a.label) {
9006
+ case 0:
9007
+ originalFrame = videoFrameData.videoFrame;
9008
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportStartFrameProcessing(originalFrame.codedWidth, originalFrame.codedHeight);
9009
+ return [4 /*yield*/, videoFrameHandler(videoFrameData)];
9010
+ case 1:
9011
+ processedFrame = _a.sent();
9012
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportFrameProcessed();
9013
+ return [2 /*return*/, processedFrame];
9014
+ }
9015
+ });
9016
+ }); };
9017
+ }
8589
9018
  function registerForVideoBuffer(videoBufferHandler, config) {
8590
9019
  ensureInitialized(runtime, FrameContexts.sidePanel);
8591
9020
  if (!isSupported() || !doesSupportSharedFrame()) {
@@ -8596,7 +9025,9 @@ var video;
8596
9025
  function (videoBufferData) {
8597
9026
  if (videoBufferData) {
8598
9027
  var timestamp_1 = videoBufferData.timestamp;
9028
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportStartFrameProcessing(videoBufferData.width, videoBufferData.height);
8599
9029
  videoBufferHandler(normalizeVideoBufferData(videoBufferData), function () {
9030
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportFrameProcessed();
8600
9031
  notifyVideoFrameProcessed(timestamp_1);
8601
9032
  }, notifyError);
8602
9033
  }
@@ -10346,6 +10777,7 @@ var marketplace;
10346
10777
 
10347
10778
 
10348
10779
 
10780
+
10349
10781
 
10350
10782
 
10351
10783
 
@@ -11625,6 +12057,7 @@ var videoEx_generator = (undefined && undefined.__generator) || function (thisAr
11625
12057
 
11626
12058
 
11627
12059
 
12060
+
11628
12061
  /**
11629
12062
  * @hidden
11630
12063
  * Extended video API
@@ -11635,6 +12068,9 @@ var videoEx_generator = (undefined && undefined.__generator) || function (thisAr
11635
12068
  */
11636
12069
  var videoEx;
11637
12070
  (function (videoEx) {
12071
+ var videoPerformanceMonitor = inServerSideRenderingEnvironment()
12072
+ ? undefined
12073
+ : new VideoPerformanceMonitor(sendMessageToParent);
11638
12074
  /**
11639
12075
  * @hidden
11640
12076
  * Error level when notifying errors to the host, the host will decide what to do acording to the error level.
@@ -11670,6 +12106,7 @@ var videoEx;
11670
12106
  throw new Error('Both videoFrameHandler and videoBufferHandler must be provided');
11671
12107
  }
11672
12108
  if (ensureInitialized(runtime, FrameContexts.sidePanel)) {
12109
+ registerHandler('video.setFrameProcessTimeLimit', function (timeLimit) { return videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.setFrameProcessTimeLimit(timeLimit); }, false);
11673
12110
  if ((_a = runtime.supports.video) === null || _a === void 0 ? void 0 : _a.mediaStream) {
11674
12111
  registerHandler('video.startVideoExtensibilityVideoStream', function (mediaStreamInfo) { return videoEx_awaiter(_this, void 0, void 0, function () {
11675
12112
  var streamId, metadataInTexture, generator, _a;
@@ -11679,11 +12116,11 @@ var videoEx;
11679
12116
  case 0:
11680
12117
  streamId = mediaStreamInfo.streamId, metadataInTexture = mediaStreamInfo.metadataInTexture;
11681
12118
  if (!metadataInTexture) return [3 /*break*/, 2];
11682
- return [4 /*yield*/, processMediaStreamWithMetadata(streamId, parameters.videoFrameHandler, notifyError)];
12119
+ return [4 /*yield*/, processMediaStreamWithMetadata(streamId, parameters.videoFrameHandler, notifyError, videoPerformanceMonitor)];
11683
12120
  case 1:
11684
12121
  _a = _d.sent();
11685
12122
  return [3 /*break*/, 4];
11686
- case 2: return [4 /*yield*/, processMediaStream(streamId, parameters.videoFrameHandler, notifyError)];
12123
+ case 2: return [4 /*yield*/, processMediaStream(streamId, parameters.videoFrameHandler, notifyError, videoPerformanceMonitor)];
11687
12124
  case 3:
11688
12125
  _a = _d.sent();
11689
12126
  _d.label = 4;
@@ -11701,8 +12138,10 @@ var videoEx;
11701
12138
  else if ((_b = runtime.supports.video) === null || _b === void 0 ? void 0 : _b.sharedFrame) {
11702
12139
  registerHandler('video.newVideoFrame', function (videoBufferData) {
11703
12140
  if (videoBufferData) {
12141
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportStartFrameProcessing(videoBufferData.width, videoBufferData.height);
11704
12142
  var timestamp_1 = videoBufferData.timestamp;
11705
12143
  parameters.videoBufferHandler(normalizedVideoBufferData(videoBufferData), function () {
12144
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.reportFrameProcessed();
11706
12145
  notifyVideoFrameProcessed(timestamp_1);
11707
12146
  }, notifyError);
11708
12147
  }
@@ -11713,6 +12152,7 @@ var videoEx;
11713
12152
  // should not happen if isSupported() is true
11714
12153
  throw errorNotSupportedOnPlatform;
11715
12154
  }
12155
+ videoPerformanceMonitor === null || videoPerformanceMonitor === void 0 ? void 0 : videoPerformanceMonitor.startMonitorSlowFrameProcessing();
11716
12156
  }
11717
12157
  }
11718
12158
  videoEx.registerForVideoFrame = registerForVideoFrame;
@@ -11756,7 +12196,7 @@ var videoEx;
11756
12196
  if (!isSupported()) {
11757
12197
  throw errorNotSupportedOnPlatform;
11758
12198
  }
11759
- registerHandler('video.effectParameterChange', createEffectParameterChangeCallback(callback), false);
12199
+ registerHandler('video.effectParameterChange', createEffectParameterChangeCallback(callback, videoPerformanceMonitor), false);
11760
12200
  sendMessageToParent('video.registerForVideoEffect');
11761
12201
  }
11762
12202
  videoEx.registerForVideoEffect = registerForVideoEffect;