aboutsummaryrefslogtreecommitdiffstats
path: root/Input
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-06-05 18:59:26 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2017-06-05 18:51:15 +0000
commit473e4b514ff411a1d4372f29eccea616d7ea4c60 (patch)
tree6632c5dc686df63546dbf7b0bb5d171d4707e5d7 /Input
parent1ae6dc57663401973bbbdd090776494b194957d1 (diff)
- Changed library icnet - application interface
Change-Id: I25112ab1e1401a21ed2530d3874a7b4bf740ec5d Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'Input')
-rw-r--r--Input/DASHReceiver.cpp2
-rw-r--r--Input/ICNConnectionConsumerApi.cpp149
-rw-r--r--Input/ICNConnectionConsumerApi.h21
3 files changed, 51 insertions, 121 deletions
diff --git a/Input/DASHReceiver.cpp b/Input/DASHReceiver.cpp
index e7a5c5c2..df9d019b 100644
--- a/Input/DASHReceiver.cpp
+++ b/Input/DASHReceiver.cpp
@@ -133,7 +133,7 @@ MediaObject* DASHReceiver::GetNextSegment ()
if(this->segmentNumber >= this->representationStream->getSize())
{
- //qDebug("looping? : %s\n", this->isLooping ? "YES" : "NO");
+ qDebug("looping? : %s\n", this->isLooping ? "YES" : "NO");
if(this->isLooping)
{
this->segmentNumber = 0;
diff --git a/Input/ICNConnectionConsumerApi.cpp b/Input/ICNConnectionConsumerApi.cpp
index d38642e4..62e9ecdf 100644
--- a/Input/ICNConnectionConsumerApi.cpp
+++ b/Input/ICNConnectionConsumerApi.cpp
@@ -23,7 +23,7 @@
using namespace dash;
using namespace dash::network;
using namespace dash::metrics;
-using namespace icnet;
+//using namespace icnet;
using std::bind;
using std::placeholders::_1;
@@ -37,7 +37,6 @@ namespace libdash {
namespace framework {
namespace input {
ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, float drop) :
- m_recv_name(ccnx::Name()),
m_first(1),
m_isFinished(false),
sizeDownloaded (0),
@@ -53,11 +52,12 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
this->deezDataSize = 0;
this->datSize = 0;
this->dataPos = 0;
+ this->res = false;
InitializeConditionVariable (&this->contentRetrieved);
InitializeCriticalSection (&this->monitorMutex);
-
- this->myConsumer = new ConsumerSocket(ccnx::Name(), TransportProtocolAlgorithms::RAAQM);
- this->myConsumer->setSocketOption(RaaqmTransportOptions::GAMMA_VALUE, (int)gamma);
+ this->hTTPClientConnection = new libl4::http::HTTPClientConnection();
+ //this->myConsumer = new ConsumerSocket(ccnx::Name(), TransportProtocolAlgorithms::RAAQM);
+ //this->myConsumer->setSocketOption(RaaqmTransportOptions::GAMMA_VALUE, (int)gamma);
bool configFile = false;
//CHECK if we are not going to override the configuration file. (if !autotune)
@@ -68,12 +68,13 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
}
if(!configFile)
{
- this->myConsumer->setSocketOption(RaaqmTransportOptions::BETA_VALUE, this->beta);
- this->myConsumer->setSocketOption(RaaqmTransportOptions::DROP_FACTOR, this->drop);
+ qDebug("beta %f, drop %f", this->beta, this->drop);
+ // this->myConsumer->setSocketOption(RaaqmTransportOptions::BETA_VALUE, this->beta);
+ // this->myConsumer->setSocketOption(RaaqmTransportOptions::DROP_FACTOR, this->drop);
}
- this->myConsumer->setSocketOption(RateEstimationOptions::RATE_ESTIMATION_OBSERVER, this);
- this->myConsumer->setSocketOption(ConsumerCallbacksOptions::CONTENT_RETRIEVED, (ConsumerContentCallback) bind(&ICNConnectionConsumerApi::processPayload, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
- this->myConsumer->setSocketOption(ConsumerCallbacksOptions::CONTENT_OBJECT_TO_VERIFY, (ConsumerContentObjectVerificationCallback)bind(&ICNConnectionConsumerApi::onPacket, this, std::placeholders::_1, std::placeholders::_2));
+ //this->myConsumer->setSocketOption(RateEstimationOptions::RATE_ESTIMATION_OBSERVER, this);
+ //this->myConsumer->setSocketOption(ConsumerCallbacksOptions::CONTENT_RETRIEVED, (ConsumerContentCallback) bind(&ICNConnectionConsumerApi::processPayload, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+ //this->myConsumer->setSocketOption(ConsumerCallbacksOptions::CONTENT_OBJECT_TO_VERIFY, (ConsumerContentObjectVerificationCallback)bind(&ICNConnectionConsumerApi::onPacket, this, std::placeholders::_1, std::placeholders::_2));
#ifdef NO_GUI
if(this->icnAlpha != 20)
this->icnRateBased = true;
@@ -85,7 +86,7 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
}
ICNConnectionConsumerApi::~ICNConnectionConsumerApi() {
- delete this->myConsumer;
+ delete this->hTTPClientConnection;
if(this->deezData)
{
free(this->deezData);
@@ -99,42 +100,27 @@ void ICNConnectionConsumerApi::Init(IChunk *chunk) {
Debug("ICN Connection: STARTING\n");
m_first = 1;
sizeDownloaded = 0;
- m_name = "ccnx:/" + chunk->Host() + chunk->Path();
+ m_name = chunk->AbsoluteURI().c_str();
m_isFinished = false;
res = false;
- dataPos = 0;
- datSize = 0;
- if(this->deezData)
- {
- memset(this->deezData, 0, this->deezDataSize);
- }
-
+ qDebug("ICN_Connection:\tINTIATED_to_name %s\n", m_name.c_str());
+ qDebug("ICN_Connection:\tSTARTING DOWNLOAD %s\n", m_name.c_str());
}
void ICNConnectionConsumerApi::InitForMPD(const std::string& url)
{
m_first = 1;
sizeDownloaded = 0;
-
- if(url.find("//") != std::string::npos)
- {
- int pos = url.find("//");
- char* myName = (char*)malloc(strlen(url.c_str()) - 1);
- strncpy(myName, url.c_str(), pos + 1);
- strncpy(myName + pos + 1, url.c_str() + pos + 2, strlen(url.c_str()) - pos - 2);
- m_name = std::string(myName);
- free(myName);
- }
- else
- {
- m_name = url;
- }
+ printf("initmpd %s\n", url.c_str());
+ m_name = url;
m_isFinished = false;
res = false;
dataPos = 0;
datSize = 0;
+
+ printf("initiated for mpd\n");
Debug("ICN_Connection:\tINTIATED_for_mpd %s\n", m_name.c_str());
}
@@ -146,60 +132,30 @@ int ICNConnectionConsumerApi::Read(uint8_t* data, size_t len, IChunk *chunk)
int ICNConnectionConsumerApi::Read(uint8_t *data, size_t len)
{
if(!res)
- m_start_time = std::chrono::system_clock::now();
-
- if(res)
{
- if(this->dataPos == this->datSize)
- {
- this->dnltime = std::chrono::duration_cast<duration_in_seconds>(std::chrono::system_clock::now() - m_start_time).count();
- if(speed == 0 || !this->icnRateBased)
- speed = (double) (sizeDownloaded * 8 / this->dnltime);
- cumulativeBytesReceived += sizeDownloaded;
- Debug("ICN_Connection:\tFINISHED DOWNLOADING %s Average_DL: %f size: %lu cumulative: %lu Throughput: %f\n", m_name.c_str(), speed, sizeDownloaded, cumulativeBytesReceived, (double) (sizeDownloaded * 8 / this->dnltime));
- return 0;
- }
- if((this->datSize - this->dataPos) > (int)len)
- {
- memcpy(data, this->deezData + this->dataPos, len);
- this->dataPos += len;
- sizeDownloaded += len;
- return len;
- }
- else
- {
- assert(this->datSize - this->dataPos > 0);
- memcpy(data, this->deezData + this->dataPos, this->datSize - this->dataPos);
- int temp = this->datSize - this->dataPos;
- this->dataPos += this->datSize - this->dataPos;
- sizeDownloaded += temp;
- return temp;
- }
+ std::string s(m_name.c_str());
+ hTTPClientConnection->get(s);
+ response = hTTPClientConnection->response();
+ std::cout << m_name.c_str()<< " SIZE:" << response.size() << std::endl;
+ this->res = true;
+ this->dataPos = 0;
}
-
- Debug("will consume: %s\n", m_name.c_str());
- this->myConsumer->consume(m_name);
- EnterCriticalSection(&this->monitorMutex);
-
- while(this->m_isFinished == false)
- SleepConditionVariableCS(&this->contentRetrieved, &this->monitorMutex, INFINITE);
-
- assert(this->datSize != 0);
- this->res = true;
- LeaveCriticalSection(&this->monitorMutex);
- if(this->datSize > (int)len)
+ if (response.size() - this->dataPos > (int)len)
{
- memcpy(data, this->deezData, len);
- this->dataPos += len;
- sizeDownloaded += len;
- return len;
- }
- else
+ memcpy(data, (char*)response.data() + this->dataPos, len);
+ this->dataPos += len;
+ return len;
+ } else
{
- memcpy(data, this->deezData, this->datSize);
- this->dataPos += this->datSize;
- sizeDownloaded += this->datSize;
- return this->datSize;
+ printf("minore uguale\n");
+ memcpy(data, (char*)response.data() + this->dataPos, response.size() - this->dataPos);
+ int length = response.size() - this->dataPos;
+ if (length == 0)
+ {
+ this->res = false;
+ }
+ this->dataPos = response.size();
+ return length;
}
}
@@ -207,33 +163,6 @@ int ICNConnectionConsumerApi::Peek(uint8_t *data, size_t len, IChunk
return -1;
}
-bool ICNConnectionConsumerApi::onPacket(ConsumerSocket& c, const ContentObject& data)
-{
- return true;
-}
-
-void ICNConnectionConsumerApi::processPayload(ConsumerSocket& c, const uint8_t* buffer, size_t bufferSize)
-{
- EnterCriticalSection(&this->monitorMutex);
- if(this->deezData == NULL)
- {
- this->deezData = (char *)malloc(bufferSize*sizeof(uint8_t));
- this->deezDataSize = bufferSize;
- }
- else
- {
- if(bufferSize > this->deezDataSize)
- {
- this->deezData = (char *)realloc(this->deezData, bufferSize * (sizeof(uint8_t)));
- this->deezDataSize = bufferSize;
- }
- }
- memcpy(this->deezData, buffer, bufferSize*sizeof(uint8_t));
- this->m_isFinished = true;
- this->datSize = (int) bufferSize;
- WakeAllConditionVariable(&this->contentRetrieved);
- LeaveCriticalSection(&this->monitorMutex);
-}
double ICNConnectionConsumerApi::GetAverageDownloadingSpeed()
{
diff --git a/Input/ICNConnectionConsumerApi.h b/Input/ICNConnectionConsumerApi.h
index a62f6b01..0ee5cba7 100644
--- a/Input/ICNConnectionConsumerApi.h
+++ b/Input/ICNConnectionConsumerApi.h
@@ -16,6 +16,13 @@
#ifndef QTPLAYER_INPUT_ICNCONNECTIONCONSUMERAPI_H_
#define QTPLAYER_INPUT_ICNCONNECTIONCONSUMERAPI_H_
+#if defined(HICNET)
+#include <hicnet/hicnet_http_facade.h>
+#else
+#include <icnet/icnet_http_facade.h>
+#endif
+
+#include <QMessageLogger>
#include "../Portable/Networking.h"
#include "IICNConnection.h"
#include "../debug.h"
@@ -30,8 +37,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <algorithm>
-#include <icnet/icnet_socket_consumer.h>
-#include <icnet/icnet_download_observer.h>
+
#include <future>
#include <inttypes.h>
#include <time.h>
@@ -50,7 +56,7 @@ namespace libdash {
namespace framework {
namespace input {
-class ICNConnectionConsumerApi : public IICNConnection, public icnet::IcnObserver {
+class ICNConnectionConsumerApi : public IICNConnection {
public:
ICNConnectionConsumerApi(double alpha, float beta, float drop);
virtual ~ICNConnectionConsumerApi();
@@ -69,10 +75,6 @@ public:
virtual double GetDownloadingTime();
- void processPayload(icnet::ConsumerSocket& , const uint8_t*, size_t);
-
- bool onPacket(icnet::ConsumerSocket& , const icnet::ContentObject&);
-
const std::vector<dash::metrics::ITCPConnection *> &GetTCPConnectionList() const;
const std::vector<dash::metrics::IHTTPTransaction *> &GetHTTPTransactionList() const;
@@ -81,6 +83,8 @@ public:
virtual void notifyStats(double throughput);
private:
+ libl4::http::HTTPClientConnection *hTTPClientConnection;
+ libl4::http::HTTPResponse response;
float beta;
float drop;
uint64_t i_chunksize;
@@ -89,8 +93,6 @@ private:
/**< number of content objects we missed in ICNBlock */
std::string m_name;
- icnet::ccnx::Name m_recv_name;
- icnet::ccnx::Portal m_portal;
int m_first;
bool m_isFinished;
uint64_t m_nextSeg;
@@ -109,7 +111,6 @@ private:
unsigned int nchunks; // XXX chunks=-1 means: download the whole file!
bool output;
bool report_path;
- icnet::ConsumerSocket* myConsumer;
bool res;
std::vector<char> mdata;
char* deezData;