Add separate fMP4 device profile

This commit is contained in:
Bill Thornton 2021-04-05 15:01:57 -04:00
parent 225e99b81f
commit 8137cf0073
5 changed files with 48 additions and 13 deletions

View File

@ -10,6 +10,7 @@ import { Platform } from 'react-native';
import iOSProfile from './profiles/ios';
import iOS10Profile from './profiles/ios10';
import iOS12Profile from './profiles/ios12';
import iOSFmp4Profile from './profiles/iosFmp4';
export function getAppName() {
return `Jellyfin Mobile (${Device.osName})`;
@ -30,12 +31,14 @@ export function getSafeDeviceName() {
return Device.modelName || 'Jellyfin Mobile Device';
}
export function getDeviceProfile() {
export function getDeviceProfile({ enableFmp4 = false } = {}) {
if (Platform.OS === 'ios') {
if (parseInt(Platform.Version, 10) < 11) {
return iOS10Profile;
} else if (parseInt(Platform.Version, 10) < 13) {
return iOS12Profile;
} else if (enableFmp4) {
return iOSFmp4Profile;
} else {
return iOSProfile;
}

View File

@ -7,9 +7,10 @@ import Constants from 'expo-constants';
import { Platform } from 'react-native';
import { getAppName, getDeviceProfile, getSafeDeviceName, isCompact, isSystemThemeSupported } from '../Device';
import iOSProfile from '../profiles/ios';
import iOS10Profile from '../profiles/ios10';
import iOS12Profile from '../profiles/ios12';
import iOSProfile from '../profiles/ios';
import iOSFmp4Profile from '../profiles/iosFmp4';
jest.mock('react-native/Libraries/Utilities/Platform');
@ -66,6 +67,11 @@ describe('Device', () => {
expect(getDeviceProfile()).toBe(iOSProfile);
});
it ('should return the correct profile for iOS 13 devices when fMP4 support is enabled', () => {
Platform.Version = '13';
expect(getDeviceProfile({ enableFmp4: true })).toBe(iOSFmp4Profile);
});
it('should return the an empty profile for Android devices', () => {
Platform.OS = 'android';
expect(getDeviceProfile()).toStrictEqual({});

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import MediaTypes from '../../constants/MediaTypes';
import BaseProfile from './base';
/**
@ -119,17 +120,6 @@ export default {
Protocol: 'http',
Type: MediaTypes.Audio
},
{
AudioCodec: 'aac,mp3,flac,alac',
BreakOnNonKeyFrames: true,
Container: 'mp4',
Context: 'Streaming',
MaxAudioChannels: '6',
MinSegments: '2',
Protocol: 'hls',
Type: MediaTypes.Video,
VideoCodec: 'hevc,h264'
},
{
AudioCodec: 'aac,mp3',
BreakOnNonKeyFrames: true,

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import MediaTypes from '../../constants/MediaTypes';
import BaseProfile from './base';
/**

35
utils/profiles/iosFmp4.js Normal file
View File

@ -0,0 +1,35 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import MediaTypes from '../../constants/MediaTypes';
import iOSProfile from './ios';
/**
* Device profile for Expo Video player on iOS 13+ with fMP4 support
*/
export default {
...iOSProfile,
Name: 'Expo iOS fMP4 Video Profile',
TranscodingProfiles: [
// Add all audio profiles from default profile
...iOSProfile.TranscodingProfiles.filter(profile => profile.Type === MediaTypes.Audio),
// Add fMP4 profile
{
AudioCodec: 'aac,mp3,flac,alac',
BreakOnNonKeyFrames: true,
Container: 'mp4',
Context: 'Streaming',
MaxAudioChannels: '6',
MinSegments: '2',
Protocol: 'hls',
Type: MediaTypes.Video,
VideoCodec: 'hevc,h264'
},
// Add all video profiles from default profile
...iOSProfile.TranscodingProfiles.filter(profile => profile.Type === MediaTypes.Video)
]
};