Skip to content

Commit 66f8169

Browse files
authored
Merge pull request #4 from DVBProject/master
Merge main updates
2 parents d092fbb + 9bbb2c9 commit 66f8169

7 files changed

Lines changed: 412 additions & 456 deletions

File tree

backend/servicelists/example.xml

Lines changed: 72 additions & 242 deletions
Large diffs are not rendered by default.

frontend/android/js/channel.js

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Channel.prototype.getMediaPresentationApp = function (serviceInstance) {
150150
if (serviceInstance && serviceInstance.mediaPresentationApps) {
151151
for (i = 0; i < serviceInstance.mediaPresentationApps.length; i++) {
152152
mediaPresentationApp = serviceInstance.mediaPresentationApps[i];
153-
if (mediaPresentationApp.contentType == XML_MIME || mediaPresentationApp.contentType == XHTML_MIMR) {
153+
if (mediaPresentationApp.contentType == XML_MIME || mediaPresentationApp.contentType == XHTML_MIME) {
154154
return mediaPresentationApp.url;
155155
}
156156
}
@@ -175,6 +175,50 @@ Channel.prototype.checkAvailability = function () {
175175
this.availablityTimer = setTimeout(this.checkAvailability.bind(this), 60 * 1000);
176176
};
177177

178+
function UUIDv7() {
179+
// see https://stackoverflow.com/questions/71816194/uuidv6-v7-v8-in-javascript-browser
180+
return "tttttttt-tttt-7xxx-yxxx-xxxxxxxxxxxx"
181+
.replace(/[xy]/g, function (c) {
182+
const r = Math.trunc(Math.random() * 16);
183+
const v = c == "x" ? r : (r & 0x3) | 0x8;
184+
return v.toString(16);
185+
})
186+
.replace(/^[t]{8}-[t]{4}/, function () {
187+
const unixtimestamp = Date.now().toString(16).padStart(12, "0");
188+
return unixtimestamp.slice(0, 8) + "-" + unixtimestamp.slice(8);
189+
});
190+
}
191+
192+
function DASHjsVersion5(player) {
193+
var [major, minor, micro] = player.getVersion().split(".");
194+
return major >= 5;
195+
}
196+
197+
function playDASH(player, instance) {
198+
if (instance == null) {
199+
player.updateSettings({ streaming: { cmcd: { enabled: false } } });
200+
player.attachSource(null);
201+
return;
202+
}
203+
204+
if (instance.hasOwnProperty("CMCDinit") && instance.CMCDinit != null) {
205+
var cmcd_vars = { ...instance.CMCDinit };
206+
cmcd_vars.sid = UUIDv7();
207+
if (DASHjsVersion5(player)) {
208+
cmcd_vars.applyParametersFromMpd = false;
209+
cmcd_vars.includeInRequests = ["segment", "mpd"];
210+
} else {
211+
delete cmcd_vars.version;
212+
}
213+
player.updateSettings({
214+
streaming: { cmcd: cmcd_vars },
215+
});
216+
} else {
217+
player.updateSettings({ streaming: { cmcd: { enabled: false } } });
218+
}
219+
player.attachSource(instance.dashUrl);
220+
}
221+
178222
Channel.prototype.channelSelected = function () {
179223
var self = this;
180224
$("#notification").hide();
@@ -193,9 +237,7 @@ Channel.prototype.channelSelected = function () {
193237
$("#notification").removeClass();
194238
$("#notification").addClass("noservice");
195239
if (self.out_of_service_image) {
196-
$("#notification").html(
197-
'<img src="' + self.out_of_service_image.mediaUri + '" class="img-fluid position-relative"/>'
198-
);
240+
$("#notification").html('<img src="' + self.out_of_service_image.mediaUri + '" class="img-fluid position-relative"/>');
199241
} else {
200242
$("#notification").text("Service not available");
201243
}
@@ -208,21 +250,21 @@ Channel.prototype.channelSelected = function () {
208250
} else if (self.isProgramAllowed()) {
209251
$("#parentalpin").hide();
210252
if (self.serviceInstance) {
211-
player.attachSource(self.serviceInstance.dashUrl);
253+
playDASH(player, self.serviceInstance);
212254
}
213255
} else {
214-
player.attachSource(null);
256+
playDASH(player, null);
215257
checkParentalPIN(
216258
"Enter parental PIN to watch service",
217259
function () {
218260
$("#notification").hide();
219261
try {
220262
if (player.getSource() != self.serviceInstance.dashUrl) {
221-
player.attachSource(self.serviceInstance.dashUrl);
263+
playDASH(player, self.serviceInstance);
222264
}
223265
} catch (e) {
224266
//player throws an error is there is no souce attached
225-
player.attachSource(self.serviceInstance.dashUrl);
267+
playDASH(player, self.serviceInstance);
226268
}
227269
},
228270
function () {
@@ -250,11 +292,11 @@ Channel.prototype.programChanged = function () {
250292
$("#notification").hide();
251293
try {
252294
if (player.getSource() != serviceInstance.dashUrl) {
253-
player.attachSource(serviceInstance.dashUrl);
295+
playDASH(player, serviceInstance);
254296
}
255297
} catch (e) {
256298
//player throws an error is there is no souce attached
257-
player.attachSource(serviceInstance.dashUrl);
299+
playDASH(player, serviceInstance);
258300
}
259301
} else {
260302
player.attachSource(null);
@@ -264,11 +306,11 @@ Channel.prototype.programChanged = function () {
264306
$("#notification").hide();
265307
try {
266308
if (player.getSource() != serviceInstance.dashUrl) {
267-
player.attachSource(serviceInstance.dashUrl);
309+
playDASH(player, serviceInstance);
268310
}
269311
} catch (e) {
270312
//player throws an error is there is no souce attached
271-
player.attachSource(serviceInstance.dashUrl);
313+
playDASH(player, serviceInstance);
272314
}
273315
},
274316
function () {
@@ -482,11 +524,11 @@ Channel.prototype.parentalRatingChanged = function (callback) {
482524
$("#notification").hide();
483525
try {
484526
if (player.getSource() != serviceInstance.dashUrl) {
485-
player.attachSource(serviceInstance.dashUrl);
527+
playDASH(player, serviceInstance);
486528
}
487529
} catch (e) {
488-
//player throws an error is there is no souce attached
489-
player.attachSource(serviceInstance.dashUrl);
530+
//player throws an error if there is no souce attached
531+
playDASH(player, serviceInstance);
490532
}
491533
} else {
492534
player.attachSource(null);
@@ -496,11 +538,11 @@ Channel.prototype.parentalRatingChanged = function (callback) {
496538
$("#notification").hide();
497539
try {
498540
if (player.getSource() != serviceInstance.dashUrl) {
499-
player.attachSource(serviceInstance.dashUrl);
541+
playDASH(player, serviceInstance);
500542
}
501543
} catch (e) {
502544
//player throws an error is there is no souce attached
503-
player.attachSource(serviceInstance.dashUrl);
545+
playDASH(player, serviceInstance);
504546
}
505547
},
506548
function () {

frontend/android/js/dvbi-mobile.js

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -707,31 +707,73 @@ function showStreamInfo() {
707707
function updateStreamInfo() {
708708
if (player) {
709709
try {
710+
document.getElementById("DASHjs_version").innerHTML = player.getVersion();
710711
var settings = player.getSettings();
711-
document.getElementById("live_settings").innerHTML =
712-
"Low latency mode:" +
713-
settings.streaming.lowLatencyEnabled +
714-
" Delay:" +
715-
settings.streaming.liveDelay +
716-
"<br/>Min drift:" +
717-
settings.streaming.liveCatchUpMinDrift +
718-
" Catchup Rate" +
719-
settings.streaming.liveCatchUpPlaybackRate;
720-
var audioTrack = player.getBitrateInfoListFor("audio")[player.getQualityFor("audio")];
721-
var videoTrack = player.getBitrateInfoListFor("video")[player.getQualityFor("video")];
722-
var bestAudio = player.getTopBitrateInfoFor("audio");
723-
var bestVideo = player.getTopBitrateInfoFor("video");
724-
if (audioTrack) {
725-
document.getElementById("audio_bitrate").innerHTML =
726-
audioTrack.bitrate / 1000 + "kbits (max:" + bestAudio.bitrate / 1000 + "kbits)";
727-
}
728-
if (videoTrack) {
729-
document.getElementById("video_bitrate").innerHTML =
730-
videoTrack.bitrate / 1000 + "kbits (max:" + bestVideo.bitrate / 1000 + "kbits)";
712+
713+
if (DASHjsVersion5(player)) {
714+
document.getElementById("live_settings").innerHTML =
715+
"Low latency mode:" +
716+
player.getLowLatencyModeEnabled() +
717+
" Delay:" +
718+
"INDEVv5" +
719+
"<br/>Min drift:" +
720+
"INDEVv5" +
721+
" Catchup Rate:" +
722+
"INDEVv5";
723+
724+
var audioTrack = player.getCurrentRepresentationForType("audio");
725+
var highestAudio = 0,
726+
audioReps = player.getRepresentationsByType("audio");
727+
for (var i = 0; i < audioReps.length; i++) {
728+
if (audioReps[i].bitrateInKbit > highestAudio) highestAudio = audioReps[i].bitrateInKbit;
729+
}
730+
document.getElementById("audio_bitrate").innerHTML = audioTrack
731+
? audioTrack.bitrateInKbit + "kbits (max:" + highestAudio + "kbits)"
732+
: "no-audio";
733+
734+
var videoTrack = player.getCurrentRepresentationForType("video");
735+
var highestVideo = 0,
736+
highestRes = null,
737+
videoReps = player.getRepresentationsByType("video");
738+
for (var j = 0; j < videoReps.length; j++) {
739+
if (videoReps[j].bitrateInKbit > highestVideo) {
740+
highestVideo = videoReps[j].bitrateInKbit;
741+
highestRes = videoReps[j].width + "x" + videoReps[j].height;
742+
}
743+
}
744+
document.getElementById("video_bitrate").innerHTML = videoTrack
745+
? videoTrack.bitrateInKbit + "kbits (max:" + highestVideo + "kbits)"
746+
: "no-video";
731747
document.getElementById("video_resolution").innerHTML =
732-
videoTrack.width + "x" + videoTrack.height + " (max:" + bestVideo.width + "x" + bestVideo.height + ")";
748+
videoTrack.width + "x" + videoTrack.height + (highestRes ? " (max:" + highestRes + ")" : "");
749+
750+
document.getElementById("live_latency").innerHTML = player.getCurrentLiveLatency() + "s";
751+
} else {
752+
document.getElementById("live_settings").innerHTML =
753+
"Low latency mode:" +
754+
settings.streaming.lowLatencyEnabled +
755+
" Delay:" +
756+
settings.streaming.liveDelay +
757+
"<br/>Min drift:" +
758+
settings.streaming.liveCatchUpMinDrift +
759+
" Catchup Rate:" +
760+
settings.streaming.liveCatchUpPlaybackRate;
761+
var audioTrack = player.getBitrateInfoListFor("audio")[player.getQualityFor("audio")];
762+
var videoTrack = player.getBitrateInfoListFor("video")[player.getQualityFor("video")];
763+
var bestAudio = player.getTopBitrateInfoFor("audio");
764+
var bestVideo = player.getTopBitrateInfoFor("video");
765+
if (audioTrack) {
766+
document.getElementById("audio_bitrate").innerHTML =
767+
audioTrack.bitrate / 1000 + "kbits (max:" + bestAudio.bitrate / 1000 + "kbits)";
768+
}
769+
if (videoTrack) {
770+
document.getElementById("video_bitrate").innerHTML =
771+
videoTrack.bitrate / 1000 + "kbits (max:" + bestVideo.bitrate / 1000 + "kbits)";
772+
document.getElementById("video_resolution").innerHTML =
773+
videoTrack.width + "x" + videoTrack.height + " (max:" + bestVideo.width + "x" + bestVideo.height + ")";
774+
}
775+
document.getElementById("live_latency").innerHTML = player.getCurrentLiveLatency() + "s";
733776
}
734-
document.getElementById("live_latency").innerHTML = player.getCurrentLiveLatency() + "s";
735777
} catch (e) {
736778
document.getElementById("audio_bitrate").innerHTML = "error";
737779
document.getElementById("video_bitrate").innerHTML = "error";

0 commit comments

Comments
 (0)