Project

General

Profile

Feature #923 ยป 0001-updated-to-upnp-1.8-API.patch

ensc, 03/30/2012 12:42 PM

View differences:

database/object.cpp
#include "database.h"
#include <vdr/tools.h>
#include <upnp/ixml.h>
#include <upnp/upnp.h>
#include "metadata.h"
#include "object.h"
#include "../common.h"
inc/server.h
*/
bool init(void);
bool uninit(void);
static int upnpActionCallback(Upnp_EventType eventtype, void *event, void *cookie);
static int upnpActionCallback(Upnp_EventType eventtype, void const *event, void *cookie);
bool mIsRunning;
bool mIsEnabled;
sockaddr_in* mServerAddr;
inc/upnp-compat.h
/* --*- c -*--
* Copyright (C) 2012 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 and/or 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HH_VDR_UPNP_UPNP_COMPAT_HH
#define HH_VDR_UPNP_UPNP_COMPAT_HH
#include <upnp/upnpconfig.h>
#include <upnp/upnp.h>
#if UPNP_VERSION >= 10800
struct UpnpVirtualDirCallbacks
{
VDCallback_GetInfo get_info;
VDCallback_Open open;
VDCallback_Read read;
VDCallback_Write write;
VDCallback_Seek seek;
VDCallback_Close close;
};
struct Upnp_Subscription_Request
{
char *ServiceId;
char *UDN;
Upnp_SID Sid;
};
struct Upnp_Action_Request
{
int ErrCode;
int Socket;
char ErrStr[LINE_SIZE];
char ActionName[NAME_SIZE];
char DevUDN[NAME_SIZE];
char ServiceID[NAME_SIZE];
IXML_Document *ActionRequest;
IXML_Document *ActionResult;
struct in_addr CtrlPtIPAddr;
IXML_Document *SoapHeader;
};
inline static int UpnpSetVirtualDirCallbacks(struct UpnpVirtualDirCallbacks const *cbs)
{
int rc = 0;
rc = UpnpVirtualDir_set_GetInfoCallback(cbs->get_info);
if (rc != UPNP_E_SUCCESS)
goto out;
rc = UpnpVirtualDir_set_OpenCallback(cbs->open);
if (rc != UPNP_E_SUCCESS)
goto out;
rc = UpnpVirtualDir_set_ReadCallback(cbs->read);
if (rc != UPNP_E_SUCCESS)
goto out;
rc = UpnpVirtualDir_set_WriteCallback(cbs->write);
if (rc != UPNP_E_SUCCESS)
goto out;
rc = UpnpVirtualDir_set_SeekCallback(cbs->seek);
if (rc != UPNP_E_SUCCESS)
goto out;
rc = UpnpVirtualDir_set_CloseCallback(cbs->close);
if (rc != UPNP_E_SUCCESS)
goto out;
out:
if (rc != 0) {
UpnpVirtualDir_set_CloseCallback(NULL);
UpnpVirtualDir_set_SeekCallback(NULL);
UpnpVirtualDir_set_WriteCallback(NULL);
UpnpVirtualDir_set_ReadCallback(NULL);
UpnpVirtualDir_set_OpenCallback(NULL);
UpnpVirtualDir_set_GetInfoCallback(NULL);
}
return rc;
}
#endif
#endif /* HH_VDR_UPNP_UPNP_COMPAT_HH */
inc/upnp/service.h
#include <upnp/upnp.h>
#include "upnp-compat.h"
/**
* UPnP Service interface
*
inc/webserver.h
#include "../common.h"
#include <upnp/upnp.h>
#include "upnp-compat.h"
/**
* The internal webserver
*
......
* @param filename The filename of which the information is gathered
* @param info The File_Info structure with the data
*/
static int getInfo(const char* filename, struct File_Info* info);
static int getInfo(const char* filename, UpnpFileInfo* info);
/**
* Opens a virtual directory file
*
server/server.cpp
this->mIsRunning = false;
this->mIsAutoDetectionEnabled = true;
this->mIsEnabled = false;
this->mDeviceHandle = NULL;
this->mMediaDatabase = NULL;
}
......
}
}
int cUPnPServer::upnpActionCallback(Upnp_EventType eventtype, void *event, void *cookie) {
int cUPnPServer::upnpActionCallback(Upnp_EventType eventtype, void const *event, void *cookie) {
// only to remove warning while compiling because cookie is unused
cookie = NULL;
Upnp_Subscription_Request* eventRequest = NULL;
server/webserver.cpp
else return NULL;
}
int cUPnPWebServer::getInfo(const char* filename, File_Info* info){
int cUPnPWebServer::getInfo(const char* filename, UpnpFileInfo* info){
MESSAGE(VERBOSE_WEBSERVER, "Getting information of file '%s'", filename);
propertyMap Properties;
......
return -1;
}
else {
File_Info_ finfo;
time_t mod_time = Resource->getLastModification();
UpnpFileInfo_set_ContentType(info,
ixmlCloneDOMString(Resource->getContentType()));
finfo.content_type = ixmlCloneDOMString(Resource->getContentType());
finfo.file_length = Resource->getFileSize();
finfo.is_directory = 0;
finfo.is_readable = 1;
finfo.last_modified = Resource->getLastModification();
memcpy(info, &finfo, sizeof(File_Info_));
UpnpFileInfo_set_FileLength(info, Resource->getFileSize());
UpnpFileInfo_set_IsDirectory(info, 0);
UpnpFileInfo_set_IsReadable(info, 1);
UpnpFileInfo_set_LastModified(info, mod_time);
MESSAGE(VERBOSE_METADATA, "==== File info of Resource #%d ====", Resource->getID());
MESSAGE(VERBOSE_METADATA, "Size: %lld", finfo.file_length);
MESSAGE(VERBOSE_METADATA, "Dir: %s", finfo.is_directory?"yes":"no");
MESSAGE(VERBOSE_METADATA, "Read: %s", finfo.is_readable?"allowed":"not allowed");
MESSAGE(VERBOSE_METADATA, "Last modified: %s", ctime(&(finfo.last_modified)));
MESSAGE(VERBOSE_METADATA, "Content-type: %s", finfo.content_type);
MESSAGE(VERBOSE_METADATA, "Size: %lld",
UpnpFileInfo_get_FileLength(info));
MESSAGE(VERBOSE_METADATA, "Dir: %s",
UpnpFileInfo_get_IsDirectory(info)?"yes":"no");
MESSAGE(VERBOSE_METADATA, "Read: %s",
UpnpFileInfo_get_IsReadable(info)?"allowed":"not allowed");
MESSAGE(VERBOSE_METADATA, "Last modified: %s", ctime(&mod_time));
MESSAGE(VERBOSE_METADATA, "Content-type: %s",
UpnpFileInfo_get_ContentType(info));
#ifdef UPNP_HAVE_CUSTOMHEADERS
UpnpAddCustomHTTPHeader("transferMode.dlna.org: Streaming");
    (1-1/1)