From 09d1c8e0a4606e6ebfa58b814dde1e8666cdd2cb Mon Sep 17 00:00:00 2001 From: Aaro Altonen Date: Fri, 17 May 2019 09:19:21 +0300 Subject: [PATCH] Send Opus packets as generic RTP packets In the future we may want to include the Opus header for versatility but for now Opus packets can be just send without the header --- src/rtp_opus.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/rtp_opus.cc b/src/rtp_opus.cc index eba3d9a..0589014 100644 --- a/src/rtp_opus.cc +++ b/src/rtp_opus.cc @@ -2,19 +2,34 @@ #include #include "conn.hh" +#include "debug.hh" #include "rtp_opus.hh" #include "rtp_generic.hh" int RTPOpus::pushOpusFrame(RTPConnection *conn, uint8_t *data, uint32_t dataLen, uint32_t timestamp) { + if (!conn || !data) + return RTP_INVALID_VALUE; + +#if 0 uint8_t buffer[MAX_PACKET] = { 0 }; RTPOpus::OpusConfig *config = (RTPOpus::OpusConfig *)conn->getConfig(); + LOG_DEBUG("sending opus packet of size %u", dataLen); + + if (config == nullptr) { + LOG_ERROR("Opus config has not been set!"); + return RTP_INVALID_VALUE; + } + buffer[0] = (config->configurationNumber << 3) | (config->channels > 1 ? (1 << 2) : 0) | 0; memcpy(&buffer[1], data, dataLen); - conn->setPayloadType(RTP_FORMAT_OPUS); return RTPGeneric::pushGenericFrame(conn, buffer, dataLen + 1, 0); +#endif + + conn->setPayloadType(RTP_FORMAT_OPUS); + return RTPGeneric::pushGenericFrame(conn, data, dataLen, 0); }