[mediatomb] Multiple fixes.
Jon Ciesla
limb at fedoraproject.org
Mon Sep 17 18:04:51 UTC 2012
commit e681ae44030f65057d31d71d6f2180b0496b3e0b
Author: Jon Ciesla <limburgher at gmail.com>
Date: Mon Sep 17 13:03:51 2012 -0500
Multiple fixes.
mediatomb-0.12.1-samsung_video_subtitles.patch | 186 ++++++++++++++++++++++++
mediatomb.spec | 101 +++++++++----
2 files changed, 254 insertions(+), 33 deletions(-)
---
diff --git a/mediatomb-0.12.1-samsung_video_subtitles.patch b/mediatomb-0.12.1-samsung_video_subtitles.patch
new file mode 100644
index 0000000..cc86de5
--- /dev/null
+++ b/mediatomb-0.12.1-samsung_video_subtitles.patch
@@ -0,0 +1,186 @@
+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__
diff --git a/mediatomb.spec b/mediatomb.spec
index 8275213..abe5739 100644
--- a/mediatomb.spec
+++ b/mediatomb.spec
@@ -1,7 +1,19 @@
+%global with_sysvinit 0
+%global with_systemd 0
+%global rhel6 0
+
+%if 0%{?rhel} > 0 && 0%{?rhel} <= 6
+%global with_sysvinit 1
+%global rhel6 1
+%endif
+%if 0%{?rhel} == 0 || 0%{?rhel} >= 7
+%global with_systemd 1
+%endif
+
Version: 0.12.1
Summary: UPnP AV MediaServer
Name: mediatomb
-Release: 17%{?dist}
+Release: 19%{?dist}
Summary: MediaTomb - UPnP AV Mediaserver for Linux
License: GPLv2
Group: Applications/Multimedia
@@ -27,29 +39,28 @@ Patch7: mediatomb-0.12.1.flacart.config.patch
Patch8: mediatomb-0.12.1.fixyoutube.patch
# Fix for gcc 4.7 build errors
Patch9: mediatomb-0.12.1.gcc47.patch
+# Add subtitles support: http://sourceforge.net/tracker/?func=detail&aid=3014026&group_id=129766&atid=715782
+Patch10: mediatomb-0.12.1-samsung_video_subtitles.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: automake
-BuildRequires: sqlite-devel, mysql-devel, libexif-devel, id3lib-devel, file-devel, js-devel, zlib-devel, taglib-devel flac-devel
+BuildRequires: sqlite-devel, mysql-devel, libexif-devel, id3lib-devel, file-devel, js-devel, zlib-devel, taglib-devel, flac-devel
BuildRequires: expat-devel, libcurl-devel
BuildRequires: libmp4v2-devel
BuildRequires: lastfmlib-devel
-%if 0%{?fedora} >= 13
-%else
-%if 0%{?fedora} >= 9
BuildRequires: xulrunner-devel
-%else
-BuildRequires: firefox-devel
-%endif
-%endif
Requires: mysql-libs, expat
Requires(pre): shadow-utils
-#Requires(post): /sbin/chkconfig
-#Requires(preun): /sbin/chkconfig
-#Requires(preun): /sbin/service
+%if %{with_sysvinit}
+Requires(post): /sbin/chkconfig
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+%endif
+%if %{with_systemd}
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
+%endif
%description
MediaTomb is an open source (GPL) UPnP MediaServer with a nice web user
@@ -64,42 +75,37 @@ be found on http://www.upnp.org/.
%patch0 -p0
%patch1 -p0
%patch2 -p0
+# these two and patch9 fail the build on RHEL6
+%if ! %{rhel6}
%patch3 -p1
%patch4 -p1
+%endif
%patch5 -p0
%patch6 -p0
%patch7 -p1
%patch8 -p3
+%if ! %{rhel6}
%patch9 -p0
+%endif
+%patch10 -p0
%build
# Patches affect configure.ac scripts, need to autoreconf
autoreconf
-# Fedora 13 on use system jsapi.h
-%if 0%{?fedora} >= 13
%configure --enable-inotify --enable-taglib --enable-libjs --enable-FLAC
-%else
-# Fedora 11 and 12 use xulrunner 1.9.1 for jsapi.h
-%if 0%{?fedora} >= 11
-%configure --enable-inotify --enable-taglib --enable-libjs --with-js-h=%{_includedir}/xulrunner-sdk-1.9.1/js
-%else
-# Fedora 10 uses xulrunner 1.9 for jsapi.h
-%if 0%{?fedora} = 10
-%configure --enable-inotify --enable-taglib --enable-libjs --with-js-h=%{_includedir}/xulrunner-sdk-1.9/js
-# Fedora 9 and below use system libjs
-%else
-%configure --enable-inotify --enable-taglib --enable-libjs
-%endif
-%endif
-%endif
%{__make} %{?_smp_mflags}
%install
%{__rm} -rf $RPM_BUILD_ROOT
+%if %{with_sysvinit}
+%{__install} -p -D -m0755 scripts/mediatomb-service-fedora $RPM_BUILD_ROOT%{_initrddir}/mediatomb
+%endif
+%if %{with_systemd}
%{__install} -p -D -m0755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/mediatomb.service
+%endif
%{__install} -p -D -m0644 config/mediatomb-conf-fedora $RPM_BUILD_ROOT%{_sysconfdir}/mediatomb.conf
make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
@@ -129,33 +135,45 @@ useradd -r -g mediatomb -d %{_sysconfdir}/mediatomb -s /sbin/nologin \
exit 0
%post
-#/sbin/chkconfig --add mediatomb
+%if %{with_sysvinit}
+/sbin/chkconfig --add mediatomb
+%endif
+%if %{with_systemd}
if [ $1 -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
+%endif
%preun
-#if [ $1 = 0 ]; then
-# /sbin/service mediatomb stop >/dev/null 2>&1
-# /sbin/chkconfig --del mediatomb
-#fi
+%if %{with_sysvinit}
+if [ $1 = 0 ]; then
+ /sbin/service mediatomb stop >/dev/null 2>&1
+ /sbin/chkconfig --del mediatomb
+fi
+%endif
+%if %{with_systemd}
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable mediatomb.service > /dev/null 2>&1 || :
/bin/systemctl stop mediatomb.service > /dev/null 2>&1 || :
fi
+%endif
%postun
+%if %{with_systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart mediatomb.service >/dev/null 2>&1 || :
fi
+%endif
+%if %{with_systemd}
+
%triggerun -- mediatomb < 0.1.12-16
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply httpd
@@ -166,6 +184,8 @@ fi
/sbin/chkconfig --del mediatomb >/dev/null 2>&1 || :
/bin/systemctl try-restart mediatomb.service >/dev/null 2>&1 || :
+%endif
+
%files
@@ -182,9 +202,24 @@ fi
%{_bindir}/mediatomb
%{_datadir}/%{name}/
%{_mandir}/man1/*
+%if %{with_sysvinit}
+%{_initrddir}/mediatomb
+%endif
+%if %{with_systemd}
%{_unitdir}/mediatomb.service
+%endif
%changelog
+* Sun Sep 16 2012 David Jaša <jasa.david at gmail.com> - 0.12.1-19
+- added patch to enable subtitles support
+- Committed by Jon Ciesla <limburgher at gmail.com>
+
+* Mon Sep 03 2012 David Jaša <djasa at redhat.com> - 0.12.1-18
+- cleaned up conditionals handling Fedora <= 13
+- added missing comma before flac-devel in BuildRequires
+- made .spec compatible with RHEL6 + EPEL
+- Committed by Jon Ciesla <limburgher at gmail.com>
+
* Fri Jul 20 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.12.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
More information about the scm-commits
mailing list