diff --git a/lib/x86_64/libhsm_sdf_api.so b/lib/x86_64/libhsm_sdf_api.so new file mode 100644 index 0000000..0a60f25 Binary files /dev/null and b/lib/x86_64/libhsm_sdf_api.so differ diff --git a/src/base/rtp_manager.cpp b/src/base/rtp_manager.cpp index 714d224..31ec5b5 100644 --- a/src/base/rtp_manager.cpp +++ b/src/base/rtp_manager.cpp @@ -336,14 +336,15 @@ RTPManager::OnRTPDecoded(RTPDecoder::DecodedPacket packet) auto last_frame = last_packet->ref_frames().back().frame; INFOL("base_offset %lu\n", last_packet->rtp_header_offset_base_frame()); + INFOL("rtp_start_pos %lu\n", last_packet->rtp_header_offset_base_frame()); INFOL("last_packet_size %lu\n", last_packet->packet_size()); INFOL("last_frame_size %lu\n", last_frame->size()); - last_packet->InsertAt(prev_sign_data.data(), prev_sign_data.size(), last_packet->packet_size()); - last_packet->SetRTSPLength(last_packet->packet_size() + prev_sign_data.size()); last_frame->set_append_length(prev_sign_data.size()); last_frame->set_sei_end_offset( last_packet->rtp_header_offset_base_frame() + last_packet->packet_size() + prev_sign_data.size()); + last_packet->InsertAt(prev_sign_data.data(), prev_sign_data.size(), last_packet->packet_size()); + last_packet->SetRTSPLength(last_packet->packet_size() + prev_sign_data.size()); auto hex = ToHex(prev_sign_data.data(), prev_sign_data.size()); INFOL("Insert Sign Data %s\n", hex.c_str()); } diff --git a/src/base/rtp_packet.cpp b/src/base/rtp_packet.cpp index 197b670..97283d3 100644 --- a/src/base/rtp_packet.cpp +++ b/src/base/rtp_packet.cpp @@ -299,7 +299,7 @@ RTPPacket::UnrefUnusedFrame(std::size_t skip_size) INFOL("Discard %lu byte.\n", skip_size); std::size_t erased_size = 0; - while (skip_size >= _ref_frames.front().frame->size()) { + while (!_ref_frames.empty() && skip_size >= _ref_frames.front().frame->size()) { INFOL("skip size: %ld\n", skip_size); auto cur_frame = _ref_frames.front(); _ref_frames.erase(_ref_frames.begin()); @@ -308,10 +308,17 @@ RTPPacket::UnrefUnusedFrame(std::size_t skip_size) erased_size += cur_frame.frame->size(); } - _tcp_data.erase(_tcp_data.begin(), _tcp_data.begin() + erased_size); - _tcp_start_pos = skip_size; if (!_ref_frames.empty()) { _ref_frames.front().start_pos = skip_size; } + + // Rebuild tcp_data + if (erased_size > 0) { + _tcp_data.clear(); + for (const auto &frame : _ref_frames) { + std::copy(frame.frame->data(), frame.frame->data() + frame.frame->size(), std::back_inserter(_tcp_data)); + } + } + return erased_size > 0; } diff --git a/src/base/util.cpp b/src/base/util.cpp index 398de51..e3cbbbf 100644 --- a/src/base/util.cpp +++ b/src/base/util.cpp @@ -100,6 +100,7 @@ GetRTSPLength(const void *data) bool FindRTSPHeader(const void *data, size_t len, void **header_ptr) { + *header_ptr = nullptr; if (len < 2 || data == nullptr) { return false; } const uint8_t *ptr = (const uint8_t *) data;