Skip to content

Commit

Permalink
Rewrite PlaybackManager with SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Feb 13, 2025
1 parent 40e0b98 commit e33d85c
Show file tree
Hide file tree
Showing 17 changed files with 523 additions and 1,154 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jellyfin.androidtv.data.compat

import org.jellyfin.apiclient.model.dlna.DeviceProfile
import org.jellyfin.apiclient.model.dlna.EncodingContext
import org.jellyfin.sdk.model.api.DeviceProfile
import org.jellyfin.sdk.model.api.MediaSourceInfo
import java.util.UUID

Expand All @@ -22,11 +21,4 @@ open class AudioOptions {
* Example: DeviceProfile supports five channel, but user only has stereo speakers
*/
var maxAudioChannels: Int? = null

/**
* The application's configured quality setting
*/
var maxBitrate: Int? = null

var context = EncodingContext.Streaming
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.jellyfin.androidtv.data.compat

import org.jellyfin.apiclient.model.dlna.PlaybackErrorCode
import org.jellyfin.sdk.model.api.PlaybackErrorCode

class PlaybackException : RuntimeException() {
var errorCode = PlaybackErrorCode.NotAllowed
var errorCode = PlaybackErrorCode.NOT_ALLOWED
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package org.jellyfin.androidtv.data.compat;

import org.jellyfin.apiclient.model.dlna.DeviceProfile;
import org.jellyfin.apiclient.model.dlna.EncodingContext;
import org.jellyfin.apiclient.model.dlna.SubtitleProfile;
import org.jellyfin.apiclient.model.dlna.TranscodeSeekInfo;
import org.jellyfin.apiclient.model.session.PlayMethod;
import org.jellyfin.sdk.api.client.ApiClient;
import org.jellyfin.sdk.model.api.MediaSourceInfo;
import org.jellyfin.sdk.model.api.MediaStream;
import org.jellyfin.sdk.model.api.MediaStreamType;
import org.jellyfin.sdk.model.api.PlayMethod;
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;

public class StreamInfo {
Expand All @@ -36,7 +30,7 @@ public final void setMediaUrl(String value) {
MediaUrl = value;
}

private PlayMethod playMethod = PlayMethod.DirectPlay;
private PlayMethod playMethod = PlayMethod.DIRECT_PLAY;

public final PlayMethod getPlayMethod() {
return playMethod;
Expand All @@ -46,16 +40,6 @@ public final void setPlayMethod(PlayMethod value) {
playMethod = value;
}

private EncodingContext Context = EncodingContext.values()[0];

public final EncodingContext getContext() {
return Context;
}

public final void setContext(EncodingContext value) {
Context = value;
}

private String Container;

public final String getContainer() {
Expand All @@ -66,16 +50,6 @@ public final void setContainer(String value) {
Container = value;
}

private DeviceProfile DeviceProfile;

public final DeviceProfile getDeviceProfile() {
return DeviceProfile;
}

public final void setDeviceProfile(DeviceProfile value) {
DeviceProfile = value;
}

private Long RunTimeTicks = null;

public final Long getRunTimeTicks() {
Expand All @@ -86,12 +60,6 @@ public final void setRunTimeTicks(Long value) {
RunTimeTicks = value;
}

private TranscodeSeekInfo TranscodeSeekInfo = getTranscodeSeekInfo().values()[0];

public final TranscodeSeekInfo getTranscodeSeekInfo() {
return TranscodeSeekInfo;
}

private MediaSourceInfo MediaSource;

public final MediaSourceInfo getMediaSource() {
Expand Down Expand Up @@ -122,36 +90,6 @@ public final String getMediaSourceId() {
return getMediaSource() == null ? null : getMediaSource().getId();
}

public final ArrayList<SubtitleStreamInfo> getSubtitleProfiles(ApiClient api) {
ArrayList<SubtitleStreamInfo> list = new ArrayList<SubtitleStreamInfo>();

if (getMediaSource() == null) return list;

for (org.jellyfin.sdk.model.api.MediaStream stream : getMediaSource().getMediaStreams()) {
if (stream.getType() == org.jellyfin.sdk.model.api.MediaStreamType.SUBTITLE) {
SubtitleStreamInfo info = getSubtitleStreamInfo(api, stream, getDeviceProfile().getSubtitleProfiles());
list.add(info);
}
}

return list;
}

private SubtitleStreamInfo getSubtitleStreamInfo(ApiClient api, org.jellyfin.sdk.model.api.MediaStream stream, SubtitleProfile[] subtitleProfiles) {
SubtitleProfile subtitleProfile = StreamBuilder.getSubtitleProfile(stream, subtitleProfiles, getPlayMethod());
SubtitleStreamInfo info = new SubtitleStreamInfo();
String tempVar2 = stream.getLanguage();
info.setName((tempVar2 != null) ? tempVar2 : "Unknown");
info.setFormat(subtitleProfile.getFormat());
info.setIndex(stream.getIndex());
info.setDeliveryMethod(subtitleProfile.getMethod());
info.setDisplayTitle(stream.getDisplayTitle());
if (stream.getDeliveryUrl() != null) {
info.setUrl(api.createUrl(stream.getDeliveryUrl(), new HashMap<>(), new HashMap<>(), true));
}
return info;
}

public final ArrayList<MediaStream> getSelectableAudioStreams() {
return getSelectableStreams(MediaStreamType.AUDIO);
}
Expand Down

This file was deleted.

Loading

0 comments on commit e33d85c

Please sign in to comment.