Move external player profile to class

This commit is contained in:
Bill Thornton
2021-05-17 15:13:27 -04:00
parent 8d33039692
commit c4c1ae5350
3 changed files with 86 additions and 73 deletions

View File

@@ -18,6 +18,7 @@ import org.jellyfin.androidtv.data.compat.VideoOptions;
import org.jellyfin.androidtv.data.service.BackgroundService;
import org.jellyfin.androidtv.preference.UserPreferences;
import org.jellyfin.androidtv.preference.constant.PreferredVideoPlayer;
import org.jellyfin.androidtv.util.profile.ExternalPlayerProfile;
import org.jellyfin.androidtv.util.profile.ProfileHelper;
import org.jellyfin.androidtv.util.Utils;
import org.jellyfin.androidtv.util.apiclient.ReportingHelper;
@@ -231,7 +232,7 @@ public class ExternalPlayerActivity extends FragmentActivity {
options.setItemId(item.getId());
options.setMediaSources(item.getMediaSources());
options.setMaxBitrate(Utils.getMaxBitrate());
options.setProfile(ProfileHelper.getExternalProfile());
options.setProfile(new ExternalPlayerProfile());
// Get playback info for each player and then decide on which one to use
get(PlaybackManager.class).getVideoStreamInfo(apiClient.getValue().getServerInfo().getId(), options, item.getResumePositionTicks(), false, apiClient.getValue(), new Response<StreamInfo>() {

View File

@@ -0,0 +1,83 @@
package org.jellyfin.androidtv.util.profile
import org.jellyfin.androidtv.constant.CodecTypes
import org.jellyfin.androidtv.constant.ContainerTypes
import org.jellyfin.androidtv.util.profile.ProfileHelper.getSubtitleProfile
import org.jellyfin.apiclient.model.dlna.DeviceProfile
import org.jellyfin.apiclient.model.dlna.DirectPlayProfile
import org.jellyfin.apiclient.model.dlna.DlnaProfileType
import org.jellyfin.apiclient.model.dlna.EncodingContext
import org.jellyfin.apiclient.model.dlna.SubtitleDeliveryMethod
import org.jellyfin.apiclient.model.dlna.TranscodingProfile
class ExternalPlayerProfile : DeviceProfile() {
init {
name = "AndroidTV-External"
maxStaticBitrate = 100000000
directPlayProfiles = arrayOf(
DirectPlayProfile().apply {
type = DlnaProfileType.Video
container = arrayOf(
ContainerTypes.M4V,
ContainerTypes._3GP,
ContainerTypes.TS,
ContainerTypes.MPEGTS,
ContainerTypes.MOV,
ContainerTypes.XVID,
ContainerTypes.VOB,
ContainerTypes.MKV,
ContainerTypes.WMV,
ContainerTypes.ASF,
ContainerTypes.OGM,
ContainerTypes.OGV,
ContainerTypes.M2V,
ContainerTypes.AVI,
ContainerTypes.MPG,
ContainerTypes.MPEG,
ContainerTypes.MP4,
ContainerTypes.WEBM,
ContainerTypes.DVR_MS,
ContainerTypes.WTV
).joinToString()
}
)
transcodingProfiles = arrayOf(
// MKV video profile
TranscodingProfile().apply {
type = DlnaProfileType.Video
context = EncodingContext.Streaming
container = ContainerTypes.MKV
videoCodec = CodecTypes.H264
audioCodec = arrayOf(
CodecTypes.AAC,
CodecTypes.MP3,
CodecTypes.AC3
).joinToString()
copyTimestamps = true
},
// MP3 audio profile
TranscodingProfile().apply {
type = DlnaProfileType.Audio
context = EncodingContext.Streaming
container = CodecTypes.MP3
audioCodec = CodecTypes.MP3
}
)
subtitleProfiles = arrayOf(
getSubtitleProfile("srt", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("subrip", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("ass", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("ssa", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("pgs", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("pbssub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("dvdsub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("vtt", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("sub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("idx", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("smi", SubtitleDeliveryMethod.Embed)
)
}
}

View File

@@ -84,77 +84,6 @@ public class ProfileHelper {
}
public static DeviceProfile getExternalProfile() {
DeviceProfile profile = new DeviceProfile();
profile.setName("Android-External");
profile.setMaxStaticBitrate(100000000);
DirectPlayProfile videoDirectPlayProfile = new DirectPlayProfile();
List<String> containers = Arrays.asList(
ContainerTypes.M4V,
ContainerTypes._3GP,
ContainerTypes.TS,
ContainerTypes.MPEGTS,
ContainerTypes.MOV,
ContainerTypes.XVID,
ContainerTypes.VOB,
ContainerTypes.MKV,
ContainerTypes.WMV,
ContainerTypes.ASF,
ContainerTypes.OGM,
ContainerTypes.OGV,
ContainerTypes.M2V,
ContainerTypes.AVI,
ContainerTypes.MPG,
ContainerTypes.MPEG,
ContainerTypes.MP4,
ContainerTypes.WEBM,
ContainerTypes.DVR_MS,
ContainerTypes.WTV
);
videoDirectPlayProfile.setContainer(Utils.join(",", containers));
videoDirectPlayProfile.setType(DlnaProfileType.Video);
profile.setDirectPlayProfiles(new DirectPlayProfile[] {videoDirectPlayProfile});
List<TranscodingProfile> transcodingProfiles = new ArrayList<>();
TranscodingProfile mkvProfile = new TranscodingProfile();
mkvProfile.setContainer(ContainerTypes.MKV);
mkvProfile.setVideoCodec(CodecTypes.H264);
mkvProfile.setAudioCodec(Utils.join(",", CodecTypes.AAC, CodecTypes.MP3, CodecTypes.AC3));
mkvProfile.setType(DlnaProfileType.Video);
mkvProfile.setContext(EncodingContext.Streaming);
mkvProfile.setCopyTimestamps(true);
transcodingProfiles.add(mkvProfile);
TranscodingProfile tempVar = new TranscodingProfile();
tempVar.setContainer(CodecTypes.MP3);
tempVar.setAudioCodec(CodecTypes.MP3);
tempVar.setType(DlnaProfileType.Audio);
tempVar.setContext(EncodingContext.Streaming);
transcodingProfiles.add(tempVar);
profile.setTranscodingProfiles(transcodingProfiles.toArray(new TranscodingProfile[transcodingProfiles.size()]));
profile.setSubtitleProfiles(new SubtitleProfile[] {
getSubtitleProfile("srt", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("subrip", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("ass", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("ssa", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("pgs", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("pgssub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("dvdsub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("vtt", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("sub", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("idx", SubtitleDeliveryMethod.Embed),
getSubtitleProfile("smi", SubtitleDeliveryMethod.Embed)
});
return profile;
}
public static void setVlcOptions(DeviceProfile profile, boolean isLiveTv) {
profile.setName("Android-VLC");
DirectPlayProfile videoDirectPlayProfile = new DirectPlayProfile();
@@ -440,7 +369,7 @@ public class ProfileHelper {
return null;
}
private static SubtitleProfile getSubtitleProfile(String format, SubtitleDeliveryMethod method) {
protected static SubtitleProfile getSubtitleProfile(String format, SubtitleDeliveryMethod method) {
SubtitleProfile subs = new SubtitleProfile();
subs.setFormat(format);
subs.setMethod(method);