Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Ptitloup/feature video p2p #925

Draft
wants to merge 73 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
4bdbc70
implement p2p-media-loader : https://github.com/Novage/p2p-media-load…
ptitloup Aug 28, 2023
ce34c8e
add p2p configuration in video script - show p2p stat in video_page_c…
ptitloup Aug 29, 2023
1b15d8f
add minus in stats info
ptitloup Aug 30, 2023
183a1cb
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Aug 30, 2023
e781dd7
change npm package to get videojs8 and p2p media loader from peertube…
ptitloup Sep 7, 2023
8c30e02
merge package.json
ptitloup Sep 7, 2023
6d7d0fc
add videojs-hlsjs-plugin.js
ptitloup Sep 7, 2023
74b20c2
workon videojs 8 plugin - ok for logo, quality selector, p2p, remove …
ptitloup Sep 7, 2023
d310993
remove chapter plugin from videojs and use video text track in webvtt…
ptitloup Sep 8, 2023
22f80c8
merge develop - fix conflicts
ptitloup Sep 8, 2023
743e85f
remove chapter from video element and add overview
ptitloup Sep 8, 2023
a4c081e
fix get element by id for playlist
ptitloup Sep 8, 2023
810ab24
remove plugin to show info in modal and use videojs api modal plyaer …
ptitloup Sep 8, 2023
56337bf
add settgins for the p2p function and improve display of p2p stats
ptitloup Sep 8, 2023
319ff1d
add jsdoc and readme - add p2p js only if p2p feature is activated - …
ptitloup Sep 11, 2023
9b23773
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
ptitloup Sep 11, 2023
334227f
add video-p2p-stats.js to store all p2p event function - add p2p to l…
ptitloup Sep 11, 2023
ed9a83e
create template to show p2p stats and call it from another template -…
ptitloup Sep 12, 2023
e4dd235
pull develop and remove videojs-info-controlbar.js
ptitloup Sep 12, 2023
5e796af
change firstplay by one play to deal with new videojs8 api - improvin…
ptitloup Sep 12, 2023
c25774d
use default configuration in live script for p2p
ptitloup Sep 13, 2023
c507eb4
replace videojs hlsjs plugin by the original - use the good init func…
ptitloup Sep 18, 2023
31aa5f8
[WIP] Update HLS with hls-plugin (#4)
SebastienCozeDev Oct 12, 2023
d2978ed
Merge develop
SebastienCozeDev Oct 13, 2023
200252c
make lang
SebastienCozeDev Oct 13, 2023
42ad6e3
Fix .mo
SebastienCozeDev Oct 13, 2023
add831d
Add buffer length
SebastienCozeDev Oct 13, 2023
04b935f
Fix conflicts
AymericJak Nov 6, 2023
523e35b
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
AymericJak Nov 7, 2023
d2f86ea
Replace deprecated methods & fix viewcounter
AymericJak Nov 7, 2023
4046e4b
Replace deprecated functions & remove redundant import
AymericJak Nov 7, 2023
1e5565b
Improve QoC of event-script.html file
AymericJak Nov 8, 2023
c6b2e57
Add Pod resolutions plugin
AymericJak Nov 8, 2023
add2355
Fix viewcounter import
AymericJak Nov 8, 2023
ab8a71e
Replace deprecated methods & remove imports
AymericJak Nov 9, 2023
a110b0c
Add parameters for video hls js config
AymericJak Nov 9, 2023
945079f
Pull develop
AymericJak Nov 9, 2023
93aff4c
QoC - Part 1
AymericJak Nov 10, 2023
10f50fb
QoC - Part 2 - hls-plugin
AymericJak Nov 10, 2023
ec8d234
QoC - Part 3
AymericJak Nov 10, 2023
4adad31
Fix chapters
AymericJak Nov 10, 2023
f12eaad
Fix conflicts
AymericJak Nov 20, 2023
5c6e4e6
Create the peer to peer application & the USE_PEER_TO_PEER setting
SebastienCozeDev Dec 12, 2023
fdc41ca
Add test
SebastienCozeDev Dec 12, 2023
618881a
Add test
SebastienCozeDev Dec 13, 2023
df56953
Resolve request bug
SebastienCozeDev Dec 14, 2023
82c8b5a
Rename functions
SebastienCozeDev Dec 14, 2023
9152e09
Add getIds function
SebastienCozeDev Dec 14, 2023
917a6fd
Update the getIds() function
SebastienCozeDev Dec 14, 2023
e6299fe
Fix peerID
AymericJak Dec 14, 2023
1189eff
Merge branch 'ptitloup/feature_video_p2p' of https://github.com/ptitl…
AymericJak Dec 14, 2023
4eb2da2
Fix storeUrlsId
AymericJak Dec 14, 2023
46e7d46
Rename videoId
AymericJak Dec 14, 2023
453a8d5
Update p2p-script.js
SebastienCozeDev Dec 14, 2023
61b14b8
Merge branch 'ptitloup/feature_video_p2p' of https://github.com/ptitl…
SebastienCozeDev Dec 14, 2023
cfcf1e3
Linting & doc
AymericJak Dec 14, 2023
2774bfb
Fix conflicts
AymericJak Dec 14, 2023
853b733
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
AymericJak Dec 14, 2023
929e018
Add connection to an other peer
SebastienCozeDev Dec 14, 2023
113d0b7
Merge develop
SebastienCozeDev Dec 14, 2023
3ac24e1
Add connectToAnyPeers
SebastienCozeDev Dec 15, 2023
56e73b4
Add clear invalid peer from caches view
AymericJak Dec 15, 2023
04359c1
Merge branch 'ptitloup/feature_video_p2p' of https://github.com/ptitl…
AymericJak Dec 15, 2023
83c5ad0
Update caches
AymericJak Dec 15, 2023
485cc75
Add connectToAnyPeers and connectToNextPeer function (not work)
SebastienCozeDev Dec 15, 2023
91ff5a2
Add beforeRequest redefine
SebastienCozeDev Dec 15, 2023
cb6688b
Add the P2p object
SebastienCozeDev Dec 15, 2023
ebc3520
Increase timeout for caches
AymericJak Dec 15, 2023
ee7944b
Fix conflicts
AymericJak Jan 4, 2024
5b37864
Manage peers in caches
AymericJak Jan 5, 2024
c6d6bf1
- Add & update documentation
SebastienCozeDev Jan 5, 2024
0193cee
Add the numberofConnections var
SebastienCozeDev Jan 16, 2024
7bbea0f
Merge develop
SebastienCozeDev Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2406,7 +2406,7 @@
],
"fr": [
"",
"Active la fonction pair à pair dans pod"
"Active la fonction pair à pair dans le lecteur vidéo de Pod"
]
},
"pod_version_end": "",
Expand Down
15 changes: 15 additions & 0 deletions pod/video/static/js/videojs-hls-plugin-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[FR]
Le plugin videojs-hlsjs-plugin a été compilé et est fourni avec le code source pour être compatible avec la version 1.3 de la lib hls.js.
Une issue est créée avec la PR correspondante. Voici le lien : https://github.com/streamroot/videojs-hlsjs-plugin/issues/116
Pour compiler le plugin, voici les commandes lancées :
[EN]
The videojs-hlsjs-plugin has been compiled and comes with the source code to be compatible with version 1.3 of the hls.js lib.
An issue is created with the corresponding PR. Here is the link: https://github.com/streamroot/videojs-hlsjs-plugin/issues/116
To compile the plugin, here are the commands launched:

> git clone https://github.com/ptitloup/videojs-hlsjs-plugin.git
> cd videojs-hlsjs-plugin/
> git checkout ptitloup-patch-bump-hls.js
> export NODE_OPTIONS=--openssl-legacy-provider
> npm install
> npm run build
9 changes: 5 additions & 4 deletions pod/video/templates/videos/video-header.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{% load static %}

{% load static custom_tags %}
{% get_setting "USE_VIDEO_P2P" False as use_video_p2p %}
{% if use_video_p2p %}
<script src="{% static '@peertube/p2p-media-loader-core/build/p2p-media-loader-core.js' %}?ver={{VERSION}}" ></script>
<script src="{% static '@peertube/p2p-media-loader-hlsjs/build/p2p-media-loader-hlsjs.js' %}?ver={{VERSION}}" ></script>
ptitloup marked this conversation as resolved.
Show resolved Hide resolved

{% endif %}
<link href="{% static 'video.js/dist/video-js.min.css' %}?ver={{VERSION}}" rel="stylesheet">
<script id="videojs_script_id" src="{% static 'video.js/dist/video.min.js' %}?ver={{VERSION}}"></script>
{% with 'video.js/dist/lang/'|add:request.LANGUAGE_CODE|add:'.js' as videojs_lang %}
<script src="{% static videojs_lang %}?ver={{VERSION}}"></script>
{% endwith %}

<script src="{% static 'js/videojs-hlsjs-plugin.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'js/videojs-hlsjs-plugin.min.js' %}?ver={{VERSION}}"></script>

<script src="{% static 'videojs-quality-selector-hls/dist/videojs-quality-selector-hls.min.js' %}"></script>
<link href="{% static 'videojs-quality-selector-hls/dist/videojs-quality-selector-hls.css' %}?ver={{VERSION}}" rel="stylesheet">
Expand Down
68 changes: 49 additions & 19 deletions pod/video/templates/videos/video-script.html
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{% get_setting "USE_VIDEO_P2P" False as use_video_p2p %}
{% get_setting "P2P_TRACKERS" "" as p2p_trackers %}
{% get_setting "P2P_STUNS" "" as p2p_stuns %}

<script id="id_video_script">
var seektime = 10;
var options = {};
Expand All @@ -17,7 +16,10 @@
var uploadTotal = 0;
var nb_peers = 0;
{% endif %}
var initialized_player = function() {
/**
* Initialize the videojs player
*/
var initialize_player = function() {

window.onmessage = function(event) {
var evt = event || window.event;
Expand Down Expand Up @@ -366,64 +368,92 @@
controlText: 'Information',
className: 'vjs-info-button'
});
button.setAttribute("aria-label", "Information");
button.setAttribute("aria-label", gettext("Information"));
{% endif %}
}

initialized_player()

initialize_player()
{% if use_video_p2p %}
/**
* Show the p2p stats.
*/
function updateStats() {
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
let httpMb = downloadTotals.http / 1048576;
let p2pMb = downloadTotals.p2p / 1048576;
let totalMb = httpMb + p2pMb;
let uploadMb = uploadTotal / 1048576;
let statInfo = "";
if (totalMb != 0) {
statInfo += '<i class="bi bi-person-fill-down"></i> '
statInfo += '<i class="bi bi-person-fill-down" aria-hidden="true"></i> '
+ Number(totalMb).toFixed(1) + " MiB ";
statInfo += '[ <i class="bi bi-server"></i> : '
statInfo += '[ <i class="bi bi-server" aria-hidden="true"></i> : '
+ Number(httpMb).toFixed(1) + " MiB / "
+ Number((httpMb * 100) / totalMb).toFixed(0) + "%";
statInfo += ' - <i class="bi bi-people"></i> : '
statInfo += ' - <i class="bi bi-people" aria-hidden="true"></i> : '
+ Number(p2pMb).toFixed(1) + " MiB / "
+ Number((p2pMb * 100) / totalMb).toFixed(0) + "% ]";
statInfo += ' - <i class="bi bi-person-fill-up"></i> '
statInfo += ' - <i class="bi bi-person-fill-up" aria-hidden="true"></i> '
+ Number(uploadMb).toFixed(1) + " MiB";
}
var stat_info = document.querySelector("#stat-info");
var stat_info = document.querySelector("#p2p-stat-info");
if(stat_info) {
stat_info.innerHTML = statInfo;
}
}

/**
* Show the number of peers sharing file with the user.
*/
function updatePeers() {
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
let statPeer = '<i class="bi bi-people-fill"></i> ' + nb_peers;
document.querySelector("#stat-peers").innerHTML = statPeer;
let statPeer = '<i class="bi bi-people-fill" aria-hidden="true"></i> ' + nb_peers;
document.querySelector("#p2p-stat-peers").innerHTML = statPeer;
}

/**
* Saves the bytes just download by the player by the download method.
* This method is called by the bytes download event.
*
* @param {string} method method used to download bytes : http or p2p.
* @param {string} segment current segment of video downloaded.
* @param {number} bytes umber of bytes downloaded.
*/
function onBytesDownloaded(method, segment, bytes) {
// console.log("onBytesDownloaded", method, size)
downloadTotals[method] += bytes;
updateStats();
}

/**
* Saves the bytes just upload by the player.
* This method is called by the bytes upload event.
*
* @param {string} method method used to upload bytes : only p2p.
* @param {string} segment current segment of video uploaded.
* @param {number} bytes umber of bytes uploaded.
*/
function onBytesUploaded(method, segment, bytes) {
// console.log("onBytesUploaded", method, size)
uploadTotal += bytes;
updateStats();
}

/**
* Increments the number of peer connected.
* This method is called by the peer connect event.
*
* @param {object} peer the current peer connected.
*/
function onPeerConnect(peer) {
nb_peers += 1;
// console.log("peer_connect", peer.id, peer.remoteAddress);
updatePeers()
}

/**
* Decrements the number of connected peers.
* This method is called by the peer close event.
*
* @param {number} peerId the id of the peer who are no more available.
*/
function onPeerClose(peerId) {
nb_peers -= 1;
// console.log("peer_close", peerId);
updatePeers();
}

{% endif %}
</script>
<script src="{% static 'js/video-show.js' %}?ver={{VERSION}}"></script>
2 changes: 1 addition & 1 deletion pod/video/templates/videos/video_page_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h4 class="accordion-header theme_title" id="theme_desc_title">
{% include 'videos/video-element.html' %}
</div>
{% if use_video_p2p %}
<div class="d-flex justify-content-end"><span id="stat-peers"><i class="bi bi-people-fill"></i> 0</span> | <span id="stat-info"> - </span></div>
<div class="d-flex justify-content-end"><span id="p2p-stat-peers"><i class="bi bi-people-fill" aria-hidden="true"></i> 0</span> | <span id="p2p-stat-info"> - </span></div>
{% endif %}
ptitloup marked this conversation as resolved.
Show resolved Hide resolved
<div id="info-video" class="pod-info-video">
{% include 'videos/video-all-info.html' %}
Expand Down
Loading