videomail-client 5.1.2 → 5.2.1

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.
@@ -88,8 +88,6 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
88
88
  let recordingBufferLength
89
89
  let recordingBuffer
90
90
 
91
- const timeControlEnabled = Boolean(options.video.timeControl)
92
-
93
91
  function writeStream(buffer, opts) {
94
92
  if (stream) {
95
93
  if (stream.destroyed) {
@@ -814,8 +812,7 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
814
812
  }
815
813
 
816
814
  function getAvgFps() {
817
- // see https://github.com/hapticdata/animitter/issues/3
818
- return (loop.getFrameCount() / loop.getElapsedTime()) * 1000
815
+ return (framesCount / getIntervalSum()) * 1000
819
816
  }
820
817
 
821
818
  this.getRecordingStats = function () {
@@ -945,7 +942,7 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
945
942
  params.eventType = e.type
946
943
  }
947
944
 
948
- debug('pause()', params)
945
+ debug(`pause() at frame ${framesCount}`, params)
949
946
 
950
947
  userMedia.pause()
951
948
  loop.stop()
@@ -960,7 +957,7 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
960
957
  }
961
958
 
962
959
  this.resume = function () {
963
- debug('Recorder: resume()')
960
+ debug(`Recorder: resume() with frame ${framesCount}`)
964
961
 
965
962
  stopPings()
966
963
 
@@ -993,7 +990,6 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
993
990
  if (!self.isPaused() && stream && ctx) {
994
991
  if (framesCount === 0) {
995
992
  self.emit(Events.SENDING_FIRST_FRAME)
996
- debug('Recorder: time control is', timeControlEnabled.toString())
997
993
  }
998
994
 
999
995
  framesCount++
@@ -1009,17 +1005,8 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
1009
1005
 
1010
1006
  bytesSum += recordingBufferLength
1011
1007
 
1012
- let frameBuffer
1013
-
1014
- if (timeControlEnabled) {
1015
- const timeControlBuffer = Buffer.from(
1016
- stringify({ frameNumber: framesCount, milliseconds: Date.now() })
1017
- )
1018
-
1019
- frameBuffer = Buffer.concat([recordingBuffer, timeControlBuffer])
1020
- } else {
1021
- frameBuffer = recordingBuffer
1022
- }
1008
+ const frameControlBuffer = Buffer.from(stringify({ frameNumber: framesCount }))
1009
+ const frameBuffer = Buffer.concat([recordingBuffer, frameControlBuffer])
1023
1010
 
1024
1011
  writeStream(frameBuffer, {
1025
1012
  frameNumber: framesCount,
@@ -1094,6 +1081,13 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
1094
1081
 
1095
1082
  self.emit(Events.RECORDING, framesCount)
1096
1083
 
1084
+ // see https://github.com/hapticdata/animitter/issues/3
1085
+ loop.on('update', function (deltaTime, elapsedTime) {
1086
+ // x1000 because of milliseconds
1087
+ const avgFPS = (framesCount / elapsedTime) * 1000
1088
+ debug('Recorder: avgFps =', Math.round(avgFPS))
1089
+ })
1090
+
1097
1091
  loop.start()
1098
1092
  }
1099
1093