-
Notifications
You must be signed in to change notification settings - Fork 5
TWCCMan evaluates recovery pct for FEC #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
195de12
0710dd5
b88b6c4
d42b2b0
507ba57
a4f282b
0bc560c
f3850fc
7796bdd
733856f
008e5d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* GStreamer | ||
* Copyright (C) <2024> Mikhail Baranov <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public | ||
* License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "gstrtprepairmeta.h" | ||
#include <string.h> | ||
|
||
static gboolean gst_rtp_repair_meta_init(GstRTPRepairMeta * meta, | ||
G_GNUC_UNUSED gpointer params, G_GNUC_UNUSED GstBuffer * buffer); | ||
static void gst_rtp_repair_meta_free(GstRTPRepairMeta *meta, | ||
G_GNUC_UNUSED GstBuffer *buffer); | ||
|
||
|
||
GType gst_rtp_repair_meta_api_get_type(void) | ||
{ | ||
static GType type = 0; | ||
static const gchar *tags[] = {NULL}; | ||
|
||
if (g_once_init_enter(&type)) { | ||
GType _type = gst_meta_api_type_register("GstRTPRepairMetaAPI", tags); | ||
g_once_init_leave(&type, _type); | ||
} | ||
|
||
return type; | ||
} | ||
|
||
const GstMetaInfo *gst_rtp_repair_meta_get_info(void) | ||
{ | ||
static const GstMetaInfo *meta_info = NULL; | ||
|
||
if (g_once_init_enter(&meta_info)) { | ||
const GstMetaInfo *mi = gst_meta_register( GST_RTP_REPAIR_META_API_TYPE, | ||
"GstRTPRepairMeta", | ||
sizeof(GstRTPRepairMeta), | ||
(GstMetaInitFunction) gst_rtp_repair_meta_init, | ||
(GstMetaFreeFunction) gst_rtp_repair_meta_free, | ||
NULL ); | ||
g_once_init_leave(&meta_info, mi); | ||
} | ||
|
||
return meta_info; | ||
} | ||
|
||
GstRTPRepairMeta *gst_buffer_get_rtp_repair_meta(GstBuffer *buffer) | ||
{ | ||
return (GstRTPRepairMeta *)gst_buffer_get_meta(buffer, | ||
gst_rtp_repair_meta_api_get_type()); | ||
} | ||
|
||
GstRTPRepairMeta *gst_buffer_add_rtp_repair_meta(GstBuffer *buffer, | ||
const guint16 idx_red_packets, const guint16 num_red_packets, | ||
const guint32 ssrc, const guint16 *seqnum, guint seqnum_count) | ||
{ | ||
GstRTPRepairMeta *repair_meta = (GstRTPRepairMeta *) gst_buffer_add_meta (buffer, | ||
GST_RTP_REPAIR_META_INFO, NULL); | ||
if (repair_meta == NULL) { | ||
return NULL; | ||
} | ||
|
||
repair_meta->idx_red_packets = idx_red_packets; | ||
repair_meta->num_red_packets = num_red_packets; | ||
repair_meta->ssrc = ssrc; | ||
g_array_insert_vals (repair_meta->seqnums, 0, seqnum, seqnum_count); | ||
|
||
return repair_meta; | ||
} | ||
|
||
gboolean gst_buffer_repairs_seqnum(GstBuffer *buffer, guint16 seqnum, guint32 ssrc) | ||
{ | ||
GstRTPRepairMeta *repair_meta = gst_buffer_get_rtp_repair_meta(buffer); | ||
if (repair_meta) { | ||
if (repair_meta->ssrc != ssrc) { | ||
return FALSE; | ||
} | ||
|
||
for (guint i = 0; i < repair_meta->seqnums->len; i++) { | ||
guint16 stored_seqnum = g_array_index(repair_meta->seqnums, guint16, i); | ||
if (stored_seqnum == seqnum) { | ||
return TRUE; | ||
} | ||
} | ||
} | ||
return FALSE; | ||
} | ||
|
||
gint gst_buffer_get_repair_idx(GstBuffer *buffer) | ||
{ | ||
GstRTPRepairMeta *repair_meta = gst_buffer_get_rtp_repair_meta(buffer); | ||
if (repair_meta) { | ||
return repair_meta->idx_red_packets; | ||
} | ||
return -1; | ||
} | ||
|
||
gint gst_buffer_get_repair_num(GstBuffer *buffer) | ||
{ | ||
GstRTPRepairMeta *repair_meta = gst_buffer_get_rtp_repair_meta(buffer); | ||
if (repair_meta) { | ||
return repair_meta->num_red_packets; | ||
} | ||
return -1; | ||
} | ||
|
||
gboolean gst_buffer_get_repair_seqnums(GstBuffer *buffer, guint32 *ssrc, | ||
GArray **seqnums) | ||
{ | ||
GstRTPRepairMeta *repair_meta = gst_buffer_get_rtp_repair_meta(buffer); | ||
if (repair_meta && repair_meta->seqnums->len > 0) { | ||
if (ssrc) { | ||
*ssrc = repair_meta->ssrc; | ||
} | ||
if (seqnums) { | ||
*seqnums = g_array_ref (repair_meta->seqnums); | ||
} | ||
return TRUE; | ||
} else { | ||
*ssrc = 0; | ||
*seqnums = NULL; | ||
} | ||
return FALSE; | ||
} | ||
|
||
static gboolean | ||
gst_rtp_repair_meta_init(GstRTPRepairMeta * meta, G_GNUC_UNUSED gpointer params, | ||
G_GNUC_UNUSED GstBuffer * buffer) | ||
{ | ||
meta->idx_red_packets = 0; | ||
meta->num_red_packets = 0; | ||
meta->ssrc = 0; | ||
meta->seqnums = g_array_new(FALSE, FALSE, sizeof(guint16)); | ||
|
||
return TRUE; | ||
} | ||
|
||
static void | ||
gst_rtp_repair_meta_free(GstRTPRepairMeta *meta, | ||
G_GNUC_UNUSED GstBuffer *buffer) | ||
{ | ||
g_array_unref (meta->seqnums); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* GStreamer | ||
* Copyright (C) <2024> Mikhail Baranov <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public | ||
* License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef __GST_RTP_REPAIR_META_H__ | ||
#define __GST_RTP_REPAIR_META_H__ | ||
|
||
#include <gst/gst.h> | ||
#include <glib.h> | ||
#include <gst/rtp/rtp-prelude.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define GST_RTP_REPAIR_META_API_TYPE (gst_rtp_repair_meta_api_get_type()) | ||
#define GST_RTP_REPAIR_META_INFO (gst_rtp_repair_meta_get_info()) | ||
typedef struct _GstRTPRepairMeta GstRTPRepairMeta; | ||
|
||
/** | ||
* GstRTPRepairMeta: | ||
* @meta: parent GstMeta structure | ||
* @idx_red_packets: index of this redundant packet for the block | ||
* @num_red_packets: number of redundant packets | ||
* @ssrc: SSRC | ||
* @seqnums: array of sequence numbers of data packets | ||
* | ||
* Meta describing the reduandant packet, e.g. FEC or RTX. | ||
* It is used to tie together the original packet and the redundant packets. | ||
*/ | ||
struct _GstRTPRepairMeta | ||
{ | ||
GstMeta meta; | ||
|
||
guint16 idx_red_packets; | ||
guint16 num_red_packets; | ||
guint32 ssrc; | ||
GArray *seqnums; | ||
}; | ||
|
||
GST_RTP_API | ||
GType gst_rtp_repair_meta_api_get_type (void); | ||
|
||
GST_RTP_API | ||
GstRTPRepairMeta *gst_buffer_add_rtp_repair_meta(GstBuffer *buffer, | ||
const guint16 idx_red_packets, const guint16 num_red_packets, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering about the "red" here, since "red" already has a very concrete meaning to rtp resilience. (https://getstream.io/resources/projects/webrtc/advanced/red/). Also on the topic of naming, I think GStreamer often leans towards keeping the variable names in API fairly short, like here: https://github.com/pexip/gstreamer/blob/main/subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtpmeta.h So could we think of some shorter names, maybe just "packet_idx" and "packet_count"? |
||
const guint32 ssrc, const guint16 *seqnum, guint seqnum_count); | ||
|
||
GST_RTP_API | ||
GstRTPRepairMeta * gst_buffer_get_rtp_repair_meta (GstBuffer * buffer); | ||
|
||
GST_RTP_API | ||
gboolean gst_buffer_repairs_seqnum(GstBuffer *buffer, guint16 seqnum, guint32 ssrc); | ||
|
||
GST_RTP_API | ||
gboolean gst_buffer_get_repair_seqnums(GstBuffer *buffer, guint32 * ssrc, | ||
GArray ** seqnums); | ||
|
||
/* If this packet is a FEC/RTX packet, what is it sequential number a block */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "what is its" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, GStreamer typically puts comments like this in the .c file, not the header. |
||
GST_RTP_API | ||
gint gst_buffer_get_repair_idx(GstBuffer *buffer); | ||
|
||
/* If this packet is a FEC/RTX packet, how many redundancy packets are in a block. | ||
* -1 if not a repair packet */ | ||
GST_RTP_API | ||
gint gst_buffer_get_repair_num(GstBuffer *buffer); | ||
|
||
GST_RTP_API | ||
const GstMetaInfo * gst_rtp_repair_meta_get_info (void); | ||
|
||
G_END_DECLS | ||
|
||
#endif /* __GST_RTP_REPAIR_META_H__ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs gst-indent run on it