root/mediatomb/sources/samsung_video_subtitles.patch
Revision 4, 7.6 kB (checked in by ixs, 13 years ago) |
---|
-
src/config_manager.cc
old new 1433 1433 NEW_BOOL_OPTION(temp == "yes" ? true : false); 1434 1434 SET_BOOL_OPTION(CFG_SERVER_EXTEND_PROTOCOLINFO_CL_HACK); 1435 1435 */ 1436 temp = getOption(_("/server/protocolInfo/attribute::samsung-hack"), 1437 _(DEFAULT_EXTEND_PROTOCOLINFO_SM_HACK)); 1438 if (!validateYesNo(temp)) 1439 throw _Exception(_("Error in config file: samsung-hack attribute of the " 1440 "protocolInfo tag must be either \"yes\" or \"no\"")); 1441 1442 NEW_BOOL_OPTION(temp == "yes" ? true : false); 1443 SET_BOOL_OPTION(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK); 1436 1444 #endif 1437 1445 1438 1446 temp = getOption(_("/server/pc-directory/attribute::upnp-hide"), -
src/common.h
old new 196 196 #define XML_DC_NAMESPACE "http://purl.org/dc/elements/1.1/" 197 197 #define XML_UPNP_NAMESPACE_ATTR "xmlns:upnp" 198 198 #define XML_UPNP_NAMESPACE "urn:schemas-upnp-org:metadata-1-0/upnp/" 199 #define XML_SEC_NAMESPACE_ATTR "xmlns:sec" 200 #define XML_SEC_NAMESPACE "http://www.sec.co.kr/" 199 201 200 202 // default values 201 203 #define DEFAULT_INTERNAL_CHARSET "UTF-8" … … 243 245 #define DEFAULT_LAYOUT_TYPE "builtin" 244 246 #define DEFAULT_EXTEND_PROTOCOLINFO NO 245 247 //#define DEFAULT_EXTEND_PROTOCOLINFO_CL_HACK NO 248 #define DEFAULT_EXTEND_PROTOCOLINFO_SM_HACK NO 246 249 #define DEFAULT_HIDE_PC_DIRECTORY NO 247 250 #ifdef YOUTUBE 248 251 #define YOUTUBE_PAGESIZE 106496 -
src/config_manager.h
old new 73 73 CFG_SERVER_EXTEND_PROTOCOLINFO_CL_HACK, 74 74 #endif 75 75 #endif//EXTEND_PROTOCOLINFO 76 CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK, 76 77 CFG_SERVER_HIDE_PC_DIRECTORY, 77 78 CFG_SERVER_BOOKMARK_FILE, 78 79 CFG_SERVER_CUSTOM_HTTP_HEADERS, -
src/cds_resource_manager.cc
old new 482 482 res_attrs->put(MetadataHandler::getResAttrName(R_PROTOCOLINFO), 483 483 protocolInfo); 484 484 485 if (config->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK)) 486 { 487 if (mimeType.startsWith(_("video"))) 488 { 489 element->appendElementChild(UpnpXML_DIDLRenderCaptionInfo(url)); 490 } 491 } 492 485 493 log_debug("extended protocolInfo: %s\n", protocolInfo.c_str()); 486 494 } 487 495 #endif -
src/file_request_handler.cc
old new 305 305 /// header, since chunked encoding may be active and we do not 306 306 /// know that here 307 307 } 308 309 #ifdef EXTEND_PROTOCOLINFO 310 Ref<ConfigManager> cfg = ConfigManager::getInstance(); 311 if (cfg->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK)) 312 { 313 if (item->getMimeType().startsWith(_("video"))) { 314 // Look for subtitle file and returns it's URL 315 // in CaptionInfo.sec response header. 316 // To be more compliant with original Samsung 317 // server we should check for getCaptionInfo.sec: 1 318 // request header. 319 Ref<Array<StringBase> > subexts(new Array<StringBase>()); 320 subexts->append(_(".srt")); 321 subexts->append(_(".ssa")); 322 subexts->append(_(".smi")); 323 subexts->append(_(".sub")); 324 325 String bfilepath = path.substring(0, path.rindex('.')); 326 String validext; 327 for (int i=0; i<subexts->size(); i++) { 328 String ext = subexts->get(i); 329 330 String fpath = bfilepath + ext; 331 if (access(fpath.c_str(), R_OK) == 0) 332 { 333 validext = ext; 334 break; 335 } 336 } 337 338 339 if (validext.length() > 0) 340 { 341 String burlpath = _(filename); 342 burlpath = burlpath.substring(0, burlpath.rindex('.')); 343 Ref<Server> server = Server::getInstance(); 344 String url = _("http://") 345 + server->getIP() + ":" + server->getPort() 346 + burlpath + validext; 347 348 if (string_ok(header)) 349 header = header + _("\r\n"); 350 header = header + "CaptionInfo.sec: " + url; 351 } 352 } 353 #endif 354 } 308 355 } 309 356 310 357 if (!string_ok(mimeType)) -
src/upnp_cds_actions.cc
old new 106 106 107 107 Ref<ConfigManager> cfg = ConfigManager::getInstance(); 108 108 109 #ifdef EXTEND_PROTOCOLINFO 110 if (cfg->getBoolOption(CFG_SERVER_EXTEND_PROTOCOLINFO_SM_HACK)) 111 { 112 didl_lite->setAttribute(_(XML_SEC_NAMESPACE_ATTR), 113 _(XML_SEC_NAMESPACE)); 114 } 115 #endif 116 109 117 for(int i = 0; i < arr->size(); i++) 110 118 { 111 119 Ref<CdsObject> obj = arr->get(i); -
src/upnp_xml.cc
old new 381 381 382 382 return res; 383 383 } 384 385 Ref<Element> UpnpXML_DIDLRenderCaptionInfo(String URL) { 386 Ref<Element> cap(new Element(_("sec:CaptionInfoEx"))); 387 388 // Samsung DLNA clients don't follow this URL and 389 // obtain subtitle location from video HTTP headers. 390 // We don't need to know here what the subtitle type 391 // is and even if there is a subtitle. 392 // This tag seems to be only a hint for Samsung devices, 393 // though it's necessary. 394 395 int endp = URL.rindex('.'); 396 cap->setText(URL.substring(0, endp) + ".srt"); 397 cap->setAttribute(_("sec:type"), _("srt")); 398 399 return cap; 400 } -
src/upnp_xml.h
old new 76 76 /// \param URL download location of the item (will be child element of the <res> tag) 77 77 /// \param attributes Dictionary containing the <res> tag attributes (like resolution, etc.) 78 78 zmm::Ref<mxml::Element> UpnpXML_DIDLRenderResource(zmm::String URL, zmm::Ref<Dictionary> attributes); 79 80 /// \brief Renders a subtitle resource tag (Samsung proprietary extension) 81 /// \param URL download location of the video item 82 zmm::Ref<mxml::Element> UpnpXML_DIDLRenderCaptionInfo(zmm::String URL); 79 83 #endif // __UPNP_XML_H__
Note: See TracBrowser for help on using the browser.