Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include payloadType in FrameInfo #1156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/rtc/frameinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
namespace rtc {

struct RTC_CPP_EXPORT FrameInfo {
FrameInfo(uint32_t timestamp) : timestamp(timestamp){};
FrameInfo(uint8_t payloadType, uint32_t timestamp) : payloadType(payloadType), timestamp(timestamp){};
uint8_t payloadType; // Indicates codec of the frame
uint32_t timestamp = 0; // RTP Timestamp
};

Expand Down
2 changes: 1 addition & 1 deletion include/rtc/h264rtpdepacketizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RTC_CPP_EXPORT H264RtpDepacketizer : public MediaHandler {
std::vector<message_ptr> mRtpBuffer;

message_vector buildFrames(message_vector::iterator firstPkt, message_vector::iterator lastPkt,
uint32_t timestamp);
uint8_t payloadType, uint32_t timestamp);
};

} // namespace rtc
Expand Down
8 changes: 5 additions & 3 deletions src/h264rtpdepacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const uint8_t naluTypeSTAPA = 24;
const uint8_t naluTypeFUA = 28;

message_vector H264RtpDepacketizer::buildFrames(message_vector::iterator begin,
message_vector::iterator end, uint32_t timestamp) {
message_vector::iterator end, uint8_t payloadType, uint32_t timestamp) {
message_vector out = {};
auto fua_buffer = std::vector<std::byte>{};
auto frameInfo = std::make_shared<FrameInfo>(timestamp);
auto frameInfo = std::make_shared<FrameInfo>(payloadType, timestamp);

for (auto it = begin; it != end; it++) {
auto pkt = it->get();
Expand Down Expand Up @@ -111,6 +111,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb
messages.end());

while (mRtpBuffer.size() != 0) {
uint8_t payload_type = 0;
uint32_t current_timestamp = 0;
size_t packets_in_timestamp = 0;

Expand All @@ -119,6 +120,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb

if (current_timestamp == 0) {
current_timestamp = p->timestamp();
payload_type = p->payloadType(); // should all be the same for data of the same codec
} else if (current_timestamp != p->timestamp()) {
break;
}
Expand All @@ -133,7 +135,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb
auto begin = mRtpBuffer.begin();
auto end = mRtpBuffer.begin() + (packets_in_timestamp - 1);

auto frames = buildFrames(begin, end + 1, current_timestamp);
auto frames = buildFrames(begin, end + 1, payload_type, current_timestamp);
messages.insert(messages.end(), frames.begin(), frames.end());
mRtpBuffer.erase(mRtpBuffer.begin(), mRtpBuffer.begin() + packets_in_timestamp);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rtpdepacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void RtpDepacketizer::incoming([[maybe_unused]] message_vector &messages,
auto headerSize = sizeof(rtc::RtpHeader) + pkt->csrcCount() + pkt->getExtensionHeaderSize();
result.push_back(make_message(message->begin() + headerSize, message->end(),
Message::Binary, 0, nullptr,
std::make_shared<FrameInfo>(pkt->timestamp())));
std::make_shared<FrameInfo>(pkt->payloadType(), pkt->timestamp())));
}

messages.swap(result);
Expand Down
Loading