Normalize orgPn usage

This commit is contained in:
Luke Pulverenti
2014-04-22 22:47:46 -04:00
parent fdd8c67162
commit 44bfad70d2
13 changed files with 302 additions and 157 deletions

View File

@@ -401,66 +401,38 @@ namespace MediaBrowser.Dlna.PlayTo
private string GetDlnaHeaders(PlaylistItem item)
{
var profile = item.Profile;
var streamInfo = item.StreamInfo;
var orgOp = !streamInfo.IsDirectStream ? ";DLNA.ORG_OP=00" : ";DLNA.ORG_OP=01";
var orgCi = !streamInfo.IsDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1";
const string dlnaflags = ";DLNA.ORG_FLAGS=01500000000000000000000000000000";
string contentFeatures;
var container = streamInfo.Container.TrimStart('.');
if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase))
if (streamInfo.MediaType == DlnaProfileType.Audio)
{
contentFeatures = "DLNA.ORG_PN=MP3";
}
else if (string.Equals(container, "wma", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=WMABASE";
}
else if (string.Equals(container, "wmw", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=WMVMED_BASE";
}
else if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=WMVMED_BASE";
}
else if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=AVI";
}
else if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=MATROSKA";
}
else if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=AVC_MP4_MP_HD_720p_AAC";
}
else if (string.Equals(container, "mpeg", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=MPEG_PS_PAL";
}
else if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
{
contentFeatures = "DLNA.ORG_PN=MPEG_PS_PAL";
}
else if (streamInfo.MediaType == DlnaProfileType.Video)
{
// Default to AVI for video
contentFeatures = "DLNA.ORG_PN=AVI";
}
else
{
// Default to MP3 for audio
contentFeatures = "DLNA.ORG_PN=MP3";
return new ContentFeatureBuilder(profile)
.BuildAudioHeader(streamInfo.Container,
streamInfo.AudioCodec,
streamInfo.TargetAudioBitrate,
streamInfo.TargetAudioSampleRate,
streamInfo.TargetAudioChannels,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TranscodeSeekInfo);
}
return (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';');
if (streamInfo.MediaType == DlnaProfileType.Video)
{
return new ContentFeatureBuilder(profile)
.BuildVideoHeader(streamInfo.Container,
streamInfo.VideoCodec,
streamInfo.AudioCodec,
streamInfo.TargetWidth,
streamInfo.TargetHeight,
streamInfo.TotalOutputBitrate,
streamInfo.TargetTimestamp,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TranscodeSeekInfo);
}
return null;
}
private PlaylistItem GetPlaylistItem(BaseItem item, List<MediaSourceInfo> mediaSources, DeviceProfile profile, string deviceId)
@@ -477,7 +449,9 @@ namespace MediaBrowser.Dlna.PlayTo
MediaSources = mediaSources,
Profile = profile,
DeviceId = deviceId
})
}),
Profile = profile
};
}
@@ -493,7 +467,9 @@ namespace MediaBrowser.Dlna.PlayTo
MediaSources = mediaSources,
Profile = profile,
DeviceId = deviceId
})
}),
Profile = profile
};
}

View File

@@ -104,10 +104,6 @@ namespace MediaBrowser.Dlna.PlayTo
}
}
public void Stop()
{
}
/// <summary>
/// Creates a socket for the interface and listends for data.
/// </summary>

View File

@@ -104,7 +104,6 @@ namespace MediaBrowser.Dlna.PlayTo
{
try
{
_manager.Stop();
_manager.Dispose();
}
catch (Exception ex)

View File

@@ -11,5 +11,7 @@ namespace MediaBrowser.Dlna.PlayTo
public string Didl { get; set; }
public StreamInfo StreamInfo { get; set; }
public DeviceProfile Profile { get; set; }
}
}

View File

@@ -19,7 +19,9 @@ namespace MediaBrowser.Dlna.PlayTo
{
ItemId = item.Id.ToString("N"),
MediaType = DlnaProfileType.Photo,
}
},
Profile = profile
};
var directPlay = profile.DirectPlayProfiles

View File

@@ -632,9 +632,7 @@ namespace MediaBrowser.Dlna.Server
var mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container,
streamInfo.AudioCodec,
streamInfo.VideoCodec,
streamInfo.TargetAudioStream,
streamInfo.TargetVideoStream);
streamInfo.VideoCodec);
var formatProfile = mediaProfile == null ? null : mediaProfile.OrgPn;
@@ -646,7 +644,7 @@ namespace MediaBrowser.Dlna.Server
targetWidth,
targetHeight,
targetBitrate,
TransportStreamTimestamp.VALID);
streamInfo.TargetTimestamp);
formatProfile = format.HasValue ? format.Value.ToString() : null;
}
@@ -731,8 +729,7 @@ namespace MediaBrowser.Dlna.Server
}
var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,
streamInfo.AudioCodec,
streamInfo.TargetAudioStream);
streamInfo.AudioCodec);
var formatProfile = mediaProfile == null ? null : mediaProfile.OrgPn;
@@ -780,11 +777,11 @@ namespace MediaBrowser.Dlna.Server
{
if (item is MusicAlbum)
{
classType = "object.container.musicAlbum";
classType = "object.container.album.musicAlbum";
}
if (item is MusicArtist)
{
classType = "object.container.musicArtist";
classType = "object.container.person.musicArtist";
}
}