diff options
Diffstat (limited to 'inc/upnp')
-rw-r--r-- | inc/upnp/connectionmanager.h | 99 | ||||
-rw-r--r-- | inc/upnp/contentdirectory.h | 56 | ||||
-rw-r--r-- | inc/upnp/dlna.h | 97 | ||||
-rw-r--r-- | inc/upnp/service.h | 119 |
4 files changed, 371 insertions, 0 deletions
diff --git a/inc/upnp/connectionmanager.h b/inc/upnp/connectionmanager.h new file mode 100644 index 0000000..6ed2987 --- /dev/null +++ b/inc/upnp/connectionmanager.h @@ -0,0 +1,99 @@ +/* + * File: connectionmanager.h + * Author: savop + * + * Created on 21. August 2009, 18:35 + */ + +#ifndef _CONNECTIONMANAGER_H +#define _CONNECTIONMANAGER_H + +#include "service.h" + +/** + * Connection status + * + * The connection status of a certain virtual connection + */ +enum eConnectionStatus { + OK, + CONTENT_FORMAT_MISMATCH, + INSUFFICIENT_BANDWIDTH, + UNRELIABLE_CHANNEL, + 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: + cString mRemoteProtocolInfo; + cString mRemoteConnectionManager; + eDirection mDirection; + int mRemoteConnectionID; + int mConnectionID; + int mAVTransportID; + const int mRcsID; + eConnectionStatus mStatus; + cVirtualConnection(); + static const char* getStatusString(eConnectionStatus Status); + static const char* getDirectionString(eDirection Direction); + static int getDirection(const char* Direction); + 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: + /** + * 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(); + /*! @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: + int getProtocolInfo(Upnp_Action_Request* Request); + int getCurrentConnectionIDs(Upnp_Action_Request* Request); + int getCurrentConnectionInfo(Upnp_Action_Request* Request); + int prepareForConnection(Upnp_Action_Request* Request); + int connectionComplete(Upnp_Action_Request* Request); + cVirtualConnection* createVirtualConnection(const char* RemoteProtocolInfo = NULL, const char* RemoteConnectionManager = NULL, int RemoteConnectionID = -1, eDirection Direction = OUTPUT); + bool destroyVirtualConnection(int ConnectionID); + const char* getConnectionIDsCVS(); + cVirtualConnection* mDefaultConnection; + cList<cVirtualConnection>* mVirtualConnections; + cString mSupportedProtocols; +}; + +#endif /* _CONNECTIONMANAGER_H */ + diff --git a/inc/upnp/contentdirectory.h b/inc/upnp/contentdirectory.h new file mode 100644 index 0000000..ec32dfa --- /dev/null +++ b/inc/upnp/contentdirectory.h @@ -0,0 +1,56 @@ +/* + * File: contentdirectory.h + * Author: savop + * + * Created on 21. August 2009, 16:12 + */ + +#ifndef _CONTENTDIRECTORY_H +#define _CONTENTDIRECTORY_H + +#include <upnp/upnp.h> +#include "service.h" +#include "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: + /** + * 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; + void Action(); + int getSearchCapabilities(Upnp_Action_Request* Request); + int getSortCapabilities(Upnp_Action_Request* Request); + int getSystemUpdateID(Upnp_Action_Request* Request); + int browse(Upnp_Action_Request* Request); +// int search(Upnp_Action_Request* Request); +// int createObject(Upnp_Action_Request* Request); +// int destroyObject(Upnp_Action_Request* Request); +// int updateObject(Upnp_Action_Request* Request); +// int deleteResource(Upnp_Action_Request* Request); +// int createReference(Upnp_Action_Request* Request); +}; + +#endif /* _CONTENTDIRECTORY_H */ + diff --git a/inc/upnp/dlna.h b/inc/upnp/dlna.h new file mode 100644 index 0000000..c61c39f --- /dev/null +++ b/inc/upnp/dlna.h @@ -0,0 +1,97 @@ +/* + * File: dlna.h + * Author: savop + * + * Created on 18. April 2009, 23:27 + */ + +#ifndef _DLNA_H +#define _DLNA_H + +#include "../common.h" +#include "profiles.h" +#include <list> + +using namespace std; + +/** + * Enable DLNA compliant media transfer + * + * This class enables media transmission with DLNA conformity. Its compliant with + * version 1.5 of the DLNA guidelines. + * + */ +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); + /** + * 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 + ); + /** + * Registeres all known DLNA profiles + * + * Registeres all well known DLNA profiles with its known options + */ + void registerProfiles(); + /** + * 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(); + /** + * 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 + 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 + ); +private: + cDlna(); + void init(void); + static cDlna* mInstance; + list<DLNAProfile*> mRegisteredProfiles; +}; + +#endif /* _DLNA_H */ + diff --git a/inc/upnp/service.h b/inc/upnp/service.h new file mode 100644 index 0000000..df74d9b --- /dev/null +++ b/inc/upnp/service.h @@ -0,0 +1,119 @@ +/* + * File: upnpservice.h + * Author: savop + * + * Created on 21. August 2009, 18:38 + */ + +#ifndef _UPNPSERVICE_H +#define _UPNPSERVICE_H + +#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: + /** + * 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(){}; + /** + * 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: + /** + * 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 */ + |