Skip to content

Commit

Permalink
Move external player profile to class
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed May 17, 2021
1 parent dc23a8b commit 7620450
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 73 deletions.
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -231,7 +232,7 @@ protected void launchExternalPlayer(int ndx) {
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>() {
Expand Down
@@ -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)
)
}
}
Expand Up @@ -84,77 +84,6 @@ public static DeviceProfile getBaseProfile(boolean isLiveTv) {

}

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();
Expand Down Expand Up @@ -440,7 +369,7 @@ private static TranscodingProfile getTranscodingProfile(DeviceProfile deviceProf
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);
Expand Down

0 comments on commit 7620450

Please sign in to comment.