ccc7f468f6
UPnP/DLNA Plugin for Video Disk Recorder This Plugins extends the VDR with the possibility to act as an UPnP/DLNA Media Server (DMS). It will serve VDR's contents in the network to any UPnP-AV and DLNA capable devices. This still is an alpha version! WWW: http://upnp.vdr-developer.org/
183 lines
6.3 KiB
Groff
183 lines
6.3 KiB
Groff
--- a/database/object.cpp
|
|
+++ b/database/object.cpp
|
|
@@ -7,6 +7,7 @@
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
+#include <upnp/upnp.h>
|
|
#include <upnp/upnptools.h>
|
|
#include <vdr/recording.h>
|
|
#include <vector>
|
|
--- a/inc/util.h
|
|
+++ b/inc/util.h
|
|
@@ -20,6 +20,12 @@ extern "C" {
|
|
|
|
#include <libavformat/avformat.h>
|
|
#include <libavcodec/avcodec.h>
|
|
+
|
|
+#ifdef __FreeBSD__
|
|
+#define off64_t off_t
|
|
+#endif
|
|
+#include <netinet/in.h>
|
|
+
|
|
/**
|
|
* Compares two strings
|
|
*
|
|
@@ -147,5 +153,7 @@ public:
|
|
virtual eOSState ProcessKey(eKeys Key);
|
|
};
|
|
|
|
+const char *IPAddrP(struct sockaddr_storage &IPAddr, char *buf, size_t buflen);
|
|
+
|
|
#endif /* _UTIL_H */
|
|
|
|
--- a/inc/webserver.h
|
|
+++ b/inc/webserver.h
|
|
@@ -22,7 +22,9 @@ class cUPnPWebServer {
|
|
friend class cUPnPServer;
|
|
private:
|
|
static cUPnPWebServer *mInstance;
|
|
+#ifdef OLDUPNPAPI
|
|
static UpnpVirtualDirCallbacks mVirtualDirCallbacks;
|
|
+#endif
|
|
const char* mRootdir;
|
|
cUPnPWebServer(const char* root = "/");
|
|
protected:
|
|
--- a/misc/util.cpp
|
|
+++ b/misc/util.cpp
|
|
@@ -532,4 +567,16 @@ IXML_Element* ixmlAddFilteredProperty(cS
|
|
return ixmlAddProperty(document, node, upnpproperty, value);
|
|
else
|
|
return NULL;
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
+
|
|
+const char *IPAddrP(struct sockaddr_storage &IPAddr, char *buf, size_t buflen){
|
|
+ *buf = '\0';
|
|
+ if (IPAddr.ss_family == AF_INET) {
|
|
+ inet_ntop(AF_INET, (void *)&((struct sockaddr_in *)&IPAddr)->sin_addr, buf, buflen);
|
|
+ return buf;
|
|
+ } else if (IPAddr.ss_family == AF_INET6) {
|
|
+ inet_ntop(AF_INET6, (void *)&((struct sockaddr_in6 *)&IPAddr)->sin6_addr, buf, buflen);
|
|
+ return buf;
|
|
+ }
|
|
+ return "??";
|
|
+}
|
|
--- a/server/webserver.cpp
|
|
+++ b/server/webserver.cpp
|
|
@@ -100,6 +100,7 @@ cUPnPWebServer::~cUPnPWebServer(){}
|
|
|
|
cUPnPWebServer* cUPnPWebServer::mInstance = NULL;
|
|
|
|
+#ifdef OLDUPNPAPI
|
|
UpnpVirtualDirCallbacks cUPnPWebServer::mVirtualDirCallbacks = {
|
|
cUPnPWebServer::getInfo,
|
|
cUPnPWebServer::open,
|
|
@@ -108,6 +109,7 @@ UpnpVirtualDirCallbacks cUPnPWebServer::
|
|
cUPnPWebServer::seek,
|
|
cUPnPWebServer::close
|
|
};
|
|
+#endif
|
|
|
|
bool cUPnPWebServer::init(){
|
|
MESSAGE(VERBOSE_WEBSERVER, "Initialize callbacks for virtual directories.");
|
|
@@ -118,7 +120,16 @@ bool cUPnPWebServer::init(){
|
|
}
|
|
MESSAGE(VERBOSE_WEBSERVER, "Setting up callbacks");
|
|
|
|
+#ifdef OLDUPNPAPI
|
|
if(UpnpSetVirtualDirCallbacks(&cUPnPWebServer::mVirtualDirCallbacks) == UPNP_E_INVALID_ARGUMENT){
|
|
+#else
|
|
+ if(UpnpVirtualDir_set_GetInfoCallback(&cUPnPWebServer::getInfo) != UPNP_E_SUCCESS ||
|
|
+ UpnpVirtualDir_set_OpenCallback(&cUPnPWebServer::open) != UPNP_E_SUCCESS ||
|
|
+ UpnpVirtualDir_set_ReadCallback(&cUPnPWebServer::read) != UPNP_E_SUCCESS ||
|
|
+ UpnpVirtualDir_set_WriteCallback(&cUPnPWebServer::write) != UPNP_E_SUCCESS ||
|
|
+ UpnpVirtualDir_set_SeekCallback(&cUPnPWebServer::seek) != UPNP_E_SUCCESS ||
|
|
+ UpnpVirtualDir_set_CloseCallback(&cUPnPWebServer::close) != UPNP_E_SUCCESS){
|
|
+#endif
|
|
ERROR("The virtual directory callbacks are invalid.");
|
|
return false;
|
|
}
|
|
--- a/upnp/connectionmanager.cpp
|
|
+++ b/upnp/connectionmanager.cpp
|
|
@@ -7,6 +7,8 @@
|
|
|
|
#include <string.h>
|
|
#include <upnp/ixml.h>
|
|
+/* XXX */
|
|
+#define UPNP_HAVE_TOOLS 1
|
|
#include <upnp/upnptools.h>
|
|
#include <vdr/tools.h>
|
|
#include "upnp/connectionmanager.h"
|
|
@@ -70,7 +72,8 @@ int cConnectionManager::execute(Upnp_Act
|
|
}
|
|
|
|
int cConnectionManager::getProtocolInfo(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CMS, "Protocol info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CMS, "Protocol info requested by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
cString Result = cString::sprintf(
|
|
"<u:%sResponse xmlns:u=\"%s\"> \
|
|
<Source>%s</Source> \
|
|
@@ -87,7 +90,8 @@ int cConnectionManager::getProtocolInfo(
|
|
}
|
|
|
|
int cConnectionManager::getCurrentConnectionIDs(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CMS, "Current connection IDs requested by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CMS, "Current connection IDs requested by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
cString Result;
|
|
const char* IDs = this->getConnectionIDsCVS();
|
|
if(!IDs){
|
|
@@ -109,7 +113,8 @@ int cConnectionManager::getCurrentConnec
|
|
}
|
|
|
|
int cConnectionManager::getCurrentConnectionInfo(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CMS, "Current connection info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CMS, "Current connection info requested by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
int ConnectionID;
|
|
|
|
if(this->parseIntegerValue(Request->ActionRequest, "ConnectionID", &ConnectionID) != 0){
|
|
@@ -156,7 +161,8 @@ int cConnectionManager::getCurrentConnec
|
|
}
|
|
|
|
int cConnectionManager::prepareForConnection(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CMS, "Request for a new connection by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CMS, "Request for a new connection by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
//char* Result = NULL;
|
|
char* RemoteProtocolInfo = NULL;
|
|
char* PeerConnectionManager = NULL;
|
|
@@ -198,7 +204,8 @@ int cConnectionManager::prepareForConnec
|
|
}
|
|
|
|
int cConnectionManager::connectionComplete(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CMS, "Request for closing an open connection by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CMS, "Request for closing an open connection by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
//char* Result = NULL;
|
|
int ConnectionID;
|
|
|
|
--- a/upnp/contentdirectory.cpp
|
|
+++ b/upnp/contentdirectory.cpp
|
|
@@ -6,6 +6,8 @@
|
|
*/
|
|
|
|
#include <upnp/ixml.h>
|
|
+/* XXX */
|
|
+#define UPNP_HAVE_TOOLS 1
|
|
#include <upnp/upnptools.h>
|
|
#include "upnp/contentdirectory.h"
|
|
#include "../common.h"
|
|
@@ -84,7 +90,8 @@ int cContentDirectory::execute(Upnp_Acti
|
|
|
|
|
|
int cContentDirectory::browse(Upnp_Action_Request* Request){
|
|
- MESSAGE(VERBOSE_CDS, "Browse requested by %s.", inet_ntoa(Request->CtrlPtIPAddr));
|
|
+ char buf[64];
|
|
+ MESSAGE(VERBOSE_CDS, "Browse requested by %s.", IPAddrP(Request->CtrlPtIPAddr, buf, sizeof buf));
|
|
|
|
char* ObjectID = NULL;
|
|
if(this->parseStringValue(Request->ActionRequest, "ObjectID", &ObjectID)){
|