servicemp3: set http headers via service reference path string
authormx3L <mx3ldev@gmail.com>
Wed, 28 Oct 2015 20:45:11 +0000 (21:45 +0100)
committerErik Slagter <erik@openpli.org>
Sat, 31 Oct 2015 10:28:11 +0000 (11:28 +0100)
To be able to set http headers for every service, we allow
passing http headers in service reference path string:

http%3a//www.path.mp4#h1=v1&h2=v2:sname
h1,h2 are header names and v1,v2 are corresponding header values

Example of bouquet entry with http headers:
SERVICE 4097:0:0:0:0:0:0:0:0:0:http%3a//www.path.mp4#h1=v1&h2=v2:sname

(cherry picked from commit 836abd21450199d65688992ba2a06357e0fce040)
Signed-off-by: Erik Slagter <erik@openpli.org>

lib/service/servicemp3.cpp

index a6d2df5..71bdaad 100644 (file)
@@ -435,7 +435,17 @@ eServiceMP3::eServiceMP3(eServiceReference ref):
        m_state = stIdle;
        eDebug("[eServiceMP3] construct!");
 
-       const char *filename = m_ref.path.c_str();
+       const char *filename;
+       std::string filename_str;
+       size_t pos = m_ref.path.find('#');
+       if (pos != std::string::npos && m_ref.path.compare(0, 4, "http") == 0)
+       {
+               filename_str = m_ref.path.substr(0, pos);
+               filename = filename_str.c_str();
+               m_extra_headers = m_ref.path.substr(pos + 1);
+       }
+       else
+               filename = m_ref.path.c_str();
        const char *ext = strrchr(filename, '.');
        if (!ext)
                ext = filename + strlen(filename);
@@ -2211,7 +2221,7 @@ void eServiceMP3::playbinNotifySource(GObject *object, GParamSpec *unused, gpoin
                                std::string name, value;
                                size_t start = pos;
                                size_t len = std::string::npos;
-                               pos = _this->m_extra_headers.find(':', pos);
+                               pos = _this->m_extra_headers.find('=', pos);
                                if (pos != std::string::npos)
                                {
                                        len = pos - start;
@@ -2219,7 +2229,7 @@ void eServiceMP3::playbinNotifySource(GObject *object, GParamSpec *unused, gpoin
                                        name = _this->m_extra_headers.substr(start, len);
                                        start = pos;
                                        len = std::string::npos;
-                                       pos = _this->m_extra_headers.find('|', pos);
+                                       pos = _this->m_extra_headers.find('&', pos);
                                        if (pos != std::string::npos)
                                        {
                                                len = pos - start;