aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-23 01:05:20 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-23 01:05:20 +0100
commitfeb997577b66367a0c4269100888640699ee890d (patch)
treeb6ff06f8d443ea963d082f97f51d07520833ae7e /libavformat
parent9bf9c314a093db16a009829bfe874bf03ffaecc9 (diff)
parent15cea3695daf3f6363794594982e3816ddc8d90b (diff)
downloadffmpeg-feb997577b66367a0c4269100888640699ee890d.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits) riff: fix invalid av_freep() calls on EOF in ff_read_riff_info pam: Fix a typo that broke writing and reading PAM files. mxfdec: fix memleak on av_realloc failures mxfdec: Do not parse slices or DeltaEntryArrays. mxfdec: hybrid demuxing/seeking solution mxfdec: Add Avid's essence element key. mfxdec: Separate mxf_essence_container_uls for audio and video. mxfdec: Compute packet offsets properly. mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack. mxfdec: use av_dlog() for 'no corresponding source package found' mxfdec: Make mxf->partitions sorted by offset. mxfdec: parse ThisPartition mxfdec: Speed up metadata and index parsing. mxfdec: Make sure DataDefinition is consistent between material track and source track. mxfdec: add EssenceContainer UL found in 0001GL00.MXF.A1.mxf_opatom.mxf mxfdec: Add hack that adjusts the n_delta calculation when system items are present. mxfdec: Parse IndexTableSegments and convert them into AVIndexEntry arrays. mxfdec: Move FooterPartition to MXFContext and make sure it is never zero. mxfdec: check return value of avio_seek mxfdec: skip to end of structural sets ... Conflicts: configure libavcodec/pnm.c libavformat/mxfdec.c libavformat/riff.c libavformat/rtsp.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mxfdec.c25
-rw-r--r--libavformat/rtsp.c21
-rw-r--r--libavformat/rtsp.h5
3 files changed, 35 insertions, 16 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index e5574e2d18..036ea94bcd 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -80,7 +80,7 @@ typedef struct {
int index_sid;
int body_sid;
int64_t this_partition;
- int64_t essence_offset; /* absolute offset of essence */
+ int64_t essence_offset; ///< absolute offset of essence
int64_t essence_length;
int32_t kag_size;
int64_t header_byte_count;
@@ -407,7 +407,7 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
- MXFPartition *partition;
+ MXFPartition *partition, *tmp_part;
UID op;
uint64_t footer_partition;
uint32_t nb_essence_containers;
@@ -415,9 +415,10 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
return AVERROR(ENOMEM);
- mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
- if (!mxf->partitions)
+ tmp_part = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
+ if (!tmp_part)
return AVERROR(ENOMEM);
+ mxf->partitions = tmp_part;
if (mxf->parsing_backward) {
/* insert the new partition pack in the middle
@@ -531,11 +532,13 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
{
+ MXFMetadataSet **tmp;
if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
return AVERROR(ENOMEM);
- mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
- if (!mxf->metadata_sets)
+ tmp = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
+ if (!tmp)
return AVERROR(ENOMEM);
+ mxf->metadata_sets = tmp;
mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
mxf->metadata_sets_count++;
return 0;
@@ -888,6 +891,7 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
if (!(unsorted_segments = av_calloc(nb_segments, sizeof(*unsorted_segments))) ||
!(*sorted_segments = av_calloc(nb_segments, sizeof(**sorted_segments)))) {
+ av_freep(sorted_segments);
av_free(unsorted_segments);
return AVERROR(ENOMEM);
}
@@ -1303,7 +1307,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
- ret = -1;
+ ret = AVERROR_INVALIDDATA;
goto fail_and_free;
}
@@ -1971,8 +1975,9 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
if (sample_time < 0)
sample_time = 0;
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
- if (avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET) < 0)
- return -1;
+
+ if ((ret = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET)) < 0)
+ return ret;
ff_update_cur_dts(s, st, sample_time);
} else {
t = &mxf->index_tables[0];
@@ -1994,7 +1999,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) << 0)
return ret;
- av_update_cur_dts(s, st, sample_time);
+ ff_update_cur_dts(s, st, sample_time);
mxf->current_edit_unit = sample_time;
avio_seek(s->pb, seekpos, SEEK_SET);
}
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 56e5de27f8..c2a0d26e5e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -81,6 +81,8 @@ const AVOption ff_rtsp_options[] = {
{ "http", "HTTP tunneling", 0, AV_OPT_TYPE_CONST, {(1 << RTSP_LOWER_TRANSPORT_HTTP)}, 0, 0, DEC, "rtsp_transport" },
RTSP_FLAG_OPTS("rtsp_flags", "RTSP flags"),
RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"),
+ { "min_port", "Minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
+ { "max_port", "Maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
{ NULL },
};
@@ -1117,14 +1119,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
/* default timeout: 1 minute */
rt->timeout = 60;
- /* for each stream, make the setup request */
- /* XXX: we assume the same server is used for the control of each
- * RTSP stream */
- port_off = av_get_random_seed() % (RTSP_RTP_PORT_MAX - RTSP_RTP_PORT_MIN);
+ /* Choose a random starting offset within the first half of the
+ * port range, to allow for a number of ports to try even if the offset
+ * happens to be at the end of the random range. */
+ port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2);
/* even random offset */
port_off -= port_off & 0x01;
- for (j = RTSP_RTP_PORT_MIN + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
+ for (j = rt->rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[2048];
/*
@@ -1161,7 +1163,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
}
/* first try in specified port range */
- while (j <= RTSP_RTP_PORT_MAX) {
+ while (j <= rt->rtp_port_max) {
ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1,
"?localport=%d", j);
/* we will use two ports per rtp stream (rtp and rtcp) */
@@ -1358,6 +1360,13 @@ int ff_rtsp_connect(AVFormatContext *s)
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
+ if (rt->rtp_port_max < rt->rtp_port_min) {
+ av_log(s, AV_LOG_ERROR, "Invalid UDP port range, max port %d less "
+ "than min port %d\n", rt->rtp_port_max,
+ rt->rtp_port_min);
+ return AVERROR(EINVAL);
+ }
+
if (!ff_network_init())
return AVERROR(EIO);
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index dd96a41ba7..f67ceb89ca 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -359,6 +359,11 @@ typedef struct RTSPState {
* Mask of all requested media types
*/
int media_type_mask;
+
+ /**
+ * Minimum and maximum local UDP ports.
+ */
+ int rtp_port_min, rtp_port_max;
} RTSPState;
#define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -