mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
rtpvp8pay: Add picture-id-offset property
Add property to set the initial value for picture-id. RFC7741 says that picture-id MAY be initialized to a random value, thus it's also valid to simply set it to a fixed initial value. A fixed value is very useful for testing. Default behavior is not changed. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/728>
This commit is contained in:
parent
543b7e5024
commit
29d5936749
3 changed files with 56 additions and 11 deletions
|
@ -15764,6 +15764,20 @@
|
||||||
"readable": true,
|
"readable": true,
|
||||||
"type": "GstVP8RTPPayMode",
|
"type": "GstVP8RTPPayMode",
|
||||||
"writable": true
|
"writable": true
|
||||||
|
},
|
||||||
|
"picture-id-offset": {
|
||||||
|
"blurb": "Offset to add to the initial picture-id (-1 = random)",
|
||||||
|
"conditionally-available": false,
|
||||||
|
"construct": false,
|
||||||
|
"construct-only": false,
|
||||||
|
"controllable": false,
|
||||||
|
"default": "-1",
|
||||||
|
"max": "32767",
|
||||||
|
"min": "-1",
|
||||||
|
"mutable": "null",
|
||||||
|
"readable": true,
|
||||||
|
"type": "gint",
|
||||||
|
"writable": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rank": "marginal"
|
"rank": "marginal"
|
||||||
|
|
|
@ -39,11 +39,13 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_pay_debug);
|
||||||
#define GST_CAT_DEFAULT gst_rtp_vp8_pay_debug
|
#define GST_CAT_DEFAULT gst_rtp_vp8_pay_debug
|
||||||
|
|
||||||
#define DEFAULT_PICTURE_ID_MODE VP8_PAY_NO_PICTURE_ID
|
#define DEFAULT_PICTURE_ID_MODE VP8_PAY_NO_PICTURE_ID
|
||||||
|
#define DEFAULT_PICTURE_ID_OFFSET (-1)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_PICTURE_ID_MODE
|
PROP_PICTURE_ID_MODE,
|
||||||
|
PROP_PICTURE_ID_OFFSET
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GST_TYPE_RTP_VP8_PAY_PICTURE_ID_MODE (gst_rtp_vp8_pay_picture_id_mode_get_type())
|
#define GST_TYPE_RTP_VP8_PAY_PICTURE_ID_MODE (gst_rtp_vp8_pay_picture_id_mode_get_type())
|
||||||
|
@ -93,7 +95,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_STATIC_CAPS ("video/x-vp8"));
|
GST_STATIC_CAPS ("video/x-vp8"));
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
picture_id_bitsize_from_mode (PictureIDMode mode)
|
picture_id_field_len (PictureIDMode mode)
|
||||||
{
|
{
|
||||||
if (VP8_PAY_NO_PICTURE_ID == mode)
|
if (VP8_PAY_NO_PICTURE_ID == mode)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -105,20 +107,28 @@ picture_id_bitsize_from_mode (PictureIDMode mode)
|
||||||
static void
|
static void
|
||||||
gst_rtp_vp8_pay_picture_id_reset (GstRtpVP8Pay * obj)
|
gst_rtp_vp8_pay_picture_id_reset (GstRtpVP8Pay * obj)
|
||||||
{
|
{
|
||||||
gint picture_id_bitsize = picture_id_bitsize_from_mode (obj->picture_id_mode);
|
gint nbits;
|
||||||
if (0 == picture_id_bitsize)
|
|
||||||
return;
|
if (obj->picture_id_offset == -1)
|
||||||
obj->picture_id = g_random_int_range (0, 1 << picture_id_bitsize);
|
obj->picture_id = g_random_int ();
|
||||||
|
else
|
||||||
|
obj->picture_id = obj->picture_id_offset;
|
||||||
|
|
||||||
|
nbits = picture_id_field_len (obj->picture_id_mode);
|
||||||
|
obj->picture_id &= (1 << nbits) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_vp8_pay_picture_id_increment (GstRtpVP8Pay * obj)
|
gst_rtp_vp8_pay_picture_id_increment (GstRtpVP8Pay * obj)
|
||||||
{
|
{
|
||||||
gint picture_id_bitsize = picture_id_bitsize_from_mode (obj->picture_id_mode);
|
gint nbits;
|
||||||
if (0 == picture_id_bitsize)
|
|
||||||
return;
|
if (obj->picture_id_mode == VP8_PAY_NO_PICTURE_ID)
|
||||||
++obj->picture_id;
|
return;
|
||||||
obj->picture_id &= (1 << picture_id_bitsize) - 1;
|
|
||||||
|
nbits = picture_id_field_len (obj->picture_id_mode);
|
||||||
|
obj->picture_id++;
|
||||||
|
obj->picture_id &= (1 << nbits) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -126,6 +136,7 @@ gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj)
|
||||||
{
|
{
|
||||||
obj->picture_id_mode = DEFAULT_PICTURE_ID_MODE;
|
obj->picture_id_mode = DEFAULT_PICTURE_ID_MODE;
|
||||||
gst_rtp_vp8_pay_picture_id_reset (obj);
|
gst_rtp_vp8_pay_picture_id_reset (obj);
|
||||||
|
obj->picture_id_offset = DEFAULT_PICTURE_ID_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -144,6 +155,18 @@ gst_rtp_vp8_pay_class_init (GstRtpVP8PayClass * gst_rtp_vp8_pay_class)
|
||||||
"The picture ID mode for payloading",
|
"The picture ID mode for payloading",
|
||||||
GST_TYPE_RTP_VP8_PAY_PICTURE_ID_MODE, DEFAULT_PICTURE_ID_MODE,
|
GST_TYPE_RTP_VP8_PAY_PICTURE_ID_MODE, DEFAULT_PICTURE_ID_MODE,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
/**
|
||||||
|
* rtpvp8pay:picture-id-offset:
|
||||||
|
*
|
||||||
|
* Offset to add to the initial picture-id (-1 = random)
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class, PROP_PICTURE_ID_OFFSET,
|
||||||
|
g_param_spec_int ("picture-id-offset", "Picture ID offset",
|
||||||
|
"Offset to add to the initial picture-id (-1 = random)",
|
||||||
|
-1, 0x7FFF, DEFAULT_PICTURE_ID_OFFSET,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
gst_element_class_add_static_pad_template (element_class,
|
gst_element_class_add_static_pad_template (element_class,
|
||||||
&gst_rtp_vp8_pay_sink_template);
|
&gst_rtp_vp8_pay_sink_template);
|
||||||
|
@ -175,6 +198,10 @@ gst_rtp_vp8_pay_set_property (GObject * object,
|
||||||
rtpvp8pay->picture_id_mode = g_value_get_enum (value);
|
rtpvp8pay->picture_id_mode = g_value_get_enum (value);
|
||||||
gst_rtp_vp8_pay_picture_id_reset (rtpvp8pay);
|
gst_rtp_vp8_pay_picture_id_reset (rtpvp8pay);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PICTURE_ID_OFFSET:
|
||||||
|
rtpvp8pay->picture_id_offset = g_value_get_int (value);
|
||||||
|
gst_rtp_vp8_pay_picture_id_reset (rtpvp8pay);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -191,6 +218,9 @@ gst_rtp_vp8_pay_get_property (GObject * object,
|
||||||
case PROP_PICTURE_ID_MODE:
|
case PROP_PICTURE_ID_MODE:
|
||||||
g_value_set_enum (value, rtpvp8pay->picture_id_mode);
|
g_value_set_enum (value, rtpvp8pay->picture_id_mode);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PICTURE_ID_OFFSET:
|
||||||
|
g_value_set_int (value, rtpvp8pay->picture_id_offset);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct _GstRtpVP8Pay
|
||||||
guint partition_offset[10];
|
guint partition_offset[10];
|
||||||
guint partition_size[9];
|
guint partition_size[9];
|
||||||
PictureIDMode picture_id_mode;
|
PictureIDMode picture_id_mode;
|
||||||
|
gint picture_id_offset;
|
||||||
guint16 picture_id;
|
guint16 picture_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue