summaryrefslogtreecommitdiff
path: root/src/components/media_manager/src/pipe_streamer_adapter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/media_manager/src/pipe_streamer_adapter.cc')
-rw-r--r--src/components/media_manager/src/pipe_streamer_adapter.cc65
1 files changed, 32 insertions, 33 deletions
diff --git a/src/components/media_manager/src/pipe_streamer_adapter.cc b/src/components/media_manager/src/pipe_streamer_adapter.cc
index a61280f057..07ca407386 100644
--- a/src/components/media_manager/src/pipe_streamer_adapter.cc
+++ b/src/components/media_manager/src/pipe_streamer_adapter.cc
@@ -36,16 +36,15 @@
#include <unistd.h>
#include "utils/logger.h"
#include "utils/file_system.h"
-#include "config_profile/profile.h"
#include "media_manager/pipe_streamer_adapter.h"
namespace media_manager {
-CREATE_LOGGERPTR_GLOBAL(logger, "PipeStreamerAdapter")
+CREATE_LOGGERPTR_GLOBAL(logger_, "PipeStreamerAdapter")
PipeStreamerAdapter::PipeStreamerAdapter(
- const std::string& named_pipe_path)
- : StreamerAdapter(new PipeStreamer(this, named_pipe_path)) {
+ const std::string& named_pipe_path, const std::string& app_storage_folder)
+ : StreamerAdapter(new PipeStreamer(this, named_pipe_path, app_storage_folder)) {
}
PipeStreamerAdapter::~PipeStreamerAdapter() {
@@ -53,75 +52,75 @@ PipeStreamerAdapter::~PipeStreamerAdapter() {
PipeStreamerAdapter::PipeStreamer::PipeStreamer(
PipeStreamerAdapter* const adapter,
- const std::string& named_pipe_path)
+ const std::string& named_pipe_path,
+ const std::string& app_storage_folder)
: Streamer(adapter),
named_pipe_path_(named_pipe_path),
+ app_storage_folder_(app_storage_folder),
pipe_fd_(0) {
- if (!file_system::CreateDirectoryRecursively(
- profile::Profile::instance()->app_storage_folder())) {
- LOG4CXX_ERROR(logger, "Cannot create app storage folder "
- << profile::Profile::instance()->app_storage_folder() );
- return;
- }
-
- if ((mkfifo(named_pipe_path_.c_str(),
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
- && (errno != EEXIST)) {
- LOG4CXX_ERROR(logger, "Cannot create pipe " << named_pipe_path_);
- } else {
- LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_
- << " was successfuly created");
- }
+ if (!file_system::CreateDirectoryRecursively(app_storage_folder_)) {
+ LOG4CXX_ERROR(logger_, "Cannot create app storage folder "
+ << app_storage_folder_ );
+ return;
+ }
+ if ((mkfifo(named_pipe_path_.c_str(),
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
+ && (errno != EEXIST)) {
+ LOG4CXX_ERROR(logger_, "Cannot create pipe " << named_pipe_path_);
+ } else {
+ LOG4CXX_INFO(logger_, "Pipe " << named_pipe_path_
+ << " was successfully created");
+ }
}
-
PipeStreamerAdapter::PipeStreamer::~PipeStreamer() {
if (0 == unlink(named_pipe_path_.c_str()) ) {
- LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ << " was removed");
+ LOG4CXX_INFO(logger_, "Pipe " << named_pipe_path_ << " was removed");
} else {
- LOG4CXX_ERROR(logger, "Error removing pipe " << named_pipe_path_);
+ LOG4CXX_ERROR(logger_, "Error removing pipe " << named_pipe_path_);
}
}
+
bool PipeStreamerAdapter::PipeStreamer::Connect() {
- LOG4CXX_AUTO_TRACE(logger);
+ LOG4CXX_AUTO_TRACE(logger_);
pipe_fd_ = open(named_pipe_path_.c_str(), O_RDWR, 0);
if (-1 == pipe_fd_) {
- LOG4CXX_ERROR(logger, "Cannot open pipe for writing "
+ LOG4CXX_ERROR(logger_, "Cannot open pipe for writing "
<< named_pipe_path_);
return false;
}
- LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_
+ LOG4CXX_INFO(logger_, "Pipe " << named_pipe_path_
<< " was successfuly opened for writing");
return true;
}
void PipeStreamerAdapter::PipeStreamer::Disconnect() {
- LOG4CXX_AUTO_TRACE(logger);
+ LOG4CXX_AUTO_TRACE(logger_);
if (0 == close(pipe_fd_)) {
- LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ << " was closed");
+ LOG4CXX_INFO(logger_, "Pipe " << named_pipe_path_ << " was closed");
} else {
- LOG4CXX_ERROR(logger, "Error closing pipe " << named_pipe_path_);
+ LOG4CXX_ERROR(logger_, "Error closing pipe " << named_pipe_path_);
}
}
bool PipeStreamerAdapter::PipeStreamer::Send(
protocol_handler::RawMessagePtr msg) {
- LOG4CXX_AUTO_TRACE(logger);
+ LOG4CXX_AUTO_TRACE(logger_);
ssize_t ret = write(pipe_fd_, msg->data(), msg->data_size());
if (-1 == ret) {
- LOG4CXX_ERROR(logger, "Failed writing data to pipe "
+ LOG4CXX_ERROR(logger_, "Failed writing data to pipe "
<< named_pipe_path_);
return false;
}
if (static_cast<uint32_t>(ret) != msg->data_size()) {
- LOG4CXX_WARN(logger, "Couldn't write all the data to pipe "
+ LOG4CXX_WARN(logger_, "Couldn't write all the data to pipe "
<< named_pipe_path_);
}
- LOG4CXX_INFO(logger, "Streamer::sent " << msg->data_size());
+ LOG4CXX_INFO(logger_, "Streamer::sent " << msg->data_size());
return true;
}