mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
[feat] enable congestion controller set target bitrate to video encoder
This commit is contained in:
@@ -9,32 +9,15 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "audio_decoder.h"
|
||||
#include "audio_encoder.h"
|
||||
// #include "congestion_control.h"
|
||||
#include "audio_channel_receive.h"
|
||||
#include "audio_channel_send.h"
|
||||
#include "clock.h"
|
||||
#include "data_channel_receive.h"
|
||||
#include "data_channel_send.h"
|
||||
#include "ice_agent.h"
|
||||
#include "ice_transport_controller.h"
|
||||
#include "io_statistics.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "rtcp_packet_info.h"
|
||||
#include "rtp_audio_receiver.h"
|
||||
#include "rtp_audio_sender.h"
|
||||
#include "rtp_data_receiver.h"
|
||||
#include "rtp_data_sender.h"
|
||||
#include "rtp_packet.h"
|
||||
#include "rtp_video_receiver.h"
|
||||
#include "rtp_video_sender.h"
|
||||
#include "video_channel_receive.h"
|
||||
#include "video_channel_send.h"
|
||||
#include "video_decoder_factory.h"
|
||||
#include "video_encoder_factory.h"
|
||||
#include "ws_client.h"
|
||||
|
||||
class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
class IceTransport {
|
||||
public:
|
||||
typedef enum { VIDEO = 96, AUDIO = 97, DATA = 127 } DATA_TYPE;
|
||||
typedef enum { H264 = 96, AV1 = 99 } VIDEO_TYPE;
|
||||
@@ -70,24 +53,11 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
|
||||
int DestroyIceTransmission();
|
||||
|
||||
void SetOnReceiveVideoFunc(
|
||||
std::function<void(const XVideoFrame *, const char *, const size_t,
|
||||
void *)>
|
||||
on_receive_video) {
|
||||
void SetOnReceiveFunc(OnReceiveVideo on_receive_video,
|
||||
OnReceiveAudio on_receive_audio,
|
||||
OnReceiveData on_receive_data) {
|
||||
on_receive_video_ = on_receive_video;
|
||||
}
|
||||
|
||||
void SetOnReceiveAudioFunc(
|
||||
std::function<void(const char *, size_t, const char *, const size_t,
|
||||
void *)>
|
||||
on_receive_audio) {
|
||||
on_receive_audio_ = on_receive_audio;
|
||||
}
|
||||
|
||||
void SetOnReceiveDataFunc(
|
||||
std::function<void(const char *, size_t, const char *, const size_t,
|
||||
void *)>
|
||||
on_receive_data) {
|
||||
on_receive_data_ = on_receive_data;
|
||||
}
|
||||
|
||||
@@ -131,9 +101,6 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
bool NegotiateAudioPayloadType(const std::string &remote_sdp);
|
||||
bool NegotiateDataPayloadType(const std::string &remote_sdp);
|
||||
|
||||
int CreateVideoCodec(rtp::PAYLOAD_TYPE video_pt, bool hardware_acceleration);
|
||||
int CreateAudioCodec();
|
||||
|
||||
private:
|
||||
uint8_t CheckIsRtpPacket(const char *buffer, size_t size);
|
||||
uint8_t CheckIsRtcpPacket(const char *buffer, size_t size);
|
||||
@@ -142,10 +109,6 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
uint8_t CheckIsDataPacket(const char *buffer, size_t size);
|
||||
|
||||
private:
|
||||
void InitializeIOStatistics();
|
||||
|
||||
void InitializeChannels(rtp::PAYLOAD_TYPE video_codec_payload_type);
|
||||
|
||||
void OnIceStateChange(NiceAgent *agent, guint stream_id, guint component_id,
|
||||
NiceComponentState state, gpointer user_ptr);
|
||||
|
||||
@@ -162,12 +125,6 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
void OnReceiveBuffer(NiceAgent *agent, guint stream_id, guint component_id,
|
||||
guint size, gchar *buffer, gpointer user_ptr);
|
||||
|
||||
void OnReceiveCompleteFrame(VideoFrame &video_frame);
|
||||
|
||||
void OnReceiveCompleteAudio(const char *data, size_t size);
|
||||
|
||||
void OnReceiveCompleteData(const char *data, size_t size);
|
||||
|
||||
bool ParseRtcpPacket(const uint8_t *buffer, size_t size,
|
||||
RtcpPacketInfo *rtcp_packet_info);
|
||||
|
||||
@@ -176,6 +133,7 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
RtcpPacketInfo *rtcp_packet_info);
|
||||
|
||||
private:
|
||||
bool hardware_acceleration_ = false;
|
||||
bool use_trickle_ice_ = true;
|
||||
bool enable_turn_ = false;
|
||||
bool use_reliable_ice_ = false;
|
||||
@@ -203,13 +161,10 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
bool is_closed_ = false;
|
||||
std::shared_ptr<WsClient> ice_ws_transport_ = nullptr;
|
||||
// CongestionControl *congestion_control_ = nullptr;
|
||||
std::function<void(const XVideoFrame *, const char *, const size_t, void *)>
|
||||
on_receive_video_ = nullptr;
|
||||
std::function<void(const char *, size_t, const char *, const size_t, void *)>
|
||||
on_receive_audio_ = nullptr;
|
||||
std::function<void(const char *, size_t, const char *, const size_t, void *)>
|
||||
on_receive_data_ = nullptr;
|
||||
|
||||
OnReceiveVideo on_receive_video_ = nullptr;
|
||||
OnReceiveAudio on_receive_audio_ = nullptr;
|
||||
OnReceiveData on_receive_data_ = nullptr;
|
||||
|
||||
std::function<void(std::string, const std::string &)> on_ice_status_change_ =
|
||||
nullptr;
|
||||
@@ -220,23 +175,7 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
on_receive_net_status_report_ = nullptr;
|
||||
|
||||
private:
|
||||
std::shared_ptr<webrtc::Clock> clock_;
|
||||
std::unique_ptr<VideoChannelSend> video_channel_send_ = nullptr;
|
||||
std::unique_ptr<VideoChannelReceive> video_channel_receive_ = nullptr;
|
||||
std::unique_ptr<AudioChannelSend> audio_channel_send_ = nullptr;
|
||||
std::unique_ptr<AudioChannelReceive> audio_channel_receive_ = nullptr;
|
||||
std::unique_ptr<DataChannelSend> data_channel_send_ = nullptr;
|
||||
std::unique_ptr<DataChannelReceive> data_channel_receive_ = 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;
|
||||
std::unique_ptr<RtpAudioSender> rtp_audio_sender_ = nullptr;
|
||||
std::unique_ptr<RtpDataReceiver> rtp_data_receiver_ = nullptr;
|
||||
std::unique_ptr<RtpDataSender> rtp_data_sender_ = nullptr;
|
||||
bool start_send_packet_ = false;
|
||||
|
||||
uint32_t last_complete_frame_ts_ = 0;
|
||||
std::shared_ptr<IceTransportController> ice_transport_controller_ = nullptr;
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||
@@ -250,19 +189,6 @@ class IceTransport : public std::enable_shared_from_this<IceTransport> {
|
||||
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;
|
||||
std::unique_ptr<VideoDecoder> video_decoder_ = nullptr;
|
||||
bool b_force_i_frame_ = false;
|
||||
bool video_codec_inited_ = false;
|
||||
bool load_nvcodec_dll_success_ = false;
|
||||
bool hardware_acceleration_ = false;
|
||||
|
||||
private:
|
||||
std::unique_ptr<AudioEncoder> audio_encoder_ = nullptr;
|
||||
std::unique_ptr<AudioDecoder> audio_decoder_ = nullptr;
|
||||
bool audio_codec_inited_ = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user