3 // based on FilterMPlayerVideo.cs
4 // Copyright (C) 2006 Alexander Macdonald <alex@alexmac.cc>
6 // Copyright (C) 2006 Bastien Nocera <hadess@hadess.net>
9 // Permission is hereby granted, free of charge, to any person obtaining a
10 // copy of this software and associated documentation files (the "Software"),
11 // to deal in the Software without restriction, including without limitation
12 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 // and/or sell copies of the Software, and to permit persons to whom the
14 // Software is furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
30 using System
.Diagnostics
;
31 using System
.Globalization
;
36 namespace Beagle
.Filters
{
38 public class FilterTotem
: Beagle
.Daemon
.Filter
{
40 static bool Debug
= false;
44 // Get the list of mime-types from the totem-video-indexer
46 SafeProcess pc
= new SafeProcess ();
47 pc
.Arguments
= new string [] { "totem-video-indexer", "--mimetype" }
;
48 pc
.RedirectStandardOutput
= true;
49 pc
.RedirectStandardError
= true;
53 } catch (SafeProcessException e
) {
55 Log
.Debug (e
.Message
);
60 StreamReader pout
= new StreamReader (pc
.StandardOutput
);
63 while ((str
= pout
.ReadLine ()) != null) {
64 AddSupportedFlavor (FilterFlavor
.NewFromMimeType (str
));
67 Log
.Debug ("Added {0} as a supported mime type for Totem video filter", str
);
76 protected override void DoPullProperties ()
78 SafeProcess pc
= new SafeProcess ();
79 pc
.Arguments
= new string [] { "totem-video-indexer", UriFu.UriToEscapedString (this.Uri) }
;
80 pc
.RedirectStandardOutput
= true;
81 pc
.RedirectStandardError
= true;
85 } catch (SafeProcessException e
) {
91 StreamReader pout
= new StreamReader (pc
.StandardOutput
);
94 while ((str
= pout
.ReadLine ()) != null) {
95 if (!str
.StartsWith ("TOTEM_INFO_"))
98 string[] tokens
= str
.Split ('=');
100 if (tokens
.Length
!= 2)
103 switch (tokens
[0]) {
106 case "TOTEM_INFO_TITLE":
107 AddProperty (Beagle
.Property
.New ("dc:title", tokens
[1]));
109 case "TOTEM_INFO_ARTIST":
110 AddProperty (Beagle
.Property
.New ("fixme:artist", tokens
[1]));
112 case "TOTEM_INFO_YEAR":
113 AddProperty (Beagle
.Property
.New ("fixme:year", tokens
[1]));
115 case "TOTEM_INFO_ALBUM":
116 AddProperty (Beagle
.Property
.New ("fixme:album", tokens
[1]));
118 case "TOTEM_INFO_DURATION":
119 //FIXME dc:extent or fixme:duration???
120 AddProperty (Beagle
.Property
.NewUnsearched ("dc:extent", Convert
.ToInt32 (tokens
[1])));
122 case "TOTEM_INFO_TRACK_NUMBER":
123 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:tracknumber", Convert
.ToInt32 (tokens
[1])));
125 case "TOTEM_INFO_HAS_VIDEO":
127 case "TOTEM_INFO_VIDEO_WIDTH":
128 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:video:width", Convert
.ToInt32 (tokens
[1])));
130 case "TOTEM_INFO_VIDEO_HEIGHT":
131 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:video:height", Convert
.ToInt32 (tokens
[1])));
133 case "TOTEM_INFO_VIDEO_CODEC":
134 AddProperty (Beagle
.Property
.NewKeyword ("fixme:video:codec", tokens
[1]));
136 case "TOTEM_INFO_FPS":
137 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:video:fps", Convert
.ToInt32 (tokens
[1])));
139 case "TOTEM_INFO_VIDEO_BITRATE":
140 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:video:bitrate", Convert
.ToInt32 (tokens
[1])));
142 case "TOTEM_INFO_HAS_AUDIO":
144 case "TOTEM_INFO_AUDIO_BITRATE":
145 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:audio:bitrate", Convert
.ToInt32 (tokens
[1])));
147 case "TOTEM_INFO_AUDIO_CODEC":
148 AddProperty (Beagle
.Property
.NewKeyword ("fixme:audio:codec", tokens
[1]));
150 case "TOTEM_INFO_AUDIO_SAMPLE_RATE":
151 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:audio:samplerate", Convert
.ToInt32 (tokens
[1])));
153 case "TOTEM_INFO_AUDIO_CHANNELS":
154 //FIXME this is very broken, needs fixing in Totem
157 // Mismatching version of Totem with more information, possibly