/// <summary> /// Open all files associated with the ISM. /// </summary> /// <param name="inPath">path name to ISM file without extension</param> public override void Open(string inPath, bool withCaching) { _mainFolderPath = Path.GetDirectoryName(inPath); _ismFile = new ISMFile(_mainFolderPath, Path.GetFileNameWithoutExtension(inPath)); foreach (ISMElement element in _ismFile.ISMElements) { GenericMediaTrack ismTrack = null; if (element.FragmentType == FragmentType.Video) { ismTrack = new ISMVideoTrack(new ISMVTrackFormat(_mainFolderPath, element.Source, element), this); } else if (element.FragmentType == FragmentType.Audio) { ismTrack = new ISMAudioTrack(new ISMVTrackFormat(_mainFolderPath, element.Source, element), this); } MediaTracks.Add(ismTrack); // choose longest track duration to be stream duration if (DurationIn100NanoSecs < ismTrack.TrackDurationIn100NanoSecs) { DurationIn100NanoSecs = ismTrack.TrackDurationIn100NanoSecs; } } CachingEnabled = withCaching; }
public void AddTrack(IMediaTrack inTrack) { Common.Logger.Instance.Info("[GenericMediaStream::AddTrack] added " + inTrack + ", " + (inTrack != null ? inTrack.GetType().Name : string.Empty)); MediaTracks.Add(inTrack); if (MediaTrackAdded != null) { MediaTrackAdded(inTrack); } }
public override void InitializeForWriting(List <IsochronousTrackInfo> mediaTracksInfo) { foreach (IsochronousTrackInfo trak in mediaTracksInfo) { if (trak.HandlerType.Equals("Video")) { GenericTrackFormat format = new H264Format(); format.Codec = new Codec(CodecTypes.Video); format.Codec.PrivateCodecData = trak.CodecPrivateData; IMediaTrack item = new GenericVideoTrack(format, this); MediaTracks.Add(item); } } base.InitializeForWriting(mediaTracksInfo); }
static void ReadMetaData() { lock (MediaTracks) { MediaTracks.Clear(); string path = get_property_string("path"); if (File.Exists(path)) { using (MediaInfo mi = new MediaInfo(path)) { int count = mi.GetCount(MediaInfoStreamKind.Video); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetVideo(i, "Format")); Add(track, mi.GetVideo(i, "Format_Profile")); Add(track, mi.GetVideo(i, "Width") + "x" + mi.GetVideo(i, "Height")); Add(track, mi.GetVideo(i, "FrameRate") + " FPS"); Add(track, mi.GetVideo(i, "Language/String")); Add(track, mi.GetVideo(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetVideo(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetVideo(i, "Title")); track.Text = "V: " + track.Text.Trim(' ', ','); track.Type = "v"; track.ID = i + 1; MediaTracks.Add(track); } count = mi.GetCount(MediaInfoStreamKind.Audio); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetAudio(i, "Language/String")); Add(track, mi.GetAudio(i, "Format")); Add(track, mi.GetAudio(i, "Format_Profile")); Add(track, mi.GetAudio(i, "BitRate/String")); Add(track, mi.GetAudio(i, "Channel(s)/String")); Add(track, mi.GetAudio(i, "SamplingRate/String")); Add(track, mi.GetAudio(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetAudio(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetAudio(i, "Title")); track.Text = "A: " + track.Text.Trim(' ', ','); track.Type = "a"; track.ID = i + 1; MediaTracks.Add(track); } count = mi.GetCount(MediaInfoStreamKind.Text); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetText(i, "Language/String")); Add(track, mi.GetText(i, "Format")); Add(track, mi.GetText(i, "Format_Profile")); Add(track, mi.GetText(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetText(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetText(i, "Title")); track.Text = "S: " + track.Text.Trim(' ', ','); track.Type = "s"; track.ID = i + 1; MediaTracks.Add(track); } count = get_property_int("edition-list/count"); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); track.Text = "E: " + get_property_string($"edition-list/{i}/title"); track.Type = "e"; track.ID = i; MediaTracks.Add(track); } void Add(MediaTrack track, string val) { if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val))) { track.Text += " " + val + ","; } } } } } lock (Chapters) { Chapters.Clear(); int count = get_property_int("chapter-list/count"); for (int x = 0; x < count; x++) { string text = get_property_string($"chapter-list/{x}/title"); double time = get_property_number($"chapter-list/{x}/time"); Chapters.Add(new KeyValuePair <string, double>(text, time)); } } }