[vlc-devel] [PATCH] live555: retrieve RTSP track languages from SDP
Gilles Chanteperdrix
gilles.chanteperdrix at xenomai.org
Tue Dec 17 19:31:04 CET 2013
On 12/17/2013 07:20 PM, Rémi Denis-Courmont wrote:
> On Tue, 17 Dec 2013 09:38:26 +0100, Gilles Chanteperdrix
> <gilles.chanteperdrix at xenomai.org> wrote:
>> by parsing the "a=lang:" attribute.
>> ---
>> modules/access/live555.cpp | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
>> index b9ed723..c226b90 100644
>> --- a/modules/access/live555.cpp
>> +++ b/modules/access/live555.cpp
>> @@ -685,6 +685,7 @@ static int SessionsSetup( demux_t *p_demux )
>> unsigned int i_receive_buffer = 0;
>> int i_frame_buffer = DEFAULT_FRAME_BUFFER_SIZE;
>> unsigned const thresh = 200000; /* RTP reorder threshold .2 second
>> (default .1) */
>> + const char *lang;
>>
>> b_rtsp_tcp = var_CreateGetBool( p_demux, "rtsp-tcp" ) ||
>> var_GetBool( p_demux, "rtsp-http" );
>> @@ -1090,6 +1091,20 @@ static int SessionsSetup( demux_t *p_demux )
>> }
>> }
>>
>> + /* Try and parse a=lang: attribute */
>> + lang = strstr(sub->savedSDPLines(), "a=lang:");
>
> Isn't there a nice getter for SDP attributes?
It is not an attribute currently parsed by live555. I could submit a
patch to live555, but the vlc code would require a version of live555
subsequent to this patch. Given the amount of work to do the parsing, I
found it simpler to add the code to vlc.
> Also, is lang only a media
> attribute, or should it be inherited from the session where
> applicable?
I have to check, I read the RFC when I added this to my server, and
forgot what I read just after having implemented that. But I believe
yes, there is also a session attribute. That said, the attribute is only
useful if there are different tracks of the same type with different
values of the attribute, otherwise, the information is not really relevant.
>
>> + if (lang) {
>> + unsigned sz;
>> +
>> + for (lang += 7, sz = 0; !isspace(lang[sz]); sz++)
>
> isspace() is subject to localization. Here, you should rather hard-code
> the set of characters and use strcspn().
Ok, isspace is faster, because it has an harcoded look-up table. Since
you did not want sscanf, I figured it was because you wanted a more
optimized solution.
>
>> + ;
>> + tk->fmt.psz_language = (char *)malloc(sz + 1);
>> + if (tk->fmt.psz_language) {
>> + memcpy(tk->fmt.psz_language, lang, sz);
>> + tk->fmt.psz_language[sz] = '\0';
>> + }
>
> strndup() ?
Well, strndup will check whether every character in the source string is
a terminator, to compute the string length, whereas we already know the
length.
Ok, will do it like you suggest.
--
Gilles.
More information about the vlc-devel
mailing list