mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 07:28:53 +00:00
info: start to use discoverer and improve the ui
Organize the info pane as a table. Add mime type and duration fields to container section.
This commit is contained in:
parent
76fb0eafff
commit
80be4db45d
1 changed files with 84 additions and 14 deletions
|
@ -24,39 +24,81 @@ using Gst;
|
||||||
we need to update the vapi for yet unreleased gstreamer api:
|
we need to update the vapi for yet unreleased gstreamer api:
|
||||||
|
|
||||||
cd vala/mediainfo/vapi
|
cd vala/mediainfo/vapi
|
||||||
vala-gen-introspect gstreamer-pbutils-0.10 packages/gstreamer-pbutils-0.10 && ../vapigen/vapigen --vapidir . --library \
|
vala-gen-introspect gstreamer-pbutils-0.10 packages/gstreamer-pbutils-0.10
|
||||||
gstreamer-pbutils-0.10 packages/gstreamer-pbutils-0.10/gstreamer-pbutils-0.10.gi
|
vapigen --vapidir . --library gstreamer-pbutils-0.10 packages/gstreamer-pbutils-0.10/gstreamer-pbutils-0.10.gi
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MediaInfo.Info : VBox
|
public class MediaInfo.Info : VBox
|
||||||
{
|
{
|
||||||
private Label uri;
|
// ui components
|
||||||
private Discoverer dc;
|
private Label mime_type;
|
||||||
|
private Label duration;
|
||||||
private DrawingArea drawing_area;
|
private DrawingArea drawing_area;
|
||||||
|
// gstreamer objects
|
||||||
|
private Discoverer dc;
|
||||||
private Pipeline pb;
|
private Pipeline pb;
|
||||||
|
|
||||||
public Info ()
|
public Info ()
|
||||||
{
|
{
|
||||||
Label label;
|
Label label;
|
||||||
|
Table table;
|
||||||
|
AttachOptions fill = AttachOptions.FILL;
|
||||||
|
AttachOptions fill_exp = AttachOptions.EXPAND|AttachOptions.FILL;
|
||||||
|
uint row = 0;
|
||||||
|
|
||||||
// configure the view
|
// configure the view
|
||||||
set_homogeneous (false);
|
set_homogeneous (false);
|
||||||
|
|
||||||
// add widgets
|
// add widgets
|
||||||
// FIXME: handle aspect ration (AspectFrame.ratio)
|
// FIXME: handle aspect ratio (AspectFrame.ratio)
|
||||||
// FIXME: paint it black from the start
|
// FIXME: paint it black from the start
|
||||||
drawing_area = new DrawingArea ();
|
drawing_area = new DrawingArea ();
|
||||||
drawing_area.set_size_request (300, 150);
|
drawing_area.set_size_request (300, 150);
|
||||||
pack_start (drawing_area, true, true, 0);
|
pack_start (drawing_area, true, true, 0);
|
||||||
|
|
||||||
// FIXME: some alignment issues with the strings
|
table = new Table (5, 2, false);
|
||||||
uri = new Label (null);
|
pack_start (table, false, false, 0);
|
||||||
pack_start (uri, false, false, 0);
|
|
||||||
|
|
||||||
label = new Label (null);
|
label = new Label (null);
|
||||||
label.set_markup("<b>Container</b>");
|
label.set_markup("<b>Container</b>");
|
||||||
pack_start (label, false, false, 0);
|
label.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 2, row, row+1, fill_exp, 0, 0, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
label = new Label ("Mime-Type:");
|
||||||
|
label.set_alignment (1.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 1, row, row+1, fill, 0, 0, 0);
|
||||||
|
mime_type = new Label (null);
|
||||||
|
mime_type.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (mime_type, 1, 2, row, row+1, fill_exp, 0, 3, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
label = new Label ("Duration:");
|
||||||
|
label.set_alignment (1.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 1, row, row+1, fill, 0, 0, 0);
|
||||||
|
duration = new Label (null);
|
||||||
|
duration.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (duration, 1, 2, row, row+1, fill_exp, 0, 3, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
label = new Label (null);
|
||||||
|
label.set_markup("<b>Video Streams</b>");
|
||||||
|
label.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 2, row, row+1, fill_exp, 0, 0, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
// TODO: add video stream info widgets
|
||||||
|
|
||||||
|
label = new Label (null);
|
||||||
|
label.set_markup("<b>Audio Streams</b>");
|
||||||
|
label.set_alignment (0.0f, 0.5f);
|
||||||
|
table.attach (label, 0, 2, row, row+1, fill_exp, 0, 0, 1);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
// TODO: add audio stream info widgets
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
show_all ();
|
show_all ();
|
||||||
|
|
||||||
|
@ -64,7 +106,7 @@ public class MediaInfo.Info : VBox
|
||||||
try {
|
try {
|
||||||
dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
|
dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
debug ("Failed to create the discoverer: %s", e.message);
|
debug ("Failed to create the discoverer: %s: %s", e.domain.to_string (), e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = ElementFactory.make ("playbin2", "player") as Pipeline;
|
pb = ElementFactory.make ("playbin2", "player") as Pipeline;
|
||||||
|
@ -89,14 +131,38 @@ public class MediaInfo.Info : VBox
|
||||||
// stop previous playback
|
// stop previous playback
|
||||||
pb.set_state (State.NULL);
|
pb.set_state (State.NULL);
|
||||||
|
|
||||||
this.uri.set_text (uri);
|
// TODO: check if uri is a regular (local file)?
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
DiscovererInfo info;
|
DiscovererInfo info;
|
||||||
|
bool uncertain;
|
||||||
|
|
||||||
|
string mime_type = g_content_type_guess (uri, null, out uncertain);
|
||||||
|
if (uncertain) {
|
||||||
|
this.mime_type.set_markup (@"<i>$mime_type</i>");
|
||||||
|
} else {
|
||||||
|
this.mime_type.set_text (mime_type);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info = dc.discover_uri (uri);
|
info = dc.discover_uri (uri);
|
||||||
|
|
||||||
|
ClockTime dur = info.get_duration ();
|
||||||
|
string dur_str = "%u:%02u:%02u.%09u".printf (
|
||||||
|
(uint) (dur / (SECOND * 60 * 60)),
|
||||||
|
(uint) ((dur / (SECOND * 60)) % 60),
|
||||||
|
(uint) ((dur / SECOND) % 60),
|
||||||
|
(uint) ((dur) % SECOND));
|
||||||
|
this.duration.set_text (dur_str);
|
||||||
|
|
||||||
|
//stdout.printf ("Duration: %s\n", dur_str);
|
||||||
|
|
||||||
|
// TODO: get more info
|
||||||
|
// list = info.get_video_streams ();
|
||||||
|
// list = info.get_audio_streams ();
|
||||||
|
// list = info.get_container_streams ();
|
||||||
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
debug ("Failed to extract metadata from %s: %s", uri, e.message);
|
debug ("Failed to extract metadata from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// play file
|
// play file
|
||||||
|
@ -119,6 +185,10 @@ public class MediaInfo.Info : VBox
|
||||||
XOverlay xoverlay = message.src as XOverlay;
|
XOverlay xoverlay = message.src as XOverlay;
|
||||||
xoverlay.set_xwindow_id (Gdk.x11_drawable_get_xid (drawing_area.window));
|
xoverlay.set_xwindow_id (Gdk.x11_drawable_get_xid (drawing_area.window));
|
||||||
|
|
||||||
|
if (message.src.get_class ().find_property ("force-aspect-ratio") != null) {
|
||||||
|
((GLib.Object)message.src).set_property ("force-aspect-ratio", true);
|
||||||
|
}
|
||||||
|
|
||||||
drawing_area.unset_flags(Gtk.WidgetFlags.DOUBLE_BUFFERED);
|
drawing_area.unset_flags(Gtk.WidgetFlags.DOUBLE_BUFFERED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue