Skip to content

Commit

Permalink
fix build with latest webrtc sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Sep 28, 2024
1 parent c08e46c commit e6cf0a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion inc/V4l2Capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class V4l2Capturer : public VideoSource

bool idr = false;
int cfg = 0;
std::vector<webrtc::H264::NaluIndex> naluIndexes = webrtc::H264::FindNaluIndices((uint8_t*)buffer, frameSize);
rtc::ArrayView<const uint8_t> data((const uint8_t*)buffer, frameSize);
std::vector<webrtc::H264::NaluIndex> naluIndexes = webrtc::H264::FindNaluIndices(data);
for (webrtc::H264::NaluIndex index : naluIndexes) {
webrtc::H264::NaluType nalu_type = webrtc::H264::ParseNaluType(buffer[index.payload_start_offset]);
RTC_LOG(LS_VERBOSE) << __FUNCTION__ << " nalu:" << nalu_type << " payload_start_offset:" << index.payload_start_offset << " start_offset:" << index.start_offset << " size:" << index.payload_size;
Expand Down
6 changes: 4 additions & 2 deletions inc/livevideosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class LiveVideoSource : public VideoDecoder, public T::Callback
}

void onH264Data(unsigned char *buffer, ssize_t size, int64_t ts, const std::string & codec) {
std::vector<webrtc::H264::NaluIndex> indexes = webrtc::H264::FindNaluIndices(buffer,size);
rtc::ArrayView<const uint8_t> data(buffer, size);
std::vector<webrtc::H264::NaluIndex> indexes = webrtc::H264::FindNaluIndices(data);
RTC_LOG(LS_VERBOSE) << "LiveVideoSource:onData nbNalu:" << indexes.size();
for (const webrtc::H264::NaluIndex & index : indexes) {
webrtc::H264::NaluType nalu_type = webrtc::H264::ParseNaluType(buffer[index.payload_start_offset]);
Expand All @@ -115,7 +116,8 @@ class LiveVideoSource : public VideoDecoder, public T::Callback
m_cfg.clear();
m_cfg.insert(m_cfg.end(), buffer + index.start_offset, buffer + index.payload_size + index.payload_start_offset);

std::optional<webrtc::SpsParser::SpsState> sps = webrtc::SpsParser::ParseSps(buffer + index.payload_start_offset + webrtc::H264::kNaluTypeSize, index.payload_size - webrtc::H264::kNaluTypeSize);
rtc::ArrayView<const uint8_t> spsBuffer(buffer + index.payload_start_offset + webrtc::H264::kNaluTypeSize, index.payload_size - webrtc::H264::kNaluTypeSize);
std::optional<webrtc::SpsParser::SpsState> sps = webrtc::SpsParser::ParseSps(spsBuffer);
if (!sps)
{
RTC_LOG(LS_ERROR) << "cannot parse sps";
Expand Down
3 changes: 2 additions & 1 deletion inc/rtmpvideosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class RtmpVideoSource : public VideoDecoder
{
m_cfg.clear();
RTC_LOG(LS_INFO) << "RtmpVideoSource::onNewSession H264 SPS size:" << spssize;
std::optional<webrtc::SpsParser::SpsState> sps = webrtc::SpsParser::ParseSps((const unsigned char*)(&body[start_sps+3]), spssize);
rtc::ArrayView<const uint8_t> spsBuffer((const unsigned char*)(&body[start_sps+3]), spssize);
std::optional<webrtc::SpsParser::SpsState> sps = webrtc::SpsParser::ParseSps(spsBuffer);
if (!sps)
{
RTC_LOG(LS_ERROR) << "cannot parse H264 sps";
Expand Down

0 comments on commit e6cf0a8

Please sign in to comment.