mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
mi-info: prepare for async discovery
The async api usage is not yet activated due to some uncertanty in the api use.
This commit is contained in:
parent
f52cdd922c
commit
0cfb4aa000
1 changed files with 337 additions and 314 deletions
|
@ -252,6 +252,7 @@ public class MediaInfo.Info : VPaned
|
||||||
// set up the gstreamer components
|
// set up the gstreamer components
|
||||||
try {
|
try {
|
||||||
dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
|
dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
|
||||||
|
dc.discovered.connect (on_uri_discovered);
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
debug ("Failed to create the discoverer: %s: %s", e.domain.to_string (), e.message);
|
debug ("Failed to create the discoverer: %s: %s", e.domain.to_string (), e.message);
|
||||||
}
|
}
|
||||||
|
@ -276,15 +277,14 @@ public class MediaInfo.Info : VPaned
|
||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
|
if (uri != null) {
|
||||||
|
File file = File.new_for_uri(uri);
|
||||||
|
|
||||||
// stop previous playback
|
// stop previous playback
|
||||||
pb.set_state (State.READY);
|
pb.set_state (State.READY);
|
||||||
album_art = null;
|
album_art = null;
|
||||||
drawing_area.queue_draw();
|
drawing_area.queue_draw();
|
||||||
|
|
||||||
if (uri != null) {
|
|
||||||
DiscovererInfo info;
|
|
||||||
File file = File.new_for_uri(uri);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileInfo finfo = file.query_info ("standard::*", FileQueryInfoFlags.NONE, null);
|
FileInfo finfo = file.query_info ("standard::*", FileQueryInfoFlags.NONE, null);
|
||||||
mime_type.set_text (finfo.get_attribute_string (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE));
|
mime_type.set_text (finfo.get_attribute_string (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE));
|
||||||
|
@ -293,7 +293,30 @@ public class MediaInfo.Info : VPaned
|
||||||
debug ("Failed to query file info from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
debug ("Failed to query file info from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
/* sync API */
|
||||||
try {
|
try {
|
||||||
|
on_uri_discovered (dc.discover_uri (uri), null);
|
||||||
|
} catch (Error e) {
|
||||||
|
debug ("Failed to extract metadata from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* async API */
|
||||||
|
stdout.printf ("Stop current discover\n");
|
||||||
|
dc.stop();
|
||||||
|
stdout.printf ("Enqueue uri\n");
|
||||||
|
dc.discover_uri_async (uri);
|
||||||
|
stdout.printf ("Start discover\n");
|
||||||
|
dc.start();
|
||||||
|
stdout.printf ("Started discover\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_uri_discovered (DiscovererInfo info, Error e)
|
||||||
|
{
|
||||||
|
string uri = info.get_uri();
|
||||||
GLib.List<DiscovererStreamInfo> l;
|
GLib.List<DiscovererStreamInfo> l;
|
||||||
DiscovererStreamInfo sinfo;
|
DiscovererStreamInfo sinfo;
|
||||||
//DiscovererVideoInfo vinfo;
|
//DiscovererVideoInfo vinfo;
|
||||||
|
@ -308,7 +331,14 @@ public class MediaInfo.Info : VPaned
|
||||||
Caps caps;
|
Caps caps;
|
||||||
Structure s;
|
Structure s;
|
||||||
|
|
||||||
info = dc.discover_uri (uri);
|
stdout.printf ("uri has been discovered\n");
|
||||||
|
|
||||||
|
if (e != null) {
|
||||||
|
debug ("Failed to extract metadata from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
||||||
|
}
|
||||||
|
if (info == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClockTime dur = info.get_duration ();
|
ClockTime dur = info.get_duration ();
|
||||||
str = "%u:%02u:%02u.%09u".printf (
|
str = "%u:%02u:%02u.%09u".printf (
|
||||||
|
@ -338,6 +368,7 @@ public class MediaInfo.Info : VPaned
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
sinfo = info.get_stream_info ();
|
sinfo = info.get_stream_info ();
|
||||||
|
if (sinfo != null) {
|
||||||
caps = sinfo.get_caps ();
|
caps = sinfo.get_caps ();
|
||||||
wikilink = wikilinks[caps.get_structure(0).get_name()];
|
wikilink = wikilinks[caps.get_structure(0).get_name()];
|
||||||
str = pb_utils_get_codec_description (caps);
|
str = pb_utils_get_codec_description (caps);
|
||||||
|
@ -346,6 +377,7 @@ public class MediaInfo.Info : VPaned
|
||||||
container_name.set_markup ("<a href=\"http://en.wikipedia.org/wiki/%s\">%s</a>".printf (wikilink, str));
|
container_name.set_markup ("<a href=\"http://en.wikipedia.org/wiki/%s\">%s</a>".printf (wikilink, str));
|
||||||
} else {
|
} else {
|
||||||
container_name.set_text (str);
|
container_name.set_text (str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset notebooks
|
// reset notebooks
|
||||||
|
@ -594,19 +626,10 @@ public class MediaInfo.Info : VPaned
|
||||||
|
|
||||||
//l = info.get_container_streams ();
|
//l = info.get_container_streams ();
|
||||||
|
|
||||||
} catch (Error e) {
|
|
||||||
debug ("Failed to extract metadata from %s: %s: %s", uri, e.domain.to_string (), e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// play file
|
// play file
|
||||||
cur_video_stream = cur_audio_stream = 0;
|
cur_video_stream = cur_audio_stream = 0;
|
||||||
((GLib.Object)pb).set_property ("uri", uri);
|
((GLib.Object)pb).set_property ("uri", uri);
|
||||||
pb.set_state (State.PLAYING);
|
pb.set_state (State.PLAYING);
|
||||||
|
|
||||||
res = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// signal handlers
|
// signal handlers
|
||||||
|
|
Loading…
Reference in a new issue