mssdemux: use standard glib methods

This commit is contained in:
Louis-Francis Ratté-Boulianne 2013-02-01 17:29:58 -05:00 committed by Thiago Santos
parent 44d02efee0
commit 218f2dee0c

View file

@ -45,8 +45,6 @@
#define MSS_PROP_TIMESCALE "TimeScale" #define MSS_PROP_TIMESCALE "TimeScale"
#define MSS_PROP_URL "Url" #define MSS_PROP_URL "Url"
#define TO_LOWER(str) { char* p = str; for ( ; *p; ++p) *p = tolower(*p); }
/* TODO check if atoi is successful? */ /* TODO check if atoi is successful? */
typedef struct _GstMssStreamFragment typedef struct _GstMssStreamFragment
@ -107,7 +105,11 @@ gst_mss_stream_quality_new (xmlNodePtr node)
q->xmlnode = node; q->xmlnode = node;
q->bitrate_str = (gchar *) xmlGetProp (node, (xmlChar *) MSS_PROP_BITRATE); q->bitrate_str = (gchar *) xmlGetProp (node, (xmlChar *) MSS_PROP_BITRATE);
q->bitrate = strtoull (q->bitrate_str, NULL, 10);
if (q->bitrate_str != NULL)
q->bitrate = g_ascii_strtoull (q->bitrate_str, NULL, 10);
else
q->bitrate = 0;
return q; return q;
} }
@ -230,8 +232,7 @@ gst_mss_manifest_new (const GstBuffer * data)
live_str = (gchar *) xmlGetProp (root, (xmlChar *) "IsLive"); live_str = (gchar *) xmlGetProp (root, (xmlChar *) "IsLive");
if (live_str) { if (live_str) {
TO_LOWER (live_str); manifest->is_live = g_ascii_strcasecmp (live_str, "true") == 0;
manifest->is_live = strcmp (live_str, "true") == 0;
xmlFree (live_str); xmlFree (live_str);
} }
@ -452,10 +453,11 @@ _gst_mss_stream_video_caps_from_qualitylevel_xml (xmlNodePtr node)
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if (max_width) if (max_width)
gst_structure_set (structure, "width", G_TYPE_INT, atoi (max_width), NULL); gst_structure_set (structure, "width", G_TYPE_INT,
g_ascii_strtoull (max_width, NULL, 10), NULL);
if (max_height) if (max_height)
gst_structure_set (structure, "height", G_TYPE_INT, atoi (max_height), gst_structure_set (structure, "height", G_TYPE_INT,
NULL); g_ascii_strtoull (max_height, NULL, 10), NULL);
if (codec_data && strlen (codec_data)) { if (codec_data && strlen (codec_data)) {
if (strcmp (fourcc, "H264") == 0 || strcmp (fourcc, "AVC1") == 0) { if (strcmp (fourcc, "H264") == 0 || strcmp (fourcc, "AVC1") == 0) {
@ -494,7 +496,7 @@ _frequency_index_from_sampling_rate (guint sampling_rate)
} }
static GstBuffer * static GstBuffer *
_make_accl_codec_data (guint sampling_rate, guint channels) _make_aacl_codec_data (guint64 sampling_rate, guint64 channels)
{ {
GstBuffer *buf; GstBuffer *buf;
guint8 *data; guint8 *data;
@ -550,18 +552,21 @@ _gst_mss_stream_audio_caps_from_qualitylevel_xml (xmlNodePtr node)
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if (channels) if (channels)
gst_structure_set (structure, "channels", G_TYPE_INT, atoi (channels), gst_structure_set (structure, "channels", G_TYPE_INT,
NULL); g_ascii_strtoull (channels, NULL, 10), NULL);
if (rate) if (rate)
gst_structure_set (structure, "rate", G_TYPE_INT, atoi (rate), NULL); gst_structure_set (structure, "rate", G_TYPE_INT,
g_ascii_strtoull (rate, NULL, 10), NULL);
if (codec_data && strlen (codec_data)) { if (codec_data && strlen (codec_data)) {
GValue *value = g_new0 (GValue, 1); GValue *value = g_new0 (GValue, 1);
g_value_init (value, GST_TYPE_BUFFER); g_value_init (value, GST_TYPE_BUFFER);
gst_value_deserialize (value, (gchar *) codec_data); gst_value_deserialize (value, (gchar *) codec_data);
gst_structure_take_value (structure, "codec_data", value); gst_structure_take_value (structure, "codec_data", value);
} else if (strcmp (fourcc, "AACL") == 0) { } else if (strcmp (fourcc, "AACL") == 0 && rate && channels) {
GstBuffer *buffer = _make_accl_codec_data (atoi (rate), atoi (channels)); GstBuffer *buffer =
_make_aacl_codec_data (g_ascii_strtoull (rate, NULL, 10),
g_ascii_strtoull (channels, NULL, 10));
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL); gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
} }
@ -596,7 +601,7 @@ gst_mss_stream_get_timescale (GstMssStream * stream)
} }
if (timescale) { if (timescale) {
ts = strtoull (timescale, NULL, 10); ts = g_ascii_strtoull (timescale, NULL, 10);
xmlFree (timescale); xmlFree (timescale);
} }
return ts; return ts;
@ -612,7 +617,7 @@ gst_mss_manifest_get_timescale (GstMssManifest * manifest)
(gchar *) xmlGetProp (manifest->xmlrootnode, (gchar *) xmlGetProp (manifest->xmlrootnode,
(xmlChar *) MSS_PROP_TIMESCALE); (xmlChar *) MSS_PROP_TIMESCALE);
if (timescale) { if (timescale) {
ts = strtoull (timescale, NULL, 10); ts = g_ascii_strtoull (timescale, NULL, 10);
xmlFree (timescale); xmlFree (timescale);
} }
return ts; return ts;
@ -628,7 +633,7 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest)
(gchar *) xmlGetProp (manifest->xmlrootnode, (gchar *) xmlGetProp (manifest->xmlrootnode,
(xmlChar *) MSS_PROP_STREAM_DURATION); (xmlChar *) MSS_PROP_STREAM_DURATION);
if (duration) { if (duration) {
dur = strtoull (duration, NULL, 10); dur = g_ascii_strtoull (duration, NULL, 10);
xmlFree (duration); xmlFree (duration);
} }
return dur; return dur;