|
mUPnP for C
|
#include <mupnp/net/url.h>#include <mupnp/typedef.h>#include <mupnp/util/list.h>#include <mupnp/util/mutex.h>#include <mupnp/util/string.h>#include <mupnp/util/time.h>#include <mupnp/xml/xml.h>#include <mupnp/action.h>#include <mupnp/event/subscriber.h>#include <mupnp/ssdp/ssdp_server.h>#include <mupnp/statevariable.h>Data Structures | |
| struct | _mUpnpService |
Typedefs | |
| typedef struct _mUpnpService | mUpnpService |
| typedef struct _mUpnpService | mUpnpServiceList |
| #define mupnp_service_clearsubscriptionsid | ( | service | ) |
Clear (i.e. empty) the service's SID (subscription ID)
| service | The service in question |
| #define MUPNP_SERVICE_CONTROL_URL "controlURL" |
| #define MUPNP_SERVICE_ELEM_NAME "service" |
| #define MUPNP_SERVICE_EVENT_KEY_INVALID 0 |
| #define MUPNP_SERVICE_EVENT_SUB_URL "eventSubURL" |
| #define mupnp_service_getdevice | ( | service | ) |
Get the service's parent device
| service | The service in question |
| #define mupnp_service_getdevicenode | ( | service | ) |
Get the parent device's XML node for the service
| service | The service in question |
| #define mupnp_service_geteventkey | ( | service | ) |
Get the service's event key
| service | The service in question |
| #define mupnp_service_getnsubscribers | ( | service | ) |
Get the number of subscribers for the service
| service | The service in question |
| #define mupnp_service_getrootdevice | ( | service | ) |
Get the service's top-most root device
| service | The service in question |
| #define mupnp_service_getscpdnode | ( | service | ) |
Get the service's SCPD node
| service | The service in question |
| #define mupnp_service_getserviceid | ( | service | ) |
Get the service's service ID
| service | The service in question |
| #define mupnp_service_getservicenode | ( | service | ) |
Get the root XML node for the service
| service | The service in question |
| #define mupnp_service_getservicetype | ( | service | ) |
Get the service's complete type string (ex. "urn:schemas-upnp-org:service:FooService:1")
| service | The service in question |
| #define mupnp_service_getsubscribers | ( | service | ) |
Get the first node in the service's list of event subscribers. Use as the starting point in iteration loops.
| service | The service in question |
| #define mupnp_service_getsubscriptionexpiration | ( | service | ) |
Get the service's subscription expiration time
| service | The service in question |
| #define mupnp_service_getsubscriptionsid | ( | service | ) |
Get the service's SID (subscription ID)
| service | The service in question |
| #define mupnp_service_getsubscriptiontimeout | ( | service | ) |
Get the service's subscription timeout (expiration) value
| service | The service in question |
| #define mupnp_service_getsubscriptiontimestamp | ( | service | ) |
Get the service's subscription time stamp
| service | The service in question |
| #define mupnp_service_getuserdata | ( | service | ) |
Get the service's arbitrary user data pointer
| service | The service in question |
| #define mupnp_service_hasactionbyname | ( | service, | |
| name ) |
Check, whether a service has an action by the given name
| service | The service in question |
| name | The name of the action |
| #define mupnp_service_hasstatevariablebyname | ( | service, | |
| name ) |
Check, whether the service has the given state variable
| service | The service in question |
| name | The name of the state variable |
| #define MUPNP_SERVICE_ID "serviceId" |
| #define mupnp_service_isparsed | ( | service | ) |
Get the service's parsing status (i.e. whether the service has been completely constructed). Useful mainly in optimized control point mode.
| service | The service in question |
| #define mupnp_service_isservicenode | ( | node | ) |
Check, whether the given XML node is a service root node
| node | mUpnpXmlNode* |
| #define mupnp_service_issubscribed | ( | service | ) |
Check, whether the service has any subscribers
| service | The service in question |
| #define mupnp_service_lock | ( | service | ) |
Lock the service's mutex
| service | The service in question |
| #define mupnp_service_next | ( | service | ) |
Get the next service in a service list. Use as an iterator.
| service | Current service |
| #define MUPNP_SERVICE_NOTIFY_WAITTIME 1000 |
| #define mupnp_service_notifyallstatevariables | ( | service | ) |
Send a notification message to all of the service's subscribers
| service | The service in question |
| #define MUPNP_SERVICE_SCPDURL "SCPDURL" |
| #define mupnp_service_setcontrolurl | ( | service, | |
| value ) |
Set the service's control URL
| service | The service in question |
| value | The control URL string |
| #define mupnp_service_setdevice | ( | service, | |
| dev ) |
Set the service's parent device
| service | The service in question |
| dev | The parent device |
| #define mupnp_service_seteventkey | ( | service, | |
| value ) |
Set the service's event key (i.e. the sequential number used in events)
| service | The service in question |
| value | The event key value (uint) |
| #define mupnp_service_seteventsuburl | ( | service, | |
| value ) |
Get the service's event subscription URL
| service | The service in question |
| value | The event subscription URL string |
| #define mupnp_service_setscpdurl | ( | service, | |
| value ) |
Set the service's SCPD (service description) URL
| service | The service in question |
| value | The SCPD URL string |
| #define mupnp_service_setserviceid | ( | service, | |
| value ) |
Set the service's service ID
| service | The service in question |
| value | Service ID string |
| #define mupnp_service_setservicenode | ( | service, | |
| node ) |
Set the root XML node for the service
| service | The service in question |
| node | The node to set |
| #define mupnp_service_setservicetype | ( | service, | |
| value ) |
Set the service's complete type string (ex. "urn:schemas-upnp-org:service:FooService:1")
| service | The service in question |
| value | The type string |
| #define mupnp_service_setsubscriptionsid | ( | service, | |
| value ) |
Set the service's subscription's SID (subscription ID)
| service | The service in question |
| value | The SID |
| #define mupnp_service_setsubscriptiontimeout | ( | service, | |
| value ) |
Set the service's subscription timeout (expiration) value
| service | The service in question |
| value | The timeout value |
| #define mupnp_service_setsubscriptiontimestamp | ( | service, | |
| value ) |
Set the service's subscription time stamp
| service | The service in question |
| value | The time stamp |
| #define mupnp_service_setuserdata | ( | service, | |
| value ) |
Set the service's arbitrary user data pointer
| service | The service in question |
| value | The user data pointer |
| #define MUPNP_SERVICE_TYPE "serviceType" |
| #define mupnp_service_unlock | ( | service | ) |
Unlock the service's mutex
| service | The service in question |
| #define mupnp_servicelist_add | ( | serviceList, | |
| service ) |
Add a service to a list of services
| serviceList | The list to add the service to |
| service | The service to add to the list |
| #define mupnp_servicelist_clear | ( | serviceList | ) |
Clear the contents of a list of services
| serviceList | The list of services to clear |
| #define MUPNP_SERVICELIST_ELEM_NAME "serviceList" |
| #define mupnp_servicelist_gets | ( | serviceList | ) |
Get the first service in a list of services. Use as the starting point in iteration loops.
| serviceList | The service list |
| #define mupnp_servicelist_size | ( | serviceList | ) |
Get the number of services in a list of services
| serviceList | The list of services |
| typedef struct _mUpnpService mUpnpService |
| typedef struct _mUpnpService mUpnpServiceList |
| bool mupnp_service_addsubscriber | ( | mUpnpService * | service, |
| mUpnpSubscriber * | sub ) |
Add a subscriber to the service
| service | The service in question |
| sub | The subscriber |
| bool mupnp_service_announcefrom | ( | mUpnpService * | service, |
| const char * | bindAddr ) |
Send a service announcement (advertisement) from the given address
| service | The service to advertise |
| bindAddr | The address to attach to the announcement |
| bool mupnp_service_byebyefrom | ( | mUpnpService * | service, |
| const char * | bindAddr ) |
Send a byebye announcement (i.e. a cancelling advertisement) from the given address
| service | The service to announce from |
| bindAddr | The address to attach to the announcement |
| void mupnp_service_clear | ( | mUpnpService * | service | ) |
Clear the contents of a UPnP service
| service | The service to clear |
| void mupnp_service_createnotifyallthread | ( | mUpnpService * | service, |
| mUpnpTime | waitTime ) |
Create a new thread to send a notification message to all of the service's subscribers
| service | The service in question |
| waitTime | The wait time to send |
| void mupnp_service_delete | ( | mUpnpService * | service | ) |
Destroy a UPnP service and free all associated resources.
Releases all resources associated with the service, including:
| service | The service to destroy. May be NULL (no-op if NULL). |
| mUpnpAction * mupnp_service_getactionbyname | ( | mUpnpService * | service, |
| const char * | name ) |
Get an action from the service by the action's name
| service | The service in question |
| name | The name of the action to look for |
| mUpnpActionList * mupnp_service_getactionlist | ( | mUpnpService * | service | ) |
Get the service's list of actions (head of list)
| service | The service in question |
| mUpnpAction * mupnp_service_getactions | ( | mUpnpService * | service | ) |
Get the first action in the service's list of actions. Use as the starting point in iteration loops.
| service | The service in question |
| mUpnpNetURL * mupnp_service_getcontrolurl | ( | mUpnpService * | service | ) |
Get the service's control URL
| service | The service in question |
Get the service's control URL
| service | The service in question |
| char * mupnp_service_getdescription | ( | mUpnpService * | service, |
| mUpnpString * | descStr ) |
Get the service's description XML nodes as a string
| service | The service in question |
| descStr | The description string |
| mUpnpNetURL * mupnp_service_geteventsuburl | ( | mUpnpService * | service | ) |
Get the service's event subscription URL
| service | The service in question |
Get the service's event subscription URL
| service | The service in question |
| char * mupnp_service_getnotifyservicetypent | ( | mUpnpService * | service, |
| char * | buf, | ||
| int | bufSize ) |
| char * mupnp_service_getnotifyservicetypeusn | ( | mUpnpService * | service, |
| char * | buf, | ||
| int | bufSize ) |
| mUpnpNetURL * mupnp_service_getscpdurl | ( | mUpnpService * | service | ) |
Get the service's SCPD (service description) URL
| service | The service in question |
| mUpnpServiceStateTable * mupnp_service_getservicestatetable | ( | mUpnpService * | service | ) |
Get the service's state table
| service | The service in question |
| mUpnpStateVariable * mupnp_service_getstatevariablebyname | ( | mUpnpService * | service, |
| const char * | name ) |
Get a state variable from the service's state table by the variable's name
| service | The service in question |
| name | the name of the variable |
| mUpnpStateVariable * mupnp_service_getstatevariables | ( | mUpnpService * | service | ) |
Get the first state variable in the service's state table. Use as the starting point in iteration loops.
| service | The service in question |
| mUpnpSubscriber * mupnp_service_getsubscriberbysid | ( | mUpnpService * | service, |
| const char * | sid ) |
Find a subscriber from the service's list of subscribers by its SID (Subscription ID)
| service | The service in question |
| sid | The SID |
| bool mupnp_service_isscpdurl | ( | mUpnpService * | service, |
| const char * | url ) |
Compare the service's SCPD URL and the given location
| service | The service in question |
| url | The URL (location) to compare |
| mUpnpService * mupnp_service_new | ( | void | ) |
Create a new UPnP service instance.
Allocates and initializes a new UPnP service object. Services represent the functional units within a UPnP device, providing actions and state variables that can be controlled and queried by control points.
The function initializes:
After creation, the service should be populated either by:
| bool mupnp_service_notify | ( | mUpnpService * | service, |
| mUpnpStateVariable * | statVar ) |
Send a notification of a service's changed state variable
| service | The service in question |
| statVar | The changed state variable |
| bool mupnp_service_notifyall | ( | mUpnpService * | service, |
| bool | doBracket ) |
Send a notification message to all of the service's subscribers
| service | The service in question |
| bool mupnp_service_parsedescription | ( | mUpnpService * | service, |
| const char * | description, | ||
| size_t | descriptionLen ) |
Parse and populate a service from an SCPD XML document.
Parses the Service Control Protocol Definition (SCPD) XML document and populates the service with:
The SCPD document must conform to the UPnP Device Architecture specification. Any existing actions and state variables are cleared before parsing.
Example SCPD structure:
| service | The service to populate. Must not be NULL. |
| description | The SCPD XML document as a string. Must not be NULL. |
| descriptionLen | The length of the XML document in bytes. |
| true | Successfully parsed the SCPD document |
| false | Parsing failed due to:
|
| bool mupnp_service_parsedescriptionurl | ( | mUpnpService * | service, |
| mUpnpNetURL * | url ) |
Create the service's contents from the given URL. Gets the XML document from the URL and passes it again to mupnp_service_parsedescription
| service | The service to create |
| url | The URL of the document to parse |
| bool mupnp_service_removesubscriber | ( | mUpnpService * | service, |
| mUpnpSubscriber * | sub ) |
Remove a subscriber from the service
| service | The service in question |
| sub | The subscriber to remove |
| void mupnp_service_setactionlistener | ( | mUpnpService * | service, |
| MUPNP_ACTION_LISTNER | actionListener ) |
Set an action listener to the service
| service | The service in question |
| actionListener | A callback function of type MUPNP_ACTION_LISTNER |
| void mupnp_service_setquerylistener | ( | mUpnpService * | service, |
| MUPNP_STATEVARIABLE_LISTNER | queryListener ) |
Set a query listener to the service
| service | The service in question |
| queryListener | A callback function of type MUPNP_STATEVARIABLE_LISTNER |
| void mupnp_service_ssdpmessagereceived | ( | mUpnpService * | service, |
| mUpnpSSDPPacket * | ssdpPkt ) |
The service's handler function that deals with received SSDP messages.
| service | The service in question |
| ssdpPkt | The received SSDP packet |
| void mupnp_servicelist_delete | ( | mUpnpServiceList * | serviceList | ) |
Destroy a list of services
| serviceList | The list of services to destroy |
| mUpnpServiceList * mupnp_servicelist_new | ( | void | ) |
Create a new list of services
| const char * mupnp_servicetype_getidentifier | ( | const char * | serviceType | ) |
Get the identifier-part of a service type string (usually "urn")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |
| char * mupnp_servicetype_getschematype | ( | const char * | serviceType | ) |
Get the schema type part of a service type string (without last colon) (ex. "urn:schemas-upnp-org:service:ContentDirectory")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |
| const char * mupnp_servicetype_getservice | ( | const char * | serviceType | ) |
Get the service part of a service type string (usually just "service")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |
| const char * mupnp_servicetype_gettype | ( | const char * | serviceType | ) |
Get the type part of a service type string (ex. "ContentDirectory")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |
| const char * mupnp_servicetype_geturn | ( | const char * | serviceType | ) |
Get the URN part of a service type string (usually "schemas-upnp-org")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |
| const char * mupnp_servicetype_getversion | ( | const char * | serviceType | ) |
Get the version part of a service type string (ex. "1")
| serviceType | A service type string (usually the result from mupnp_service_getservicetype) |