-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
325 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "HandlerImporter.h" | ||
namespace erizo { | ||
|
||
HandlerImporter::HandlerImporter() {} | ||
|
||
void HandlerImporter::loadHandlers(std::vector<std::map<std::string, std::string>> custom_handlers) { | ||
for (unsigned int i = 0; i < custom_handlers.size(); i++) { | ||
std::map <std::string, std::string> parameters = custom_handlers[i]; | ||
std::string handler_name = parameters.at("name"); | ||
handler_order.push_back(handler_name); | ||
std::shared_ptr <CustomHandler> ptr; | ||
HandlersEnum handler_enum = handlers_dic[handler_name]; | ||
|
||
switch (handler_enum) { | ||
case LoggerHandlerEnum : | ||
ptr = std::make_shared<LoggerHandler>(parameters); | ||
break; | ||
default: | ||
break; | ||
} | ||
handlers_pointer_dic.insert({handler_name, ptr}); | ||
} | ||
} | ||
} // namespace erizo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Created by licode20 on 22/3/21. | ||
// | ||
|
||
#ifndef ERIZO_SRC_ERIZO_HANDLERS_HANDLERIMPORTER_H_ | ||
#define ERIZO_SRC_ERIZO_HANDLERS_HANDLERIMPORTER_H_ | ||
|
||
#include <string> | ||
#include <map> | ||
#include "../pipeline/Handler.h" | ||
#include "./logger.h" | ||
#include "handlers/LoggerHandler.h" | ||
|
||
|
||
|
||
namespace erizo { | ||
|
||
|
||
class HandlerImporterInterface { | ||
DECLARE_LOGGER(); | ||
public: | ||
void loadHandlers(std::vector<std::map<std::string, std::string>> custom_handlers); | ||
std::map<std::string, std::shared_ptr<erizo::CustomHandler>> handlers_pointer_dic = {}; | ||
std::vector<std::string> handler_order = {}; | ||
}; | ||
|
||
|
||
class HandlerImporter: public HandlerImporterInterface { | ||
DECLARE_LOGGER(); | ||
public: | ||
HandlerImporter(); | ||
void loadHandlers(std::vector<std::map<std::string, std::string>> custom_handlers); | ||
private: | ||
enum HandlersEnum {LoggerHandlerEnum}; | ||
|
||
std::map<std::string, HandlersEnum> handlers_dic ={{"LoggerHandler", LoggerHandlerEnum}}; | ||
}; | ||
|
||
} // namespace erizo | ||
|
||
#endif // ERIZO_SRC_ERIZO_HANDLERS_HANDLERIMPORTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
#include "LoggerHandler.h" | ||
|
||
#include "../../rtp/RtpHeaders.h" // Imports headers utilities | ||
|
||
namespace erizo { | ||
|
||
DEFINE_LOGGER(LoggerHandler, "rtp.LoggerHandler"); // Defines handler logger name | ||
|
||
LoggerHandler::LoggerHandler(std::map <std::string, std::string> parameters) { | ||
ELOG_DEBUG("Creating Logger Handler "); | ||
} | ||
|
||
|
||
LoggerHandler::~LoggerHandler() { | ||
ELOG_DEBUG("Destroying Logger Handler "); | ||
} | ||
|
||
Positions LoggerHandler::position() { | ||
return MIDDLE; | ||
} | ||
|
||
void LoggerHandler::write(Context *ctx, std::shared_ptr <DataPacket> packet) { | ||
if (is_enabled) { | ||
ELOG_DEBUG("------------------------"); | ||
ELOG_DEBUG("Writing packet"); | ||
ELOG_DEBUG("Packet length %d", packet->length); | ||
rtcp_head = reinterpret_cast<RtcpHeader*> (packet->data); // Read data as RTCP packet | ||
if (rtcp_head->isRtcp()) { | ||
ELOG_DEBUG("Rtcp packet received"); | ||
} else if (packet->type == VIDEO_PACKET) { | ||
rtp_head = reinterpret_cast<RtpHeader*> (packet->data); // Read RTP data and log some fields | ||
ELOG_DEBUG("Rtp video packet received"); | ||
ELOG_DEBUG("Timestamp %d", rtp_head->timestamp); | ||
ELOG_DEBUG("SSRC %d", rtp_head->ssrc); | ||
} else if (packet->type == AUDIO_PACKET) { // Audio packets | ||
ELOG_DEBUG("Audio packet received"); | ||
} else if (packet->type == OTHER_PACKET) { // Data or other packets | ||
ELOG_DEBUG("Other packet received"); | ||
} | ||
if (packet->priority == HIGH_PRIORITY) { // Log priority field for packet | ||
ELOG_DEBUG("Packet with high priority"); | ||
} else if (packet->priority == LOW_PRIORITY) { | ||
ELOG_DEBUG("Packet with low priority"); | ||
} | ||
ctx->fireWrite(std::move(packet)); // Gives packet ownership to next handler in pipeline | ||
} | ||
} | ||
|
||
void LoggerHandler::read(Context *ctx, std::shared_ptr <DataPacket> packet) { | ||
if (is_enabled) { | ||
ELOG_DEBUG("------------------------"); | ||
ELOG_DEBUG("Reading packet "); | ||
ELOG_DEBUG("Packet length %d", packet->length); | ||
rtcp_head = reinterpret_cast<RtcpHeader*> (packet->data); | ||
if (rtcp_head->isRtcp()) { | ||
ELOG_DEBUG("Rtcp packet received"); | ||
} else if (packet->type == VIDEO_PACKET) { | ||
rtp_head = reinterpret_cast<RtpHeader*> (packet->data); | ||
ELOG_DEBUG("Rtp video packet received"); | ||
ELOG_DEBUG("Timestamp %d", rtp_head->timestamp); | ||
ELOG_DEBUG("SSRC %d", rtp_head->ssrc); | ||
} else if (packet->type == AUDIO_PACKET) { | ||
ELOG_DEBUG("Audio packet received"); | ||
} else if (packet->type == OTHER_PACKET) { | ||
ELOG_DEBUG("Other packet received"); | ||
} | ||
if (packet->priority == HIGH_PRIORITY) { | ||
ELOG_DEBUG("Packet with high priority"); | ||
} else if (packet->priority == LOW_PRIORITY) { | ||
ELOG_DEBUG("Packet with low priority"); | ||
} | ||
ELOG_DEBUG("------------------------"); | ||
ctx->fireRead(std::move(packet)); // Gives packet ownership to next handler in pipeline | ||
} | ||
} | ||
|
||
void LoggerHandler::enable() { | ||
is_enabled = true; | ||
} | ||
|
||
void LoggerHandler::disable() { | ||
is_enabled = false; | ||
} | ||
|
||
std::string LoggerHandler::getName() { | ||
return "LoggerHandler"; | ||
} | ||
|
||
void LoggerHandler::notifyUpdate() { | ||
} | ||
} // namespace erizo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef ERIZO_SRC_ERIZO_HANDLERS_HANDLERS_LOGGERHANDLER_H_ | ||
#define ERIZO_SRC_ERIZO_HANDLERS_HANDLERS_LOGGERHANDLER_H_ | ||
|
||
#include "../../pipeline/Handler.h" // Import CustomHandler interface | ||
#include "../../MediaDefinitions.h" // Imports DataPacket struct | ||
#include "./logger.h" // Include logger | ||
|
||
|
||
namespace erizo { // Handlers are include in erizo namespace | ||
class LoggerHandler : public CustomHandler { | ||
DECLARE_LOGGER(); // Declares logger for debugging and logging | ||
public: | ||
explicit LoggerHandler(std::map <std::string, std::string> parameters); | ||
~LoggerHandler(); | ||
void read(Context *ctx, std::shared_ptr <DataPacket> packet) override; // Process packet sent by client | ||
void write(Context *ctx, std::shared_ptr <DataPacket> packet) override; // Process packet sent to client | ||
Positions position() override; // Returns position to place handler. | ||
void enable() override; // Enable handler | ||
void disable() override; // Disable handler | ||
std::string getName() override; // Returns handler name | ||
void notifyUpdate() override; // Recieves update | ||
private: | ||
RtcpHeader* rtcp_head; | ||
RtpHeader* rtp_head; | ||
bool is_enabled = true; | ||
}; | ||
} // namespace erizo | ||
|
||
#endif // ERIZO_SRC_ERIZO_HANDLERS_HANDLERS_LOGGERHANDLER_H_" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.