summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/media/mediaManager.h58
-rw-r--r--include/plugin.h20
-rw-r--r--include/pluginManager.h35
-rw-r--r--include/tools.h129
4 files changed, 64 insertions, 178 deletions
diff --git a/include/media/mediaManager.h b/include/media/mediaManager.h
index 16dbb4d..c9e042d 100644
--- a/include/media/mediaManager.h
+++ b/include/media/mediaManager.h
@@ -20,35 +20,9 @@
namespace upnp {
-class cMediaManager;
-
-class cResourceStreamer {
- friend class cMediaManager;
-private:
- cUPnPResourceProvider* provider;
- cMetadata::Resource* resource;
-
- cMediaManager* manager;
-
- StringVector protocolInfo;
-
- cResourceStreamer(cMediaManager* manager, cUPnPResourceProvider* provider, cMetadata::Resource* resource);
-public:
- virtual ~cResourceStreamer();
- std::string GetContentFeatures() const;
- size_t GetContentLength() const;
- std::string GetContentType() const;
- std::string GetTransferMode(const std::string& requestedMode ) const;
- bool Seekable() const;
-
- bool Open();
- size_t Read(char* buf, size_t bufLen);
- bool Seek(size_t offset, int origin);
- void Close();
-};
+class cResourceStreamer;
class cMediaManager : public cThread {
- friend class upnp::cPluginManager;
private:
struct MediaRequest {
@@ -111,9 +85,6 @@ private:
cUPnPResourceProvider* CreateResourceProvider(const std::string& uri);
- void AddProviderFunctor(upnp::cPluginManager::FunctionPtr providerFunctor);
- void AddProfiler(cMediaProfiler* profiler);
-
uint32_t systemUpdateID;
IdList eventedContainerUpdateIDs;
StringList scanDirectories;
@@ -123,12 +94,31 @@ private:
upnp::cPluginManager* pluginManager;
- typedef std::map<std::string, upnp::cPluginManager::FunctionPtr> ProviderMap;
- typedef std::list<boost::shared_ptr<cMediaProfiler> > ProfilerList;
+};
+
+class cResourceStreamer {
+ friend class cMediaManager;
+private:
+ cUPnPResourceProvider* provider;
+ cMetadata::Resource* resource;
+
+ cMediaManager* manager;
+
+ StringVector protocolInfo;
- ProviderMap providers;
- ProfilerList profilers;
+ cResourceStreamer(cMediaManager* manager, cUPnPResourceProvider* provider, cMetadata::Resource* resource);
+public:
+ virtual ~cResourceStreamer();
+ std::string GetContentFeatures() const;
+ size_t GetContentLength() const;
+ std::string GetContentType() const;
+ std::string GetTransferMode(const std::string& requestedMode ) const;
+ bool Seekable() const;
+ bool Open();
+ size_t Read(char* buf, size_t bufLen);
+ bool Seek(size_t offset, int origin);
+ void Close();
};
} // namespace upnp
diff --git a/include/plugin.h b/include/plugin.h
index 6896ebf..c30ce2b 100644
--- a/include/plugin.h
+++ b/include/plugin.h
@@ -257,7 +257,7 @@ public:
*
* The given URI is an absolute URI.
*/
- virtual EntryList GetContainerEntries(string uri) = 0;
+ virtual EntryList GetContainerEntries(const string& uri) = 0;
/**
* Checks if the given URI is a container.
@@ -268,7 +268,7 @@ public:
* If it is a container, the plugin manager will try to recurse
* into that directory and get the elements of it.
*/
- virtual bool IsContainer(string uri) = 0;
+ virtual bool IsContainer(const string& uri) = 0;
/**
* Checks if the given URI is a link to another element.
@@ -283,7 +283,7 @@ public:
* registered as a reference to the original element. Otherwise
* the element is skipped.
*/
- virtual bool IsLink(string uri, string& target) = 0;
+ virtual bool IsLink(const string& uri, string& target) = 0;
/**
* Returns the containerUpdateId of the given container
@@ -306,7 +306,7 @@ public:
* confused, if the elements differ though the updateId remains
* the same.
*/
- virtual long GetContainerUpdateId(string uri) = 0;
+ virtual long GetContainerUpdateId(const string& uri) = 0;
/**
* Returns the meta data of a specific container.
@@ -331,7 +331,7 @@ public:
* - Restricted: true
*
*/
- virtual cMetadata GetMetadata(string uri);
+ virtual bool GetMetadata(const string& uri, cMetadata& metadata);
/**
* Get the HTTP Uri.
@@ -348,7 +348,7 @@ public:
* The implementor of a resource provider MUST either implement
* this function or the file access methods below.
*/
- virtual string GetHTTPUri(string uri);
+ virtual string GetHTTPUri(const string& uri, const string& currentIP = string());
virtual bool Seekable() const;
@@ -365,7 +365,7 @@ public:
*
* The default implementation return false.
*/
- virtual bool Open(string uri);
+ virtual bool Open(const string& uri);
/**
* Reads data from the stream
@@ -446,7 +446,7 @@ protected:
* - change of the parent container, where the file or container
* was moved to
*/
- void OnContainerUpdate(string uri, long containerUpdateId, string changesUri = string());
+ void OnContainerUpdate(const string& uri, long containerUpdateId, const string& changesUri = string());
};
@@ -474,7 +474,7 @@ public:
*
* @return \b true if the plugin can handle the uri schema, \b false if not.
*/
- virtual bool CanHandleSchema(string schema) = 0;
+ virtual bool CanHandleSchema(const string& schema) = 0;
/**
* Get the metadata from a specific resource.
@@ -504,7 +504,7 @@ public:
* @return true, if this profiler was able to get the specific metadata,
* false, if not.
*/
- virtual bool GetMetadata(string uri, cMetadata& metadata) = 0;
+ virtual bool GetMetadata(const string& uri, cMetadata& metadata) = 0;
protected:
};
diff --git a/include/pluginManager.h b/include/pluginManager.h
index a40308f..8520b01 100644
--- a/include/pluginManager.h
+++ b/include/pluginManager.h
@@ -16,36 +16,51 @@
namespace upnp {
-class cMediaManager;
-
class cPluginManager {
public:
- typedef void*(*FunctionPtr)(void);
- cPluginManager(cMediaManager* manager);
+ typedef std::list< boost::shared_ptr<cMediaProfiler> > ProfilerList;
+
+ cPluginManager();
virtual ~cPluginManager();
bool LoadPlugins(const std::string& directory);
+
+ int Count() const;
+
+ const ProfilerList& GetProfilers() const;
+ cUPnPResourceProvider* CreateProvider(const string& schema);
+
private:
+
+ typedef cUPnPResourceProvider*(*ResourceProviderFuncPtr)(void);
+ typedef cMediaProfiler*(*MediaProfilerFuncPtr)(void);
+
class DLL {
public:
DLL(const std::string& file);
virtual ~DLL();
bool Load();
- FunctionPtr GetProvider() const { return provider; };
- FunctionPtr GetProfiler() const { return profiler; };
+
+ bool IsProvider() const { return isProvider; }
+
+ typedef void*(*FuncPtr)(void);
+
+ FuncPtr GetFunc() const { return function; };
private:
std::string file;
void* handle;
- FunctionPtr provider;
- FunctionPtr profiler;
+ bool isProvider;
+ FuncPtr function;
};
typedef std::list< boost::shared_ptr<DLL> > DLLList;
+ typedef std::map<string, ResourceProviderFuncPtr > ProviderMap;
- DLLList dlls;
- cMediaManager* manager;
+ DLLList dlls;
+ ProviderMap providers;
+ ProfilerList profilers;
};
diff --git a/include/tools.h b/include/tools.h
index cf34b42..a92b8a2 100644
--- a/include/tools.h
+++ b/include/tools.h
@@ -11,7 +11,6 @@
#include <vector>
#include <string>
#include <iostream>
-#include <upnp/upnp.h>
#include <string.h>
#include <vdr/tools.h>
#include <map>
@@ -28,139 +27,21 @@ using namespace std;
#define NL "\n"
-#define att(s) strchr(s,'@')!=NULL?strchr(s,'@')+1:NULL
-#define prop(s) substr(s, 0, strchr(s,'@')-s)
-
#define MAX_METADATA_LENGTH_L 1024
#define MAX_METADATA_LENGTH_S 256
-/**
- * creates a part of a string
- *
- * This creates a substring of a string which begins at the given offset and has the
- * specified lenght.
- *
- * @return the new string
- * @param str the full string
- * @param offset the starting index
- * @param length the length of the new string
- */
-char* substr(const char* str, unsigned int offset, unsigned int length);
-
-/****************************************************
- *
- * Known Errors
- *
- ****************************************************/
-
-/* Errors 401-404, 501 are already defined in
- * Intel SDK, however 403 MUST NOT USED.
- */
-
-/****** 600 Common Action Errors ******/
-
-#define UPNP_SOAP_E_ARGUMENT_INVALID 600
-#define UPNP_SOAP_E_ARGUMENT_OUT_OF_RANGE 601
-#define UPNP_SOAP_E_ACTION_NOT_IMPLEMENTED 602
-#define UPNP_SOAP_E_OUT_OF_MEMORY 603
-#define UPNP_SOAP_E_HUMAN_INTERVENTION 604
-#define UPNP_SOAP_E_STRING_TO_LONG 605
-#define UPNP_SOAP_E_NOT_AUTHORIZED 606
-#define UPNP_SOAP_E_SIGNATURE_FAILURE 607
-#define UPNP_SOAP_E_SIGNATURE_MISSING 608
-#define UPNP_SOAP_E_NOT_ENCRYPTED 609
-#define UPNP_SOAP_E_INVALID_SEQUENCE 610
-#define UPNP_SOAP_E_INVALID_CONTROL_URL 611
-#define UPNP_SOAP_E_NO_SUCH_SESSION 612
-
-/****** 700 Action specific Errors ******/
-
-#define UPNP_CDS_E_NO_SUCH_OBJECT 701
-#define UPNP_CDS_E_INVALID_CURRENT_TAG 702
-#define UPNP_CDS_E_INVALID_NEW_TAG 703
-#define UPNP_CDS_E_REQUIRED_TAG 704
-#define UPNP_CDS_E_READ_ONLY_TAG 705
-#define UPNP_CDS_E_PARAMETER_MISMATCH 706
-#define UPNP_CDS_E_INVALID_SEARCH_CRITERIA 708
-#define UPNP_CDS_E_INVALID_SORT_CRITERIA 709
-#define UPNP_CDS_E_NO_SUCH_CONTAINER 710
-#define UPNP_CDS_E_RESTRICTED_OBJECT 711
-#define UPNP_CDS_E_BAD_METADATA 712
-#define UPNP_CDS_E_RESTRICTED_PARENT 713
-#define UPNP_CDS_E_NO_SUCH_SOURCE_RESOURCE 714
-#define UPNP_CDS_E_RESOURCE_ACCESS_DENIED 715
-#define UPNP_CDS_E_TRANSFER_BUSY 716
-#define UPNP_CDS_E_NO_SUCH_FILE_TRANSFER 717
-#define UPNP_CDS_E_NO_SUCH_DESTINATION_RESOURCE 718
-#define UPNP_CDS_E_DEST_RESOURCE_ACCESS_DENIED 719
-#define UPNP_CDS_E_CANT_PROCESS_REQUEST 720
-
-#define UPNP_CMS_E_INCOMPATIBLE_PROTOCOL_INFO 701
-#define UPNP_CMS_E_INCOMPATIBLE_DIRECTIONS 702
-#define UPNP_CMS_E_INSUFFICIENT_RESOURCES 703
-#define UPNP_CMS_E_LOCAL_RESTRICTIONS 704
-#define UPNP_CMS_E_ACCESS_DENIED 705
-#define UPNP_CMS_E_INVALID_CONNECTION_REFERENCE 706
-#define UPNP_CMS_E_NOT_IN_NETWORK 707
-
namespace upnp {
typedef std::list<std::string> StringList;
typedef std::vector<std::string> StringVector;
typedef std::map<std::string, uint32_t> IdList;
-namespace tools {
- string GetAddressByInterface(string Interface);
- string GetNetworkInterfaceByIndex(int Index, bool skipLoop);
- StringVector GetNetworkInterfaces(bool skipLoop);
-
- string ToString(long number);
-
- string StringListToCSV(StringList list);
- string IdListToCSV(IdList list);
-
- string GenerateUUIDFromURL(string url);
- string GenerateUUIDRandomly();
-
- void StringExplode(string str, string separator, StringVector& results);
-}
-
-namespace ixml {
- void XmlEscapeSpecialChars(string& doc);
- /**
- * First occurance of item
- *
- * Finds the first occurance of a specified item in a given \bc IXML document and returns its value.
- * If an error occures, its code is stored in the last parameter \c 'error'.
- *
- * @return error the error code in case of an error
- * @param doc the \c IXML document to be parsed
- * @param item the item which shall be found
- * @param the value of the item
- */
- int IxmlGetFirstDocumentItem( IN IXML_Document * doc, IN const string item, string& value );
- /**
- * Adds a property
- *
- * This adds a UPnP property to an \bc IXML document.
- * The property must have the pattern "namespace:property@attribute".
- *
- * @return returns
- * - \bc NULL, in case of an error
- * - \bc the newly created property node or the node at which the attribute was
- * appended to
- * @param document the \c IXML document to put the parameter in
- * @param node the specific node where to put the parameter
- * @param upnpproperty the upnp property
- * @param value the value of the upnp property
- */
- IXML_Element* IxmlAddProperty(IN IXML_Document* document, IN IXML_Element* node, IN const string& upnpproperty, IN const string& value );
-
- IXML_Element* IxmlAddFilteredProperty(IN const StringList& Filter, IN IXML_Document* document, IN IXML_Element* node, IN const string& upnpproperty, IN const string& value );
-
- IXML_Element* IxmlReplaceProperty(IN IXML_Document* document, IN IXML_Element* node, IN const string& upnpproperty, IN const string& newValue );
}
-}
+#include "tools/error.h"
+#include "tools/ixml.h"
+#include "tools/net.h"
+#include "tools/string.h"
+#include "tools/uuid.h"
#endif /* TOOLS_H_ */