[fix] fix h264 rtp packet packetization and depacketization

This commit is contained in:
dijunkun
2025-01-23 17:28:17 +08:00
parent cd349cd98d
commit 7b839ab773
50 changed files with 871 additions and 422 deletions

View File

@@ -22,7 +22,6 @@
#include "rtcp_packet_info.h"
#include "rtp_audio_receiver.h"
#include "rtp_audio_sender.h"
#include "rtp_codec.h"
#include "rtp_data_receiver.h"
#include "rtp_data_sender.h"
#include "rtp_packet.h"
@@ -66,7 +65,7 @@ class IceTransport {
std::string &turn_ip, int turn_port,
std::string &turn_username,
std::string &turn_password,
RtpPacket::PAYLOAD_TYPE video_codec_payload_type);
rtp::PAYLOAD_TYPE video_codec_payload_type);
int DestroyIceTransmission();
@@ -74,7 +73,6 @@ class IceTransport {
std::function<void(const XVideoFrame *, const char *, const size_t,
void *)>
on_receive_video) {
LOG_ERROR("!!!!!!!!!!!!!!!!!!!!!!!!!!!");
on_receive_video_ = on_receive_video;
}
@@ -121,7 +119,7 @@ class IceTransport {
int SendAnswer();
std::vector<RtpPacket::PAYLOAD_TYPE> GetNegotiatedCapabilities();
std::vector<rtp::PAYLOAD_TYPE> GetNegotiatedCapabilities();
private:
int AppendLocalCapabilitiesToOffer(const std::string &remote_sdp);
@@ -132,10 +130,7 @@ class IceTransport {
bool NegotiateAudioPayloadType(const std::string &remote_sdp);
bool NegotiateDataPayloadType(const std::string &remote_sdp);
int CreateMediaCodec();
int CreateVideoCodec(RtpPacket::PAYLOAD_TYPE video_pt,
bool hardware_acceleration);
int CreateVideoCodec(rtp::PAYLOAD_TYPE video_pt, bool hardware_acceleration);
int CreateAudioCodec();
private:
@@ -148,7 +143,7 @@ class IceTransport {
private:
void InitializeIOStatistics();
void InitializeChannels(RtpPacket::PAYLOAD_TYPE video_codec_payload_type);
void InitializeChannels(rtp::PAYLOAD_TYPE video_codec_payload_type);
void OnIceStateChange(NiceAgent *agent, guint stream_id, guint component_id,
NiceComponentState state, gpointer user_ptr);
@@ -231,10 +226,6 @@ class IceTransport {
std::unique_ptr<DataChannelSend> data_channel_send_ = nullptr;
std::unique_ptr<DataChannelReceive> data_channel_receive_ = nullptr;
std::unique_ptr<RtpCodec> video_rtp_codec_ = nullptr;
std::unique_ptr<RtpCodec> audio_rtp_codec_ = nullptr;
std::unique_ptr<RtpCodec> data_rtp_codec_ = nullptr;
std::unique_ptr<RtpVideoReceiver> rtp_video_receiver_ = nullptr;
std::unique_ptr<RtpVideoSender> rtp_video_sender_ = nullptr;
std::unique_ptr<RtpAudioReceiver> rtp_audio_receiver_ = nullptr;
@@ -249,20 +240,14 @@ class IceTransport {
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
private:
RtpPacket::PAYLOAD_TYPE video_codec_payload_type_;
rtp::PAYLOAD_TYPE video_codec_payload_type_;
bool remote_capabilities_got_ = false;
RtpPacket::PAYLOAD_TYPE remote_prefered_video_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
RtpPacket::PAYLOAD_TYPE remote_prefered_audio_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
RtpPacket::PAYLOAD_TYPE remote_prefered_data_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
RtpPacket::PAYLOAD_TYPE negotiated_video_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
RtpPacket::PAYLOAD_TYPE negotiated_audio_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
RtpPacket::PAYLOAD_TYPE negotiated_data_pt_ =
RtpPacket::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE remote_prefered_video_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE remote_prefered_audio_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE remote_prefered_data_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE negotiated_video_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE negotiated_audio_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
rtp::PAYLOAD_TYPE negotiated_data_pt_ = rtp::PAYLOAD_TYPE::UNDEFINED;
private:
std::unique_ptr<VideoEncoder> video_encoder_ = nullptr;