static bool MessageLoop(Element element, ref TagList tags) { Bus bus = element.Bus; bool done = false; while (!done) { Message message = bus.Pop(); if (message == null) { break; } switch (message.Type) { case MessageType.Error: string error; message.ParseError(out error); message.Dispose(); return(true); case MessageType.Eos: message.Dispose(); return(true); case MessageType.Tag: TagList new_tags = message.ParseTag(); if (tags != null) { tags = tags.Merge(new_tags, TagMergeMode.KeepAll); new_tags.Dispose(); } else { tags = new_tags; } break; default: break; } message.Dispose(); } bus.Dispose(); return(true); }
static void AnalyzeStreams() { // Read some properties _data.NVideo = (int)_data.Playbin["n-video"]; _data.NAudio = (int)_data.Playbin["n-audio"]; _data.NText = (int)_data.Playbin["n-text"]; Console.WriteLine($"{_data.NVideo} video streams, {_data.NAudio} audio streams, {_data.NText} text streams"); string str; for (int i = 0; i < _data.NVideo; i++) { // Retrieve the stream's video tags using (TagList tags = (TagList)_data.Playbin.Emit("get-video-tags", i)) { if (tags == null) { continue; } Console.WriteLine($"video stream {i}:"); if (tags.GetString(Gst.Constants.TAG_VIDEO_CODEC, out str)) { Console.WriteLine(" codec: {0}", str ?? "unknown"); } tags.Dispose(); } } for (int i = 0; i < _data.NAudio; i++) { // Retrieve the stream's audio tags using (TagList tags = (TagList)_data.Playbin.Emit("get-audio-tags", i)) { if (tags == null) { continue; } Console.WriteLine($"audio stream {i}:"); if (tags.GetString(Gst.Constants.TAG_AUDIO_CODEC, out str)) { Console.WriteLine(" codec: {0}", str ?? "unknown"); } if (tags.GetString(Gst.Constants.TAG_LANGUAGE_CODE, out str)) { Console.WriteLine($" language: {str}"); } if (tags.GetUint(Gst.Constants.TAG_BITRATE, out uint rate)) { Console.WriteLine($" bitrage: {rate}"); } } } for (int i = 0; i < _data.NText; i++) { //Retrieve the stream's subtitle tags TagList tags = (TagList)_data.Playbin.Emit("get-text-tags", i); { if (tags == null) { continue; } Console.WriteLine("Subtitle stream: {0}", i); if (tags.GetString(Gst.Constants.TAG_LANGUAGE_CODE, out str)) { Console.WriteLine($" language: {str}"); } } } _data.CurrentVideo = (int)_data.Playbin.GetProperty("current-video"); _data.CurrentAudio = (int)_data.Playbin.GetProperty("current-audio"); _data.CurrentText = (int)_data.Playbin.GetProperty("current-text"); Console.WriteLine($"Currently playing video stream {_data.CurrentVideo}, audio stream {_data.CurrentAudio} and text stream {_data.CurrentText}"); Console.WriteLine("Type any number and hit ENTER to select a different subtitle stream"); }
public static void Main(string [] args) { Application.Init(); if (args.Length < 1) { Console.WriteLine("Please give filenames to read metadata from\n\n"); return; } MakePipeline(); int i = -1; while (++i < args.Length) { State state, pending; TagList tags = null; string filename = args[i]; if (!File.Exists(filename)) { Console.WriteLine("File {0} does not exist", filename); continue; } source["location"] = filename; StateChangeReturn sret = pipeline.SetState(State.Paused); if (sret == StateChangeReturn.Async) { if (StateChangeReturn.Success != pipeline.GetState(out state, out pending, Clock.Second * 5)) { Console.WriteLine("State change failed for {0}. Aborting\n", filename); break; } } else if (sret != StateChangeReturn.Success) { Console.WriteLine("{0} - Could not read file ({1})\n", filename, sret); continue; } if (!MessageLoop(pipeline, ref tags)) { Console.Error.WriteLine("Failed in message reading for {0}", args[i]); } if (tags != null) { Console.WriteLine("Metadata for {0}:", filename); foreach (string tag in tags.Tags) { PrintTag(tags, tag); } tags.Dispose(); tags = null; } else { Console.WriteLine("No metadata found for {0}", args[0]); } sret = pipeline.SetState(State.Null); if (StateChangeReturn.Async == sret) { if (StateChangeReturn.Failure == pipeline.GetState(out state, out pending, Clock.TimeNone)) { Console.WriteLine("State change failed. Aborting"); } } } if (pipeline != null) { pipeline.Dispose(); } }
void ReleaseDesignerOutlets() { if (AddTagButton != null) { AddTagButton.Dispose(); AddTagButton = null; } if (ArrangerBox != null) { ArrangerBox.Dispose(); ArrangerBox = null; } if (BackgroundBox != null) { BackgroundBox.Dispose(); BackgroundBox = null; } if (BookmarkLabelBox != null) { BookmarkLabelBox.Dispose(); BookmarkLabelBox = null; } if (BookmarkList != null) { BookmarkList.Dispose(); BookmarkList = null; } if (BookmarkMeasureBox != null) { BookmarkMeasureBox.Dispose(); BookmarkMeasureBox = null; } if (ComposerBox != null) { ComposerBox.Dispose(); ComposerBox = null; } if (CopyrightBox != null) { CopyrightBox.Dispose(); CopyrightBox = null; } if (DifficultyBox != null) { DifficultyBox.Dispose(); DifficultyBox = null; } if (FingerHintBox != null) { FingerHintBox.Dispose(); FingerHintBox = null; } if (HandsBox != null) { HandsBox.Dispose(); HandsBox = null; } if (LicenseBox != null) { LicenseBox.Dispose(); LicenseBox = null; } if (MadeFamousByBox != null) { MadeFamousByBox.Dispose(); MadeFamousByBox = null; } if (PartsBox != null) { PartsBox.Dispose(); PartsBox = null; } if (PropertiesGroup != null) { PropertiesGroup.Dispose(); PropertiesGroup = null; } if (RatingBox != null) { RatingBox.Dispose(); RatingBox = null; } if (RemoveBookmarkButton != null) { RemoveBookmarkButton.Dispose(); RemoveBookmarkButton = null; } if (RemoveTagButton != null) { RemoveTagButton.Dispose(); RemoveTagButton = null; } if (RetargetButton != null) { RetargetButton.Dispose(); RetargetButton = null; } if (SongList != null) { SongList.Dispose(); SongList = null; } if (SubtitleBox != null) { SubtitleBox.Dispose(); SubtitleBox = null; } if (TagBox != null) { TagBox.Dispose(); TagBox = null; } if (TagList != null) { TagList.Dispose(); TagList = null; } if (TitleBox != null) { TitleBox.Dispose(); TitleBox = null; } if (UniqueIdBox != null) { UniqueIdBox.Dispose(); UniqueIdBox = null; } }