Skip to content

Commit f4658e4

Browse files
Merge branch 'DVBProject:master' into master
2 parents 8d2923b + 37e4831 commit f4658e4

17 files changed

Lines changed: 665 additions & 1008 deletions

File tree

INSTALL-SERVER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Build a DVB-I Server
2-
2+
(This guide assumes some Linux experience, exact system directories, package names and system maintenance commands may vary between Linux distributions)
33
## System libraries and modules
4-
### Install PHP 7.4 (includes Apache 2)
4+
### Install latest PHP 8 (includes Apache 2)
55
``sudo apt install php``
66

77
### Configure PHP to allow execution in user directories

backend/servicelists/example.xml

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

frontend/android/js/channel.js

Lines changed: 86 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
Channel.prototype.getNowNext = function (callback) {
22
var self = this;
33
if (self.contentGuideURI) {
4-
$.get(
5-
self.contentGuideURI + "?sid=" + self.getServiceRef() + "&now_next=true",
6-
function (data) {
4+
NetworkRequest(self.contentGuideURI + "?sid=" + self.getServiceRef() + "&now_next=true", {
5+
success: function (data) {
76
var now_next = {};
87
var newPrograms = self.parseSchedule(data);
98
if (newPrograms.length > 0) {
@@ -25,8 +24,8 @@ Channel.prototype.getNowNext = function (callback) {
2524
callback.call();
2625
}
2726
},
28-
"text"
29-
);
27+
dataType: "text",
28+
});
3029
}
3130
};
3231

@@ -35,23 +34,25 @@ Channel.prototype.getSchedule = function (callback) {
3534
self.programs = [];
3635

3736
if (self.contentGuideURI) {
38-
$.get(
37+
NetworkRequest(
3938
self.contentGuideURI + "?sid=" + self.getServiceRef() + "&start=" + self.epg.start + "&end=" + self.epg.end,
40-
function (data) {
41-
var programData = self.parseSchedule(data);
42-
self.programs = [];
43-
for (var i = 0; i < programData.length; i++) {
44-
var program2 = new Program(programData[i], this.element_id + "_program_" + i, self);
45-
program2.bilingual = this.bilingual;
46-
program2.channelimage = this.image;
47-
program2.channel_streamurl = this.streamurl;
48-
self.programs.push(program2);
49-
}
50-
if (typeof callback == "function") {
51-
callback.call();
52-
}
53-
},
54-
"text"
39+
{
40+
success: function (data) {
41+
var programData = self.parseSchedule(data);
42+
self.programs = [];
43+
for (var i = 0; i < programData.length; i++) {
44+
var program2 = new Program(programData[i], this.element_id + "_program_" + i, self);
45+
program2.bilingual = this.bilingual;
46+
program2.channelimage = this.image;
47+
program2.channel_streamurl = this.streamurl;
48+
self.programs.push(program2);
49+
}
50+
if (typeof callback == "function") {
51+
callback.call();
52+
}
53+
},
54+
dataType: "text",
55+
}
5556
);
5657
}
5758
};
@@ -74,7 +75,7 @@ Channel.prototype.init = function (init_obj, channel_index) {
7475
var span1 = document.createElement("span");
7576
span1.classList.add("chicon", "pl-1", "order-3");
7677
var img = document.createElement("img");
77-
img.src = this.getImageSrc(self.image);
78+
img.src = getImageSrc(self.image);
7879
span1.appendChild(img);
7980
newTextbox.appendChild(span1);
8081
var span = document.createElement("span");
@@ -149,7 +150,7 @@ Channel.prototype.getMediaPresentationApp = function (serviceInstance) {
149150
if (serviceInstance && serviceInstance.mediaPresentationApps) {
150151
for (i = 0; i < serviceInstance.mediaPresentationApps.length; i++) {
151152
mediaPresentationApp = serviceInstance.mediaPresentationApps[i];
152-
if (mediaPresentationApp.contentType == XML_MIME || mediaPresentationApp.contentType == XHTML_MIMR) {
153+
if (mediaPresentationApp.contentType == XML_MIME || mediaPresentationApp.contentType == XHTML_MIME) {
153154
return mediaPresentationApp.url;
154155
}
155156
}
@@ -174,6 +175,50 @@ Channel.prototype.checkAvailability = function () {
174175
this.availablityTimer = setTimeout(this.checkAvailability.bind(this), 60 * 1000);
175176
};
176177

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+
177222
Channel.prototype.channelSelected = function () {
178223
var self = this;
179224
$("#notification").hide();
@@ -192,7 +237,9 @@ Channel.prototype.channelSelected = function () {
192237
$("#notification").removeClass();
193238
$("#notification").addClass("noservice");
194239
if (self.out_of_service_image) {
195-
$("#notification").html('<img src="' + self.out_of_service_image + '" class="img-fluid position-relative"/>');
240+
$("#notification").html(
241+
'<img src="' + getImageSrc(self.out_of_service_image) + '" class="img-fluid position-relative"/>'
242+
);
196243
} else {
197244
$("#notification").text("Service not available");
198245
}
@@ -205,21 +252,21 @@ Channel.prototype.channelSelected = function () {
205252
} else if (self.isProgramAllowed()) {
206253
$("#parentalpin").hide();
207254
if (self.serviceInstance) {
208-
player.attachSource(self.serviceInstance.dashUrl);
255+
playDASH(player, self.serviceInstance);
209256
}
210257
} else {
211-
player.attachSource(null);
258+
playDASH(player, null);
212259
checkParentalPIN(
213260
"Enter parental PIN to watch service",
214261
function () {
215262
$("#notification").hide();
216263
try {
217264
if (player.getSource() != self.serviceInstance.dashUrl) {
218-
player.attachSource(self.serviceInstance.dashUrl);
265+
playDASH(player, self.serviceInstance);
219266
}
220267
} catch (e) {
221268
//player throws an error is there is no souce attached
222-
player.attachSource(self.serviceInstance.dashUrl);
269+
playDASH(player, self.serviceInstance);
223270
}
224271
},
225272
function () {
@@ -247,11 +294,11 @@ Channel.prototype.programChanged = function () {
247294
$("#notification").hide();
248295
try {
249296
if (player.getSource() != serviceInstance.dashUrl) {
250-
player.attachSource(serviceInstance.dashUrl);
297+
playDASH(player, serviceInstance);
251298
}
252299
} catch (e) {
253300
//player throws an error is there is no souce attached
254-
player.attachSource(serviceInstance.dashUrl);
301+
playDASH(player, serviceInstance);
255302
}
256303
} else {
257304
player.attachSource(null);
@@ -261,11 +308,11 @@ Channel.prototype.programChanged = function () {
261308
$("#notification").hide();
262309
try {
263310
if (player.getSource() != serviceInstance.dashUrl) {
264-
player.attachSource(serviceInstance.dashUrl);
311+
playDASH(player, serviceInstance);
265312
}
266313
} catch (e) {
267314
//player throws an error is there is no souce attached
268-
player.attachSource(serviceInstance.dashUrl);
315+
playDASH(player, serviceInstance);
269316
}
270317
},
271318
function () {
@@ -321,9 +368,7 @@ Channel.prototype.updateChannelInfo = function () {
321368
cpsInstance;
322369
var channelInfo = $("#channel_info");
323370
channelInfo.empty();
324-
channelInfo.append(
325-
'<span class="menuitem_chicon d-inline-block"><img src="' + this.getImageSrc(self.image) + '"></span>'
326-
);
371+
channelInfo.append('<span class="menuitem_chicon d-inline-block"><img src="' + getImageSrc(self.image) + '"></span>');
327372
channelInfo.append(
328373
'<span class="menuitem_chnumber d-inline-block">' +
329374
self.lcn +
@@ -432,7 +477,7 @@ Channel.prototype.showEPG = function () {
432477
var header = document.createElement("div");
433478
header.addClass("epg_chinfo align-items-center sticky-top px-2");
434479
var logo = document.createElement("img");
435-
logo.setAttribute("src", self.image || "./images/empty.png");
480+
logo.setAttribute("src", getImageSrc(self?.image));
436481
logo.setAttribute("alt", "channel icon");
437482
logo.addClass("chicon img-fluid d-block");
438483
header.appendChild(logo);
@@ -479,11 +524,11 @@ Channel.prototype.parentalRatingChanged = function (callback) {
479524
$("#notification").hide();
480525
try {
481526
if (player.getSource() != serviceInstance.dashUrl) {
482-
player.attachSource(serviceInstance.dashUrl);
527+
playDASH(player, serviceInstance);
483528
}
484529
} catch (e) {
485-
//player throws an error is there is no souce attached
486-
player.attachSource(serviceInstance.dashUrl);
530+
//player throws an error if there is no souce attached
531+
playDASH(player, serviceInstance);
487532
}
488533
} else {
489534
player.attachSource(null);
@@ -493,11 +538,11 @@ Channel.prototype.parentalRatingChanged = function (callback) {
493538
$("#notification").hide();
494539
try {
495540
if (player.getSource() != serviceInstance.dashUrl) {
496-
player.attachSource(serviceInstance.dashUrl);
541+
playDASH(player, serviceInstance);
497542
}
498543
} catch (e) {
499544
//player throws an error is there is no souce attached
500-
player.attachSource(serviceInstance.dashUrl);
545+
playDASH(player, serviceInstance);
501546
}
502547
},
503548
function () {

0 commit comments

Comments
 (0)