sync model

This commit is contained in:
Luke Pulverenti 2015-03-31 15:53:09 -04:00
parent df5792afc0
commit 24f10cc0cf
8 changed files with 237 additions and 23 deletions

View File

@ -201,6 +201,15 @@ public class UserConfiguration
{
HasMigratedToPolicy = value;
}
private boolean HidePlayedInLatest;
public final boolean getHidePlayedInLatest()
{
return HidePlayedInLatest;
}
public final void setHidePlayedInLatest(boolean value)
{
HidePlayedInLatest = value;
}
/**
Initializes a new instance of the <see cref="UserConfiguration" /> class.

View File

@ -277,6 +277,49 @@ public class StreamBuilder
return playMethods;
}
private Integer GetDefaultSubtitleStreamIndex(MediaSourceInfo item, SubtitleProfile[] subtitleProfiles)
{
int highestScore = -1;
for (MediaStream stream : item.getMediaStreams())
{
if (stream.getType() == MediaStreamType.Subtitle && stream.getScore() != null)
{
if (stream.getScore() > highestScore)
{
highestScore = stream.getScore();
}
}
}
java.util.ArrayList<MediaStream> topStreams = new java.util.ArrayList<MediaStream>();
for (MediaStream stream : item.getMediaStreams())
{
if (stream.getType() == MediaStreamType.Subtitle && stream.getScore() != null && stream.getScore() == highestScore)
{
topStreams.add(stream);
}
}
// If multiple streams have an equal score, try to pick the most efficient one
if (topStreams.size() > 1)
{
for (MediaStream stream : topStreams)
{
for (SubtitleProfile profile : subtitleProfiles)
{
if (profile.getMethod() == SubtitleDeliveryMethod.External && StringHelper.EqualsIgnoreCase(profile.getFormat(), stream.getCodec()))
{
return stream.getIndex();
}
}
}
}
// If no optimization panned out, just use the original default
return item.getDefaultSubtitleStreamIndex();
}
private StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options)
{
StreamInfo tempVar = new StreamInfo();
@ -289,12 +332,16 @@ public class StreamBuilder
StreamInfo playlistItem = tempVar;
Integer tempVar2 = options.getSubtitleStreamIndex();
playlistItem.setSubtitleStreamIndex((tempVar2 != null) ? tempVar2 : item.getDefaultSubtitleStreamIndex());
playlistItem.setSubtitleStreamIndex((tempVar2 != null) ? tempVar2 : GetDefaultSubtitleStreamIndex(item, options.getProfile().getSubtitleProfiles()));
MediaStream subtitleStream = playlistItem.getSubtitleStreamIndex() != null ? item.GetMediaStream(MediaStreamType.Subtitle, playlistItem.getSubtitleStreamIndex()) : null;
Integer tempVar3 = options.getAudioStreamIndex();
MediaStream audioStream = item.GetDefaultAudioStream((tempVar3 != null) ? tempVar3 : item.getDefaultAudioStreamIndex());
Integer audioStreamIndex = audioStream == null ? (Integer)null : audioStream.getIndex();
Integer audioStreamIndex = null;
if (audioStream != null)
{
audioStreamIndex = audioStream.getIndex();
}
MediaStream videoStream = item.getVideoStream();
@ -608,6 +655,8 @@ public class StreamBuilder
// Look for an external profile that matches the stream type (text/graphical)
for (SubtitleProfile profile : subtitleProfiles)
{
boolean requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.getCodec(), profile.getFormat());
if (!profile.SupportsLanguage(subtitleStream.getLanguage()))
{
continue;
@ -615,6 +664,11 @@ public class StreamBuilder
if (profile.getMethod() == SubtitleDeliveryMethod.External && subtitleStream.getIsTextSubtitleStream() == MediaStream.IsTextFormat(profile.getFormat()))
{
if (!requiresConversion)
{
return profile;
}
if (subtitleStream.getSupportsExternalStream())
{
return profile;
@ -630,6 +684,8 @@ public class StreamBuilder
for (SubtitleProfile profile : subtitleProfiles)
{
boolean requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.getCodec(), profile.getFormat());
if (!profile.SupportsLanguage(subtitleStream.getLanguage()))
{
continue;
@ -637,6 +693,11 @@ public class StreamBuilder
if (profile.getMethod() == SubtitleDeliveryMethod.Embed && subtitleStream.getIsTextSubtitleStream() == MediaStream.IsTextFormat(profile.getFormat()))
{
if (!requiresConversion)
{
return profile;
}
return profile;
}
}

View File

@ -466,9 +466,9 @@ public class StreamInfo
return list;
}
public final java.util.ArrayList<SubtitleStreamInfo> GetExternalSubtitles(boolean includeSelectedTrackOnly, String baseUrl, String accessToken)
public final java.util.ArrayList<SubtitleStreamInfo> GetExternalSubtitles(boolean includeSelectedTrackOnly, boolean enableAllProfiles, String baseUrl, String accessToken)
{
java.util.ArrayList<SubtitleStreamInfo> list = GetSubtitleProfiles(includeSelectedTrackOnly, baseUrl, accessToken);
java.util.ArrayList<SubtitleStreamInfo> list = GetSubtitleProfiles(includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken);
java.util.ArrayList<SubtitleStreamInfo> newList = new java.util.ArrayList<SubtitleStreamInfo>();
// First add the selected track
@ -484,6 +484,11 @@ public class StreamInfo
}
public final java.util.ArrayList<SubtitleStreamInfo> GetSubtitleProfiles(boolean includeSelectedTrackOnly, String baseUrl, String accessToken)
{
return GetSubtitleProfiles(includeSelectedTrackOnly, false, baseUrl, accessToken);
}
public final java.util.ArrayList<SubtitleStreamInfo> GetSubtitleProfiles(boolean includeSelectedTrackOnly, boolean enableAllProfiles, String baseUrl, String accessToken)
{
java.util.ArrayList<SubtitleStreamInfo> list = new java.util.ArrayList<SubtitleStreamInfo>();
@ -497,9 +502,7 @@ public class StreamInfo
{
if (stream.getType() == MediaStreamType.Subtitle && stream.getIndex() == getSubtitleStreamIndex())
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
list.add(info);
AddSubtitleProfiles(list, stream, enableAllProfiles, baseUrl, accessToken, startPositionTicks);
}
}
}
@ -510,9 +513,7 @@ public class StreamInfo
{
if (stream.getType() == MediaStreamType.Subtitle && (getSubtitleStreamIndex() == null || stream.getIndex() != getSubtitleStreamIndex()))
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
list.add(info);
AddSubtitleProfiles(list, stream, enableAllProfiles, baseUrl, accessToken, startPositionTicks);
}
}
}
@ -520,31 +521,51 @@ public class StreamInfo
return list;
}
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, String baseUrl, String accessToken, long startPositionTicks)
private void AddSubtitleProfiles(java.util.ArrayList<SubtitleStreamInfo> list, MediaStream stream, boolean enableAllProfiles, String baseUrl, String accessToken, long startPositionTicks)
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
if (info.getDeliveryMethod() == SubtitleDeliveryMethod.External && !tangible.DotNetToJavaStringHelper.isNullOrEmpty(baseUrl))
if (enableAllProfiles)
{
info.setUrl(String.format("%1$s/Videos/%2$s/%3$s/Subtitles/%4$s/%5$s/Stream.%6$s", baseUrl, getItemId(), getMediaSourceId(), StringHelper.ToStringCultureInvariant(stream.getIndex()), StringHelper.ToStringCultureInvariant(startPositionTicks), getSubtitleFormat()));
}
for (SubtitleProfile profile : getDeviceProfile().getSubtitleProfiles())
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, new SubtitleProfile[] {profile});
return info;
list.add(info);
}
}
else
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, getDeviceProfile().getSubtitleProfiles());
list.add(info);
}
}
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream)
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, String baseUrl, String accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles)
{
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, getDeviceProfile().getSubtitleProfiles(), getContext());
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, getContext());
SubtitleStreamInfo tempVar = new SubtitleStreamInfo();
tempVar.setIsForced(stream.getIsForced());
tempVar.setLanguage(stream.getLanguage());
String tempVar2 = stream.getLanguage();
tempVar.setName((tempVar2 != null) ? tempVar2 : "Unknown");
tempVar.setFormat(getSubtitleFormat());
tempVar.setFormat(subtitleProfile.getFormat());
tempVar.setIndex(stream.getIndex());
tempVar.setDeliveryMethod(subtitleProfile.getMethod());
return tempVar;
SubtitleStreamInfo info = tempVar;
if (info.getDeliveryMethod() == SubtitleDeliveryMethod.External)
{
if (getMediaSource().getProtocol() == MediaProtocol.File || !StringHelper.EqualsIgnoreCase(stream.getCodec(), subtitleProfile.getFormat()))
{
info.setUrl(String.format("%1$s/Videos/%2$s/%3$s/Subtitles/%4$s/%5$s/Stream.%6$s", baseUrl, getItemId(), getMediaSourceId(), StringHelper.ToStringCultureInvariant(stream.getIndex()), StringHelper.ToStringCultureInvariant(startPositionTicks), subtitleProfile.getFormat()));
}
else
{
info.setUrl(stream.getPath());
}
}
return info;
}
/**

View File

@ -396,7 +396,12 @@ public class MediaSourceInfo
}
}
return numStreams == 0 ? (Integer)null : numMatches;
if (numStreams == 0)
{
return null;
}
return numMatches;
}
public final Boolean IsSecondaryAudio(MediaStream stream)

View File

@ -310,6 +310,21 @@ public class MediaStream
Index = value;
}
/**
Gets or sets the score.
<value>The score.</value>
*/
private Integer Score = null;
public final Integer getScore()
{
return Score;
}
public final void setScore(Integer value)
{
Score = value;
}
/**
Gets or sets a value indicating whether this instance is external.

View File

@ -4,6 +4,86 @@ import mediabrowser.model.dlna.*;
public class PlaybackInfoRequest
{
private String Id;
public final String getId()
{
return Id;
}
public final void setId(String value)
{
Id = value;
}
private String UserId;
public final String getUserId()
{
return UserId;
}
public final void setUserId(String value)
{
UserId = value;
}
private Integer MaxStreamingBitrate;
public final Integer getMaxStreamingBitrate()
{
return MaxStreamingBitrate;
}
public final void setMaxStreamingBitrate(Integer value)
{
MaxStreamingBitrate = value;
}
private Long StartTimeTicks;
public final Long getStartTimeTicks()
{
return StartTimeTicks;
}
public final void setStartTimeTicks(Long value)
{
StartTimeTicks = value;
}
private Integer AudioStreamIndex;
public final Integer getAudioStreamIndex()
{
return AudioStreamIndex;
}
public final void setAudioStreamIndex(Integer value)
{
AudioStreamIndex = value;
}
private Integer SubtitleStreamIndex;
public final Integer getSubtitleStreamIndex()
{
return SubtitleStreamIndex;
}
public final void setSubtitleStreamIndex(Integer value)
{
SubtitleStreamIndex = value;
}
private String MediaSourceId;
public final String getMediaSourceId()
{
return MediaSourceId;
}
public final void setMediaSourceId(String value)
{
MediaSourceId = value;
}
private String LiveStreamId;
public final String getLiveStreamId()
{
return LiveStreamId;
}
public final void setLiveStreamId(String value)
{
LiveStreamId = value;
}
private DeviceProfile DeviceProfile;
public final DeviceProfile getDeviceProfile()
{

View File

@ -74,6 +74,20 @@ public class LocalItem
{
ItemId = value;
}
/**
Gets or sets the synchronize job item identifier.
<value>The synchronize job item identifier.</value>
*/
private String SyncJobItemId;
public final String getSyncJobItemId()
{
return SyncJobItemId;
}
public final void setSyncJobItemId(String value)
{
SyncJobItemId = value;
}
/**
Gets or sets the user ids with access.

View File

@ -20,6 +20,15 @@ public class SyncDataRequest
{
OfflineUserIds = value;
}
private java.util.ArrayList<String> SyncJobItemIds;
public final java.util.ArrayList<String> getSyncJobItemIds()
{
return SyncJobItemIds;
}
public final void setSyncJobItemIds(java.util.ArrayList<String> value)
{
SyncJobItemIds = value;
}
private String TargetId;
public final String getTargetId()