forked from jellyfin/jellyfin-webos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-device-profile.html
More file actions
240 lines (210 loc) · 9.29 KB
/
test-device-profile.html
File metadata and controls
240 lines (210 loc) · 9.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DeviceProfile Test</title>
<style>
body {
font-family: monospace;
padding: 20px;
background: #1a1a1a;
color: #00ff00;
}
.test-section {
margin: 20px 0;
padding: 10px;
border: 1px solid #333;
background: #0a0a0a;
}
.pass { color: #00ff00; }
.fail { color: #ff0000; }
.info { color: #ffff00; }
pre {
background: #000;
padding: 10px;
overflow-x: auto;
}
</style>
</head>
<body>
<h1>DeviceProfile Test Suite</h1>
<div id="results"></div>
<script src="frontend/webOSTVjs-1.2.11/webOSTV.js"></script>
<script src="frontend-build/js/device-profile.js"></script>
<script>
const results = document.getElementById('results');
function log(message, type = 'info') {
const div = document.createElement('div');
div.className = type;
div.textContent = message;
results.appendChild(div);
}
function section(title) {
const div = document.createElement('div');
div.className = 'test-section';
div.innerHTML = '<h2>' + title + '</h2>';
results.appendChild(div);
return div;
}
function pre(data) {
const p = document.createElement('pre');
p.textContent = JSON.stringify(data, null, 2);
results.lastElementChild.appendChild(p);
}
// Test 1: Module exists
section('Test 1: DeviceProfile Module');
if (typeof DeviceProfile !== 'undefined') {
log('✓ DeviceProfile module loaded', 'pass');
} else {
log('✗ DeviceProfile module NOT loaded', 'fail');
}
// Test 2: Public API methods exist
section('Test 2: Public API Methods');
const methods = [
'init', 'getProfile', 'getProfileAsync', 'getCapabilities',
'getDeviceInfo', 'loadDeviceInfo', 'shouldUseNativeHls',
'shouldUseHlsJs', 'getPlayMethod', 'getWebOSVersion',
'supportsHdr10', 'supportsDolbyVision', 'supportsDolbyAtmos'
];
methods.forEach(method => {
if (typeof DeviceProfile[method] === 'function') {
log('✓ DeviceProfile.' + method + '() exists', 'pass');
} else {
log('✗ DeviceProfile.' + method + '() missing', 'fail');
}
});
// Test 3: webOS version detection
section('Test 3: webOS Version Detection');
try {
const version = DeviceProfile.getWebOSVersion();
log('✓ webOS version detected: ' + version, 'pass');
log('User Agent: ' + navigator.userAgent, 'info');
} catch (e) {
log('✗ Error detecting webOS version: ' + e.message, 'fail');
}
// Test 4: Capabilities detection
section('Test 4: Capabilities Detection');
try {
const caps = DeviceProfile.getCapabilities();
log('✓ Capabilities detected', 'pass');
pre(caps);
} catch (e) {
log('✗ Error detecting capabilities: ' + e.message, 'fail');
}
// Test 5: Device profile generation
section('Test 5: Device Profile Generation');
try {
const profile = DeviceProfile.getProfile();
log('✓ Profile generated successfully', 'pass');
log('DirectPlay profiles: ' + profile.DirectPlayProfiles.length, 'info');
log('Transcoding profiles: ' + profile.TranscodingProfiles.length, 'info');
log('Codec profiles: ' + profile.CodecProfiles.length, 'info');
pre(profile);
} catch (e) {
log('✗ Error generating profile: ' + e.message, 'fail');
}
// Test 6: HDR/DV support functions
section('Test 6: HDR/DV Support Detection');
try {
const hdr10 = DeviceProfile.supportsHdr10();
const dv = DeviceProfile.supportsDolbyVision();
const atmos = DeviceProfile.supportsDolbyAtmos();
log('HDR10 support: ' + hdr10, hdr10 ? 'pass' : 'info');
log('Dolby Vision support: ' + dv, dv ? 'pass' : 'info');
log('Dolby Atmos support: ' + atmos, atmos ? 'pass' : 'info');
} catch (e) {
log('✗ Error checking HDR/DV support: ' + e.message, 'fail');
}
// Test 7: Play method determination
section('Test 7: Play Method Determination');
try {
const testSource1 = {
Container: 'mp4',
SupportsDirectPlay: true,
MediaStreams: [
{ Type: 'Video', Codec: 'h264', VideoRangeType: 'SDR' },
{ Type: 'Audio', Codec: 'aac' }
]
};
const testSource2 = {
Container: 'mkv',
SupportsDirectPlay: true,
MediaStreams: [
{ Type: 'Video', Codec: 'hevc', VideoRangeType: 'HDR10', BitDepth: 10 },
{ Type: 'Audio', Codec: 'truehd' }
]
};
const method1 = DeviceProfile.getPlayMethod(testSource1);
const method2 = DeviceProfile.getPlayMethod(testSource2);
log('✓ H.264 SDR -> ' + method1, 'pass');
log('✓ HEVC HDR10 -> ' + method2, 'pass');
} catch (e) {
log('✗ Error determining play method: ' + e.message, 'fail');
}
// Test 8: webOS.deviceInfo API (if available)
section('Test 8: webOS.deviceInfo API');
if (typeof webOS !== 'undefined' && typeof webOS.deviceInfo === 'function') {
log('✓ webOS.deviceInfo API available', 'pass');
log('Loading device info...', 'info');
DeviceProfile.loadDeviceInfo(function(deviceInfo) {
log('✓ Device info loaded', 'pass');
pre(deviceInfo);
// Re-check HDR/DV support with device info
section('Test 9: HDR/DV Support After Device Info Load');
const hdr10 = DeviceProfile.supportsHdr10();
const dv = DeviceProfile.supportsDolbyVision();
const atmos = DeviceProfile.supportsDolbyAtmos();
log('HDR10 support (with device info): ' + hdr10, hdr10 ? 'pass' : 'info');
log('Dolby Vision support (with device info): ' + dv, dv ? 'pass' : 'info');
log('Dolby Atmos support (with device info): ' + atmos, atmos ? 'pass' : 'info');
});
} else {
log('⚠ webOS.deviceInfo API not available (normal on non-webOS)', 'info');
log('This is expected when testing in a browser', 'info');
}
// Test 9: Profile consistency
section('Test 10: Profile Consistency Check');
try {
const profile = DeviceProfile.getProfile();
const caps = DeviceProfile.getCapabilities();
// Check if HEVC is in profile when capability says it's supported
const hevcInProfile = profile.DirectPlayProfiles.some(p =>
p.VideoCodec && p.VideoCodec.includes('hevc')
);
if (caps.hevc && !hevcInProfile) {
log('⚠ HEVC capability exists but not in profile', 'fail');
} else if (caps.hevc && hevcInProfile) {
log('✓ HEVC capability matches profile', 'pass');
} else {
log('✓ HEVC not supported (profile consistent)', 'info');
}
// Check HDR video range types
const hevcCodecProfile = profile.CodecProfiles.find(p =>
p.Codec === 'hevc'
);
if (hevcCodecProfile) {
const rangeCondition = hevcCodecProfile.Conditions.find(c =>
c.Property === 'VideoRangeType'
);
if (rangeCondition) {
log('✓ HEVC VideoRangeType condition: ' + rangeCondition.Value, 'pass');
if (caps.hdr10 && rangeCondition.Value.includes('HDR10')) {
log('✓ HDR10 included in video range types', 'pass');
} else if (caps.hdr10) {
log('⚠ HDR10 capability exists but not in range types', 'fail');
}
if (caps.dolbyVision && rangeCondition.Value.includes('DOVI')) {
log('✓ Dolby Vision included in video range types', 'pass');
} else if (caps.dolbyVision) {
log('⚠ Dolby Vision capability exists but not in range types', 'fail');
}
}
}
} catch (e) {
log('✗ Error checking profile consistency: ' + e.message, 'fail');
}
section('Test Suite Complete');
log('All tests finished. Check results above.', 'info');
</script>
</body>
</html>