~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to src/sopcast_content_handler.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
9
9
    
10
 
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
 
10
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
                            Leonhard Wimmer <leo@mediatomb.cc>
13
13
    
24
24
    version 2 along with MediaTomb; if not, write to the Free Software
25
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
26
    
27
 
    $Id: sopcast_content_handler.cc 1698 2008-02-23 20:48:30Z lww $
 
27
    $Id: sopcast_content_handler.cc 2010 2009-01-11 19:10:43Z lww $
28
28
*/
29
29
 
30
30
/// \file sopcast_content_handler.cc
55
55
 
56
56
    channels = service;
57
57
 
58
 
    group_count = channels->elementChildCount();
 
58
    group_count = channels->childCount();
59
59
    if (group_count < 1)
60
60
        return false;
61
61
 
74
74
{
75
75
#define DATE_BUF_LEN 12
76
76
    String temp;
77
 
    time_t epoch;
78
 
    struct tm t;
79
 
    char datebuf[DATE_BUF_LEN];
80
77
    struct timespec ts;
81
 
    String current_group_name;
82
78
 
83
79
    while (current_group_node_index < group_count)
84
80
    {
85
81
        if (current_group == nil)
86
82
        {
87
 
            current_group = channels->getElementChild(current_group_node_index);
 
83
            Ref<Node> n = channels->getChild(current_group_node_index);
88
84
            current_group_node_index++;
 
85
 
 
86
            if (n == nil)
 
87
                continue;
 
88
 
 
89
            if (n->getType() != mxml_node_element)
 
90
                continue;
 
91
 
 
92
            current_group = RefCast(n, Element);
89
93
            channel_count = current_group->childCount();
90
94
 
91
95
            if ((current_group->getName() != "group") ||
97
101
            }
98
102
            else
99
103
            {
100
 
                current_group_name = current_group->getAttribute(_("en"));
 
104
                current_group_name = current_group->getText();
101
105
                if (!string_ok(current_group_name))
102
 
                    curreng_group_name = _("Unknown");
 
106
                {
 
107
                    current_group_name = current_group->getAttribute(_("en"));
 
108
                    if (!string_ok(current_group_name))
 
109
                        current_group_name = _("Unknown");
 
110
                }
103
111
            }
104
112
 
105
113
            current_channel_index = 0;
113
121
 
114
122
        while (current_channel_index < channel_count)
115
123
        {
116
 
            Ref<Element> channel = current_group->getElementChild(current_channel_index);
 
124
            Ref<Node> n = current_group->getChild(current_channel_index);
117
125
            current_channel_index++;
 
126
 
 
127
            if ((n == nil) || (n->getType() != mxml_node_element))
 
128
                continue;
 
129
 
 
130
            Ref<Element> channel = RefCast(n, Element);
 
131
 
118
132
            if (channel->getName() != "channel")
119
133
                continue;
120
134
 
121
135
            Ref<CdsItemExternalURL> item(new CdsItemExternalURL());
122
136
            Ref<CdsResource> resource(new CdsResource(CH_DEFAULT));
123
 
            resource->addParameter(_(ONLINE_SERVICE_AUX_ID),
124
 
                    String::from(OS_SopCast));
 
137
            item->addResource(resource);
125
138
 
126
139
            item->setAuxData(_(ONLINE_SERVICE_AUX_ID),
127
140
                    String::from(OS_SopCast));
128
141
 
129
 
            item->setAuxData(_(SOPCAST_GROUP_NAME), current_group_name);
 
142
            item->setAuxData(_(SOPCAST_AUXDATA_GROUP), current_group_name);
130
143
 
131
144
            temp = channel->getAttribute(_("id"));
132
145
            if (!string_ok(temp))
146
159
            }
147
160
            
148
161
            // I wish they had a mimetype setting
149
 
            String mt = extension_mimetype_map->get(temp);
 
162
            //String mt = extension_mimetype_map->get(temp);
 
163
            String mt;
150
164
            // map was empty, we have to do construct the mimetype ourselves
151
165
            if (!string_ok(mt))
152
166
            {
153
167
                if (temp == "wmv")
154
 
                    mt = _("video/x-ms-wmv");
 
168
                    mt = _("video/sopcast-x-ms-wmv");
155
169
                else if (temp == "mp3")
156
 
                    mt = _("audio/mpeg");
 
170
                    mt = _("audio/sopcast-mpeg");
157
171
                else if (temp == "wma")
158
 
                    mt = _("audio/x-ms-wma");
 
172
                    mt = _("audio/sopcast-x-ms-wma");
159
173
                else
160
174
                {
161
175
                    log_warning("Could not determine mimetype for SopCast channel (stream_type: %s)\n", temp.c_str());
162
 
                    mt = _("application/octet-stream");
 
176
                    mt = _("application/sopcast-stream");
163
177
                }
164
178
            }
165
179
            resource->addAttribute(MetadataHandler::getResAttrName(R_PROTOCOLINFO),
166
 
                    renderProtocolInfo(mt));
167
 
            item->addResource(resource);
 
180
                    renderProtocolInfo(mt, _(SOPCAST_PROTOCOL)));
 
181
            item->setMimeType(mt);
168
182
           
169
183
            Ref<Element> tmp_el = channel->getChildByName(_("sop_address"));
170
184
            if (tmp_el == nil)