diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-07-07 15:04:27 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-10-11 08:35:03 +0200 |
commit | 056f47282902cc6f1a0e72fae99451c689f4d12c (patch) | |
tree | 3506e8ee532a0a594c11a3a5152c239d8309abc5 | |
parent | 952dc04531f06716b9286aafaa3ee76766075950 (diff) |
lavf: add M3U playlist demuxer.
-rw-r--r-- | libavformat/Makefile | 1 | ||||
-rw-r--r-- | libavformat/allformats.c | 1 | ||||
-rw-r--r-- | libavformat/m3udec.c | 58 |
3 files changed, 60 insertions, 0 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index 10943605d2..b1e8ed18d0 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -114,6 +114,7 @@ OBJS-$(CONFIG_LATM_DEMUXER) += rawdec.o OBJS-$(CONFIG_LATM_MUXER) += latmenc.o OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o OBJS-$(CONFIG_LXF_DEMUXER) += lxfdec.o +OBJS-$(CONFIG_M3U_DEMUXER) += m3udec.o OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o rawdec.o OBJS-$(CONFIG_M4V_MUXER) += rawenc.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 8e89b2f4ff..5bfd840f3f 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -116,6 +116,7 @@ void av_register_all(void) REGISTER_MUXDEMUX (LATM, latm); REGISTER_DEMUXER (LMLM4, lmlm4); REGISTER_DEMUXER (LXF, lxf); + REGISTER_DEMUXER (M3U, m3u); REGISTER_MUXDEMUX (M4V, m4v); REGISTER_MUXER (MD5, md5); REGISTER_MUXDEMUX (MATROSKA, matroska); diff --git a/libavformat/m3udec.c b/libavformat/m3udec.c new file mode 100644 index 0000000000..e68ca0d4fa --- /dev/null +++ b/libavformat/m3udec.c @@ -0,0 +1,58 @@ +/* + * M3U playlist demuxer. + * Copyright (c) 2011 Anton Khirnov + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "internal.h" +#include "playlist.h" +#include "libavutil/avutil.h" + +static int m3u_read_header(AVFormatContext *s, AVFormatParameters *ap) +{ + uint8_t buf[1024]; + int ret = 0; + + while (ff_get_line(s->pb, buf, sizeof(buf)) > 0) { + if (!buf[0] || buf[0] == '#') + continue; + + /* get rid of the newline */ + buf[strlen(buf) - 1] = 0; + + if (!ff_playlist_add_entry(s, buf)) { + ret = AVERROR(ENOMEM); + break; + } + } + + return ret; +} + +static int m3u_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + return AVERROR_EOF; +} + +AVInputFormat ff_m3u_demuxer = { + .name = "M3U", + .read_header = m3u_read_header, + .read_packet = m3u_read_packet, + .extensions = "m3u", +}; |