Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 22 additions & 5 deletions webos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ npm ci --ignore-scripts
npm run package
```

This copies only the shipped files to `dist/app`, runs `ares-package --check`, and writes
`dist/ipk/com.soplay.sozo.webos_1.0.0_all.ipk` (about 241 KB). It then opens the ipk and fails unless it
holds exactly the shipped files, byte for byte.
This copies only the shipped files to `dist/app` and the relay service (`service/`) to `dist/service`,
runs `ares-package --check`, and writes `dist/ipk/com.soplay.sozo.webos_1.0.0_all.ipk` (about 246 KB). It
then opens the ipk and fails unless it holds exactly the shipped app and service files, byte for byte.
`ares-package` prints a generic Node.js version notice for any package with a service; that one notice is
allowed, because `service/` is held to ES5 by the tests.

`--no-minify` is deliberate. By default `ares-package` runs terser over every `.js`, including
`hls.min.js`, so the ES5 checks would no longer describe what ships.
Expand Down Expand Up @@ -103,7 +105,22 @@ A TV takes a different path for HLS: it tries the platform's native player first
uses hls.js only as a fallback where the source allows it. vidapi's segments are named `.html` and sent as
`text/html`. On an LG webOS 10.3 TV the native player rejects them at once (`MEDIA_ELEMENT_ERROR: Format
error`), while hls.js plays the same stream at 1080p; its segment host now sends `Access-Control-Allow-Origin: *`.
So vidapi falls back to hls.js. sportstv is still untried on a TV.
So on webOS vidapi goes through the relay below, with hls.js as the fallback. sportstv plays natively on the
same TV at 1080p without the relay or hls.js (Setanta Sports 1 Eurasia via `stream.mcquack.net` and Futbol via
`185.121.1.163:8083`, both plain HTTP).

### Native HLS relay (webOS only)

The ipk carries a small JS service, `com.soplay.sozo.webos.service` (`service/`). At startup the app
subscribes to it through `PalmServiceBridge`; the service listens on `127.0.0.1` on a free port and answers
with that port and a random per-run token. For a provider marked `relabel: true` (vidapi), the native
player is given `http://127.0.0.1:<port>/<token>/p?u=<stream URL>`. The service fetches the same bytes,
names them by content (`#EXTM3U` as a playlist, `0x47` as MPEG-TS, and so on) instead of trusting
`text/html`, and rewrites every playlist URI to come back through itself. Nothing is decoded or changed.

On an LG webOS 10.3 TV a vidapi film started in 1.7 s at 1920x800 this way, and hls.js was never loaded;
plain hls.js starts on the lowest level. If the service is missing or down, the URL is left as it is,
the native player fails, and the ladder falls back to hls.js. Off webOS nothing calls the service.

### Why the other 33 are left out

Expand Down Expand Up @@ -161,6 +178,6 @@ on Chromium 53. Nothing here has run on Chromium 53.

- Install on the oldest TV available and check Home, Search, Detail and the exit dialog.
- Play one mp4 source and one HLS source, then seek, change source and resume.
- Try vidapi and sportstv with native HLS.
- Try vidapi and sportstv with native HLS on webOS older than 10.3.
- Use the Magic Remote pointer, the arrows, OK and Back, including held keys.
- Check that the screensaver stays off during playback and how `ended` behaves.
1 change: 1 addition & 0 deletions webos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<script src="js/lib/model.js"></script>
<script src="js/lib/store.js"></script>
<script src="js/lib/api.js"></script>
<script src="js/lib/relabel.js"></script>
<script src="js/lib/playback.js"></script>
<script src="js/lib/subtitles.js"></script>
<script src="js/lib/i18n.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions webos/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@
root.addEventListener('resize', fit, false);
applyLanguage();
app.api = Sozo.Api.create({ onStatus: function (ok) { setOffline(!ok); } });
app.relabel = Sozo.Relabel.create({ isWebOS: Sozo.Platform.isWebOS(root.navigator && root.navigator.userAgent) });
app.relabel.start();
app.topbar = Sozo.Topbar.create(app);
Nav.init(doc.getElementById('app'));
Nav.onBack(function () { app.back(); });
Expand Down
2 changes: 1 addition & 1 deletion webos/js/lib/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{ id: 'idub', kind: 'vod', search: true, viewAll: true, related: true,
hosts: /^v\.mover\.uz$/, ignoreHeaders: [], hlsjs: false },
{ id: 'vidapi', kind: 'vod', search: false, viewAll: false, related: false,
hosts: null, ignoreHeaders: ['referer', 'origin', 'user-agent'], hlsjs: true },
hosts: null, ignoreHeaders: ['referer', 'origin', 'user-agent'], hlsjs: true, relabel: true },
{ id: 'anilibria', kind: 'vod', search: true, viewAll: true, related: true,
hosts: /^cache\.libria\.fun$/, ignoreHeaders: ['user-agent'], hlsjs: true },
{ id: 'animevost', kind: 'vod', search: true, viewAll: true, related: true,
Expand Down
47 changes: 47 additions & 0 deletions webos/js/lib/relabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(function (root) {
'use strict';
var Sozo = root.Sozo || (root.Sozo = {});

var SERVICE = 'luna://com.soplay.sozo.webos.service/relay';

// webOS only: the bundled service relays HLS over loopback with corrected content types,
// so the native player can play sources whose hosts label segments as text/html.
function create(options) {
var o = options || {};
var Bridge = o.Bridge || root.PalmServiceBridge;
var base = null;
var bridge = null;
var started = false;

function start() {
if (started || !o.isWebOS || typeof Bridge !== 'function') return;
started = true;
try {
bridge = new Bridge();
bridge.onservicecallback = function (text) {
var m = null;
try { m = JSON.parse(text); } catch (e) { m = null; }
if (m && m.returnValue && m.port && /^[0-9a-f]+$/.test(m.token || '')) {
base = 'http://127.0.0.1:' + m.port + '/' + m.token + '/p?u=';
} else {
base = null;
}
};
bridge.call(SERVICE, JSON.stringify({ subscribe: true }));
} catch (e) {
bridge = null;
base = null;
}
}

return {
start: start,
ready: function () { return base !== null; },
wrap: function (u) { return base === null ? u : base + encodeURIComponent(u); }
};
}

var api = { create: create, SERVICE: SERVICE };
Sozo.Relabel = api;
if (typeof module !== 'undefined' && module.exports) module.exports = api;
}(typeof window !== 'undefined' ? window : global));
8 changes: 7 additions & 1 deletion webos/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
// A failing <source> reports here, not on the video element.
child.onerror = function () { if (id === token) fail({}); };
child.type = 'application/x-mpegURL';
child.src = source.url;
child.src = relabelled(source.url);
video.appendChild(child);
video.load();
doPlay();
Expand All @@ -805,6 +805,12 @@
}
}

// Native HLS through the loopback relay where the provider's hosts mislabel segments.
function relabelled(u) {
var r = app && app.relabel;
return provider.relabel === true && r && r.ready() ? r.wrap(u) : u;
}

function fail(info) {
if (!open || !ladder || failedToken === token) return;
failedToken = token;
Expand Down
5 changes: 5 additions & 0 deletions webos/service/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "com.soplay.sozo.webos.service",
"version": "1.0.0",
"main": "service.js"
}
Loading
Loading