add 'total downloaded' stats from server and peers in player (#3394)

Implements https://github.com/Chocobozzz/PeerTube/issues/3384
This will only work with HLS. The display for Webtorrent is left untouched.

Co-authored-by: Rigel Kent <par@rigelk.eu>
pull/3401/head
Florian CUNY 2020-12-04 16:30:01 +01:00 committed by GitHub
parent f8b530e0a5
commit 171528373e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -153,6 +153,7 @@ class P2pMediaLoaderPlugin extends Plugin {
this.statsHTTPBytes.pendingUpload = []
return this.player.trigger('p2pInfo', {
source: 'p2p-media-loader',
http: {
downloadSpeed: httpDownloadSpeed,
uploadSpeed: httpUploadSpeed,

View File

@ -175,6 +175,8 @@ type AutoResolutionUpdateData = {
}
type PlayerNetworkInfo = {
source: 'webtorrent' | 'p2p-media-loader'
http: {
downloadSpeed: number
uploadSpeed: number

View File

@ -84,8 +84,17 @@ class P2pInfoButton extends Button {
const totalUploaded = bytes(p2pStats.uploaded + httpStats.uploaded)
const numPeers = p2pStats.numPeers
subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' +
this.player().localize('Total uploaded: ' + totalUploaded.join(' '))
subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n'
if (data.source === 'p2p-media-loader') {
const downloadedFromServer = bytes(httpStats.downloaded).join(' ')
const downloadedFromPeers = bytes(p2pStats.downloaded).join(' ')
subDivWebtorrent.title +=
'* ' + this.player().localize('From the server: ') + downloadedFromServer + '\n' +
'* ' + this.player().localize('From peers: ') + downloadedFromPeers + '\n'
}
subDivWebtorrent.title += this.player().localize('Total uploaded: ') + totalUploaded.join(' ')
downloadSpeedNumber.textContent = downloadSpeed[ 0 ]
downloadSpeedUnit.textContent = ' ' + downloadSpeed[ 1 ]

View File

@ -487,6 +487,7 @@ class WebTorrentPlugin extends Plugin {
if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed)
return this.player.trigger('p2pInfo', {
source: 'webtorrent',
http: {
downloadSpeed: 0,
uploadSpeed: 0,