Take web socket downloads into account for the bandwidth meter

This commit is contained in:
0xb00bface 2021-11-09 19:36:10 +01:00
parent de9c11baf5
commit 8b6b96c606
2 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package ctbrec.sites.secretfriends;
import ctbrec.Config;
import ctbrec.Model;
import ctbrec.Recording;
import ctbrec.io.BandwidthMeter;
import ctbrec.io.HttpClient;
import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.Download;
@ -172,7 +173,9 @@ public class SecretFriendsWebrtcDownload extends AbstractDownload {
super.onMessage(webSocket, bytes);
timeOfLastTransfer = Instant.now();
try {
fout.write(bytes.toByteArray());
byte[] videoData = bytes.toByteArray();
fout.write(videoData);
BandwidthMeter.add(videoData.length);
} catch (IOException e) {
if (running) {
LOG.error("Couldn't write video stream to file", e);

View File

@ -3,6 +3,7 @@ package ctbrec.sites.showup;
import ctbrec.Config;
import ctbrec.Model;
import ctbrec.Recording;
import ctbrec.io.BandwidthMeter;
import ctbrec.io.HttpClient;
import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.Download;
@ -167,7 +168,9 @@ public class ShowupWebrtcDownload extends AbstractDownload {
super.onMessage(webSocket, bytes);
timeOfLastTransfer = Instant.now();
try {
fout.write(bytes.toByteArray());
byte[] videoData = bytes.toByteArray();
fout.write(videoData);
BandwidthMeter.add(videoData.length);
} catch (IOException e) {
if (running) {
LOG.error("Couldn't write video stream to file", e);