mssdemux: replace gst_value_deserialize with simpler function
The deserialization was only used to convert hex strings into GstBuffers. Replace gst_value_deserialize with a simpler, direct function.
This commit is contained in:
parent
1458500850
commit
210f6c510c
@ -92,6 +92,8 @@ struct _GstMssManifest
|
|||||||
GSList *streams;
|
GSList *streams;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GstBuffer *gst_buffer_from_hex_string (const gchar * s);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
node_has_type (xmlNodePtr node, const gchar * name)
|
node_has_type (xmlNodePtr node, const gchar * name)
|
||||||
{
|
{
|
||||||
@ -377,8 +379,6 @@ _make_h264_codec_data (GstBuffer * sps, GstBuffer * pps)
|
|||||||
static void
|
static void
|
||||||
_gst_mss_stream_add_h264_codec_data (GstCaps * caps, const gchar * codecdatastr)
|
_gst_mss_stream_add_h264_codec_data (GstCaps * caps, const gchar * codecdatastr)
|
||||||
{
|
{
|
||||||
GValue sps_value = { 0, };
|
|
||||||
GValue pps_value = { 0, };
|
|
||||||
GstBuffer *sps;
|
GstBuffer *sps;
|
||||||
GstBuffer *pps;
|
GstBuffer *pps;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
@ -401,17 +401,12 @@ _gst_mss_stream_add_h264_codec_data (GstCaps * caps, const gchar * codecdatastr)
|
|||||||
return; /* invalid mss codec data */
|
return; /* invalid mss codec data */
|
||||||
}
|
}
|
||||||
|
|
||||||
g_value_init (&sps_value, GST_TYPE_BUFFER);
|
|
||||||
pps_str[0] = '\0';
|
pps_str[0] = '\0';
|
||||||
gst_value_deserialize (&sps_value, sps_str);
|
sps = gst_buffer_from_hex_string (sps_str);
|
||||||
pps_str[0] = '0';
|
pps_str[0] = '0';
|
||||||
|
|
||||||
g_value_init (&pps_value, GST_TYPE_BUFFER);
|
|
||||||
pps_str = pps_str + 8;
|
pps_str = pps_str + 8;
|
||||||
gst_value_deserialize (&pps_value, pps_str);
|
pps = gst_buffer_from_hex_string (pps_str);
|
||||||
|
|
||||||
sps = gst_value_get_buffer (&sps_value);
|
|
||||||
pps = gst_value_get_buffer (&pps_value);
|
|
||||||
|
|
||||||
nalu.ref_idc = (GST_BUFFER_DATA (sps)[0] & 0x60) >> 5;
|
nalu.ref_idc = (GST_BUFFER_DATA (sps)[0] & 0x60) >> 5;
|
||||||
nalu.type = GST_H264_NAL_SPS;
|
nalu.type = GST_H264_NAL_SPS;
|
||||||
@ -428,8 +423,8 @@ _gst_mss_stream_add_h264_codec_data (GstCaps * caps, const gchar * codecdatastr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer = _make_h264_codec_data (sps, pps);
|
buffer = _make_h264_codec_data (sps, pps);
|
||||||
g_value_reset (&sps_value);
|
gst_buffer_unref (sps);
|
||||||
g_value_reset (&pps_value);
|
gst_buffer_unref (pps);
|
||||||
|
|
||||||
if (buffer != NULL) {
|
if (buffer != NULL) {
|
||||||
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
||||||
@ -470,10 +465,10 @@ _gst_mss_stream_video_caps_from_qualitylevel_xml (xmlNodePtr node)
|
|||||||
if (strcmp (fourcc, "H264") == 0 || strcmp (fourcc, "AVC1") == 0) {
|
if (strcmp (fourcc, "H264") == 0 || strcmp (fourcc, "AVC1") == 0) {
|
||||||
_gst_mss_stream_add_h264_codec_data (caps, codec_data);
|
_gst_mss_stream_add_h264_codec_data (caps, codec_data);
|
||||||
} else {
|
} else {
|
||||||
GValue value = { 0, };
|
GstBuffer *buffer = gst_buffer_from_hex_string ((gchar *) codec_data);
|
||||||
g_value_init (&value, GST_TYPE_BUFFER);
|
gst_structure_set (structure, "codec_data", GST_TYPE_BUFFER, buffer,
|
||||||
gst_value_deserialize (&value, (gchar *) codec_data);
|
NULL);
|
||||||
gst_structure_take_value (structure, "codec_data", &value);
|
gst_buffer_unref (buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,10 +561,9 @@ _gst_mss_stream_audio_caps_from_qualitylevel_xml (xmlNodePtr node)
|
|||||||
g_ascii_strtoull (rate, NULL, 10), NULL);
|
g_ascii_strtoull (rate, NULL, 10), NULL);
|
||||||
|
|
||||||
if (codec_data && strlen (codec_data)) {
|
if (codec_data && strlen (codec_data)) {
|
||||||
GValue value = { 0, };
|
GstBuffer *buffer = gst_buffer_from_hex_string ((gchar *) codec_data);
|
||||||
g_value_init (&value, GST_TYPE_BUFFER);
|
gst_structure_set (structure, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
||||||
gst_value_deserialize (&value, (gchar *) codec_data);
|
gst_buffer_unref (buffer);
|
||||||
gst_structure_take_value (structure, "codec_data", &value);
|
|
||||||
} else if (strcmp (fourcc, "AACL") == 0 && rate && channels) {
|
} else if (strcmp (fourcc, "AACL") == 0 && rate && channels) {
|
||||||
GstBuffer *buffer =
|
GstBuffer *buffer =
|
||||||
_make_aacl_codec_data (g_ascii_strtoull (rate, NULL, 10),
|
_make_aacl_codec_data (g_ascii_strtoull (rate, NULL, 10),
|
||||||
@ -1078,3 +1072,34 @@ gst_mss_manifest_change_bitrate (GstMssManifest * manifest, guint64 bitrate)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstBuffer *
|
||||||
|
gst_buffer_from_hex_string (const gchar * s)
|
||||||
|
{
|
||||||
|
GstBuffer *buffer = NULL;
|
||||||
|
gint len;
|
||||||
|
gchar ts[3];
|
||||||
|
guint8 *data;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
len = strlen (s);
|
||||||
|
if (len & 1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (len / 2);
|
||||||
|
data = GST_BUFFER_DATA (buffer);
|
||||||
|
for (i = 0; i < len / 2; i++) {
|
||||||
|
if (!isxdigit ((int) s[i * 2]) || !isxdigit ((int) s[i * 2 + 1])) {
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ts[0] = s[i * 2 + 0];
|
||||||
|
ts[1] = s[i * 2 + 1];
|
||||||
|
ts[2] = 0;
|
||||||
|
|
||||||
|
data[i] = (guint8) strtoul (ts, NULL, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user