Skip to content

feat: TiVo Auto device #8785

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

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions build/types/devices
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
+../../lib/device/webkit_stb.js
+../../lib/device/webos.js
+../../lib/device/xbox.js
+../../lib/device/tivo_auto.js
1 change: 1 addition & 0 deletions lib/device/i_device.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ shaka.device.IDevice.DeviceType = {
'VR': 'VR',
'CONSOLE': 'CONSOLE',
'CAST': 'CAST',
'AUTOMOTIVE': 'AUTOMOTIVE',
};

/**
Expand Down
108 changes: 108 additions & 0 deletions lib/device/tivo_auto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*! @license
* Shaka Player
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

goog.provide('shaka.device.TiVoAuto');

goog.require('shaka.config.CrossBoundaryStrategy');
goog.require('shaka.device.AbstractDevice');
goog.require('shaka.device.DeviceFactory');
goog.require('shaka.device.IDevice');
goog.require('shaka.util.Lazy');


/**
* @final
*/
shaka.device.TiVoAuto = class extends shaka.device.AbstractDevice {
constructor() {
super();

/** @private {!shaka.util.Lazy<boolean>} */
this.isAndroid_ = new shaka.util.Lazy(() => {
return navigator.userAgent.includes('Andr0id');
});
}

/**
* @override
*/
getDeviceName() {
return 'TiVoAuto';
}

/**
* @override
*/
getVersion() {
return null;
}

/**
* @override
*/
getBrowserEngine() {
return shaka.device.IDevice.BrowserEngine.CHROMIUM;
}

/**
* @override
*/
getDeviceType() {
return shaka.device.IDevice.DeviceType.AUTOMOTIVE;
}

/**
* @override
*/
supportsMediaCapabilities() {
return false;
}

/**
* @override
*/
detectMaxHardwareResolution() {
const maxResolution = {
width: window.screen.width * window.devicePixelRatio,
height: window.screen.height * window.devicePixelRatio,
};
return Promise.resolve(maxResolution);
}

/**
* @override
*/
adjustConfig(config) {
super.adjustConfig(config);
if (this.isAndroid_.value()) {
config.streaming.crossBoundaryStrategy =
shaka.config.CrossBoundaryStrategy.RESET_TO_ENCRYPTED;
} else {
config.streaming.crossBoundaryStrategy =
shaka.config.CrossBoundaryStrategy.RESET;
}
return config;
}

/**
* Check if the current platform runs TiVoAuto.
*
* @return {boolean}
* @private
*/
static isTiVoAuto_() {
if (navigator.userAgent.includes('Linux') &&
navigator.userAgent.includes('BMW/')) {
return true;
}
return navigator.userAgent.includes('TiVoAuto');
}
};

if (shaka.device.TiVoAuto.isTiVoAuto_()) {
shaka.device.DeviceFactory.registerDeviceFactory(
() => new shaka.device.TiVoAuto());
}
2 changes: 2 additions & 0 deletions project-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ linksource
longname

# 3rd party
Andr0id
apac
APPSTB
Bitcodin
Expand Down Expand Up @@ -201,6 +202,7 @@ Kaltura
Livesim
muxjs
Nagra
Optimus
Playready
Quicktime
teppeis
Expand Down
1 change: 1 addition & 0 deletions shaka-player.uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.require('shaka.device.Chromecast');
goog.require('shaka.device.DefaultBrowser');
goog.require('shaka.device.Hisense');
goog.require('shaka.device.PlayStation');
goog.require('shaka.device.TiVoAuto');
goog.require('shaka.device.Tizen');
goog.require('shaka.device.Vizio');
goog.require('shaka.device.WebKitSTB');
Expand Down
38 changes: 38 additions & 0 deletions test/device/tivo_auto_unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*! @license
* Shaka Player
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

describe('TiVo Auto', () => {
/* eslint-disable @stylistic/max-len */
const bmwLinux = 'Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/573.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 BMW/162';
const bmwAndroid = 'Mozilla/5.0 (Linux; Andr0id 13; bmw_idc23 for arm64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.100 Safari/537.36 OMI/4.25.1.126.Optimus.244.4 Model/BMW-Andr0id21screen TiVoAuto';
/* eslint-enable @stylistic/max-len */

const Util = shaka.test.Util;
const CrossBoundaryStrategy = shaka.config.CrossBoundaryStrategy;
const originalUserAgent = navigator.userAgent;

afterEach(() => {
Util.setUserAgent(originalUserAgent);
});

it('should use RESET crossBoundaryStrategy on BMW Linux', () => {
Util.setUserAgent(bmwLinux);
const device = new shaka.device.TiVoAuto();
const config = shaka.util.PlayerConfiguration.createDefault();
device.adjustConfig(config);
expect(config.streaming.crossBoundaryStrategy)
.toBe(CrossBoundaryStrategy.RESET);
});

it('should use RESET_TO_ENCRYPTED crossBoundaryStrategy on BMW Android', () => {
Util.setUserAgent(bmwAndroid);
const device = new shaka.device.TiVoAuto();
const config = shaka.util.PlayerConfiguration.createDefault();
device.adjustConfig(config);
expect(config.streaming.crossBoundaryStrategy)
.toBe(CrossBoundaryStrategy.RESET_TO_ENCRYPTED);
});
});
Loading