aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-03-22 11:04:20 +0100
committerAngelo Mantellini <manangel@cisco.com>2019-03-22 11:36:21 +0100
commitb5fc2106912f0ed3168972caee33b45ee6bb4b53 (patch)
tree4340be4fdab0c0d54c36f041d69421bc6ff41e05
parent78089ad6898f15bc6a716eb39e3f6087dfd9f553 (diff)
[HICN-8] Update viper video player to use hicn sockets over HTTP
Change-Id: I0aa727e513e3ffcf3286cecc7e7c43237da5155f Signed-off-by: Angelo Mantellini <manangel@cisco.com>
-rw-r--r--.qmake.stash15
-rw-r--r--Input/ICNConnectionConsumerApi.cpp25
-rw-r--r--Input/ICNConnectionConsumerApi.h11
-rw-r--r--UI/DASHPlayer.cpp1
-rw-r--r--Websocket/WebSocketService.cpp4
-rw-r--r--Websocket/WebSocketService.h1
-rw-r--r--Websocket/communication-protocol.cpp11
-rw-r--r--Websocket/communication-protocol.h4
-rw-r--r--Websocket/tcp-server.cpp48
-rw-r--r--Websocket/tcp-server.h12
-rw-r--r--Websocket/websocket-server.cpp8
-rw-r--r--viper.pro40
12 files changed, 93 insertions, 87 deletions
diff --git a/.qmake.stash b/.qmake.stash
deleted file mode 100644
index d717b0a6..00000000
--- a/.qmake.stash
+++ /dev/null
@@ -1,15 +0,0 @@
-QMAKE_DEFAULT_INCDIRS = \
- /usr/include/c++/5 \
- /usr/include/x86_64-linux-gnu/c++/5 \
- /usr/include/c++/5/backward \
- /usr/lib/gcc/x86_64-linux-gnu/5/include \
- /usr/local/include \
- /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed \
- /usr/include/x86_64-linux-gnu \
- /usr/include
-QMAKE_DEFAULT_LIBDIRS = \
- /usr/lib/gcc/x86_64-linux-gnu/5 \
- /usr/lib/x86_64-linux-gnu \
- /usr/lib \
- /lib/x86_64-linux-gnu \
- /lib
diff --git a/Input/ICNConnectionConsumerApi.cpp b/Input/ICNConnectionConsumerApi.cpp
index 15475d5f..f983a054 100644
--- a/Input/ICNConnectionConsumerApi.cpp
+++ b/Input/ICNConnectionConsumerApi.cpp
@@ -55,8 +55,12 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
this->res = false;
InitializeConditionVariable (&this->contentRetrieved);
InitializeCriticalSection (&this->monitorMutex);
- this->hTTPClientConnection = new libl4::http::HTTPClientConnection();
- libl4::transport::ConsumerSocket &c = this->hTTPClientConnection->getConsumer();
+ this->hTTPClientConnection = new libl4::http::HTTPClientConnection();
+#ifdef HICNET
+ transport::interface::ConsumerSocket &c = this->hTTPClientConnection->getConsumer();
+#else
+ libl4::transport::ConsumerSocket &c = this->hTTPClientConnection->getConsumer();
+#endif
bool configFile = false;
//CHECK if we are not going to override the configuration file. (if !autotune)
if(FILE *fp = fopen("/usr/etc/consumer.conf", "r"))
@@ -64,14 +68,25 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
fclose(fp);
configFile = true;
}
+#ifdef HICNET
if(!configFile)
{
qDebug("beta %f, drop %f", this->beta, this->drop);
- c.setSocketOption(libl4::transport::RaaqmTransportOptions::BETA_VALUE, this->beta);
- c.setSocketOption(libl4::transport::RaaqmTransportOptions::DROP_FACTOR, this->drop);
+ c.setSocketOption(transport::interface::RaaqmTransportOptions::BETA_VALUE, this->beta);
+ c.setSocketOption(transport::interface::RaaqmTransportOptions::DROP_FACTOR, this->drop);
}
- c.setSocketOption(int(libl4::transport::RateEstimationOptions::RATE_ESTIMATION_OBSERVER), (libl4::transport::IcnObserver * )this);
+ c.setSocketOption(int(transport::interface::RateEstimationOptions::RATE_ESTIMATION_OBSERVER), (transport::protocol::IcnObserver * )this);
+#else
+ if(!configFile)
+ {
+ qDebug("beta %f, drop %f", this->beta, this->drop);
+
+ c.setSocketOption(libl4::transport::RaaqmTransportOptions::BETA_VALUE, this->beta);
+ c.setSocketOption(libl4::transport::RaaqmTransportOptions::DROP_FACTOR, this->drop);
+ }
+ c.setSocketOption(int(libl4::transport::RateEstimationOptions::RATE_ESTIMATION_OBSERVER), (libl4::transport::IcnObserver * )this);
+#endif
#ifdef NO_GUI
if(this->icnAlpha != 20)
this->icnRateBased = true;
diff --git a/Input/ICNConnectionConsumerApi.h b/Input/ICNConnectionConsumerApi.h
index 9a5f8a47..c05c5244 100644
--- a/Input/ICNConnectionConsumerApi.h
+++ b/Input/ICNConnectionConsumerApi.h
@@ -17,7 +17,8 @@
#define QTPLAYER_INPUT_ICNCONNECTIONCONSUMERAPI_H_
#if defined(HICNET)
-#include <hicnet/hicnet_http_facade.h>
+#include <hicn/transport/http/facade.h>
+#include <hicn/transport/protocols/download_observer.h>
#else
#include <icnet/icnet_http_facade.h>
#endif
@@ -45,7 +46,6 @@
#include <errno.h>
#include "../Portable/MultiThreading.h"
-#include <boost/exception/diagnostic_information.hpp>
//logging purpose
#include <chrono>
@@ -56,7 +56,13 @@ namespace libdash {
namespace framework {
namespace input {
+#if defined(HICNET)
+class ICNConnectionConsumerApi : public IICNConnection, public transport::protocol::IcnObserver{
+#else
class ICNConnectionConsumerApi : public IICNConnection, public libl4::transport::IcnObserver{
+#endif
+
+
public:
ICNConnectionConsumerApi(double alpha, float beta, float drop);
virtual ~ICNConnectionConsumerApi();
@@ -81,7 +87,6 @@ public:
virtual void SetBeta(float beta);
virtual void SetDrop(float drop);
- //libl4::transport::IcnObserver
virtual void notifyStats(double throughput);
virtual void notifyDownloadTime(double downloadingTime);
diff --git a/UI/DASHPlayer.cpp b/UI/DASHPlayer.cpp
index e2910ea8..efb85620 100644
--- a/UI/DASHPlayer.cpp
+++ b/UI/DASHPlayer.cpp
@@ -11,6 +11,7 @@
#include "DASHPlayer.h"
#include <iostream>
+#include "QtAV/AVError.h"
using namespace libdash::framework::adaptation;
using namespace libdash::framework::mpd;
diff --git a/Websocket/WebSocketService.cpp b/Websocket/WebSocketService.cpp
index b2fd4e16..c4cc83ab 100644
--- a/Websocket/WebSocketService.cpp
+++ b/Websocket/WebSocketService.cpp
@@ -65,7 +65,9 @@ void* WebSocketService::listenWebsocket(void *webSocketServiceObject)
std::string command((char *) data, size);
- boost::trim(command);
+ std::stringstream trimmer;
+ trimmer << command;
+ trimmer >> command;
std::cout << command << std::endl;
diff --git a/Websocket/WebSocketService.h b/Websocket/WebSocketService.h
index 9b084a24..631da4c9 100644
--- a/Websocket/WebSocketService.h
+++ b/Websocket/WebSocketService.h
@@ -18,7 +18,6 @@
#include "connection-pool.h"
#include "query.h"
#include "communication-protocol.h"
-#include <boost/algorithm/string/trim.hpp>
class WebSocketService
diff --git a/Websocket/communication-protocol.cpp b/Websocket/communication-protocol.cpp
index 99bcfa90..3e5f979c 100644
--- a/Websocket/communication-protocol.cpp
+++ b/Websocket/communication-protocol.cpp
@@ -16,7 +16,6 @@
#include "websocket-server.h"
#include "communication-protocol.h"
-
///////////////////
//Explanation: A query can select/update 2 objects:
// - Coordinates of a node
@@ -34,7 +33,7 @@ std::set<std::string> ProtocolDetails::AllowedObjectName = {"stats"};
std::set<std::string> ProtocolDetails::AllowedActions = { "select", "subscribe"};
std::set<std::string> ProtocolDetails::AllowedFields = {"quality", "rate", "all"};
-std::function<void(const boost::system::error_code&)> CommunicationProtocol::timerCallback;
+std::function<void(const std::error_code&)> CommunicationProtocol::timerCallback;
CommunicationProtocol::CommunicationProtocol(ProtocolVersion version)
: version(version)
@@ -150,10 +149,10 @@ CommunicationProtocol::processQuery(Server *s, websocketpp::connection_hdl hdl,
} else if (action == *ProtocolDetails::AllowedActions.find("subscribe")) {
- subscribeTimer = std::shared_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer(s->get_io_service(),
- boost::posix_time::milliseconds(1000)));
+ subscribeTimer = std::shared_ptr<asio::steady_timer>(new asio::steady_timer(s->get_io_service(),
+ std::chrono::milliseconds(1000)));
timerCallback = [this, s, hdl, msg, query]
- (const boost::system::error_code &ec) {
+ (const std::error_code &ec) {
if (!ec) {
Query reply = this->makeReplyQuery(query);
@@ -171,7 +170,7 @@ CommunicationProtocol::processQuery(Server *s, websocketpp::connection_hdl hdl,
return;
}
- subscribeTimer->expires_from_now(boost::posix_time::milliseconds(1000));
+ subscribeTimer->expires_from_now(std::chrono::milliseconds(1000));
subscribeTimer->async_wait(timerCallback);
}
};
diff --git a/Websocket/communication-protocol.h b/Websocket/communication-protocol.h
index f3c488ef..25b15a6f 100644
--- a/Websocket/communication-protocol.h
+++ b/Websocket/communication-protocol.h
@@ -71,14 +71,14 @@ public:
void
setGraphDataSource(GraphDataSource *graphDataSource);
- static std::function<void(const boost::system::error_code&)> timerCallback;
+ static std::function<void(const std::error_code&)> timerCallback;
private:
GraphDataSource *graphDataSource;
ProtocolVersion version;
- std::shared_ptr<boost::asio::deadline_timer> subscribeTimer;
+ std::shared_ptr<asio::steady_timer> subscribeTimer;
};
diff --git a/Websocket/tcp-server.cpp b/Websocket/tcp-server.cpp
index 4eb5d29d..cffd326b 100644
--- a/Websocket/tcp-server.cpp
+++ b/Websocket/tcp-server.cpp
@@ -35,11 +35,11 @@ TcpServer::start()
if (io_service.stopped())
io_service.reset();
- boost::asio::ip::tcp::endpoint endpoint;
- endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port);
+ asio::ip::tcp::endpoint endpoint;
+ endpoint = asio::ip::tcp::endpoint(asio::ip::tcp::v4(), port);
acceptor.open(endpoint.protocol());
- acceptor.set_option(boost::asio::socket_base::reuse_address(true));
+ acceptor.set_option(asio::socket_base::reuse_address(true));
acceptor.bind(endpoint);
acceptor.listen();
@@ -47,10 +47,10 @@ TcpServer::start()
//Set interrupt callbacks
- boost::asio::io_service io_service;
- boost::asio::signal_set signals(io_service, SIGINT, SIGQUIT);
+ asio::io_service io_service;
+ asio::signal_set signals(io_service, SIGINT, SIGQUIT);
- signals.async_wait([this] (const boost::system::error_code &errorCode, int) {
+ signals.async_wait([this] (const std::error_code &errorCode, int) {
std::cout << "Gracefully terminating tcp server" << std::endl;
this->io_service.reset();
this->acceptor.cancel();
@@ -64,12 +64,12 @@ TcpServer::accept()
{
//Create new socket for this connection
//Shared_ptr is used to pass temporary objects to the asynchronous functions
- std::shared_ptr<boost::asio::ip::tcp::socket> socket(new boost::asio::ip::tcp::socket(io_service));
- acceptor.async_accept(*socket, [this, socket](const boost::system::error_code &ec) {
+ std::shared_ptr<asio::ip::tcp::socket> socket(new asio::ip::tcp::socket(io_service));
+ acceptor.async_accept(*socket, [this, socket](const std::error_code &ec) {
accept();
if (ec) {
- if (ec == boost::asio::error::operation_aborted) // when the socket is closed by someone
+ if (ec == asio::error::operation_aborted) // when the socket is closed by someone
return;
}
@@ -78,17 +78,17 @@ TcpServer::accept()
}
void
-TcpServer::processIncomingData(std::shared_ptr<boost::asio::ip::tcp::socket> socket)
+TcpServer::processIncomingData(std::shared_ptr<asio::ip::tcp::socket> socket)
{
// Set timeout on the following boost::asio::async-read or write function
- std::shared_ptr<boost::asio::deadline_timer> timer;
+ std::shared_ptr<asio::steady_timer> timer;
if (read_timeout > 0)
timer = set_timeout_on_socket(socket, read_timeout);
- std::shared_ptr<boost::asio::streambuf> buffer(new boost::asio::streambuf());
+ std::shared_ptr<asio::streambuf> buffer(new asio::streambuf());
- boost::asio::async_read_until(*socket, *buffer, "\r\n\r\n",
- [this, timer, buffer, socket](const boost::system::error_code& error, std::size_t bytes_transferred) {
+ asio::async_read_until(*socket, *buffer, "\r\n\r\n",
+ [this, timer, buffer, socket](const std::error_code& error, std::size_t bytes_transferred) {
if (read_timeout > 0)
timer->cancel();
@@ -99,14 +99,14 @@ TcpServer::processIncomingData(std::shared_ptr<boost::asio::ip::tcp::socket> soc
std::size_t bufferSize = buffer->size();
buffer->commit(buffer->size());
- const uint8_t *data = boost::asio::buffer_cast<const uint8_t *>(buffer->data());
+ const uint8_t *data = asio::buffer_cast<const uint8_t *>(buffer->data());
std::string reply = handler(data, bufferSize);
if (reply != "") {
- boost::asio::async_write(*socket, boost::asio::buffer(reply.c_str(), reply.size()), [this]
- (boost::system::error_code ec, std::size_t /*length*/)
+ asio::async_write(*socket, asio::buffer(reply.c_str(), reply.size()), [this]
+ (std::error_code ec, std::size_t /*length*/)
{
if (!ec) {
std::cout << "Reply sent!" << std::endl;
@@ -120,16 +120,16 @@ TcpServer::processIncomingData(std::shared_ptr<boost::asio::ip::tcp::socket> soc
}
-std::shared_ptr<boost::asio::deadline_timer>
-TcpServer::set_timeout_on_socket(std::shared_ptr<boost::asio::ip::tcp::socket> socket, long seconds)
+std::shared_ptr<asio::steady_timer>
+TcpServer::set_timeout_on_socket(std::shared_ptr<asio::ip::tcp::socket> socket, long seconds)
{
- std::shared_ptr<boost::asio::deadline_timer> timer(new boost::asio::deadline_timer(io_service));
- timer->expires_from_now(boost::posix_time::seconds(seconds));
- timer->async_wait([socket](const boost::system::error_code &ec) {
+ std::shared_ptr<asio::steady_timer> timer(new asio::steady_timer(io_service));
+ timer->expires_from_now(std::chrono::seconds(seconds));
+ timer->async_wait([socket](const std::error_code &ec) {
if (!ec) {
- boost::system::error_code ec;
+ std::error_code ec;
std::cout << "Connection timeout!" << std::endl;
- socket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
+ socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec);
socket->lowest_layer().close();
}
});
diff --git a/Websocket/tcp-server.h b/Websocket/tcp-server.h
index f93d1b43..720d2c7e 100644
--- a/Websocket/tcp-server.h
+++ b/Websocket/tcp-server.h
@@ -17,8 +17,8 @@
#define TCP_SERVER_H
#include <functional>
-#include <boost/asio.hpp>
#include <iostream>
+#include <asio.hpp>
typedef std::function<std::string(const uint8_t*,
std::size_t)> HandlerFunction;
@@ -43,14 +43,14 @@ private:
accept();
void
- processIncomingData(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
+ processIncomingData(std::shared_ptr<asio::ip::tcp::socket> socket);
- std::shared_ptr<boost::asio::deadline_timer>
- set_timeout_on_socket(std::shared_ptr<boost::asio::ip::tcp::socket> socket, long seconds);
+ std::shared_ptr<asio::steady_timer>
+ set_timeout_on_socket(std::shared_ptr<asio::ip::tcp::socket> socket, long seconds);
unsigned short port;
- boost::asio::io_service io_service;
- boost::asio::ip::tcp::acceptor acceptor;
+ asio::io_service io_service;
+ asio::ip::tcp::acceptor acceptor;
long read_timeout;
HandlerFunction handler;
};
diff --git a/Websocket/websocket-server.cpp b/Websocket/websocket-server.cpp
index ee79ccdb..58463caa 100644
--- a/Websocket/websocket-server.cpp
+++ b/Websocket/websocket-server.cpp
@@ -29,7 +29,7 @@ WebSocketServer::WebSocketServer(unsigned short port)
server.set_message_handler(bind(&WebSocketServer::onMessage, this, &server, ::_1, ::_2));
// Listen on port
- server.listen(boost::asio::ip::tcp::v4(),port);
+ server.listen(asio::ip::tcp::v4(),port);
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
@@ -58,10 +58,10 @@ WebSocketServer::start()
//Set interrupt callbacks
- boost::asio::io_service io_service;
- boost::asio::signal_set signals(server.get_io_service(), SIGINT, SIGQUIT);
+ asio::io_service io_service;
+ asio::signal_set signals(server.get_io_service(), SIGINT, SIGQUIT);
- signals.async_wait([this](const boost::system::error_code &errorCode, int) {
+ signals.async_wait([this](const std::error_code &errorCode, int) {
std::cout << "Gracefully terminating websocket server" << std::endl;
this->m_isRunning = false;
this->server.stop();
diff --git a/viper.pro b/viper.pro
index f344babd..4290c7e1 100644
--- a/viper.pro
+++ b/viper.pro
@@ -18,12 +18,11 @@ android {
QT += androidextras
}
-message($$TRANSPORT_LIBRARY)
CONFIG -= release
CONFIG += debug
-CONFIG += c++11
-QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DANDROID_STL=c++_static #-DICNICPDOWNLOAD
-QMAKE_CXXFLAGS += -std=c++11 -g -fpermissive
+CONFIG += c++14
+QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DANDROID_STL=c++_static
+QMAKE_CXXFLAGS += -std=c++14 -g -fpermissive -DASIO_STANDALONE=1
# Add more folders to ship with the application, here
folder_01.source = qml/Viper
folder_01.target = qml
@@ -277,30 +276,32 @@ unix:!macx:!android {
INCLUDEPATH += /usr/include
INCLUDEPATH += /usr/include/libdash
equals(TRANSPORT_LIBRARY, "HICNET") {
- LIBS += -L/usr/local/lib -ldash -lboost_system -lhicnet -lavcodec -lavutil -lavformat
+ LIBS += -L/usr/local/lib -ldash -lhicntransport -lavcodec -lavutil -lavformat
DEFINES += "HICNET=ON"
} else {
- LIBS += -L/usr/local/lib -ldash -lboost_system -licnet -lavcodec -lavutil -lavformat
+ LIBS += -L/usr/local/lib -ldash -licnet -lavcodec -lavutil -lavformat
DEFINES += "ICNET=ON"
}
}
macx:!ios {
-
QMAKE_INFO_PLIST = $$COMMON/Info.plist
ICON = $$COMMON/Viper.icns
QMAKE_RPATHDIR += /usr/local/lib
INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/libdash
INCLUDEPATH += $$[QT_HOST_PREFIX]/include/
+ INCLUDEPATH += $$[QT_HOST_PREFIX]/lib/QtAV.framework/Headers
equals(TRANSPORT_LIBRARY, "HICNET") {
- LIBS += -L"/usr/local/lib" -framework CoreServices -ldash -lavformat -lavutil -lavcodec -lboost_system -lboost_regex -lswscale -lhicnet -lssl -lcrypto
- DEFINES += "HICNET=ON"
- } else {
- LIBS += -L"/usr/local/lib" -framework CoreServices -ldash -lavformat -lavutil -lavcodec -lboost_system -lboost_regex -lswscale -licnet -lssl -lcrypto
- DEFINES += "ICNET=ON"
- }
+ LIBS += -L"/usr/local/lib" -framework CoreServices -ldash -lavformat -lavutil -lavcodec -lswscale -lhicntransport -lssl -lcrypto
+ LIBS += -F$$[QT_HOST_PREFIX]/lib/ -framework QtAV
+ DEFINES += "HICNET=ON"
+ } else {
+ LIBS += -L"/usr/local/lib" -framework CoreServices -ldash -lavformat -lavutil -lavcodec -lswscale -licnet -lssl -lcrypto
+ LIBS += -F$$[QT_HOST_PREFIX]/lib/ -framework QtAV
+ DEFINES += "ICNET=ON"
+ }
}
SOURCES *= main.cpp
android {
@@ -318,12 +319,12 @@ android {
INCLUDEPATH += $$(DISTILLARY_INSTALLATION_PATH)/include
INCLUDEPATH += $$(DISTILLARY_INSTALLATION_PATH)/include/libdash
equals(TRANSPORT_LIBRARY, "HICNET") {
- LIBS += -L"$$(DISTILLARY_INSTALLATION_PATH)/lib" -lhicnet -ljsoncpp -ldash -lcurl -lxml2 -lccnx_hicn_api_portal -lccnx_hicn_transport_rta -lccnx_hicn_api_control -lccnx_hicn_api_notify -lccnx_common -lparc -llongbow -llongbow-ansiterm -llongbow-textplain -lhicn -levent -lssl -lcrypto -lavcodec -lavutil -lavformat -lboost_system
- DEFINES += "HICNET=ON"
- } else {
- LIBS += -L"$$(DISTILLARY_INSTALLATION_PATH)/lib" -licnet -ldash -lcurl -lxml2 -lccnx_api_portal -lccnx_transport_rta -lccnx_api_control -lccnx_api_notify -lccnx_common -lparc -llongbow -llongbow-ansiterm -llongbow-textplain -levent -lssl -lcrypto -lavcodec -lavutil -lavformat -lboost_system
- DEFINES += "ICNET=ON"
- }
+ LIBS += -L"$$(DISTILLARY_INSTALLATION_PATH)/lib" -lhicnet -ljsoncpp -ldash -lcurl -lxml2 -lccnx_common -lparc -lhicntransport -lhicn -levent -lssl -lcrypto -lavcodec -lavutil -lavformat
+ DEFINES += "HICNET=ON"
+ } else {
+ LIBS += -L"$$(DISTILLARY_INSTALLATION_PATH)/lib" -licnet -ldash -lcurl -lxml2 -lccnx_api_portal -lccnx_transport_rta -lccnx_api_control -lccnx_api_notify -lccnx_common -lparc -llongbow -llongbow-ansiterm -llongbow-textplain -levent -lssl -lcrypto -lavcodec -lavutil -lavformat -lboost_system
+ DEFINES += "ICNET=ON"
+ }
}
@@ -336,4 +337,3 @@ DISTFILES += \
android/gradle.properties \
android/src/org/qtav/qmlplayer/ViperActivity.java \
android/src/org/player/viper/ViperActivity.java
-