44d9ad742defcc6c70e5581a434b13af004fcc87
[profile/ivi/rygel.git] / src / rygel / rygel-xbmc-hacks.vala
1 /*
2  * Copyright (C) 2011 Nokia Corporation.
3  *
4  * Author: Jens Georg <jensg@openismus.com>
5  *
6  * This file is part of Rygel.
7  *
8  * Rygel is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Rygel is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22
23 using Soup;
24 using GUPnP;
25
26 internal class Rygel.XBMCHacks : ClientHacks {
27     // FIXME: Limit to known broken versions once this is fixed in XBMC as
28     // promised by developers.
29     private const string AGENT = ".*Platinum/.*|.*XBMC/.*";
30
31     public XBMCHacks () throws ClientHacksError, RegexError {
32         base (AGENT);
33     }
34
35     public XBMCHacks.for_action (ServiceAction action)
36                                  throws ClientHacksError {
37         unowned MessageHeaders headers = action.get_message ().request_headers;
38         this.for_headers (headers);
39     }
40
41     public XBMCHacks.for_headers (MessageHeaders headers)
42                                   throws ClientHacksError {
43         base (AGENT, headers);
44     }
45
46     public override void apply (MediaItem item) {
47         if (item.mime_type == "audio/mp4" ||
48             item.mime_type == "audio/3gpp" ||
49             item.mime_type == "audio/vnd.dlna.adts") {
50             item.mime_type = "audio/aac";
51         }
52     }
53 }