|
@@ -21,6 +21,7 @@
|
|
#include "mediachainablehandler.hpp"
|
|
#include "mediachainablehandler.hpp"
|
|
|
|
|
|
#include "impl/internals.hpp"
|
|
#include "impl/internals.hpp"
|
|
|
|
+#include "impl/message.hpp"
|
|
|
|
|
|
#include <cassert>
|
|
#include <cassert>
|
|
|
|
|
|
@@ -34,7 +35,7 @@ MediaChainableHandler::~MediaChainableHandler() { leaf->recursiveRemoveChain();
|
|
bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
|
|
bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
|
|
bool result = true;
|
|
bool result = true;
|
|
if (product.control) {
|
|
if (product.control) {
|
|
- assert(product.control->type == Message::Control);
|
|
|
|
|
|
+ assert(product.control->type == impl::Message::Control);
|
|
auto sendResult = send(product.control);
|
|
auto sendResult = send(product.control);
|
|
if (!sendResult) {
|
|
if (!sendResult) {
|
|
LOG_DEBUG << "Failed to send control message";
|
|
LOG_DEBUG << "Failed to send control message";
|
|
@@ -48,7 +49,7 @@ bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
|
|
if (!message) {
|
|
if (!message) {
|
|
LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << messages->size();
|
|
LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << messages->size();
|
|
}
|
|
}
|
|
- auto sendResult = send(make_message(*message));
|
|
|
|
|
|
+ auto sendResult = send(impl::make_message(*message));
|
|
if (!sendResult) {
|
|
if (!sendResult) {
|
|
LOG_DEBUG << "Failed to send message " << i + 1 << "/" << messages->size();
|
|
LOG_DEBUG << "Failed to send message " << i + 1 << "/" << messages->size();
|
|
}
|
|
}
|
|
@@ -59,7 +60,7 @@ bool MediaChainableHandler::sendProduct(ChainedOutgoingProduct product) {
|
|
}
|
|
}
|
|
|
|
|
|
message_ptr MediaChainableHandler::handleIncomingBinary(message_ptr msg) {
|
|
message_ptr MediaChainableHandler::handleIncomingBinary(message_ptr msg) {
|
|
- assert(msg->type == Message::Binary);
|
|
|
|
|
|
+ assert(msg->type == impl::Message::Binary);
|
|
auto messages = root->split(msg);
|
|
auto messages = root->split(msg);
|
|
auto incoming = getLeaf()->formIncomingBinaryMessage(
|
|
auto incoming = getLeaf()->formIncomingBinaryMessage(
|
|
messages, [this](ChainedOutgoingProduct outgoing) { return sendProduct(outgoing); });
|
|
messages, [this](ChainedOutgoingProduct outgoing) { return sendProduct(outgoing); });
|
|
@@ -71,15 +72,15 @@ message_ptr MediaChainableHandler::handleIncomingBinary(message_ptr msg) {
|
|
}
|
|
}
|
|
|
|
|
|
message_ptr MediaChainableHandler::handleIncomingControl(message_ptr msg) {
|
|
message_ptr MediaChainableHandler::handleIncomingControl(message_ptr msg) {
|
|
- assert(msg->type == Message::Control);
|
|
|
|
|
|
+ assert(msg->type == impl::Message::Control);
|
|
auto incoming = getLeaf()->formIncomingControlMessage(
|
|
auto incoming = getLeaf()->formIncomingControlMessage(
|
|
msg, [this](ChainedOutgoingProduct outgoing) { return sendProduct(outgoing); });
|
|
msg, [this](ChainedOutgoingProduct outgoing) { return sendProduct(outgoing); });
|
|
- assert(!incoming || incoming->type == Message::Control);
|
|
|
|
|
|
+ assert(!incoming || incoming->type == impl::Message::Control);
|
|
return incoming;
|
|
return incoming;
|
|
}
|
|
}
|
|
|
|
|
|
message_ptr MediaChainableHandler::handleOutgoingBinary(message_ptr msg) {
|
|
message_ptr MediaChainableHandler::handleOutgoingBinary(message_ptr msg) {
|
|
- assert(msg->type == Message::Binary);
|
|
|
|
|
|
+ assert(msg->type == impl::Message::Binary);
|
|
auto messages = make_chained_messages_product(msg);
|
|
auto messages = make_chained_messages_product(msg);
|
|
auto optOutgoing = root->formOutgoingBinaryMessage(ChainedOutgoingProduct(messages));
|
|
auto optOutgoing = root->formOutgoingBinaryMessage(ChainedOutgoingProduct(messages));
|
|
if (!optOutgoing.has_value()) {
|
|
if (!optOutgoing.has_value()) {
|
|
@@ -102,17 +103,17 @@ message_ptr MediaChainableHandler::handleOutgoingBinary(message_ptr msg) {
|
|
if (!message) {
|
|
if (!message) {
|
|
LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << outgoing.messages->size();
|
|
LOG_DEBUG << "Invalid message to send " << i + 1 << "/" << outgoing.messages->size();
|
|
}
|
|
}
|
|
- if (!send(make_message(*message))) {
|
|
|
|
|
|
+ if (!send(impl::make_message(*message))) {
|
|
LOG_DEBUG << "Failed to send message " << i + 1 << "/" << outgoing.messages->size();
|
|
LOG_DEBUG << "Failed to send message " << i + 1 << "/" << outgoing.messages->size();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return make_message(*lastMessage);
|
|
|
|
|
|
+ return impl::make_message(*lastMessage);
|
|
}
|
|
}
|
|
|
|
|
|
message_ptr MediaChainableHandler::handleOutgoingControl(message_ptr msg) {
|
|
message_ptr MediaChainableHandler::handleOutgoingControl(message_ptr msg) {
|
|
- assert(msg->type == Message::Control);
|
|
|
|
|
|
+ assert(msg->type == impl::Message::Control);
|
|
auto outgoing = root->formOutgoingControlMessage(msg);
|
|
auto outgoing = root->formOutgoingControlMessage(msg);
|
|
- assert(!outgoing || outgoing->type == Message::Control);
|
|
|
|
|
|
+ assert(!outgoing || outgoing->type == impl::Message::Control);
|
|
if (!outgoing) {
|
|
if (!outgoing) {
|
|
LOG_ERROR << "Generating outgoing control message failed";
|
|
LOG_ERROR << "Generating outgoing control message failed";
|
|
return nullptr;
|
|
return nullptr;
|
|
@@ -126,9 +127,9 @@ message_ptr MediaChainableHandler::outgoing(message_ptr ptr) {
|
|
LOG_ERROR << "Outgoing message is nullptr, ignoring";
|
|
LOG_ERROR << "Outgoing message is nullptr, ignoring";
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
- if (ptr->type == Message::Binary) {
|
|
|
|
|
|
+ if (ptr->type == impl::Message::Binary) {
|
|
return handleOutgoingBinary(ptr);
|
|
return handleOutgoingBinary(ptr);
|
|
- } else if (ptr->type == Message::Control) {
|
|
|
|
|
|
+ } else if (ptr->type == impl::Message::Control) {
|
|
return handleOutgoingControl(ptr);
|
|
return handleOutgoingControl(ptr);
|
|
}
|
|
}
|
|
return ptr;
|
|
return ptr;
|
|
@@ -139,9 +140,9 @@ message_ptr MediaChainableHandler::incoming(message_ptr ptr) {
|
|
LOG_ERROR << "Incoming message is nullptr, ignoring";
|
|
LOG_ERROR << "Incoming message is nullptr, ignoring";
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
- if (ptr->type == Message::Binary) {
|
|
|
|
|
|
+ if (ptr->type == impl::Message::Binary) {
|
|
return handleIncomingBinary(ptr);
|
|
return handleIncomingBinary(ptr);
|
|
- } else if (ptr->type == Message::Control) {
|
|
|
|
|
|
+ } else if (ptr->type == impl::Message::Control) {
|
|
return handleIncomingControl(ptr);
|
|
return handleIncomingControl(ptr);
|
|
}
|
|
}
|
|
return ptr;
|
|
return ptr;
|