public TSStreamClip( TSStreamFile streamFile, TSStreamClipFile streamClipFile) { if (streamFile != null) { Name = streamFile.Name; StreamFile = streamFile; FileSize = (ulong)StreamFile.FileInfo.Length; if (StreamFile.InterleavedFile != null) { InterleavedFileSize = (ulong)StreamFile.InterleavedFile.FileInfo.Length; } } StreamClipFile = streamClipFile; }
public void Scan() { List<TSStreamClipFile> errorStreamClipFiles = new List<TSStreamClipFile>(); foreach (TSStreamClipFile streamClipFile in StreamClipFiles.Values) { try { streamClipFile.Scan(); } catch (Exception ex) { errorStreamClipFiles.Add(streamClipFile); if (StreamClipFileScanError != null) { if (StreamClipFileScanError(streamClipFile, ex)) { continue; } else { break; } } else throw ex; } } foreach (TSStreamFile streamFile in StreamFiles.Values) { string ssifName = Path.GetFileNameWithoutExtension(streamFile.Name) + ".SSIF"; if (InterleavedFiles.ContainsKey(ssifName)) { streamFile.InterleavedFile = InterleavedFiles[ssifName]; } } TSStreamFile[] streamFiles = new TSStreamFile[StreamFiles.Count]; StreamFiles.Values.CopyTo(streamFiles, 0); Array.Sort(streamFiles, CompareStreamFiles); List<TSPlaylistFile> errorPlaylistFiles = new List<TSPlaylistFile>(); foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) { try { playlistFile.Scan(StreamFiles, StreamClipFiles); } catch (Exception ex) { errorPlaylistFiles.Add(playlistFile); if (PlaylistFileScanError != null) { if (PlaylistFileScanError(playlistFile, ex)) { continue; } else { break; } } else throw ex; } } List<TSStreamFile> errorStreamFiles = new List<TSStreamFile>(); foreach (TSStreamFile streamFile in streamFiles) { try { List<TSPlaylistFile> playlists = new List<TSPlaylistFile>(); foreach (TSPlaylistFile playlist in PlaylistFiles.Values) { foreach (TSStreamClip streamClip in playlist.StreamClips) { if (streamClip.Name == streamFile.Name) { playlists.Add(playlist); break; } } } streamFile.Scan(playlists, false); } catch (Exception ex) { errorStreamFiles.Add(streamFile); if (StreamFileScanError != null) { if (StreamFileScanError(streamFile, ex)) { continue; } else { break; } } else throw ex; } } foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values) { playlistFile.Initialize(); if (!Is50Hz) { foreach (TSVideoStream videoStream in playlistFile.VideoStreams) { if (videoStream.FrameRate == TSFrameRate.FRAMERATE_25 || videoStream.FrameRate == TSFrameRate.FRAMERATE_50) { Is50Hz = true; } } } } }
public static int CompareStreamFiles( TSStreamFile x, TSStreamFile y) { // TODO: Use interleaved file sizes if ((x == null || x.FileInfo == null) && (y == null || y.FileInfo == null)) { return 0; } else if ((x == null || x.FileInfo == null) && (y != null && y.FileInfo != null)) { return 1; } else if ((x != null || x.FileInfo != null) && (y == null || y.FileInfo == null)) { return -1; } else { if (x.FileInfo.Length > y.FileInfo.Length) { return 1; } else if (y.FileInfo.Length > x.FileInfo.Length) { return -1; } else { return 0; } } }