Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
patch for mediatomb subtitles and samsung tv
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
ebray187
Tux's lil' helper
Tux's lil' helper


Joined: 02 Mar 2005
Posts: 121
Location: Al otro lado de la pantalla

PostPosted: Sun May 18, 2014 3:41 am    Post subject: patch for mediatomb subtitles and samsung tv Reply with quote

I just want to post this so it can help people with the same problem and for future references. Its a nasty solution but works.
For solving the issue with samsung tvs no reading the srt subtitles thru mediatomb just use this patch (Downloaded from here):

samsung.patch:

Index: src/config_manager.cc
===================================================================
--- src/config_manager.cc   (revision 2102)
+++ src/config_manager.cc   (working copy)
@@ -1433,6 +1433,14 @@
     NEW_BOOL_OPTION(temp == "yes" ? true : false);
     SET_BOOL_OPTION(CFG_SERVER_EXTEND_PROTOCOLINFO_CL_HACK);
 */
+    temp = getOption(_("/server/protocolInfo/attribute::samsung-hack"),
+                     _(DEFAULT_EXTEND_PROTOCOLINFO_SM_HACK));
+    if (!validateYesNo(temp))
+        throw _Exception(_("Error in config file: samsung-hack attribute of the "
+                          "protocolInfo tag must be either \"yes\" or \"no\""));
+
+    NEW_BOOL_OPTION(temp == "yes" ? true : false);
+    SET_BOOL_OPTION(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK);
 #endif
 
     temp = getOption(_("/server/pc-directory/attribute::upnp-hide"),
Index: src/common.h
===================================================================
--- src/common.h   (revision 2102)
+++ src/common.h   (working copy)
@@ -196,6 +196,8 @@
 #define XML_DC_NAMESPACE                "http://purl.org/dc/elements/1.1/"
 #define XML_UPNP_NAMESPACE_ATTR         "xmlns:upnp"
 #define XML_UPNP_NAMESPACE              "urn:schemas-upnp-org:metadata-1-0/upnp/"
+#define XML_SEC_NAMESPACE_ATTR          "xmlns:sec"
+#define XML_SEC_NAMESPACE               "http://www.sec.co.kr/"
 
 // default values
 #define DEFAULT_INTERNAL_CHARSET        "UTF-8"
@@ -243,6 +245,7 @@
 #define DEFAULT_LAYOUT_TYPE             "builtin"
 #define DEFAULT_EXTEND_PROTOCOLINFO     NO
 //#define DEFAULT_EXTEND_PROTOCOLINFO_CL_HACK     NO
+#define DEFAULT_EXTEND_PROTOCOLINFO_SM_HACK     NO
 #define DEFAULT_HIDE_PC_DIRECTORY       NO
 #ifdef YOUTUBE
     #define YOUTUBE_PAGESIZE            106496
Index: src/config_manager.h
===================================================================
--- src/config_manager.h   (revision 2102)
+++ src/config_manager.h   (working copy)
@@ -73,6 +73,7 @@
     CFG_SERVER_EXTEND_PROTOCOLINFO_CL_HACK,
 #endif
 #endif//EXTEND_PROTOCOLINFO
+    CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK,
     CFG_SERVER_HIDE_PC_DIRECTORY,
     CFG_SERVER_BOOKMARK_FILE,
     CFG_SERVER_CUSTOM_HTTP_HEADERS,
Index: src/cds_resource_manager.cc
===================================================================
--- src/cds_resource_manager.cc   (revision 2102)
+++ src/cds_resource_manager.cc   (working copy)
@@ -482,6 +482,14 @@
         res_attrs->put(MetadataHandler::getResAttrName(R_PROTOCOLINFO),
                        protocolInfo);
 
+        if (config->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK))
+        {
+            if (mimeType.startsWith(_("video")))
+            {
+                element->appendElementChild(UpnpXML_DIDLRenderCaptionInfo(url));
+            }
+        }
+
         log_debug("extended protocolInfo: %s\n", protocolInfo.c_str());
         }
 #endif
Index: src/file_request_handler.cc
===================================================================
--- src/file_request_handler.cc   (revision 2102)
+++ src/file_request_handler.cc   (working copy)
@@ -305,6 +305,53 @@
                     /// header, since chunked encoding may be active and we do not
                     /// know that here
                 }
+
+#ifdef EXTEND_PROTOCOLINFO
+                    Ref<ConfigManager> cfg = ConfigManager::getInstance();
+                    if (cfg->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK))
+                    {
+                        if (item->getMimeType().startsWith(_("video"))) {
+                            // Look for subtitle file and returns it's URL
+                            // in CaptionInfo.sec response header.
+                            // To be more compliant with original Samsung
+                            // server we should check for getCaptionInfo.sec: 1
+                            // request header.
+                            Ref<Array<StringBase> > subexts(new Array<StringBase>());
+                            subexts->append(_(".srt"));
+                            subexts->append(_(".ssa"));
+                            subexts->append(_(".smi"));
+                            subexts->append(_(".sub"));
+
+                            String bfilepath = path.substring(0, path.rindex('.'));
+                            String validext;
+                            for (int i=0; i<subexts->size(); i++) {
+                                String ext = subexts->get(i);
+
+                                String fpath = bfilepath + ext;
+                                if (access(fpath.c_str(), R_OK) == 0)
+                                {
+                                    validext = ext;
+                                    break;
+                                }
+                            }
+
+
+                            if (validext.length() > 0)
+                            {
+                                String burlpath = _(filename);
+                                burlpath = burlpath.substring(0, burlpath.rindex('.'));
+                                Ref<Server> server = Server::getInstance();
+                                String url = _("http://")
+                                    + server->getIP() + ":" + server->getPort()
+                                    + burlpath + validext;
+
+                                if (string_ok(header))
+                                    header = header + _("\r\n");
+                                header = header + "CaptionInfo.sec: " + url;
+                            }
+                        }
+#endif
+                    }
             }
 
         if (!string_ok(mimeType))
Index: src/upnp_cds_actions.cc
===================================================================
--- src/upnp_cds_actions.cc   (revision 2102)
+++ src/upnp_cds_actions.cc   (working copy)
@@ -106,6 +106,14 @@
 
     Ref<ConfigManager> cfg = ConfigManager::getInstance();
 
+#ifdef EXTEND_PROTOCOLINFO
+    if (cfg->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK))
+    {
+        didl_lite->setAttribute(_(XML_SEC_NAMESPACE_ATTR),
+                                _(XML_SEC_NAMESPACE));
+    }
+#endif
+
     for(int i = 0; i < arr->size(); i++)
     {
         Ref<CdsObject> obj = arr->get(i);
Index: src/upnp_xml.cc
===================================================================
--- src/upnp_xml.cc   (revision 2102)
+++ src/upnp_xml.cc   (working copy)
@@ -381,3 +381,20 @@
 
     return res;
 }
+
+Ref<Element> UpnpXML_DIDLRenderCaptionInfo(String URL) {
+    Ref<Element> cap(new Element(_("sec:CaptionInfoEx")));
+
+    // Samsung DLNA clients don't follow this URL and
+    // obtain subtitle location from video HTTP headers.
+    // We don't need to know here what the subtitle type
+    // is and even if there is a subtitle.
+    // This tag seems to be only a hint for Samsung devices,
+    // though it's necessary.
+   
+    int endp = URL.rindex('.');   
+    cap->setText(URL.substring(0, endp) + ".srt");
+    cap->setAttribute(_("sec:type"), _("srt"));
+   
+    return cap;
+}
Index: src/upnp_xml.h
===================================================================
--- src/upnp_xml.h   (revision 2102)
+++ src/upnp_xml.h   (working copy)
@@ -76,4 +76,8 @@
 /// \param URL download location of the item (will be child element of the <res> tag)
 /// \param attributes Dictionary containing the <res> tag attributes (like resolution, etc.)
 zmm::Ref<mxml::Element> UpnpXML_DIDLRenderResource(zmm::String URL, zmm::Ref<Dictionary> attributes);
+
+/// \brief Renders a subtitle resource tag (Samsung proprietary extension)
+/// \param URL download location of the video item
+zmm::Ref<mxml::Element> UpnpXML_DIDLRenderCaptionInfo(zmm::String URL);
 #endif // __UPNP_XML_H__


Just add to the ebuild the epatch line with the location to the file:
Code:
# nano /usr/portage/net-misc/mediatomb/mediatomb-0.12.1-r8.ebuild
[...]
src_prepare() {
epatch "${FILESDIR}"/samsung.patch


Then digest and emerge:
Code:
#ebuild mediatomb-version digest
#emerge mediatomb


Finally set up acording your config.xml. The trick is in this sections:

Code:
    <protocolInfo extend="yes" samsung-hack="yes"/>

Code:
    <custom-http-headers>
      <add header="transferMode.dlna.org: Streaming"/>
      <add header="contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"/>
      <add header="X-User-Agent: redsonic"/>
    </custom-http-headers>


Then restart mediatomb. In my case:
Code:
# /etc/init.d/mediatomb restart

And all works (for me at least). Remember the file names must be the same: movieName.mkv, movieName.srt

Saludos
_________________
# emerge -C world >> 9/8
A flower?!
Back to top
View user's profile Send private message
Maitreya
Guru
Guru


Joined: 11 Jan 2006
Posts: 441

PostPosted: Tue May 20, 2014 10:25 pm    Post subject: Reply with quote

Thank you! I will try this.


I have looked into the mediatomb ebuild. It utilizes "epatch_user". So placing the patch in "/etc/portage/patches/net-misc/mediatomb" will be enough instead of adjusting the ebuild.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum