private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) { var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id) .ToList(); var locationType = i.LocationType; var info = new MediaSourceInfo { Id = i.Id.ToString("N"), IsoType = i.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, Name = GetMediaSourceName(i, mediaStreams), Path = enablePathSubstitution ? GetMappedPath(i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, Video3DFormat = i.Video3DFormat, VideoType = i.VideoType, Container = i.Container, Size = i.Size, Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(), SupportsDirectStream = i.VideoType == VideoType.VideoFile }; if (info.Protocol == MediaProtocol.File) { info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); } if (i.IsShortcut) { info.Path = i.ShortcutPath; if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Http; } else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtmp; } else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtsp; } else { info.Protocol = MediaProtocol.File; } } if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); } } } try { var bitrate = i.TotalBitrate ?? info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) .Select(m => m.BitRate ?? 0) .Sum(); if (bitrate > 0) { info.Bitrate = bitrate; } } catch (OverflowException ex) { Logger.ErrorException("Error calculating total bitrate", ex); } return info; }
public bool BuildGraph(string source, MediaSourceType mediaSourceType) { return(_mediaControl.BuildGraph(source, mediaSourceType)); }
internal MediaSource(string name, MediaSourceType type) { Name = name; MediaSourceType = type; }
internal MediaSource(string name, MediaSourceType type) { this._name = name; this._type = type; }
private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) { var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id) .ToList(); var locationType = i.LocationType; var info = new MediaSourceInfo { Id = i.Id.ToString("N"), IsoType = i.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, Name = GetMediaSourceName(i, mediaStreams), Path = enablePathSubstitution ? GetMappedPath(i, i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, Video3DFormat = i.Video3DFormat, VideoType = i.VideoType, Container = i.Container, Size = i.Size, Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(), SupportsDirectStream = i.VideoType == VideoType.VideoFile }; if (info.Protocol == MediaProtocol.File) { info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); } if (i.IsShortcut) { info.Path = i.ShortcutPath; if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Http; } else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtmp; } else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtsp; } else { info.Protocol = MediaProtocol.File; } } if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); } } } try { var bitrate = i.TotalBitrate ?? info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) .Select(m => m.BitRate ?? 0) .Sum(); if (bitrate > 0) { info.Bitrate = bitrate; } } catch (OverflowException ex) { Logger.ErrorException("Error calculating total bitrate", ex); } return(info); }
private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video media, MediaSourceType type) { if (media == null) { throw new ArgumentNullException("media"); } var locationType = media.LocationType; var info = new MediaSourceInfo { Id = media.Id.ToString("N"), IsoType = media.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = MediaSourceManager.GetMediaStreams(media.Id), Name = GetMediaSourceName(media), Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path, RunTimeTicks = media.RunTimeTicks, Video3DFormat = media.Video3DFormat, VideoType = media.VideoType, Container = media.Container, Size = media.Size, Timestamp = media.Timestamp, Type = type, SupportsDirectStream = media.VideoType == VideoType.VideoFile, IsRemote = media.IsShortcut }; if (info.Protocol == MediaProtocol.File) { info.ETag = media.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); } if (media.IsShortcut) { info.Path = media.ShortcutPath; if (!string.IsNullOrWhiteSpace(info.Path)) { if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Http; info.SupportsDirectStream = false; } else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtmp; info.SupportsDirectStream = false; } else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtsp; info.SupportsDirectStream = false; } else { info.Protocol = MediaProtocol.File; } } } if (string.IsNullOrEmpty(info.Container)) { if (media.VideoType == VideoType.VideoFile || media.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(media.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(media.Path).TrimStart('.'); } } } info.Bitrate = media.TotalBitrate; info.InferTotalBitrate(); return(info); }
internal static extern WebRTCErrorCode AddMediaSource(IntPtr handle, MediaSourceType type, out uint sourceId);
private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) { var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id) .ToList(); var locationType = i.LocationType; var info = new MediaSourceInfo { Id = i.Id.ToString("N"), IsoType = i.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, Name = GetMediaSourceName(i, mediaStreams), Path = enablePathSubstitution ? GetMappedPath(i, i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, Video3DFormat = i.Video3DFormat, VideoType = i.VideoType, Container = i.Container, Size = i.Size, Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(), SupportsDirectStream = i.VideoType == VideoType.VideoFile, IsRemote = i.IsShortcut }; if (info.Protocol == MediaProtocol.File) { info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); } if (i.IsShortcut) { info.Path = i.ShortcutPath; if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Http; } else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtmp; } else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtsp; } else { info.Protocol = MediaProtocol.File; } } if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); } } } info.Bitrate = i.TotalBitrate; info.InferTotalBitrate(); return(info); }
public bool BuildGraph(string source, MediaSourceType mediaSourceType) { return(MediaEngine.BuildGraph(source, mediaSourceType)); }
private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) { var mediaStreams = ItemRepository.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id }).ToList(); var locationType = i.LocationType; var info = new MediaSourceInfo { Id = i.Id.ToString("N"), IsoType = i.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, Name = GetMediaSourceName(i, mediaStreams), Path = enablePathSubstitution ? GetMappedPath(i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, Video3DFormat = i.Video3DFormat, VideoType = i.VideoType, Container = i.Container, Size = i.Size, Formats = (i.FormatName ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList() }; if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); } } } try { var bitrate = i.TotalBitrate ?? info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) .Select(m => m.BitRate ?? 0) .Sum(); if (bitrate > 0) { info.Bitrate = bitrate; } } catch (OverflowException ex) { Logger.ErrorException("Error calculating total bitrate", ex); } return(info); }
private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) { var mediaStreams = ItemRepository.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id }).ToList(); var locationType = i.LocationType; var info = new MediaSourceInfo { Id = i.Id.ToString("N"), IsoType = i.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, Name = GetMediaSourceName(i, mediaStreams), Path = enablePathSubstitution ? GetMappedPath(i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, Video3DFormat = i.Video3DFormat, VideoType = i.VideoType, Container = i.Container, Size = i.Size, Formats = (i.FormatName ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList() }; if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); } } } try { var bitrate = i.TotalBitrate ?? info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) .Select(m => m.BitRate ?? 0) .Sum(); if (bitrate > 0) { info.Bitrate = bitrate; } } catch (OverflowException ex) { Logger.ErrorException("Error calculating total bitrate", ex); } return info; }
public static IFilterGraph BuildFilterGraph(string source, MediaSourceType mediaSourceType, IntPtr hMediaWindow, Renderer preferredVideoRenderer, Action <string> onErrorCallback, Func <string, bool> onPartialSuccessCallback) { IFilterGraph filterGraph = null; var success = false; try { TraceSink.GetTraceSink().TraceInformation( String.Format("Start building filter graph. Source: {0}. WhatToPlay: {1}. PreferredVideoRenderer: {2}.", source, mediaSourceType, preferredVideoRenderer)); filterGraph = GetInitialFilterGraph(source, mediaSourceType); var parameters = new FilterGraphBuilderParameters { Source = source, MediaWindowHandle = hMediaWindow, PreferredVideoRenderer = preferredVideoRenderer, DiscPath = source, Flags = AM_DVD_GRAPH_FLAGS.AM_DVD_HWDEC_PREFER, OnPartialSuccessCallback = onPartialSuccessCallback }; filterGraph.BuildUp(parameters); #if DEBUG filterGraph.AddToRot(); #endif TraceSink.GetTraceSink().TraceInformation("The graph was built successfully."); success = true; return(filterGraph); } catch (AbortException) { TraceSink.GetTraceSink().TraceWarning("User abort."); return(null); } catch (FilterGraphBuilderException e) { TraceSink.GetTraceSink().TraceError(e.ToString()); onErrorCallback(e.Message); return(null); } catch (Exception e) { TraceSink.GetTraceSink().TraceError(e.ToString()); onErrorCallback(e.Message); return(null); } finally { if (!success && filterGraph != null) { filterGraph.Dispose(); } } }