diff options
Diffstat (limited to 'upnpcomponents')
-rw-r--r-- | upnpcomponents/connectionmanager.cpp | 48 | ||||
-rw-r--r-- | upnpcomponents/connectionmanager.h | 40 | ||||
-rw-r--r-- | upnpcomponents/contentdirectory.cpp | 8 | ||||
-rw-r--r-- | upnpcomponents/contentdirectory.h | 20 | ||||
-rw-r--r-- | upnpcomponents/dlna.cpp | 8 | ||||
-rw-r--r-- | upnpcomponents/dlna.h | 108 | ||||
-rw-r--r-- | upnpcomponents/upnpservice.cpp | 4 | ||||
-rw-r--r-- | upnpcomponents/upnpservice.h | 106 | ||||
-rw-r--r-- | upnpcomponents/upnpwebserver.cpp | 42 | ||||
-rw-r--r-- | upnpcomponents/upnpwebserver.h | 45 |
10 files changed, 349 insertions, 80 deletions
diff --git a/upnpcomponents/connectionmanager.cpp b/upnpcomponents/connectionmanager.cpp index b2c7149..e0d9203 100644 --- a/upnpcomponents/connectionmanager.cpp +++ b/upnpcomponents/connectionmanager.cpp @@ -70,7 +70,7 @@ int cConnectionManager::execute(Upnp_Action_Request* Request){ } int cConnectionManager::getProtocolInfo(Upnp_Action_Request* Request){ - MESSAGE("Protocol info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CMS, "Protocol info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); cString Result = cString::sprintf( "<u:%sResponse xmlns:u=\"%s\"> \ <Source>%s</Source> \ @@ -87,7 +87,7 @@ int cConnectionManager::getProtocolInfo(Upnp_Action_Request* Request){ } int cConnectionManager::getCurrentConnectionIDs(Upnp_Action_Request* Request){ - MESSAGE("Current connection IDs requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CMS, "Current connection IDs requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); cString Result; const char* IDs = this->getConnectionIDsCVS(); if(!IDs){ @@ -109,7 +109,7 @@ int cConnectionManager::getCurrentConnectionIDs(Upnp_Action_Request* Request){ } int cConnectionManager::getCurrentConnectionInfo(Upnp_Action_Request* Request){ - MESSAGE("Current connection info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CMS, "Current connection info requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); int ConnectionID; if(this->parseIntegerValue(Request->ActionRequest, "ConnectionID", &ConnectionID) != 0){ @@ -156,7 +156,7 @@ int cConnectionManager::getCurrentConnectionInfo(Upnp_Action_Request* Request){ } int cConnectionManager::prepareForConnection(Upnp_Action_Request* Request){ - MESSAGE("Request for a new connection by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CMS, "Request for a new connection by %s.", inet_ntoa(Request->CtrlPtIPAddr)); //char* Result = NULL; char* RemoteProtocolInfo = NULL; char* PeerConnectionManager = NULL; @@ -198,7 +198,7 @@ int cConnectionManager::prepareForConnection(Upnp_Action_Request* Request){ } int cConnectionManager::connectionComplete(Upnp_Action_Request* Request){ - MESSAGE("Request for closing an open connection by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CMS, "Request for closing an open connection by %s.", inet_ntoa(Request->CtrlPtIPAddr)); //char* Result = NULL; int ConnectionID; @@ -216,27 +216,27 @@ int cConnectionManager::connectionComplete(Upnp_Action_Request* Request){ return Request->ErrCode; } -bool cConnectionManager::setProtocolInfo(const char* ProtocolInfo){ - if(strcmp(this->mSupportedProtocols, ProtocolInfo)){ - // ProtocolInfo changed, save and invoke a event notification - this->mSupportedProtocols = ProtocolInfo; - - IXML_Document* PropertySet = NULL; - UpnpAddToPropertySet(&PropertySet, "SourceProtocolInfo", this->mSupportedProtocols); - int ret = UpnpNotifyExt(this->mDeviceHandle, UPNP_DEVICE_UDN, UPNP_CMS_SERVICE_ID, PropertySet); - ixmlDocument_free(PropertySet); - - if(ret != UPNP_E_SUCCESS){ - ERROR("State change notification failed (Error code: %d)",ret); - return false; - } - } - return true; -} +//bool cConnectionManager::setProtocolInfo(const char* ProtocolInfo){ +// if(strcmp(this->mSupportedProtocols, ProtocolInfo)){ +// // ProtocolInfo changed, save and invoke a event notification +// this->mSupportedProtocols = ProtocolInfo; +// +// IXML_Document* PropertySet = NULL; +// UpnpAddToPropertySet(&PropertySet, "SourceProtocolInfo", this->mSupportedProtocols); +// int ret = UpnpNotifyExt(this->mDeviceHandle, UPNP_DEVICE_UDN, UPNP_CMS_SERVICE_ID, PropertySet); +// ixmlDocument_free(PropertySet); +// +// if(ret != UPNP_E_SUCCESS){ +// ERROR("State change notification failed (Error code: %d)",ret); +// return false; +// } +// } +// return true; +//} cVirtualConnection* cConnectionManager::createVirtualConnection(const char* RemoteProtocolInfo, const char* RemoteConnectionManager, int RemoteConnectionID, eDirection Direction){ static int lastConnectionID = 0; - MESSAGE("Create virtual connection"); + MESSAGE(VERBOSE_CMS, "Create virtual connection"); if(lastConnectionID == 2147483647) lastConnectionID = 1; cVirtualConnection* Connection = new cVirtualConnection; // AVT is available @@ -268,7 +268,7 @@ cVirtualConnection* cConnectionManager::createVirtualConnection(const char* Remo ERROR("State change notification failed (Error code: %d)",ret); return NULL; } - MESSAGE("Notification of connection creation sent"); + MESSAGE(VERBOSE_CMS, "Notification of connection creation sent"); this->mVirtualConnections->Add(Connection); return Connection; } diff --git a/upnpcomponents/connectionmanager.h b/upnpcomponents/connectionmanager.h index 202df59..4aa25f3 100644 --- a/upnpcomponents/connectionmanager.h +++ b/upnpcomponents/connectionmanager.h @@ -10,6 +10,11 @@ #include "upnpservice.h" +/** + * Connection status + * + * The connection status of a certain virtual connection + */ enum eConnectionStatus { OK, CONTENT_FORMAT_MISMATCH, @@ -18,11 +23,22 @@ enum eConnectionStatus { UNKNOWN }; +/** + * Direction + * + * The direction of a virtual connection. Input means client to server, Output + * server to client + */ enum eDirection { OUTPUT, INPUT }; +/** + * Virtual connection + * + * A virtual connection managed by the connection manager service + */ class cVirtualConnection : public cListObject { friend class cConnectionManager; private: @@ -41,15 +57,31 @@ private: static int getConnectionStatus(const char* ConnectionStatus); }; +/** + * The connection manager service + * + * This is the connection manager service which handles all incoming connection, + * creates and destroys connections to clients. + */ class cConnectionManager : public cUpnpService { public: - cConnectionManager(UpnpDevice_Handle DeviceHandle); + /** + * Constructor of a Connection manager + * + * This creates an instance of a <em>Connection Manager Service</em> and provides + * interfaces for executing actions and subscribing on events. + */ + cConnectionManager( + UpnpDevice_Handle DeviceHandle ///< the UPnP device handle of this root device + ); virtual ~cConnectionManager(); - virtual int execute(Upnp_Action_Request* Request); + /*! @copydoc cUpnpService::subscribe(Upnp_Subscription_Request* Request) */ virtual int subscribe(Upnp_Subscription_Request* Request); - bool setProtocolInfo(const char* ProtocolInfo); -private: + /*! @copydoc cUpnpService::execute(Upnp_Action_Request* Request) */ + virtual int execute(Upnp_Action_Request* Request); + /*! @copydoc cUpnpService::setError(Upnp_Action_Request* Request, int Error) */ virtual void setError(Upnp_Action_Request* Request, int Error); +private: int getProtocolInfo(Upnp_Action_Request* Request); int getCurrentConnectionIDs(Upnp_Action_Request* Request); int getCurrentConnectionInfo(Upnp_Action_Request* Request); diff --git a/upnpcomponents/contentdirectory.cpp b/upnpcomponents/contentdirectory.cpp index a9afdfa..494b638 100644 --- a/upnpcomponents/contentdirectory.cpp +++ b/upnpcomponents/contentdirectory.cpp @@ -40,7 +40,7 @@ int cContentDirectory::subscribe(Upnp_Subscription_Request* Request){ void cContentDirectory::Action(){ static int Retry = 5; - MESSAGE("Start Content directory thread"); + MESSAGE(VERBOSE_CDS, "Start Content directory thread"); while(this->Running()){ IXML_Document* PropertySet = NULL; UpnpAddToPropertySet(&PropertySet, "SystemUpdateID", itoa(this->mMediaDatabase->getSystemUpdateID())); @@ -84,7 +84,7 @@ int cContentDirectory::execute(Upnp_Action_Request* Request){ int cContentDirectory::browse(Upnp_Action_Request* Request){ - MESSAGE("Browse requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); + MESSAGE(VERBOSE_CDS, "Browse requested by %s.", inet_ntoa(Request->CtrlPtIPAddr)); char* ObjectID = NULL; if(this->parseStringValue(Request->ActionRequest, "ObjectID", &ObjectID)){ @@ -201,7 +201,7 @@ int cContentDirectory::getSystemUpdateID(Upnp_Action_Request* Request){ } int cContentDirectory::getSearchCapabilities(Upnp_Action_Request* Request){ - MESSAGE("Sorry, no search capabilities yet"); + MESSAGE(VERBOSE_CDS, "Sorry, no search capabilities yet"); cString Result = cString::sprintf( "<u:%sResponse xmlns:u=\"%s\"> \ @@ -220,7 +220,7 @@ int cContentDirectory::getSearchCapabilities(Upnp_Action_Request* Request){ } int cContentDirectory::getSortCapabilities(Upnp_Action_Request* Request){ - MESSAGE("Sorry, no sort capabilities yet"); + MESSAGE(VERBOSE_CDS, "Sorry, no sort capabilities yet"); cString Result = cString::sprintf( "<u:%sResponse xmlns:u=\"%s\"> \ diff --git a/upnpcomponents/contentdirectory.h b/upnpcomponents/contentdirectory.h index a504fdc..7fb4bb9 100644 --- a/upnpcomponents/contentdirectory.h +++ b/upnpcomponents/contentdirectory.h @@ -12,12 +12,30 @@ #include "upnpservice.h" #include "../database/metadata.h" +/** + * The content directory service + * + * This is the content directory service which handles all incoming requests + * for contents managed by the media server. + */ class cContentDirectory : public cUpnpService, public cThread { public: - cContentDirectory(UpnpDevice_Handle DeviceHandle, cMediaDatabase* MediaDatabase); + /** + * Constructor of a Content Directory + * + * This creates an instance of a <em>Content Directory Service</em> and provides + * interfaces for executing actions and subscribing on events. + */ + cContentDirectory( + UpnpDevice_Handle DeviceHandle, ///< The UPnP device handle of the root device + cMediaDatabase* MediaDatabase ///< the media database where requests are processed + ); virtual ~cContentDirectory(); + /*! @copydoc cUpnpService::subscribe(Upnp_Subscription_Request* Request) */ virtual int subscribe(Upnp_Subscription_Request* Request); + /*! @copydoc cUpnpService::execute(Upnp_Action_Request* Request) */ virtual int execute(Upnp_Action_Request* Request); + /*! @copydoc cUpnpService::setError(Upnp_Action_Request* Request, int Error) */ virtual void setError(Upnp_Action_Request* Request, int Error); private: cMediaDatabase* mMediaDatabase; diff --git a/upnpcomponents/dlna.cpp b/upnpcomponents/dlna.cpp index eaa23c1..27f84f2 100644 --- a/upnpcomponents/dlna.cpp +++ b/upnpcomponents/dlna.cpp @@ -21,7 +21,7 @@ cDlna* cDlna::getInstance(void){ } cDlna::cDlna() { - this->mRegisteredProfiles = new cRegisteredProfiles; + this->mRegisteredProfiles = new cList<cRegisteredProfile>; this->init(); } @@ -47,6 +47,8 @@ void cDlna::registerProfile(DLNAProfile* Profile, int Op, const char* Ps, int Ci void cDlna::registerMainProfiles(){ this->registerProfile(&DLNA_PROFILE_MPEG_TS_SD_EU, -1, NULL, -1, DLNA_FLAGS_PLUGIN_SUPPORT); this->registerProfile(&DLNA_PROFILE_AVC_TS_HD_EU, -1, NULL, -1, DLNA_FLAGS_PLUGIN_SUPPORT); + this->registerProfile(&DLNA_PROFILE_MPEG_TS_SD_EU_ISO, -1, NULL, -1, DLNA_FLAGS_PLUGIN_SUPPORT); + this->registerProfile(&DLNA_PROFILE_AVC_TS_HD_EU_ISO, -1, NULL, -1, DLNA_FLAGS_PLUGIN_SUPPORT); } const char* cDlna::getSupportedProtocols(){ @@ -73,9 +75,9 @@ DLNAProfile* cDlna::getProfileOfChannel(cChannel* Channel){ switch(Channel->Vtype()){ case 0x02: // MPEG2 Video - return &DLNA_PROFILE_MPEG_TS_SD_EU; + return &DLNA_PROFILE_MPEG_TS_SD_EU_ISO; case 0x1B: - return &DLNA_PROFILE_AVC_TS_HD_EU; + return &DLNA_PROFILE_AVC_TS_HD_EU_ISO; default: ERROR("Unknown video type %d for channel %s!", Channel->Vtype(), Channel->Name()); return NULL; diff --git a/upnpcomponents/dlna.h b/upnpcomponents/dlna.h index c05d69a..80ac328 100644 --- a/upnpcomponents/dlna.h +++ b/upnpcomponents/dlna.h @@ -14,6 +14,12 @@ class cDlna; +/** + * Registered DLNA profile + * + * This class contains information about a certain registered profile + * like play speeds or flags + */ class cRegisteredProfile : public cListObject { friend class cDlna; private: @@ -27,10 +33,6 @@ public: virtual ~cRegisteredProfile(){}; }; -class cRegisteredProfiles : public cList<cRegisteredProfile> { - friend class cDlna; -}; - /** * Enable DLNA compliant media transfer * @@ -41,23 +43,107 @@ class cRegisteredProfiles : public cList<cRegisteredProfile> { class cDlna { friend class cUPnPServer; public: + /** + * Returns the instance of DLNA object + * + * This will create a DLNA object instance. It will return the same instance + * on subsequent calls. + * + * @return the DLNA object instance + */ static cDlna* getInstance(void); virtual ~cDlna(); //const char* getProtocolInfo(UPnPObjectID OID); - const char* getDeviceDescription(const char* URLBase); - void registerProfile(DLNAProfile* Profile, int Op = -1, const char* Ps = NULL, int Ci = -1, unsigned int Flags = 0); + /** + * Device description document + * + * This will return the device description document with service type + * definitions as well as some DLNA specific information + * + * @return The description document + */ + const char* getDeviceDescription( + const char* URLBase ///< the URLBase to be set in the document + ); + /** + * Registeres a DLNA profile + * + * Registeres a DLNA profile with specific optional options + * + * @see common.h + */ + void registerProfile( + DLNAProfile* Profile, ///< the DLNA profile + int Op = -1, ///< operation mode + const char* Ps = NULL, ///< play speed (CSV list) + int Ci = -1, ///< conversion indication flag + unsigned int Flags = 0 ///< DLNA flags + ); + /** + * Registeres all known DLNA profiles + * + * Registeres all well known DLNA profiles with its known options + */ void registerMainProfiles(); + /** + * CSV list of supported protocols + * + * Returns a comma separated list with all supported protocols. This + * means, it returns the list of protocols of the registered profiles. + * + * @return CSV list of registered protocols + */ const char* getSupportedProtocols(); - const char* getProtocolInfo(DLNAProfile *Prof); - DLNAProfile* getProfileOfChannel(cChannel* Channel); - DLNAProfile* getProfileOfRecording(cRecording* Recording); - DLNAProfile* getProfileOfFile(cString File); + /** + * Protocol info of a specific DLNA profile + * + * Returns the protocol info string of a specific DLNA profile with its + * options and flags. + * + * @return the protocol info string of the profile + */ + const char* getProtocolInfo( + DLNAProfile *Prof ///< the Profile of which the protocol info shall be returned + ); + /** + * Profile of a channel + * + * Returns the DLNA profile of a VDR channel. It checks the video type to determine + * which profile will match. + * + * @return the matching DLNA profile + */ + DLNAProfile* getProfileOfChannel( + cChannel* Channel ///< the channel of which the profile should created from + ); + /** + * Profile of a recording + * + * Returns the DLNA profile of a VDR recording. It checks the video file to determine + * which profile will match. + * + * @return the matching DLNA profile + */ + DLNAProfile* getProfileOfRecording( + cRecording* Recording ///< the recording of which the profile should be created from + ); + /** + * Profile of a file + * + * Returns the DLNA profile of a file. It checks the content of the file with \em ffmpeg to + * determine which profile will match. + * + * @return the matching DLNA profile + */ + DLNAProfile* getProfileOfFile( + cString File ///< the file of which the profile should be created from + ); private: const char* getRegisteredProtocolInfoString(cRegisteredProfile *Profile); cDlna(); void init(void); static cDlna* mInstance; - cRegisteredProfiles* mRegisteredProfiles; + cList<cRegisteredProfile>* mRegisteredProfiles; }; #endif /* _DLNA_H */ diff --git a/upnpcomponents/upnpservice.cpp b/upnpcomponents/upnpservice.cpp index a1d6a47..fc24cca 100644 --- a/upnpcomponents/upnpservice.cpp +++ b/upnpcomponents/upnpservice.cpp @@ -13,7 +13,7 @@ cUpnpService::cUpnpService(UpnpDevice_Handle DeviceHandle) { this->mDeviceHandle = DeviceHandle; } -int cUpnpService::parseIntegerValue(IXML_Document* Document, const char* Item, int* Value){ +int cUpnpService::parseIntegerValue(IN IXML_Document* Document, IN const char* Item, OUT int* Value){ char* Val = NULL; int Error = 0; @@ -34,7 +34,7 @@ int cUpnpService::parseIntegerValue(IXML_Document* Document, const char* Item, i return Error; } -int cUpnpService::parseStringValue(IXML_Document* Document, const char* Item, char** Value){ +int cUpnpService::parseStringValue(IN IXML_Document* Document, IN const char* Item, OUT char** Value){ char* Val = NULL; int Error = 0; diff --git a/upnpcomponents/upnpservice.h b/upnpcomponents/upnpservice.h index c8630b5..df74d9b 100644 --- a/upnpcomponents/upnpservice.h +++ b/upnpcomponents/upnpservice.h @@ -10,17 +10,109 @@ #include <upnp/upnp.h> +/** + * UPnP Service interface + * + * This is a service interface implemented by a UPnP service like CDS oder CMS + * + * It comes with some tool functions which are commonly useful for processing + * an event or action. + */ class cUpnpService { public: - cUpnpService(UpnpDevice_Handle DeviceHandle); + /** + * Constructor of a service + * + * @private + * @param DeviceHandle the UPnP device handle of this root device + */ + cUpnpService( + UpnpDevice_Handle DeviceHandle ///< the UPnP device handle of this root device + ); virtual ~cUpnpService(){}; - virtual int subscribe(Upnp_Subscription_Request* Request) = 0; - virtual int execute(Upnp_Action_Request* Request) = 0; + /** + * Subscribes to an event + * + * This is a callback function to register a new subscriber for an event. + * + * @return An integer representing one of the following: + * - \bc UPNP_E_SUCCESS, if subscription was okay + * - or any other non null value in case of an error + * + * @param Request Information about the subscription + */ + virtual int subscribe( + Upnp_Subscription_Request* Request ///< Information about the subscription + ) = 0; + /** + * Executes an action + * + * This executes an action initialized by a control point. The result is + * stored in the first parameter. + * + * @return An integer representing one of the following: + * - \bc UPNP_E_SUCCESS, if subscription was okay + * - or any other non null value in case of an error + * + * @param Request Input and output parameters of an action + */ + virtual int execute( + Upnp_Action_Request* Request ///< Input and output parameters of an action + ) = 0; protected: - virtual void setError(Upnp_Action_Request* Request, int Error); - int parseIntegerValue(IN IXML_Document* Document, IN const char* Item, OUT int* Value); - int parseStringValue(IN IXML_Document* Document, IN const char* Item, OUT char** Value); - UpnpDevice_Handle mDeviceHandle; + /** + * Sets an error on an action request + * + * This function puts a error message into the action request structure + * according to its error code + * + * @param Request the action request, to set the error for + * @param Error the error code of which the message should be obtained + */ + virtual void setError( + Upnp_Action_Request* Request, ///< the action request, to set the error for + int Error ///< the error code of which the message should be obtained + ); + /** + * Parses an integer value + * + * This tool function parses an integer value from a given \em IXML document. It is searching + * for the very first occurance of the demanded item. + * + * @return Returns + * - \bc 0, if parsing was successful + * - \bc <0, if an error occured + * + * @param Document the document, which is parsed + * @param Item the demanded item + * @param Value the value of the item + */ + int parseIntegerValue( + IN IXML_Document* Document, ///< the document, which is parsed + IN const char* Item, ///< the demanded item + OUT int* Value ///< the value of the item + ); + /** + * Parses a string value + * + * This tool function parses a string value from a given \em IXML document. It is searching + * for the very first occurance of the demanded item. + * + * @return Returns + * - \bc 0, if parsing was successful + * - \bc <0, if an error occured + * + * @param Document the document, which is parsed + * @param Item the demanded item + * @param Value the value of the item + */ + int parseStringValue( + IN IXML_Document* Document, ///< the document, which is parsed + IN const char* Item, ///< the demanded item + OUT char** Value ///< the value of the item + ); + + UpnpDevice_Handle mDeviceHandle; ///< the UPnP device handle of the root device }; #endif /* _UPNPSERVICE_H */ diff --git a/upnpcomponents/upnpwebserver.cpp b/upnpcomponents/upnpwebserver.cpp index 383b201..892f5b1 100644 --- a/upnpcomponents/upnpwebserver.cpp +++ b/upnpcomponents/upnpwebserver.cpp @@ -46,6 +46,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ +/** @private */ struct File_Info_ { /** The length of the file. A length less than 0 indicates the size @@ -73,6 +74,7 @@ struct File_Info_ }; +/** @private */ struct cWebFileHandle { cString Filename; off64_t Size; @@ -108,13 +110,13 @@ UpnpVirtualDirCallbacks cUPnPWebServer::mVirtualDirCallbacks = { }; bool cUPnPWebServer::init(){ - MESSAGE("Initialize callbacks for virtual directories."); + MESSAGE(VERBOSE_WEBSERVER, "Initialize callbacks for virtual directories."); if(UpnpSetWebServerRootDir(this->mRootdir) == UPNP_E_INVALID_ARGUMENT){ ERROR("The root directory of the webserver is invalid."); return false; } - MESSAGE("Setting up callbacks"); + MESSAGE(VERBOSE_WEBSERVER, "Setting up callbacks"); if(UpnpSetVirtualDirCallbacks(&cUPnPWebServer::mVirtualDirCallbacks) == UPNP_E_INVALID_ARGUMENT){ ERROR("The virtual directory callbacks are invalid."); @@ -126,7 +128,7 @@ bool cUPnPWebServer::init(){ return false; } - MESSAGE("Add virtual directories."); + MESSAGE(VERBOSE_WEBSERVER, "Add virtual directories."); if(UpnpAddVirtualDir(UPNP_DIR_SHARES) == UPNP_E_INVALID_ARGUMENT){ ERROR("The virtual directory %s is invalid.",UPNP_DIR_SHARES); return false; @@ -135,7 +137,7 @@ bool cUPnPWebServer::init(){ } bool cUPnPWebServer::uninit(){ - MESSAGE("Disabling the internal webserver"); + MESSAGE(VERBOSE_WEBSERVER, "Disabling the internal webserver"); UpnpEnableWebserver(FALSE); return true; @@ -152,7 +154,7 @@ cUPnPWebServer* cUPnPWebServer::getInstance(const char* rootdir){ } int cUPnPWebServer::getInfo(const char* filename, File_Info* info){ - MESSAGE("Getting information of file '%s'", filename); + MESSAGE(VERBOSE_WEBSERVER, "Getting information of file '%s'", filename); propertyMap Properties; int Method; @@ -164,7 +166,7 @@ int cUPnPWebServer::getInfo(const char* filename, File_Info* info){ switch(Method){ case UPNP_WEB_METHOD_STREAM: { - MESSAGE("Stream request"); + MESSAGE(VERBOSE_WEBSERVER, "Stream request"); propertyMap::iterator It = Properties.find("resId"); unsigned int ResourceID = 0; if(It == Properties.end()){ @@ -188,12 +190,12 @@ int cUPnPWebServer::getInfo(const char* filename, File_Info* info){ finfo.last_modified = Resource->getLastModification(); memcpy(info, &finfo, sizeof(File_Info_)); - MESSAGE("==== File info of Resource #%d ====", Resource->getID()); - MESSAGE("Size: %lld", finfo.file_length); - MESSAGE("Dir: %s", finfo.is_directory?"yes":"no"); - MESSAGE("Read: %s", finfo.is_readable?"allowed":"not allowed"); - MESSAGE("Last modified: %s", ctime(&(finfo.last_modified))); - MESSAGE("Content-type: %s", finfo.content_type); + 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); } } } @@ -222,7 +224,7 @@ int cUPnPWebServer::getInfo(const char* filename, File_Info* info){ } UpnpWebFileHandle cUPnPWebServer::open(const char* filename, UpnpOpenFileMode mode){ - MESSAGE("File %s was opened for %s.",filename,mode==UPNP_READ ? "reading" : "writing"); + MESSAGE(VERBOSE_WEBSERVER, "File %s was opened for %s.",filename,mode==UPNP_READ ? "reading" : "writing"); propertyMap Properties; int Method; @@ -235,7 +237,7 @@ UpnpWebFileHandle cUPnPWebServer::open(const char* filename, UpnpOpenFileMode mo switch(Method){ case UPNP_WEB_METHOD_STREAM: { - MESSAGE("Stream request"); + MESSAGE(VERBOSE_WEBSERVER, "Stream request"); propertyMap::iterator It = Properties.find("resId"); unsigned int ResourceID = 0; if(It == Properties.end()){ @@ -258,7 +260,7 @@ UpnpWebFileHandle cUPnPWebServer::open(const char* filename, UpnpOpenFileMode mo { char* ChannelID = strtok(strdup(Resource->getResource()),":"); int AudioID = atoi(strtok(NULL,":")); - MESSAGE("Try to create Receiver for Channel %s with Audio ID %d", ChannelID, AudioID); + MESSAGE(VERBOSE_LIVE_TV, "Try to create Receiver for Channel %s with Audio ID %d", ChannelID, AudioID); cChannel* Channel = Channels.GetByChannelID(tChannelID::FromString(ChannelID)); if(!Channel){ ERROR("No such channel with ID %s", ChannelID); @@ -303,32 +305,32 @@ UpnpWebFileHandle cUPnPWebServer::open(const char* filename, UpnpOpenFileMode mo else { return NULL; } - MESSAGE("Open the file handle"); + MESSAGE(VERBOSE_WEBSERVER, "Open the file handle"); WebFileHandle->FileHandle->open(mode); return (UpnpWebFileHandle)WebFileHandle; } int cUPnPWebServer::write(UpnpWebFileHandle fh, char* buf, size_t buflen){ cWebFileHandle* FileHandle = (cWebFileHandle*)fh; - MESSAGE("Writing to %s", *FileHandle->Filename); + MESSAGE(VERBOSE_BUFFERS, "Writing to %s", *FileHandle->Filename); return FileHandle->FileHandle->write(buf, buflen); } int cUPnPWebServer::read(UpnpWebFileHandle fh, char* buf, size_t buflen){ cWebFileHandle* FileHandle = (cWebFileHandle*)fh; - MESSAGE("Reading from %s", *FileHandle->Filename); + MESSAGE(VERBOSE_BUFFERS, "Reading from %s", *FileHandle->Filename); return FileHandle->FileHandle->read(buf, buflen); } int cUPnPWebServer::seek(UpnpWebFileHandle fh, off_t offset, int origin){ cWebFileHandle* FileHandle = (cWebFileHandle*)fh; - MESSAGE("Seeking on %s", *FileHandle->Filename); + MESSAGE(VERBOSE_BUFFERS, "Seeking on %s", *FileHandle->Filename); return FileHandle->FileHandle->seek(offset, origin); } int cUPnPWebServer::close(UpnpWebFileHandle fh){ cWebFileHandle *FileHandle = (cWebFileHandle *)fh; - MESSAGE("Closing file %s", *FileHandle->Filename); + MESSAGE(VERBOSE_WEBSERVER, "Closing file %s", *FileHandle->Filename); FileHandle->FileHandle->close(); delete FileHandle->FileHandle; delete FileHandle; diff --git a/upnpcomponents/upnpwebserver.h b/upnpcomponents/upnpwebserver.h index 613f97b..0a49cf9 100644 --- a/upnpcomponents/upnpwebserver.h +++ b/upnpcomponents/upnpwebserver.h @@ -11,6 +11,13 @@ #include "../common.h" #include <upnp/upnp.h> +/** + * The internal webserver + * + * This is the internal webserver. It distributes all the contents of the + * UPnP-Server. + * + */ class cUPnPWebServer { friend class cUPnPServer; private: @@ -19,11 +26,40 @@ private: const char* mRootdir; cUPnPWebServer(const char* root = "/"); protected: - bool enable(bool enable); public: + /** + * Initializes the webserver + * + * It enables the webserver which comes with the <em>Intel SDK</em> and creates + * virtual directories for shares media. + * + * @return returns + * - \bc true, if initializing was successful + * - \bc false, otherwise + */ bool init(); + /** + * Uninitializes the webserver + * + * This stops the webserver. + * + * @return returns + * - \bc true, if initializing was successful + * - \bc false, otherwise + */ bool uninit(); - static cUPnPWebServer* getInstance(const char* rootdir = "/"); + /** + * Returns the instance of the webserver + * + * Returns the instance of the webserver. This will create a single + * instance of none is existing on the very first call. A subsequent call + * will return the same instance. + * + * @return the instance of webserver + */ + static cUPnPWebServer* getInstance( + const char* rootdir = "/" /**< the root directory of the webserver */ + ); virtual ~cUPnPWebServer(); //}; @@ -32,6 +68,7 @@ public: * The callback functions for the webserver * ****************************************************/ + /** * Retrieve file information * @@ -48,8 +85,8 @@ public: * Opens a file in a virtual directory with the specified mode. * * Possible modes are: - * - UPNP_READ : Opens the file for reading - * - UPNP_WRITE: Opens the file for writing + * - \b UPNP_READ, Opens the file for reading + * - \b UPNP_WRITE, Opens the file for writing * * It returns a file handle to the opened file, NULL otherwise * |