@vidtreo/recorder 1.7.6 → 1.7.8

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +2883 -2880
  2. package/dist/index.js +39 -21
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6074,8 +6074,6 @@ var RECORDING_CODEC_UNSUPPORTED_CODES = new Set([
6074
6074
  ]);
6075
6075
  var RECORDING_SERVER_TRANSCODE_FALLBACK_CODES = new Set([
6076
6076
  "recording.post-recording-transcode-fallback",
6077
- "recording.mediarecorder-empty",
6078
- "recording.mediarecorder-error",
6079
6077
  "transcode.post-recording-fallback",
6080
6078
  "route.post-recording-transcode-fallback"
6081
6079
  ]);
@@ -6128,6 +6126,12 @@ function classifyRecordingPipelineCode(errorCode) {
6128
6126
  if (RECORDING_CODEC_UNSUPPORTED_CODES.has(errorCode)) {
6129
6127
  return "recording.codec-unsupported";
6130
6128
  }
6129
+ if (errorCode === "recording.mediarecorder-empty") {
6130
+ return "recording.mediarecorder-empty";
6131
+ }
6132
+ if (errorCode === "recording.mediarecorder-error") {
6133
+ return "recording.mediarecorder-error";
6134
+ }
6131
6135
  if (RECORDING_SERVER_TRANSCODE_FALLBACK_CODES.has(errorCode)) {
6132
6136
  return "recording.post-recording-transcode-fallback";
6133
6137
  }
@@ -6311,7 +6315,7 @@ function resolveDeviceError(input) {
6311
6315
  // package.json
6312
6316
  var package_default = {
6313
6317
  name: "@vidtreo/recorder",
6314
- version: "1.7.6",
6318
+ version: "1.7.8",
6315
6319
  type: "module",
6316
6320
  description: "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
6317
6321
  main: "./dist/index.js",
@@ -22762,10 +22766,6 @@ var DEFAULT_ROUTE_DECISION2 = {
22762
22766
  var DEFAULT_RECORDING_MANAGER_DEPENDENCIES = {
22763
22767
  transcodeVideo
22764
22768
  };
22765
- function isBlobAlreadyInTargetFormat(blob, config) {
22766
- const expectedMimeTypePrefix = getMimeTypeForOutputFormat(config.format);
22767
- return blob.type.toLowerCase().startsWith(expectedMimeTypePrefix);
22768
- }
22769
22769
 
22770
22770
  class RecordingManager {
22771
22771
  recordingState = RECORDING_STATE_IDLE;
@@ -22793,6 +22793,7 @@ class RecordingManager {
22793
22793
  startupAborted = false;
22794
22794
  activeRecordingConfig = null;
22795
22795
  activeRouteDecision = DEFAULT_ROUTE_DECISION2;
22796
+ isFinalizingRecording = false;
22796
22797
  constructor(streamManager, callbacks, dependencies) {
22797
22798
  this.streamManager = streamManager;
22798
22799
  this.callbacks = callbacks;
@@ -22843,6 +22844,9 @@ class RecordingManager {
22843
22844
  }
22844
22845
  }
22845
22846
  async startRecording() {
22847
+ if (this.recordingState !== RECORDING_STATE_IDLE || this.isFinalizingRecording) {
22848
+ throw new Error("Recording is not ready to start");
22849
+ }
22846
22850
  try {
22847
22851
  this.callbacks.onClearUploadStatus();
22848
22852
  if (this.countdownDuration > 0) {
@@ -22967,16 +22971,26 @@ class RecordingManager {
22967
22971
  }
22968
22972
  async stopRecording() {
22969
22973
  logger.debug("[RecordingManager] stopRecording called");
22970
- try {
22971
- if (this.recordingState !== RECORDING_STATE_RECORDING) {
22972
- const stopRequestedState = this.recordingState;
22973
- this.cancelCountdown();
22974
- throw createRecordingLifecycleError(ERROR_RECORDING_STOP_NOT_READY, "Recording is not ready to stop", {
22975
- recordingState: stopRequestedState,
22976
- hasStreamProcessor: !!this.streamProcessor
22977
- });
22978
- }
22974
+ if (this.isFinalizingRecording) {
22975
+ throw createRecordingLifecycleError(ERROR_RECORDING_STOP_NOT_READY, "Recording is not ready to stop", {
22976
+ recordingState: this.recordingState,
22977
+ hasStreamProcessor: !!this.streamProcessor
22978
+ });
22979
+ }
22980
+ if (this.recordingState !== RECORDING_STATE_RECORDING) {
22981
+ const stopRequestedState = this.recordingState;
22979
22982
  this.cancelCountdown();
22983
+ const error = createRecordingLifecycleError(ERROR_RECORDING_STOP_NOT_READY, "Recording is not ready to stop", {
22984
+ recordingState: stopRequestedState,
22985
+ hasStreamProcessor: !!this.streamProcessor
22986
+ });
22987
+ this.handleError(error);
22988
+ throw error;
22989
+ }
22990
+ this.isFinalizingRecording = true;
22991
+ try {
22992
+ this.callbacks.onFinalizationStart?.();
22993
+ this.clearCountdownTimers();
22980
22994
  this.clearTimer(this.recordingIntervalId, clearInterval);
22981
22995
  this.recordingIntervalId = null;
22982
22996
  this.clearTimer(this.maxTimeTimer, clearTimeout);
@@ -23022,6 +23036,7 @@ class RecordingManager {
23022
23036
  }
23023
23037
  throw normalizedError;
23024
23038
  } finally {
23039
+ this.isFinalizingRecording = false;
23025
23040
  this.activeRecordingConfig = null;
23026
23041
  this.activeRouteDecision = DEFAULT_ROUTE_DECISION2;
23027
23042
  }
@@ -23055,14 +23070,17 @@ class RecordingManager {
23055
23070
  }
23056
23071
  }
23057
23072
  cancelCountdown() {
23073
+ this.clearCountdownTimers();
23074
+ this.recordingState = RECORDING_STATE_IDLE;
23075
+ this.callbacks.onCountdownUpdate(this.recordingState, this.countdownRemaining);
23076
+ }
23077
+ clearCountdownTimers() {
23058
23078
  this.clearTimer(this.countdownTimeoutId, clearTimeout);
23059
23079
  this.countdownTimeoutId = null;
23060
23080
  this.clearTimer(this.countdownIntervalId, clearInterval);
23061
23081
  this.countdownIntervalId = null;
23062
- this.recordingState = RECORDING_STATE_IDLE;
23063
23082
  this.countdownRemaining = 0;
23064
23083
  this.countdownStartTime = null;
23065
- this.callbacks.onCountdownUpdate(this.recordingState, this.countdownRemaining);
23066
23084
  }
23067
23085
  cleanup() {
23068
23086
  this.cancelCountdown();
@@ -23090,9 +23108,6 @@ class RecordingManager {
23090
23108
  if (!this.activeRecordingConfig) {
23091
23109
  throw new Error("Recording config unavailable for final video processing");
23092
23110
  }
23093
- if (isBlobAlreadyInTargetFormat(blob, this.activeRecordingConfig)) {
23094
- return blob;
23095
- }
23096
23111
  this.callbacks.onTranscodingProgress?.(0);
23097
23112
  const result = await this.dependencies.transcodeVideo(blob, this.activeRecordingConfig, (progress) => {
23098
23113
  this.callbacks.onTranscodingProgress?.(progress);
@@ -23162,6 +23177,9 @@ class RecordingManager {
23162
23177
  this.callbacks.onError(errorMessage);
23163
23178
  }
23164
23179
  handleFatalProcessorError(error) {
23180
+ if (this.isFinalizingRecording) {
23181
+ return;
23182
+ }
23165
23183
  if (this.recordingState === RECORDING_STATE_RECORDING) {
23166
23184
  this.clearTimer(this.recordingIntervalId, clearInterval);
23167
23185
  this.recordingIntervalId = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidtreo/recorder",
3
- "version": "1.7.6",
3
+ "version": "1.7.8",
4
4
  "type": "module",
5
5
  "description": "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
6
6
  "main": "./dist/index.js",