Pārlūkot izejas kodu

fix(tracks) Add metadata to jitsi tracks (#1777)

Add timestamp to all tracks, and display surface to screen sharing tracks
dev1
Robert Pintilii 3 gadus atpakaļ
vecāks
revīzija
03bc5278da
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 22 papildinājumiem un 0 dzēšanām
  1. 22
    0
      modules/RTC/JitsiLocalTrack.js

+ 22
- 0
modules/RTC/JitsiLocalTrack.js Parādīt failu

81
             this._startStreamEffect(effect);
81
             this._startStreamEffect(effect);
82
         }
82
         }
83
 
83
 
84
+        const displaySurface = videoType === VideoType.DESKTOP
85
+            ? track.getSettings().displaySurface
86
+            : null;
87
+
88
+        /**
89
+         * Track metadata.
90
+         */
91
+        this.metadata = {
92
+            timestamp: Date.now(),
93
+            ...displaySurface ? { displaySurface } : {}
94
+        };
95
+
96
+
84
         /**
97
         /**
85
          * The ID assigned by the RTC module on instance creation.
98
          * The ID assigned by the RTC module on instance creation.
86
          *
99
          *
196
         this._initNoDataFromSourceHandlers();
209
         this._initNoDataFromSourceHandlers();
197
     }
210
     }
198
 
211
 
212
+    /**
213
+     * Get the duration of the track.
214
+     *
215
+     * @returns {Number} the duration of the track in seconds
216
+     */
217
+    getDuration() {
218
+        return (Date.now() / 1000) - (this.metadata.timestamp / 1000);
219
+    }
220
+
199
     /**
221
     /**
200
      * Returns if associated MediaStreamTrack is in the 'ended' state
222
      * Returns if associated MediaStreamTrack is in the 'ended' state
201
      *
223
      *

Notiek ielāde…
Atcelt
Saglabāt