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
@ -252,6 +252,7 @@ public class MediaInfo.Info : VPaned
|
||||
// set up the gstreamer components
|
||||
try {
|
||||
dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
|
||||
dc.discovered.connect (on_uri_discovered);
|
||||
} catch (Error e) {
|
||||
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;
|
||||
|
||||
if (uri != null) {
|
||||
File file = File.new_for_uri(uri);
|
||||
|
||||
// stop previous playback
|
||||
pb.set_state (State.READY);
|
||||
album_art = null;
|
||||
drawing_area.queue_draw();
|
||||
|
||||
if (uri != null) {
|
||||
DiscovererInfo info;
|
||||
File file = File.new_for_uri(uri);
|
||||
|
||||
try {
|
||||
FileInfo finfo = file.query_info ("standard::*", FileQueryInfoFlags.NONE, null);
|
||||
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);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
/* sync API */
|
||||
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;
|
||||
DiscovererStreamInfo sinfo;
|
||||
//DiscovererVideoInfo vinfo;
|
||||
@ -308,7 +331,14 @@ public class MediaInfo.Info : VPaned
|
||||
Caps caps;
|
||||
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 ();
|
||||
str = "%u:%02u:%02u.%09u".printf (
|
||||
@ -338,6 +368,7 @@ public class MediaInfo.Info : VPaned
|
||||
}
|
||||
*/
|
||||
sinfo = info.get_stream_info ();
|
||||
if (sinfo != null) {
|
||||
caps = sinfo.get_caps ();
|
||||
wikilink = wikilinks[caps.get_structure(0).get_name()];
|
||||
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));
|
||||
} else {
|
||||
container_name.set_text (str);
|
||||
}
|
||||
}
|
||||
|
||||
// reset notebooks
|
||||
@ -594,19 +626,10 @@ public class MediaInfo.Info : VPaned
|
||||
|
||||
//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
|
||||
cur_video_stream = cur_audio_stream = 0;
|
||||
((GLib.Object)pb).set_property ("uri", uri);
|
||||
pb.set_state (State.PLAYING);
|
||||
|
||||
res = true;
|
||||
}
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
// signal handlers
|
||||
|
Loading…
x
Reference in New Issue
Block a user