mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 02:30:35 +00:00
mi: code cleanups, comments
This commit is contained in:
parent
2309c6d7fb
commit
d70da55d3b
3 changed files with 78 additions and 69 deletions
|
@ -25,8 +25,7 @@ public class MediaInfo.App : Window
|
||||||
private FileChooserWidget chooser;
|
private FileChooserWidget chooser;
|
||||||
private Info info;
|
private Info info;
|
||||||
|
|
||||||
public App (string? directory_or_uri)
|
public App (string? directory_or_uri) {
|
||||||
{
|
|
||||||
GLib.Object (type : WindowType.TOPLEVEL);
|
GLib.Object (type : WindowType.TOPLEVEL);
|
||||||
|
|
||||||
string directory = null;
|
string directory = null;
|
||||||
|
@ -85,8 +84,7 @@ public class MediaInfo.App : Window
|
||||||
|
|
||||||
// helper
|
// helper
|
||||||
|
|
||||||
private MenuBar create_menu ()
|
private MenuBar create_menu () {
|
||||||
{
|
|
||||||
MenuBar menu_bar = new MenuBar ();
|
MenuBar menu_bar = new MenuBar ();
|
||||||
Gtk.MenuItem item;
|
Gtk.MenuItem item;
|
||||||
Gtk.Menu sub_menu;
|
Gtk.Menu sub_menu;
|
||||||
|
@ -142,8 +140,7 @@ public class MediaInfo.App : Window
|
||||||
|
|
||||||
// signal handler
|
// signal handler
|
||||||
|
|
||||||
private void on_update_preview ()
|
private void on_update_preview () {
|
||||||
{
|
|
||||||
File file = chooser.get_file();
|
File file = chooser.get_file();
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
|
@ -153,8 +150,7 @@ public class MediaInfo.App : Window
|
||||||
chooser.set_preview_widget_active (res);
|
chooser.set_preview_widget_active (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_fullscreen_toggled (CheckMenuItem item)
|
private void on_fullscreen_toggled (CheckMenuItem item) {
|
||||||
{
|
|
||||||
if (item.active) {
|
if (item.active) {
|
||||||
fullscreen();
|
fullscreen();
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,8 +158,7 @@ public class MediaInfo.App : Window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_about_clicked (Gtk.MenuItem item)
|
private void on_about_clicked (Gtk.MenuItem item) {
|
||||||
{
|
|
||||||
AboutDialog dlg = new AboutDialog ();
|
AboutDialog dlg = new AboutDialog ();
|
||||||
|
|
||||||
dlg.set_version(Config.PACKAGE_VERSION);
|
dlg.set_version(Config.PACKAGE_VERSION);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class MediaInfo.Info : Box
|
||||||
private Notebook video_streams; // depending on screen resolution
|
private Notebook video_streams; // depending on screen resolution
|
||||||
private Notebook audio_streams;
|
private Notebook audio_streams;
|
||||||
private Notebook subtitle_streams;
|
private Notebook subtitle_streams;
|
||||||
|
private Label toc_entries; // TODO(ensonic): use treeview
|
||||||
private Preview preview;
|
private Preview preview;
|
||||||
private ScrolledWindow info_area;
|
private ScrolledWindow info_area;
|
||||||
// gstreamer objects
|
// gstreamer objects
|
||||||
|
@ -53,8 +54,7 @@ public class MediaInfo.Info : Box
|
||||||
private HashSet<string> tag_black_list;
|
private HashSet<string> tag_black_list;
|
||||||
private HashMap<string, string> wikilinks;
|
private HashMap<string, string> wikilinks;
|
||||||
|
|
||||||
public Info ()
|
public Info () {
|
||||||
{
|
|
||||||
Label label;
|
Label label;
|
||||||
Table table;
|
Table table;
|
||||||
AttachOptions fill = AttachOptions.FILL;
|
AttachOptions fill = AttachOptions.FILL;
|
||||||
|
@ -251,6 +251,17 @@ public class MediaInfo.Info : Box
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label = new Label (null);
|
||||||
|
label.set_markup("<b>Toc</b>");
|
||||||
|
label.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
toc_entries = new Label (null); // TODO(ensonic): use TreeView
|
||||||
|
//toc.row_activated.connect (on_toc_entry_activated);
|
||||||
|
table.attach (toc_entries, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
// TODO: add container stream info widgets
|
// TODO: add container stream info widgets
|
||||||
|
|
||||||
// TODO: add tag list widget
|
// TODO: add tag list widget
|
||||||
|
@ -274,16 +285,14 @@ public class MediaInfo.Info : Box
|
||||||
bus.sync_message["element"].connect (on_element_sync_message);
|
bus.sync_message["element"].connect (on_element_sync_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Info ()
|
~Info () {
|
||||||
{
|
|
||||||
// stop previous playback
|
// stop previous playback
|
||||||
pb.set_state (State.NULL);
|
pb.set_state (State.NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public methods
|
// public methods
|
||||||
|
|
||||||
public bool discover (string uri)
|
public bool discover (string uri) {
|
||||||
{
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
|
@ -318,8 +327,7 @@ public class MediaInfo.Info : Box
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_uri_discovered (DiscovererInfo info, Error e)
|
private void on_uri_discovered (DiscovererInfo info, Error e) {
|
||||||
{
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
debug ("Failed to extract metadata from %s: %s: %s", info.get_uri(), e.domain.to_string (), e.message);
|
debug ("Failed to extract metadata from %s: %s: %s", info.get_uri(), e.domain.to_string (), e.message);
|
||||||
container_caps.set_text ("");
|
container_caps.set_text ("");
|
||||||
|
@ -329,24 +337,7 @@ public class MediaInfo.Info : Box
|
||||||
process_new_uri (info);
|
process_new_uri (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set_wikilink(Label label, Caps caps)
|
private void process_new_uri (DiscovererInfo info) {
|
||||||
{
|
|
||||||
string str = get_codec_description (caps);
|
|
||||||
string wikilink = wikilinks[str];
|
|
||||||
|
|
||||||
if (wikilink == null) {
|
|
||||||
wikilink = wikilinks[caps.get_structure(0).get_name()];
|
|
||||||
}
|
|
||||||
if (wikilink != null) {
|
|
||||||
// FIXME: make prefix (en) and link translatable
|
|
||||||
label.set_markup ("<a href=\"http://en.wikipedia.org/wiki/%s\">%s</a>".printf (wikilink, str));
|
|
||||||
} else {
|
|
||||||
label.set_text (str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process_new_uri (DiscovererInfo info)
|
|
||||||
{
|
|
||||||
string uri = info.get_uri();
|
string uri = info.get_uri();
|
||||||
GLib.List<DiscovererStreamInfo> l;
|
GLib.List<DiscovererStreamInfo> l;
|
||||||
DiscovererStreamInfo sinfo;
|
DiscovererStreamInfo sinfo;
|
||||||
|
@ -360,6 +351,7 @@ public class MediaInfo.Info : Box
|
||||||
Caps caps;
|
Caps caps;
|
||||||
unowned Structure s;
|
unowned Structure s;
|
||||||
unowned TagList t;
|
unowned TagList t;
|
||||||
|
unowned Toc toc = null;
|
||||||
// sort streams
|
// sort streams
|
||||||
ArrayList<string> sids = new ArrayList<string> ();
|
ArrayList<string> sids = new ArrayList<string> ();
|
||||||
int six;
|
int six;
|
||||||
|
@ -404,23 +396,18 @@ public class MediaInfo.Info : Box
|
||||||
caps = sinfo.get_caps ();
|
caps = sinfo.get_caps ();
|
||||||
container_caps.set_text (caps.to_string ());
|
container_caps.set_text (caps.to_string ());
|
||||||
set_wikilink (container_name, caps);
|
set_wikilink (container_name, caps);
|
||||||
|
|
||||||
|
toc = sinfo.get_toc();
|
||||||
|
// irks: we can also have the toc on a *_stream
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset notebooks
|
// reset notebooks
|
||||||
if (compact_mode) {
|
if (compact_mode) {
|
||||||
while (all_streams.get_n_pages() > 0) {
|
clear_notebook (all_streams);
|
||||||
all_streams.remove_page (-1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
while (video_streams.get_n_pages() > 0) {
|
clear_notebook (video_streams);
|
||||||
video_streams.remove_page (-1);
|
clear_notebook (audio_streams);
|
||||||
}
|
clear_notebook (subtitle_streams);
|
||||||
while (audio_streams.get_n_pages() > 0) {
|
|
||||||
audio_streams.remove_page (-1);
|
|
||||||
}
|
|
||||||
while (subtitle_streams.get_n_pages() > 0) {
|
|
||||||
subtitle_streams.remove_page (-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
page_offset = 0;
|
page_offset = 0;
|
||||||
|
|
||||||
|
@ -548,7 +535,9 @@ public class MediaInfo.Info : Box
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sinfo.get_toc()
|
if (toc == null) {
|
||||||
|
toc = sinfo.get_toc();
|
||||||
|
}
|
||||||
|
|
||||||
six = get_stream_index (sinfo, sids);
|
six = get_stream_index (sinfo, sids);
|
||||||
nb.insert_page (table, new Label (@"video $i"), page_offset + six);
|
nb.insert_page (table, new Label (@"video $i"), page_offset + six);
|
||||||
|
@ -657,6 +646,10 @@ public class MediaInfo.Info : Box
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toc == null) {
|
||||||
|
toc = sinfo.get_toc();
|
||||||
|
}
|
||||||
|
|
||||||
six = get_stream_index (sinfo, sids);
|
six = get_stream_index (sinfo, sids);
|
||||||
nb.insert_page (table, new Label (@"audio $i"), page_offset + six);
|
nb.insert_page (table, new Label (@"audio $i"), page_offset + six);
|
||||||
}
|
}
|
||||||
|
@ -723,6 +716,10 @@ public class MediaInfo.Info : Box
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toc == null) {
|
||||||
|
toc = sinfo.get_toc();
|
||||||
|
}
|
||||||
|
|
||||||
six = get_stream_index (sinfo, sids);
|
six = get_stream_index (sinfo, sids);
|
||||||
nb.insert_page (table, new Label (@"subtitle $i"), page_offset + six);
|
nb.insert_page (table, new Label (@"subtitle $i"), page_offset + six);
|
||||||
}
|
}
|
||||||
|
@ -731,6 +728,12 @@ public class MediaInfo.Info : Box
|
||||||
}
|
}
|
||||||
nb.show_all();
|
nb.show_all();
|
||||||
|
|
||||||
|
if (toc != null) {
|
||||||
|
toc_entries.set_text ("has toc");
|
||||||
|
} else {
|
||||||
|
toc_entries.set_text (null);
|
||||||
|
}
|
||||||
|
|
||||||
if (have_video) {
|
if (have_video) {
|
||||||
Gdk.Point res = video_resolutions[0];
|
Gdk.Point res = video_resolutions[0];
|
||||||
preview.set_content_size(res.x, res.y);
|
preview.set_content_size(res.x, res.y);
|
||||||
|
@ -749,8 +752,7 @@ public class MediaInfo.Info : Box
|
||||||
|
|
||||||
// signal handlers
|
// signal handlers
|
||||||
|
|
||||||
private void on_preview_size_allocate (Widget widget, Gtk.Allocation box)
|
private void on_preview_size_allocate (Widget widget, Gtk.Allocation box) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
Gtk.Allocation alloc;
|
Gtk.Allocation alloc;
|
||||||
get_allocation (out alloc);
|
get_allocation (out alloc);
|
||||||
|
@ -766,8 +768,7 @@ public class MediaInfo.Info : Box
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool on_preview_draw (Widget widget, Cairo.Context cr)
|
private bool on_preview_draw (Widget widget, Cairo.Context cr) {
|
||||||
{
|
|
||||||
if (pb.current_state < State.PAUSED || !have_video) {
|
if (pb.current_state < State.PAUSED || !have_video) {
|
||||||
widget.set_double_buffered (true);
|
widget.set_double_buffered (true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -776,16 +777,14 @@ public class MediaInfo.Info : Box
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_element_sync_message (Gst.Bus bus, Message message)
|
private void on_element_sync_message (Gst.Bus bus, Message message) {
|
||||||
{
|
|
||||||
if (Gst.Video.is_video_overlay_prepare_window_handle_message (message)) {
|
if (Gst.Video.is_video_overlay_prepare_window_handle_message (message)) {
|
||||||
Gst.Video.Overlay overlay = message.src as Gst.Video.Overlay;
|
Gst.Video.Overlay overlay = message.src as Gst.Video.Overlay;
|
||||||
overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (preview.get_window ()));
|
overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (preview.get_window ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_video_stream_switched (Notebook nb, Widget page, uint page_num)
|
private void on_video_stream_switched (Notebook nb, Widget page, uint page_num) {
|
||||||
{
|
|
||||||
if (pb.current_state > State.PAUSED) {
|
if (pb.current_state > State.PAUSED) {
|
||||||
debug ("Switching video to: %u", page_num);
|
debug ("Switching video to: %u", page_num);
|
||||||
((GLib.Object)pb).set_property ("current-video", (int)page_num);
|
((GLib.Object)pb).set_property ("current-video", (int)page_num);
|
||||||
|
@ -794,24 +793,21 @@ public class MediaInfo.Info : Box
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_audio_stream_switched (Notebook nb, Widget page, uint page_num)
|
private void on_audio_stream_switched (Notebook nb, Widget page, uint page_num) {
|
||||||
{
|
|
||||||
if (pb.current_state > State.PAUSED) {
|
if (pb.current_state > State.PAUSED) {
|
||||||
debug ("Switching audio to: %u", page_num);
|
debug ("Switching audio to: %u", page_num);
|
||||||
((GLib.Object)pb).set_property ("current-audio", (int)page_num);
|
((GLib.Object)pb).set_property ("current-audio", (int)page_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_subtitle_stream_switched (Notebook nb, Widget page, uint page_num)
|
private void on_subtitle_stream_switched (Notebook nb, Widget page, uint page_num) {
|
||||||
{
|
|
||||||
if (pb.current_state > State.PAUSED) {
|
if (pb.current_state > State.PAUSED) {
|
||||||
debug ("Switching subtitle to: %u", page_num);
|
debug ("Switching subtitle to: %u", page_num);
|
||||||
((GLib.Object)pb).set_property ("current-text", (int)page_num);
|
((GLib.Object)pb).set_property ("current-text", (int)page_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_stream_switched (Notebook nb, Widget page, uint page_num)
|
private void on_stream_switched (Notebook nb, Widget page, uint page_num) {
|
||||||
{
|
|
||||||
if (pb.current_state > State.PAUSED) {
|
if (pb.current_state > State.PAUSED) {
|
||||||
if (page_num < num_video_streams) {
|
if (page_num < num_video_streams) {
|
||||||
debug ("Switching video to: %u", page_num);
|
debug ("Switching video to: %u", page_num);
|
||||||
|
@ -835,9 +831,29 @@ public class MediaInfo.Info : Box
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
|
|
||||||
|
private void clear_notebook (NoteBook nb) {
|
||||||
|
while (nb.get_n_pages() > 0) {
|
||||||
|
nb.remove_page (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_wikilink (Label label, Caps caps) {
|
||||||
|
string str = get_codec_description (caps);
|
||||||
|
string wikilink = wikilinks[str];
|
||||||
|
|
||||||
|
if (wikilink == null) {
|
||||||
|
wikilink = wikilinks[caps.get_structure(0).get_name()];
|
||||||
|
}
|
||||||
|
if (wikilink != null) {
|
||||||
|
// FIXME: make prefix (en) and link translatable
|
||||||
|
label.set_markup ("<a href=\"http://en.wikipedia.org/wiki/%s\">%s</a>".printf (wikilink, str));
|
||||||
|
} else {
|
||||||
|
label.set_text (str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get stream index where streams are orderd by stream_id
|
// get stream index where streams are orderd by stream_id
|
||||||
private int get_stream_index (DiscovererStreamInfo sinfo, ArrayList<string> sids)
|
private int get_stream_index (DiscovererStreamInfo sinfo, ArrayList<string> sids) {
|
||||||
{
|
|
||||||
string sid = sinfo.get_stream_id ();
|
string sid = sinfo.get_stream_id ();
|
||||||
int six = 0;
|
int six = 0;
|
||||||
|
|
||||||
|
@ -850,8 +866,7 @@ public class MediaInfo.Info : Box
|
||||||
return six;
|
return six;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string build_taglist_info (TagList t)
|
private string build_taglist_info (TagList t) {
|
||||||
{
|
|
||||||
uint i;
|
uint i;
|
||||||
string str, fn, vstr;
|
string str, fn, vstr;
|
||||||
GLib.Value v;
|
GLib.Value v;
|
||||||
|
|
|
@ -26,8 +26,7 @@ const OptionEntry[] options = {
|
||||||
{ null }
|
{ null }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(string[] args)
|
int main(string[] args) {
|
||||||
{
|
|
||||||
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
|
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
|
||||||
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
|
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
|
||||||
Intl.textdomain (Config.GETTEXT_PACKAGE);
|
Intl.textdomain (Config.GETTEXT_PACKAGE);
|
||||||
|
|
Loading…
Reference in a new issue