rtptwcc: make RTPTWCCManager a GObject

This commit is contained in:
Havard Graff 2020-03-02 13:50:55 +01:00 committed by Havard Graff
parent 026223cde2
commit 4046970b01
3 changed files with 56 additions and 36 deletions

View file

@ -733,7 +733,7 @@ rtp_session_finalize (GObject * object)
for (i = 0; i < 1; i++)
g_hash_table_destroy (sess->ssrcs[i]);
rtp_twcc_manager_free (sess->twcc);
g_object_unref (sess->twcc);
rtp_twcc_stats_free (sess->twcc_stats);
g_mutex_clear (&sess->lock);

View file

@ -29,29 +29,6 @@ GST_DEBUG_CATEGORY_EXTERN (rtp_session_debug);
#define DELTA_UNIT (250 * GST_USECOND)
#define MAX_TS_DELTA (0xff * DELTA_UNIT)
struct _RTPTWCCManager
{
guint mtu;
guint max_packets_per_rtcp;
GArray *recv_packets;
guint8 fb_pkt_count;
gint32 last_seqnum;
GArray *sent_packets;
GArray *parsed_packets;
GQueue *rtcp_buffers;
guint64 recv_sender_ssrc;
guint64 recv_media_ssrc;
guint16 expected_recv_seqnum;
gboolean first_fci_parse;
guint16 expected_parsed_seqnum;
guint8 expected_parsed_fb_pkt_count;
};
typedef enum
{
RTP_TWCC_CHUNK_TYPE_RUN_LENGTH = 0,
@ -87,13 +64,37 @@ typedef struct
gboolean lost;
} SentPacket;
RTPTWCCManager *
rtp_twcc_manager_new (guint mtu)
struct _RTPTWCCManager
{
RTPTWCCManager *twcc = g_new0 (RTPTWCCManager, 1);
GObject object;
guint mtu;
guint max_packets_per_rtcp;
GArray *recv_packets;
guint8 fb_pkt_count;
gint32 last_seqnum;
GArray *sent_packets;
GArray *parsed_packets;
GQueue *rtcp_buffers;
guint64 recv_sender_ssrc;
guint64 recv_media_ssrc;
guint16 expected_recv_seqnum;
gboolean first_fci_parse;
guint16 expected_parsed_seqnum;
guint8 expected_parsed_fb_pkt_count;
};
G_DEFINE_TYPE (RTPTWCCManager, rtp_twcc_manager, G_TYPE_OBJECT);
static void
rtp_twcc_manager_init (RTPTWCCManager * twcc)
{
twcc->recv_packets = g_array_new (FALSE, FALSE, sizeof (RecvPacket));
twcc->sent_packets = g_array_new (FALSE, FALSE, sizeof (SentPacket));
twcc->parsed_packets = g_array_new (FALSE, FALSE, sizeof (RecvPacket));
@ -103,21 +104,37 @@ rtp_twcc_manager_new (guint mtu)
twcc->recv_media_ssrc = -1;
twcc->recv_sender_ssrc = -1;
rtp_twcc_manager_set_mtu (twcc, mtu);
twcc->first_fci_parse = TRUE;
return twcc;
}
void
rtp_twcc_manager_free (RTPTWCCManager * twcc)
static void
rtp_twcc_manager_finalize (GObject * object)
{
RTPTWCCManager *twcc = RTP_TWCC_MANAGER_CAST (object);
g_array_unref (twcc->recv_packets);
g_array_unref (twcc->sent_packets);
g_array_unref (twcc->parsed_packets);
g_queue_free_full (twcc->rtcp_buffers, (GDestroyNotify) gst_buffer_unref);
g_free (twcc);
G_OBJECT_CLASS (rtp_twcc_manager_parent_class)->finalize (object);
}
static void
rtp_twcc_manager_class_init (RTPTWCCManagerClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = rtp_twcc_manager_finalize;
}
RTPTWCCManager *
rtp_twcc_manager_new (guint mtu)
{
RTPTWCCManager *twcc = g_object_new (RTP_TYPE_TWCC_MANAGER, NULL);
rtp_twcc_manager_set_mtu (twcc, mtu);
return twcc;
}
static void

View file

@ -29,6 +29,10 @@ typedef struct _RTPTWCCManager RTPTWCCManager;
typedef struct _RTPTWCCPacket RTPTWCCPacket;
typedef enum _RTPTWCCPacketStatus RTPTWCCPacketStatus;
G_DECLARE_FINAL_TYPE (RTPTWCCManager, rtp_twcc_manager, RTP, TWCC_MANAGER, GObject)
#define RTP_TYPE_TWCC_MANAGER (rtp_twcc_manager_get_type())
#define RTP_TWCC_MANAGER_CAST(obj) ((RTPTWCCManager *)(obj))
enum _RTPTWCCPacketStatus
{
RTP_TWCC_PACKET_STATUS_NOT_RECV = 0,
@ -49,7 +53,6 @@ struct _RTPTWCCPacket
};
RTPTWCCManager * rtp_twcc_manager_new (guint mtu);
void rtp_twcc_manager_free (RTPTWCCManager * twcc);
void rtp_twcc_manager_set_mtu (RTPTWCCManager * twcc, guint mtu);