summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/mediaManager.cpp44
-rw-r--r--media/pluginManager.cpp6
-rw-r--r--media/profile.cpp51
3 files changed, 75 insertions, 26 deletions
diff --git a/media/mediaManager.cpp b/media/mediaManager.cpp
index 3df218a..377ed19 100644
--- a/media/mediaManager.cpp
+++ b/media/mediaManager.cpp
@@ -5,6 +5,7 @@
* Author: savop
*/
+#include "../include/webserver.h"
#include "../include/media/mediaManager.h"
#include "../include/pluginManager.h"
#include "../include/server.h"
@@ -326,27 +327,40 @@ int cMediaManager::CreateResponse(MediaRequest& request, const string& select, c
select2.setString("objectID", objectID);
+ int i=0;
+ string resourceFile;
+ string resourceURI;
+ stringstream tntnet;
for(tntdb::Statement::const_iterator it2 = select2.begin(); it2 != select2.end(); ++it2){
row2 = (*it2);
- boost::shared_ptr<cUPnPResourceProvider> provider(CreateResourceProvider(row2.getString(property::resource::KEY_RESOURCE)));
+ string resourceFile = row2.getString(property::resource::KEY_RESOURCE);
+ boost::shared_ptr<cUPnPResourceProvider> provider(CreateResourceProvider(resourceFile));
+ tntnet.str(string());
if(provider.get()){
- string resourceURI = provider->GetHTTPUri(row2.getString(property::resource::KEY_RESOURCE), cMediaServer::GetInstance()->GetServerIPAddress());
-
- IXML_Element* resource = ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_RESOURCE, resourceURI);
-
- if(resource){
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_PROTOCOL_INFO, row2.getString(property::resource::KEY_PROTOCOL_INFO));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_BITRATE, row2.getString(property::resource::KEY_BITRATE));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_BITS_PER_SAMPLE, row2.getString(property::resource::KEY_BITS_PER_SAMPLE));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_COLOR_DEPTH, row2.getString(property::resource::KEY_COLOR_DEPTH));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_DURATION, row2.getString(property::resource::KEY_DURATION));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_NR_AUDIO_CHANNELS, row2.getString(property::resource::KEY_NR_AUDIO_CHANNELS));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_RESOLUTION, row2.getString(property::resource::KEY_RESOLUTION));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_SAMPLE_FREQUENCY, row2.getString(property::resource::KEY_SAMPLE_FREQUENCY));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_SIZE, tools::ToString(row2.getInt64(property::resource::KEY_SIZE)));
+ resourceURI = provider->GetHTTPUri(resourceFile, cMediaServer::GetInstance()->GetServerIPAddress(), row2.getString(property::resource::KEY_PROTOCOL_INFO));
+ if(resourceURI.empty()){
+ tntnet << cMediaServer::GetInstance()->GetWebserver().GetBaseUrl() << "getStream?objectID=" << objectID << "&resourceID=" << i++;
+ resourceURI = tntnet.str();
}
+ } else if(resourceFile.find("thumb://",0) == 0 && !resourceFile.substr(8).empty()) {
+ tntnet << cMediaServer::GetInstance()->GetWebserver().GetBaseUrl() << "thumbs/" << resourceFile.substr(8);
+ resourceURI = tntnet.str();
+ }
+
+ IXML_Element* resource = ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::resource::KEY_RESOURCE, resourceURI);
+
+ if(resource){
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_PROTOCOL_INFO, row2.getString(property::resource::KEY_PROTOCOL_INFO));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_BITRATE, row2.getString(property::resource::KEY_BITRATE));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_BITS_PER_SAMPLE, row2.getString(property::resource::KEY_BITS_PER_SAMPLE));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_COLOR_DEPTH, row2.getString(property::resource::KEY_COLOR_DEPTH));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_DURATION, row2.getString(property::resource::KEY_DURATION));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_NR_AUDIO_CHANNELS, row2.getString(property::resource::KEY_NR_AUDIO_CHANNELS));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_RESOLUTION, row2.getString(property::resource::KEY_RESOLUTION));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_SAMPLE_FREQUENCY, row2.getString(property::resource::KEY_SAMPLE_FREQUENCY));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, resource, property::resource::KEY_SIZE, tools::ToString(row2.getInt64(property::resource::KEY_SIZE)));
}
}
diff --git a/media/pluginManager.cpp b/media/pluginManager.cpp
index ea7f82a..66cf69d 100644
--- a/media/pluginManager.cpp
+++ b/media/pluginManager.cpp
@@ -278,7 +278,7 @@ bool cUPnPResourceProvider::GetMetadata(const string& uri, cMetadata& metadata){
}
-string cUPnPResourceProvider::GetHTTPUri(const string&, const string&){
+string cUPnPResourceProvider::GetHTTPUri(const string&, const string&, const string&){
return string();
}
@@ -393,16 +393,12 @@ bool upnp::cPluginManager::DLL::Load(){
if (!(error = dlerror())){
isProvider = true;
return true;
- } else {
- cerr << error << endl;
}
function = (FuncPtr)dlsym(handle, "UPnPCreateMediaProfiler");
if (!(error = dlerror())){
isProvider = false;
return true;
- } else {
- cerr << error << endl;
}
} else {
cerr << "Error while opening plugin: " << error << endl;
diff --git a/media/profile.cpp b/media/profile.cpp
index 0cff566..8c9df6f 100644
--- a/media/profile.cpp
+++ b/media/profile.cpp
@@ -11,6 +11,42 @@
using namespace upnp;
+ProtocolInfo::ProtocolInfo()
+: streamType(DLNA_STREAM_HTTP)
+, contentType(string())
+, fourthField(DLNA4thField())
+{
+}
+
+ProtocolInfo::ProtocolInfo(string ct, DLNA4thField ffld, StreamType t)
+: streamType(t)
+, contentType(ct)
+, fourthField(ffld)
+{
+}
+
+string ProtocolInfo::ToString(){
+ if(contentType.empty()) return string();
+
+ stringstream ss;
+ switch(streamType){
+ case DLNA_STREAM_HTTP:
+ ss << "http-get:";
+ break;
+ case DLNA_STREAM_RTP:
+ ss << "rtsp-rtp-udp:";
+ break;
+ }
+
+ ss << "*:";
+
+ ss << contentType << ":";
+
+ ss << fourthField.ToString();
+
+ return ss.str();
+}
+
DLNA4thField::DLNA4thField()
: profile(string())
, operations(DLNA_OPERATION_NONE)
@@ -30,17 +66,20 @@ DLNA4thField::DLNA4thField(string pn, uint8_t op, string ps, bool ci, uint32_t f
}
string DLNA4thField::ToString(){
- stringstream ss;
-
if(profile.empty()) return "*";
- ss << "DLNA.ORG_PN=" << profile << ";";
+ stringstream ss;
+ ss << "DLNA.ORG_PN=" << profile;
+
+ if(primaryFlags){
+ ss << ";";
- ss << "DLNA.ORG_OP=" << bitset<2>(operations) << ";";
+ ss << "DLNA.ORG_OP=" << bitset<2>(operations) << ";";
- ss << "DLNA.ORG_CI=" << bitset<1>(conversionIndicator) << ";";
+ ss << "DLNA.ORG_CI=" << bitset<1>(conversionIndicator) << ";";
- ss << "DLNA.ORG_FLAGS=" << hex << primaryFlags << "000000000000000000000000" << ";";
+ ss << "DLNA.ORG_FLAGS=" << hex << primaryFlags << "000000000000000000000000";
+ }
return ss.str();
}