summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-27 23:47:05 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-27 23:48:22 +0200
commit8381ab143779d25611a1bb05d674bc39fe940f77 (patch)
tree74773be2c947475433dcc47898aec49a0c4b198b /libavformat
parentb8773e44d56667edea2d68d067d0c156522ca304 (diff)
parent79aeade6f6f8fbd7ce1da619fdd475e5db88ae24 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (29 commits) ARM: disable ff_vector_fmul_vfp on VFPv3 systems ARM: check for VFPv3 swscale: Remove unused variables in x86 code. doc: Drop DJGPP section, Libav now compiles out-of-the-box on FreeDOS. x86: Add appropriate ifdefs around certain AVX functions. cmdutils: use sws_freeContext() instead of av_freep(). swscale: delay allocation of formatConvBuffer(). swscale: fix build with --disable-swscale-alpha. movenc: Deprecate the global RTP hinting flag, use a private AVOption instead movenc: Add an AVClass for setting muxer specific options swscale: fix non-bitexact yuv2yuv[X2]() MMX/MMX2 functions. configure: report yasm/nasm presence properly tcp: make connect() timeout properly rawdec: factor video demuxer definitions into a macro. rtspdec: add initial_pause private option. lavf: deprecate AVFormatParameters.width/height. tty: add video_size private option. rawdec: add video_size private option. x11grab: add video_size private option. x11grab: factorize returning error codes. ... Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h12
-rw-r--r--libavformat/cavsvideodec.c11
-rw-r--r--libavformat/diracdec.c11
-rw-r--r--libavformat/dnxhddec.c11
-rw-r--r--libavformat/h261dec.c12
-rw-r--r--libavformat/h263dec.c12
-rw-r--r--libavformat/h264dec.c12
-rw-r--r--libavformat/id3v2.c9
-rw-r--r--libavformat/m4vdec.c12
-rw-r--r--libavformat/movenc.c30
-rw-r--r--libavformat/movenc.h5
-rw-r--r--libavformat/mpegvideodec.c11
-rw-r--r--libavformat/options.c4
-rw-r--r--libavformat/rawdec.c63
-rw-r--r--libavformat/rawdec.h18
-rw-r--r--libavformat/rawvideodec.c3
-rw-r--r--libavformat/rtsp.h8
-rw-r--r--libavformat/rtspdec.c21
-rw-r--r--libavformat/tcp.c25
-rw-r--r--libavformat/tty.c25
-rw-r--r--libavformat/version.h3
21 files changed, 189 insertions, 129 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 00fe8a6a45..59123ca101 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -231,9 +231,9 @@ typedef struct AVFormatParameters {
#if FF_API_FORMAT_PARAMETERS
attribute_deprecated int sample_rate;
attribute_deprecated int channels;
+ attribute_deprecated int width;
+ attribute_deprecated int height;
#endif
- int width;
- int height;
enum PixelFormat pix_fmt;
#if FF_API_FORMAT_PARAMETERS
attribute_deprecated int channel; /**< Used to select DV channel. */
@@ -241,9 +241,9 @@ typedef struct AVFormatParameters {
attribute_deprecated unsigned int mpeg2ts_raw:1; /**< deprecated, use mpegtsraw demuxer */
/**< deprecated, use mpegtsraw demuxer-specific options instead */
attribute_deprecated unsigned int mpeg2ts_compute_pcr:1;
+ attribute_deprecated unsigned int initial_pause:1; /**< Do not begin to play the stream
+ immediately (RTSP only). */
#endif
- unsigned int initial_pause:1; /**< Do not begin to play the stream
- immediately (RTSP only). */
unsigned int prealloced_context:1;
} AVFormatParameters;
@@ -733,7 +733,9 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
-#define AVFMT_FLAG_RTP_HINT 0x0040 ///< Add RTP hinting to the output file
+#if FF_API_FLAG_RTP_HINT
+#define AVFMT_FLAG_RTP_HINT 0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
+#endif
#define AVFMT_FLAG_MP4A_LATM 0x0080 ///< Enable RTP MP4A-LATM payload
#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
diff --git a/libavformat/cavsvideodec.c b/libavformat/cavsvideodec.c
index 6db9ad9fcf..4a399a26d1 100644
--- a/libavformat/cavsvideodec.c
+++ b/libavformat/cavsvideodec.c
@@ -65,13 +65,4 @@ static int cavsvideo_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_cavsvideo_demuxer = {
- "cavsvideo",
- NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
- 0,
- cavsvideo_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .value = CODEC_ID_CAVS,
-};
+FF_DEF_RAWVIDEO_DEMUXER(cavsvideo, "raw Chinese AVS video", cavsvideo_probe, NULL, CODEC_ID_CAVS)
diff --git a/libavformat/diracdec.c b/libavformat/diracdec.c
index 6c6896163b..6afda533dc 100644
--- a/libavformat/diracdec.c
+++ b/libavformat/diracdec.c
@@ -31,13 +31,4 @@ static int dirac_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_dirac_demuxer = {
- "dirac",
- NULL_IF_CONFIG_SMALL("raw Dirac"),
- 0,
- dirac_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .value = CODEC_ID_DIRAC,
-};
+FF_DEF_RAWVIDEO_DEMUXER(dirac, "raw Dirac", dirac_probe, NULL, CODEC_ID_DIRAC)
diff --git a/libavformat/dnxhddec.c b/libavformat/dnxhddec.c
index 035e1c4b30..f89782a880 100644
--- a/libavformat/dnxhddec.c
+++ b/libavformat/dnxhddec.c
@@ -42,13 +42,4 @@ static int dnxhd_probe(AVProbeData *p)
return AVPROBE_SCORE_MAX;
}
-AVInputFormat ff_dnxhd_demuxer = {
- "dnxhd",
- NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
- 0,
- dnxhd_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .value = CODEC_ID_DNXHD,
-};
+FF_DEF_RAWVIDEO_DEMUXER(dnxhd, "raw DNxHD (SMPTE VC-3)", dnxhd_probe, NULL, CODEC_ID_DNXHD)
diff --git a/libavformat/h261dec.c b/libavformat/h261dec.c
index 1478ed663f..354a7c78c1 100644
--- a/libavformat/h261dec.c
+++ b/libavformat/h261dec.c
@@ -62,14 +62,4 @@ static int h261_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_h261_demuxer = {
- "h261",
- NULL_IF_CONFIG_SMALL("raw H.261"),
- 0,
- h261_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "h261",
- .value = CODEC_ID_H261,
-};
+FF_DEF_RAWVIDEO_DEMUXER(h261, "raw H.261", h261_probe, "h261", CODEC_ID_H261)
diff --git a/libavformat/h263dec.c b/libavformat/h263dec.c
index 634923d885..b07e9782b8 100644
--- a/libavformat/h263dec.c
+++ b/libavformat/h263dec.c
@@ -64,14 +64,4 @@ static int h263_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_h263_demuxer = {
- "h263",
- NULL_IF_CONFIG_SMALL("raw H.263"),
- 0,
- h263_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
-// .extensions = "h263", //FIXME remove after writing mpeg4_probe
- .value = CODEC_ID_H263,
-};
+FF_DEF_RAWVIDEO_DEMUXER(h263, "raw H.263", h263_probe, NULL, CODEC_ID_H263)
diff --git a/libavformat/h264dec.c b/libavformat/h264dec.c
index cec8f85275..e7c6d70deb 100644
--- a/libavformat/h264dec.c
+++ b/libavformat/h264dec.c
@@ -67,14 +67,4 @@ static int h264_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_h264_demuxer = {
- "h264",
- NULL_IF_CONFIG_SMALL("raw H.264 video format"),
- 0,
- h264_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
- .value = CODEC_ID_H264,
-};
+FF_DEF_RAWVIDEO_DEMUXER(h264 , "raw H.264 video format", h264_probe, "h26l,h264,264", CODEC_ID_H264)
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 3640b11ab1..4e0c7d47ce 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -228,7 +228,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
avio_skip(s->pb, get_size(s->pb, 4));
while (len >= taghdrlen) {
- unsigned int tflags;
+ unsigned int tflags = 0;
int tunsync = 0;
if (isv34) {
@@ -245,7 +245,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
tag[3] = 0;
tlen = avio_rb24(s->pb);
}
- if (tlen > (1<<28))
+ if (tlen > (1<<28) || !tlen)
break;
len -= taghdrlen + tlen;
@@ -268,6 +268,10 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
if (unsync || tunsync) {
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
+ if (!buffer) {
+ av_log(s, AV_LOG_ERROR, "Failed to alloc %d bytes\n", tlen);
+ goto seek;
+ }
for (i = 0, j = 0; i < tlen; i++, j++) {
buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
@@ -288,6 +292,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
break;
}
/* Skip to end of tag */
+seek:
avio_seek(s->pb, next, SEEK_SET);
}
diff --git a/libavformat/m4vdec.c b/libavformat/m4vdec.c
index f830c7afcf..88f838022e 100644
--- a/libavformat/m4vdec.c
+++ b/libavformat/m4vdec.c
@@ -49,14 +49,4 @@ static int mpeg4video_probe(AVProbeData *probe_packet)
return 0;
}
-AVInputFormat ff_m4v_demuxer = {
- "m4v",
- NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
- 0,
- mpeg4video_probe, /** probing for MPEG-4 data */
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "m4v",
- .value = CODEC_ID_MPEG4,
-};
+FF_DEF_RAWVIDEO_DEMUXER(m4v, "raw MPEG-4 video format", mpeg4video_probe, "m4v", CODEC_ID_MPEG4)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a4ec51d082..7b0eed979c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -32,10 +32,24 @@
#include "libavcodec/put_bits.h"
#include "internal.h"
#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
#undef NDEBUG
#include <assert.h>
+static const AVOption options[] = {
+ { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "rtphint", "Add RTP hint tracks", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { NULL },
+};
+
+static const AVClass mov_muxer_class = {
+ .class_name = "MOV/3GP/MP4/3G2 muxer",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
//FIXME support 64 bit variant with wide placeholders
static int64_t updateSize(AVIOContext *pb, int64_t pos)
{
@@ -2125,7 +2139,15 @@ static int mov_write_header(AVFormatContext *s)
if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
+#if FF_API_FLAG_RTP_HINT
if (s->flags & AVFMT_FLAG_RTP_HINT) {
+ av_log(s, AV_LOG_WARNING, "The RTP_HINT flag is deprecated, enable it "
+ "via the -movflags rtphint muxer option "
+ "instead.\n");
+ mov->flags |= FF_MOV_FLAG_RTP_HINT;
+ }
+#endif
+ if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Add hint tracks for each audio and video stream */
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
@@ -2221,7 +2243,7 @@ static int mov_write_header(AVFormatContext *s)
if (mov->chapter_track)
mov_create_chapter_track(s, mov->chapter_track);
- if (s->flags & AVFMT_FLAG_RTP_HINT) {
+ if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Initialize the hint tracks for each audio and video stream */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
@@ -2298,6 +2320,7 @@ AVOutputFormat ff_mov_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
#if CONFIG_TGP_MUXER
@@ -2314,6 +2337,7 @@ AVOutputFormat ff_tgp_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
#if CONFIG_MP4_MUXER
@@ -2330,6 +2354,7 @@ AVOutputFormat ff_mp4_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
#if CONFIG_PSP_MUXER
@@ -2346,6 +2371,7 @@ AVOutputFormat ff_psp_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
#if CONFIG_TG2_MUXER
@@ -2362,6 +2388,7 @@ AVOutputFormat ff_tg2_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
#if CONFIG_IPOD_MUXER
@@ -2378,5 +2405,6 @@ AVOutputFormat ff_ipod_muxer = {
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
.codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0},
+ .priv_class = &mov_muxer_class,
};
#endif
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 182c5edc8c..4e583b3108 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -101,6 +101,7 @@ typedef struct MOVIndex {
} MOVTrack;
typedef struct MOVMuxContext {
+ const AVClass *av_class;
int mode;
int64_t time;
int nb_streams;
@@ -108,8 +109,12 @@ typedef struct MOVMuxContext {
int64_t mdat_pos;
uint64_t mdat_size;
MOVTrack *tracks;
+
+ int flags;
} MOVMuxContext;
+#define FF_MOV_FLAG_RTP_HINT 1
+
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index);
diff --git a/libavformat/mpegvideodec.c b/libavformat/mpegvideodec.c
index d1ba1f8c2c..d38d6955e4 100644
--- a/libavformat/mpegvideodec.c
+++ b/libavformat/mpegvideodec.c
@@ -55,13 +55,4 @@ static int mpegvideo_probe(AVProbeData *p)
return 0;
}
-AVInputFormat ff_mpegvideo_demuxer = {
- "mpegvideo",
- NULL_IF_CONFIG_SMALL("raw MPEG video"),
- 0,
- mpegvideo_probe,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .value = CODEC_ID_MPEG1VIDEO,
-};
+FF_DEF_RAWVIDEO_DEMUXER(mpegvideo, "raw MPEG video", mpegvideo_probe, NULL, CODEC_ID_MPEG1VIDEO)
diff --git a/libavformat/options.c b/libavformat/options.c
index 6281b7fbcd..7cd359db29 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -49,7 +49,9 @@ static const AVOption options[]={
{"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"},
{"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
{"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
-{"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"},
+#if FF_API_FLAG_RTP_HINT
+{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"},
+#endif
{"sortdts", "try to interleave outputted packets by dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"},
{"keepside", "dont merge side data", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
{"latm", "enable RTP MP4A-LATM payload", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index daacae0c24..a1617f00c4 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -24,6 +24,7 @@
#include "avio_internal.h"
#include "rawdec.h"
#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
/* raw input */
int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
@@ -66,17 +67,34 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
}
- case AVMEDIA_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO: {
+ FFRawVideoDemuxerContext *s1 = s->priv_data;
+ int width = 0, height = 0, ret;
if(ap->time_base.num)
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
else
av_set_pts_info(st, 64, 1, 25);
- st->codec->width = ap->width;
- st->codec->height = ap->height;
+ if (s1->video_size) {
+ ret = av_parse_video_size(&width, &height, s1->video_size);
+ av_freep(&s1->video_size);
+ if (ret < 0) {
+ av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
+ return ret;
+ }
+ }
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->width > 0)
+ width = ap->width;
+ if (ap->height > 0)
+ height = ap->height;
+#endif
+ st->codec->width = width;
+ st->codec->height = height;
st->codec->pix_fmt = ap->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
+ }
default:
return -1;
}
@@ -166,6 +184,22 @@ const AVClass ff_rawaudio_demuxer_class = {
.version = LIBAVUTIL_VERSION_INT,
};
+#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption video_options[] = {
+ { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+ { NULL },
+};
+#undef OFFSET
+#undef DEC
+
+const AVClass ff_rawvideo_demuxer_class = {
+ .class_name = "rawvideo demuxer",
+ .item_name = av_default_item_name,
+ .option = video_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
#if CONFIG_G722_DEMUXER
AVInputFormat ff_g722_demuxer = {
"g722",
@@ -196,17 +230,7 @@ AVInputFormat ff_gsm_demuxer = {
#endif
#if CONFIG_MJPEG_DEMUXER
-AVInputFormat ff_mjpeg_demuxer = {
- "mjpeg",
- NULL_IF_CONFIG_SMALL("raw MJPEG video"),
- 0,
- NULL,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .flags= AVFMT_GENERIC_INDEX,
- .extensions = "mjpg,mjpeg",
- .value = CODEC_ID_MJPEG,
-};
+FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg", CODEC_ID_MJPEG)
#endif
#if CONFIG_MLP_DEMUXER
@@ -252,14 +276,5 @@ AVInputFormat ff_shorten_demuxer = {
#endif
#if CONFIG_VC1_DEMUXER
-AVInputFormat ff_vc1_demuxer = {
- "vc1",
- NULL_IF_CONFIG_SMALL("raw VC-1"),
- 0,
- NULL /* vc1_probe */,
- ff_raw_video_read_header,
- ff_raw_read_partial_packet,
- .extensions = "vc1",
- .value = CODEC_ID_VC1,
-};
+FF_DEF_RAWVIDEO_DEMUXER(vc1, "raw VC-1", NULL, "vc1", CODEC_ID_VC1)
#endif
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index a989ea9ce6..3eed6e711d 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -31,7 +31,13 @@ typedef struct RawAudioDemuxerContext {
int channels;
} RawAudioDemuxerContext;
+typedef struct FFRawVideoDemuxerContext {
+ const AVClass *class; /**< Class for private options. */
+ char *video_size; /**< String describing video size, set by a private option. */
+} FFRawVideoDemuxerContext;
+
extern const AVClass ff_rawaudio_demuxer_class;
+extern const AVClass ff_rawvideo_demuxer_class;
int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap);
@@ -41,4 +47,16 @@ int ff_raw_audio_read_header(AVFormatContext *s, AVFormatParameters *ap);
int ff_raw_video_read_header(AVFormatContext *s, AVFormatParameters *ap);
+#define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\
+AVInputFormat ff_ ## shortname ## _demuxer = {\
+ .name = #shortname,\
+ .long_name = NULL_IF_CONFIG_SMALL(longname),\
+ .read_probe = probe,\
+ .read_header = ff_raw_video_read_header,\
+ .read_packet = ff_raw_read_partial_packet,\
+ .extensions = ext,\
+ .flags = AVFMT_GENERIC_INDEX,\
+ .value = id,\
+};
+
#endif /* AVFORMAT_RAWDEC_H */
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index 127119f18a..36f5d954ae 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -47,11 +47,12 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
AVInputFormat ff_rawvideo_demuxer = {
"rawvideo",
NULL_IF_CONFIG_SMALL("raw video format"),
- 0,
+ sizeof(FFRawVideoDemuxerContext),
NULL,
ff_raw_read_header,
rawvideo_read_packet,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "yuv,cif,qcif,rgb",
.value = CODEC_ID_RAWVIDEO,
+ .priv_class = &ff_rawvideo_demuxer_class,
};
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 56160cefc2..57990b763c 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -28,6 +28,8 @@
#include "network.h"
#include "httpauth.h"
+#include "libavutil/log.h"
+
/**
* Network layer over which RTP/etc packet data will be transported.
*/
@@ -196,6 +198,7 @@ enum RTSPServerType {
* @todo Use AVIOContext instead of URLContext
*/
typedef struct RTSPState {
+ const AVClass *class; /**< Class for private options. */
URLContext *rtsp_hd; /* RTSP TCP connection handle */
/** number of items in the 'rtsp_streams' variable */
@@ -336,6 +339,11 @@ typedef struct RTSPState {
* Whether the server supports the GET_PARAMETER method.
*/
int get_parameter_supported;
+
+ /**
+ * Do not begin to play the stream immediately.
+ */
+ int initial_pause;
} RTSPState;
/**
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 454a31c3f9..d6a7d1b1ac 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -21,6 +21,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
#include "avformat.h"
#include "internal.h"
@@ -165,7 +166,12 @@ static int rtsp_read_header(AVFormatContext *s,
return AVERROR(ENOMEM);
rt->real_setup = rt->real_setup_cache + s->nb_streams;
- if (ap->initial_pause) {
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->initial_pause)
+ rt->initial_pause = ap->initial_pause;
+#endif
+
+ if (rt->initial_pause) {
/* do not start immediately */
} else {
if (rtsp_read_play(s) < 0) {
@@ -399,6 +405,18 @@ static int rtsp_read_close(AVFormatContext *s)
return 0;
}
+static const AVOption options[] = {
+ { "initial_pause", "Don't start playing the stream immediately", offsetof(RTSPState, initial_pause), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+const AVClass rtsp_demuxer_class = {
+ .class_name = "RTSP demuxer",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_rtsp_demuxer = {
"rtsp",
NULL_IF_CONFIG_SMALL("RTSP input format"),
@@ -411,4 +429,5 @@ AVInputFormat ff_rtsp_demuxer = {
.flags = AVFMT_NOFILE,
.read_play = rtsp_read_play,
.read_pause = rtsp_read_pause,
+ .priv_class = &rtsp_demuxer_class,
};
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 0c764d361b..b144e31457 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -45,6 +45,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
char buf[256];
int ret;
socklen_t optlen;
+ int timeout = 100;
char hostname[1024],proto[1024],path[1024];
char portstr[10];
@@ -57,6 +58,9 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
if (p) {
if (av_find_info_tag(buf, sizeof(buf), "listen", p))
listen_socket = 1;
+ if (av_find_info_tag(buf, sizeof(buf), "timeout", p)) {
+ timeout = strtol(buf, NULL, 10);
+ }
}
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@@ -73,6 +77,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
cur_ai = ai;
restart:
+ ret = AVERROR(EIO);
fd = socket(cur_ai->ai_family, cur_ai->ai_socktype, cur_ai->ai_protocol);
if (fd < 0)
goto fail;
@@ -84,29 +89,30 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
fd1 = accept(fd, NULL, NULL);
closesocket(fd);
fd = fd1;
+ ff_socket_nonblock(fd, 1);
} else {
redo:
+ ff_socket_nonblock(fd, 1);
ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
}
- ff_socket_nonblock(fd, 1);
-
if (ret < 0) {
int timeout=50;
struct pollfd p = {fd, POLLOUT, 0};
- if (ff_neterrno() == AVERROR(EINTR)) {
+ ret = ff_neterrno();
+ if (ret == AVERROR(EINTR)) {
if (url_interrupt_cb()) {
ret = AVERROR_EXIT;
goto fail1;
}
goto redo;
}
- if (ff_neterrno() != AVERROR(EINPROGRESS) &&
- ff_neterrno() != AVERROR(EAGAIN))
+ if (ret != AVERROR(EINPROGRESS) &&
+ ret != AVERROR(EAGAIN))
goto fail;
/* wait until we are connected or until abort */
- for(;;) {
+ while(timeout--) {
if (url_interrupt_cb()) {
ret = AVERROR_EXIT;
goto fail1;
@@ -121,7 +127,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
goto fail;
}
}
-
+ if (ret <= 0) {
+ ret = AVERROR(ETIMEDOUT);
+ goto fail;
+ }
/* test error */
optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
@@ -129,6 +138,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
av_log(h, AV_LOG_ERROR,
"TCP connection to %s:%d failed: %s\n",
hostname, port, strerror(ret));
+ ret = AVERROR(ret);
goto fail;
}
}
@@ -151,7 +161,6 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
closesocket(fd);
goto restart;
}
- ret = AVERROR(EIO);
fail1:
if (fd >= 0)
closesocket(fd);
diff --git a/libavformat/tty.c b/libavformat/tty.c
index 171099d3cb..8340218bd2 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
#include "avformat.h"
#include "sauce.h"
@@ -35,6 +36,7 @@ typedef struct {
AVClass *class;
int chars_per_frame;
uint64_t fsize; /**< file size less metadata buffer */
+ char *video_size;/**< A string describing video size, set by a private option. */
} TtyDemuxContext;
/**
@@ -71,14 +73,30 @@ static int read_header(AVFormatContext *avctx,
AVFormatParameters *ap)
{
TtyDemuxContext *s = avctx->priv_data;
+ int width = 0, height = 0, ret;
AVStream *st = av_new_stream(avctx, 0);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_tag = 0;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANSI;
- if (ap->width) st->codec->width = ap->width;
- if (ap->height) st->codec->height = ap->height;
+
+ if (s->video_size) {
+ ret = av_parse_video_size(&width, &height, s->video_size);
+ av_freep(&s->video_size);
+ if (ret < 0) {
+ av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n");
+ return ret;
+ }
+ }
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->width > 0)
+ width = ap->width;
+ if (ap->height > 0)
+ height = ap->height;
+#endif
+ st->codec->width = width;
+ st->codec->height = height;
if (!ap->time_base.num) {
av_set_pts_info(st, 60, 1, 25);
@@ -129,8 +147,11 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
return 0;
}
+#define OFFSET(x) offsetof(TtyDemuxContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM},
+ { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ NULL },
};
diff --git a/libavformat/version.h b/libavformat/version.h
index fe8e85dadf..203ac34039 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -74,5 +74,8 @@
#ifndef FF_API_FORMAT_PARAMETERS
#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_FLAG_RTP_HINT
+#define FF_API_FLAG_RTP_HINT (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
#endif /* AVFORMAT_VERSION_H */