-
-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inverse of OpusRtpPacketizer. Takes incoming Opus packets and emits frames.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2024 Paul-Louis Ageneau | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef RTC_RTP_DEPACKETIZER_H | ||
#define RTC_RTP_DEPACKETIZER_H | ||
|
||
#if RTC_ENABLE_MEDIA | ||
|
||
#include "mediahandler.hpp" | ||
#include "message.hpp" | ||
|
||
namespace rtc { | ||
|
||
class RTC_CPP_EXPORT RtpDepacketizer : public MediaHandler { | ||
public: | ||
RtpDepacketizer() = default; | ||
virtual ~RtpDepacketizer() = default; | ||
|
||
virtual void incoming(message_vector &messages, const message_callback &send) override; | ||
}; | ||
|
||
using OpusRtpDepacketizer = RtpDepacketizer; | ||
using AACRtpDepacketizer = RtpDepacketizer; | ||
|
||
} // namespace rtc | ||
|
||
#endif /* RTC_ENABLE_MEDIA */ | ||
|
||
#endif /* RTC_RTP_DEPACKETIZER_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,50 @@ | ||
/** | ||
* Copyright (c) 2024 Paul-Louis Ageneau | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#if RTC_ENABLE_MEDIA | ||
|
||
#include "rtpdepacketizer.hpp" | ||
#include "rtp.hpp" | ||
|
||
#include "impl/logcounter.hpp" | ||
|
||
#include <cmath> | ||
#include <cstring> | ||
|
||
namespace rtc { | ||
|
||
void RtpDepacketizer::incoming([[maybe_unused]] message_vector &messages, | ||
[[maybe_unused]] const message_callback &send) { | ||
|
||
messages.erase(std::remove_if(messages.begin(), messages.end(), | ||
[](message_ptr message) { | ||
// Filter RTCP | ||
if (message->type == Message::Control) { | ||
return true; | ||
} | ||
|
||
if (message->size() < sizeof(RtpHeader)) { | ||
PLOG_VERBOSE << "RTP packet is too small, size=" | ||
<< message->size(); | ||
return true; | ||
} | ||
|
||
return false; | ||
}), | ||
messages.end()); | ||
|
||
for (auto &message : messages) { | ||
auto pkt = reinterpret_cast<const rtc::RtpHeader *>(message->data()); | ||
auto headerSize = sizeof(rtc::RtpHeader) + pkt->csrcCount() + pkt->getExtensionHeaderSize(); | ||
message = make_message(message->begin() + headerSize, message->end()); | ||
} | ||
} | ||
|
||
} // namespace rtc | ||
|
||
#endif /* RTC_ENABLE_MEDIA */ |