-
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.
Add a codec parser in front of the pipeline (#1179)
- Loading branch information
Showing
10 changed files
with
102 additions
and
11 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,52 @@ | ||
#include "rtp/PacketCodecParser.h" | ||
|
||
#include "./MediaStream.h" | ||
|
||
namespace erizo { | ||
|
||
DEFINE_LOGGER(PacketCodecParser, "rtp.PacketCodecParser"); | ||
|
||
PacketCodecParser::PacketCodecParser() : | ||
stream_ { nullptr }, enabled_ { true }, initialized_ { false } { | ||
} | ||
|
||
void PacketCodecParser::enable() { | ||
enabled_ = true; | ||
} | ||
|
||
void PacketCodecParser::disable() { | ||
enabled_ = false; | ||
} | ||
|
||
void PacketCodecParser::read(Context *ctx, std::shared_ptr<DataPacket> packet) { | ||
RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data); | ||
if (!chead->isRtcp() && enabled_) { | ||
RtpHeader *rtp_header = reinterpret_cast<RtpHeader*>(packet->data); | ||
RtpMap *codec = | ||
stream_->getRemoteSdpInfo()->getCodecByExternalPayloadType( | ||
rtp_header->getPayloadType()); | ||
if (codec) { | ||
packet->codec = codec->encoding_name; | ||
packet->clock_rate = codec->clock_rate; | ||
ELOG_DEBUG("Reading codec: %s, clock: %u", packet->codec.c_str(), packet->clock_rate); | ||
} | ||
} | ||
ctx->fireRead(std::move(packet)); | ||
} | ||
|
||
void PacketCodecParser::notifyUpdate() { | ||
if (initialized_) { | ||
return; | ||
} | ||
|
||
auto pipeline = getContext()->getPipelineShared(); | ||
if (!pipeline) { | ||
return; | ||
} | ||
|
||
stream_ = pipeline->getService<MediaStream>().get(); | ||
if (!stream_) { | ||
return; | ||
} | ||
} | ||
} // 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,35 @@ | ||
#ifndef ERIZO_SRC_ERIZO_RTP_PACKETCODECPARSER_H_ | ||
#define ERIZO_SRC_ERIZO_RTP_PACKETCODECPARSER_H_ | ||
|
||
#include "./logger.h" | ||
#include "pipeline/Handler.h" | ||
|
||
namespace erizo { | ||
|
||
class MediaStream; | ||
|
||
class PacketCodecParser: public InboundHandler { | ||
DECLARE_LOGGER(); | ||
|
||
|
||
public: | ||
PacketCodecParser(); | ||
|
||
void enable() override; | ||
void disable() override; | ||
|
||
std::string getName() override { | ||
return "packet_codec_parser"; | ||
} | ||
|
||
void read(Context *ctx, std::shared_ptr<DataPacket> packet) override; | ||
void notifyUpdate() override; | ||
|
||
private: | ||
MediaStream *stream_; | ||
bool enabled_; | ||
bool initialized_; | ||
}; | ||
} // namespace erizo | ||
|
||
#endif // ERIZO_SRC_ERIZO_RTP_PACKETCODECPARSER_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
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