[vlc-devel] [vlc-commits] stream: add stream_IsMimeType()

Rémi Denis-Courmont remi at remlab.net
Tue Apr 25 18:30:22 CEST 2017


Le tiistaina 25. huhtikuuta 2017, 11.27.37 EEST Steve Lhomme a écrit :
> On Tue, Apr 18, 2017 at 8:41 PM, Rémi Denis-Courmont <git at videolan.org> 
wrote:
> > vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 17
> > 23:02:51 2017 +0300| [5bd39f0fa1aab9608e2236e2ae17f223f4bea331] |
> > committer: Rémi Denis-Courmont
> > 
> > stream: add stream_IsMimeType()
> > 
> >> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5bd39f0fa1aab9608e
> >> 2236e2ae17f223f4bea331> 
> > ---
> > 
> >  include/vlc_demux.h  | 11 +----------
> >  include/vlc_stream.h | 17 +++++++++++++++++
> >  2 files changed, 18 insertions(+), 10 deletions(-)
> > 
> > diff --git a/include/vlc_demux.h b/include/vlc_demux.h
> > index 3f7f139d48..5c89b30324 100644
> > --- a/include/vlc_demux.h
> > +++ b/include/vlc_demux.h
> > @@ -399,16 +399,7 @@ static inline bool demux_IsPathExtension( demux_t
> > *p_demux, const char *psz_exte> 
> >  VLC_USED
> >  static inline bool demux_IsContentType(demux_t *demux, const char *type)
> >  {
> > 
> > -    char *mime = stream_ContentType(demux->s);
> > -    if (mime == NULL)
> > -        return false;
> > -
> > -    size_t len = strlen(type);
> > -    bool ok = strncasecmp(mime, type, len) == 0
> > -           && memchr("\t ;", (unsigned char)mime[len], 4) != NULL;
> > -
> > -    free(mime);
> > -    return ok;
> > +    return stream_IsMimeType(demux->s, type);
> > 
> >  }
> >  
> >  VLC_USED
> > 
> > diff --git a/include/vlc_stream.h b/include/vlc_stream.h
> > index 6960260291..36cb9cddd0 100644
> > --- a/include/vlc_stream.h
> > +++ b/include/vlc_stream.h
> > @@ -345,6 +345,23 @@ static inline char *stream_MimeType( stream_t *s )
> > 
> >  }
> >  
> >  /**
> > 
> > + * Checks for a MIME type.
> > + *
> > + * Checks if the stream has a specific MIME type.
> > + */
> > +VLC_USED
> > +static inline bool stream_IsMimeType(stream_t *s, const char *type)
> > +{
> > +    char *mime = stream_MimeType(s);
> > +    if (mime == NULL)
> > +        return false;
> > +
> > +    bool ok = strcasecmp(mime, type);
> 
> Is it ok to call strcasecmp from a public header ?

It´s no worse than calling strncasecmp() (before this change).

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list