Skip to content

Commit 807722e

Browse files
Merge pull request #1156 from singpolyma/payload-type-in-frame
Include payloadType in FrameInfo
2 parents fe7bec8 + e9060bf commit 807722e

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

include/rtc/frameinfo.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
namespace rtc {
1515

1616
struct RTC_CPP_EXPORT FrameInfo {
17-
FrameInfo(uint32_t timestamp) : timestamp(timestamp){};
17+
FrameInfo(uint8_t payloadType, uint32_t timestamp) : payloadType(payloadType), timestamp(timestamp){};
18+
uint8_t payloadType; // Indicates codec of the frame
1819
uint32_t timestamp = 0; // RTP Timestamp
1920
};
2021

include/rtc/h264rtpdepacketizer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RTC_CPP_EXPORT H264RtpDepacketizer : public MediaHandler {
3333
std::vector<message_ptr> mRtpBuffer;
3434

3535
message_vector buildFrames(message_vector::iterator firstPkt, message_vector::iterator lastPkt,
36-
uint32_t timestamp);
36+
uint8_t payloadType, uint32_t timestamp);
3737
};
3838

3939
} // namespace rtc

src/h264rtpdepacketizer.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ const uint8_t naluTypeSTAPA = 24;
3232
const uint8_t naluTypeFUA = 28;
3333

3434
message_vector H264RtpDepacketizer::buildFrames(message_vector::iterator begin,
35-
message_vector::iterator end, uint32_t timestamp) {
35+
message_vector::iterator end, uint8_t payloadType, uint32_t timestamp) {
3636
message_vector out = {};
3737
auto fua_buffer = std::vector<std::byte>{};
38-
auto frameInfo = std::make_shared<FrameInfo>(timestamp);
38+
auto frameInfo = std::make_shared<FrameInfo>(payloadType, timestamp);
3939

4040
for (auto it = begin; it != end; it++) {
4141
auto pkt = it->get();
@@ -122,6 +122,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb
122122
messages.end());
123123

124124
while (mRtpBuffer.size() != 0) {
125+
uint8_t payload_type = 0;
125126
uint32_t current_timestamp = 0;
126127
size_t packets_in_timestamp = 0;
127128

@@ -130,6 +131,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb
130131

131132
if (current_timestamp == 0) {
132133
current_timestamp = p->timestamp();
134+
payload_type = p->payloadType(); // should all be the same for data of the same codec
133135
} else if (current_timestamp != p->timestamp()) {
134136
break;
135137
}
@@ -144,7 +146,7 @@ void H264RtpDepacketizer::incoming(message_vector &messages, const message_callb
144146
auto begin = mRtpBuffer.begin();
145147
auto end = mRtpBuffer.begin() + (packets_in_timestamp - 1);
146148

147-
auto frames = buildFrames(begin, end + 1, current_timestamp);
149+
auto frames = buildFrames(begin, end + 1, payload_type, current_timestamp);
148150
messages.insert(messages.end(), frames.begin(), frames.end());
149151
mRtpBuffer.erase(mRtpBuffer.begin(), mRtpBuffer.begin() + packets_in_timestamp);
150152
}

src/rtpdepacketizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void RtpDepacketizer::incoming([[maybe_unused]] message_vector &messages,
3636
auto headerSize = sizeof(rtc::RtpHeader) + pkt->csrcCount() + pkt->getExtensionHeaderSize();
3737
result.push_back(make_message(message->begin() + headerSize, message->end(),
3838
Message::Binary, 0, nullptr,
39-
std::make_shared<FrameInfo>(pkt->timestamp())));
39+
std::make_shared<FrameInfo>(pkt->payloadType(), pkt->timestamp())));
4040
}
4141

4242
messages.swap(result);

0 commit comments

Comments
 (0)