Skip to content

Commit

Permalink
Remove unused compat streaminfo code
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Jul 16, 2024
1 parent 5891264 commit 1c80f6e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 163 deletions.
156 changes: 0 additions & 156 deletions app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import org.jellyfin.androidtv.util.Utils;
import org.jellyfin.apiclient.model.dlna.DeviceProfile;
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.SubtitleProfile;
import org.jellyfin.apiclient.model.dlna.TranscodeSeekInfo;
import org.jellyfin.apiclient.model.dto.NameValuePair;
import org.jellyfin.apiclient.model.session.PlayMethod;
import org.jellyfin.sdk.model.api.MediaProtocol;
import org.jellyfin.sdk.model.api.MediaSourceInfo;
Expand All @@ -18,14 +16,6 @@
import java.util.UUID;

public class StreamInfo {
private static final String START_TIME_TICKS = "StartTimeTicks";
private static final String SUBTITLE_STREAM_INDEX = "SubtitleStreamIndex";
private static final String STATIC = "Static";

public StreamInfo() {
setAudioCodecs(new String[]{});
}

private UUID ItemId;

public final UUID getItemId() {
Expand Down Expand Up @@ -66,16 +56,6 @@ public final void setContext(EncodingContext value) {
Context = value;
}

private DlnaProfileType MediaType = DlnaProfileType.values()[0];

public final DlnaProfileType getMediaType() {
return MediaType;
}

public final void setMediaType(DlnaProfileType value) {
MediaType = value;
}

private String Container;

public final String getContainer() {
Expand All @@ -96,16 +76,6 @@ public final void setStartPositionTicks(long value) {
StartPositionTicks = value;
}

private String[] AudioCodecs;

public final String[] getAudioCodecs() {
return AudioCodecs;
}

public final void setAudioCodecs(String[] value) {
AudioCodecs = value;
}

private DeviceProfile DeviceProfile;

public final DeviceProfile getDeviceProfile() {
Expand All @@ -116,16 +86,6 @@ public final void setDeviceProfile(DeviceProfile value) {
DeviceProfile = value;
}

private String DeviceId;

public final String getDeviceId() {
return DeviceId;
}

public final void setDeviceId(String value) {
DeviceId = value;
}

private Long RunTimeTicks = null;

public final Long getRunTimeTicks() {
Expand Down Expand Up @@ -172,122 +132,6 @@ public final String getMediaSourceId() {
return getMediaSource() == null ? null : getMediaSource().getId();
}

public final boolean getIsDirectStream() {
return getPlayMethod() == PlayMethod.DirectStream || getPlayMethod() == PlayMethod.DirectPlay;
}

public final String toUrl(String baseUrl, String accessToken) {
if (!Utils.isEmpty(getMediaUrl())) {
return getMediaUrl();
}

if (getPlayMethod() == PlayMethod.DirectPlay) {
return getMediaSource().getPath();
}

if (Utils.isEmpty(baseUrl)) {
throw new IllegalArgumentException(baseUrl);
}

ArrayList<String> list = new ArrayList<String>();
for (NameValuePair pair : buildParams(this, accessToken, false)) {
if (Utils.isEmpty(pair.getValue())) {
continue;
}

// Try to keep the url clean by omitting defaults
if (START_TIME_TICKS.equalsIgnoreCase(pair.getName()) && "0".equalsIgnoreCase(pair.getValue())) {
continue;
}
if (SUBTITLE_STREAM_INDEX.equalsIgnoreCase(pair.getName()) && "-1".equalsIgnoreCase(pair.getValue())) {
continue;
}
if (STATIC.equalsIgnoreCase(pair.getName()) && "false".equalsIgnoreCase(pair.getValue())) {
continue;
}

list.add(String.format("%1$s=%2$s", pair.getName(), pair.getValue()));
}

String queryString = Utils.join("&", list);

return getUrl(baseUrl, queryString);
}

private String getUrl(String baseUrl, String queryString) {
if (Utils.isEmpty(baseUrl)) {
throw new IllegalArgumentException(baseUrl);
}

String extension = Utils.isEmpty(getContainer()) ? "" : "." + getContainer();

// remove trailing slashes
baseUrl = baseUrl.replaceAll("[/]+$", "");

if (getMediaType() == DlnaProfileType.Audio) {
return String.format("%1$s/audio/%2$s/stream%3$s?%4$s", baseUrl, getItemId(), extension, queryString);
}

return String.format("%1$s/videos/%2$s/stream%3$s?%4$s", baseUrl, getItemId(), extension, queryString);
}

private static ArrayList<NameValuePair> buildParams(StreamInfo item, String accessToken, boolean isDlna) {
ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();

String audioCodecs = item.getAudioCodecs().length == 0 ? "" : Utils.join(",", item.getAudioCodecs());

list.add(new NameValuePair("DeviceProfileId", ""));
String tempVar2 = item.getDeviceId();
list.add(new NameValuePair("DeviceId", (tempVar2 != null) ? tempVar2 : ""));
String tempVar3 = item.getMediaSourceId();
list.add(new NameValuePair("MediaSourceId", (tempVar3 != null) ? tempVar3 : ""));
list.add(new NameValuePair(STATIC, Boolean.valueOf(item.getIsDirectStream()).toString().toLowerCase()));
list.add(new NameValuePair("VideoCodec", ""));
list.add(new NameValuePair("AudioCodec", audioCodecs));
list.add(new NameValuePair("AudioStreamIndex", ""));
list.add(new NameValuePair("SubtitleStreamIndex", ""));
list.add(new NameValuePair("VideoBitrate", ""));
list.add(new NameValuePair("AudioBitrate", ""));
list.add(new NameValuePair("MaxAudioChannels", ""));
list.add(new NameValuePair("MaxFramerate", ""));
list.add(new NameValuePair("MaxWidth", ""));
list.add(new NameValuePair("MaxHeight", ""));

list.add(new NameValuePair(START_TIME_TICKS, String.valueOf(item.getStartPositionTicks())));

list.add(new NameValuePair("Level", ""));

list.add(new NameValuePair("MaxRefFrames", ""));
list.add(new NameValuePair("MaxVideoBitDepth", ""));
list.add(new NameValuePair("Profile", ""));

// no longer used
list.add(new NameValuePair("Cabac", ""));

String tempVar6 = item.getPlaySessionId();
list.add(new NameValuePair("PlaySessionId", (tempVar6 != null) ? tempVar6 : ""));
list.add(new NameValuePair("api_key", (accessToken != null) ? accessToken : ""));

String liveStreamId = item.getMediaSource() == null ? null : item.getMediaSource().getLiveStreamId();
list.add(new NameValuePair("LiveStreamId", (liveStreamId != null) ? liveStreamId : ""));

if (isDlna) {
list.add(new NameValuePair("ItemId", item.getItemId().toString()));
}

list.add(new NameValuePair("CopyTimestamps", "false"));
list.add(new NameValuePair("ForceLiveStream", "false"));
list.add(new NameValuePair("SubtitleMethod", ""));

list.add(new NameValuePair("TranscodingMaxAudioChannels", ""));
list.add(new NameValuePair("EnableSubtitlesInManifest", "false"));

String tempVar7 = item.getMediaSource().getETag();
list.add(new NameValuePair("Tag", (tempVar7 != null) ? tempVar7 : ""));

return list;
}

public final ArrayList<SubtitleStreamInfo> getSubtitleProfiles(boolean includeSelectedTrackOnly, String baseUrl, String accessToken) {
return getSubtitleProfiles(includeSelectedTrackOnly, false, baseUrl, accessToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.jellyfin.apiclient.interaction.ApiClient;
import org.jellyfin.apiclient.interaction.QueryStringDictionary;
import org.jellyfin.apiclient.interaction.Response;
import org.jellyfin.apiclient.model.dlna.DlnaProfileType;
import org.jellyfin.apiclient.model.dlna.PlaybackErrorCode;
import org.jellyfin.apiclient.model.dto.MediaSourceInfo;
import org.jellyfin.apiclient.model.mediainfo.LiveStreamRequest;
Expand Down Expand Up @@ -90,17 +89,11 @@ private void onResponseInternal(PlaybackInfoResponse playbackInfo, MediaSourceIn

streamInfo = new StreamInfo();
streamInfo.setItemId(options.getItemId());
if (isVideo) {
streamInfo.setMediaType(DlnaProfileType.Video);
} else {
streamInfo.setMediaType(DlnaProfileType.Audio);
}
streamInfo.setMediaSource(ModelCompat.asSdk(mediaSourceInfo));
streamInfo.setRunTimeTicks(mediaSourceInfo.getRunTimeTicks());

streamInfo.setContext(options.getContext());
streamInfo.setItemId(options.getItemId());
streamInfo.setDeviceId(deviceInfo.getId());
streamInfo.setDeviceProfile(options.getProfile());
streamInfo.setPlaySessionId(playbackInfo.getPlaySessionId());
streamInfo.setStartPositionTicks(startPositionTicks);
Expand Down

0 comments on commit 1c80f6e

Please sign in to comment.