You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavf/avio: temporarily accept 0 as EOF.
Print a warning to let applicatios fix their use. After a deprecation period, check with a low-level assert. Also make the constraint explicit in the doxygen comment. Signed-off-by: Nicolas George <george@nsup.org>
This commit is contained in:
committed by
Jan Ekström
parent
bfb1a94625
commit
a606f27f4c
@@ -452,6 +452,8 @@ void avio_free_directory_entry(AVIODirEntry **entry);
|
|||||||
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
||||||
* @param opaque An opaque pointer to user-specific data.
|
* @param opaque An opaque pointer to user-specific data.
|
||||||
* @param read_packet A function for refilling the buffer, may be NULL.
|
* @param read_packet A function for refilling the buffer, may be NULL.
|
||||||
|
* For stream protocols, must never return 0 but rather
|
||||||
|
* a proper AVERROR code.
|
||||||
* @param write_packet A function for writing the buffer contents, may be NULL.
|
* @param write_packet A function for writing the buffer contents, may be NULL.
|
||||||
* The function may not change the input buffers content.
|
* The function may not change the input buffers content.
|
||||||
* @param seek A function for seeking to specified byte position, may be NULL.
|
* @param seek A function for seeking to specified byte position, may be NULL.
|
||||||
|
@@ -524,6 +524,24 @@ void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType typ
|
|||||||
s->last_time = time;
|
s->last_time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!s->read_packet)
|
||||||
|
return AVERROR_EOF;
|
||||||
|
ret = s->read_packet(s->opaque, buf, size);
|
||||||
|
#if FF_API_OLD_AVIO_EOF_0
|
||||||
|
if (!ret && !s->max_packet_size) {
|
||||||
|
av_log(NULL, AV_LOG_WARNING, "Invalid return value 0 for stream protocol\n");
|
||||||
|
ret = AVERROR_EOF;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
av_assert2(ret || s->max_packet_size);
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Input stream */
|
/* Input stream */
|
||||||
|
|
||||||
static void fill_buffer(AVIOContext *s)
|
static void fill_buffer(AVIOContext *s)
|
||||||
@@ -562,10 +580,7 @@ static void fill_buffer(AVIOContext *s)
|
|||||||
len = s->orig_buffer_size;
|
len = s->orig_buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->read_packet)
|
len = read_packet_wrapper(s, dst, len);
|
||||||
len = s->read_packet(s->opaque, dst, len);
|
|
||||||
else
|
|
||||||
len = AVERROR_EOF;
|
|
||||||
if (len == AVERROR_EOF) {
|
if (len == AVERROR_EOF) {
|
||||||
/* do not modify buffer if EOF reached so that a seek back can
|
/* do not modify buffer if EOF reached so that a seek back can
|
||||||
be done without rereading data */
|
be done without rereading data */
|
||||||
@@ -638,10 +653,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
|
|||||||
if (len == 0 || s->write_flag) {
|
if (len == 0 || s->write_flag) {
|
||||||
if((s->direct || size > s->buffer_size) && !s->update_checksum) {
|
if((s->direct || size > s->buffer_size) && !s->update_checksum) {
|
||||||
// bypass the buffer and read data directly into buf
|
// bypass the buffer and read data directly into buf
|
||||||
if(s->read_packet)
|
len = read_packet_wrapper(s, buf, size);
|
||||||
len = s->read_packet(s->opaque, buf, size);
|
|
||||||
else
|
|
||||||
len = AVERROR_EOF;
|
|
||||||
if (len == AVERROR_EOF) {
|
if (len == AVERROR_EOF) {
|
||||||
/* do not modify buffer if EOF reached so that a seek back can
|
/* do not modify buffer if EOF reached so that a seek back can
|
||||||
be done without rereading data */
|
be done without rereading data */
|
||||||
@@ -708,7 +720,7 @@ int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (s->read_packet && s->write_flag) {
|
if (s->read_packet && s->write_flag) {
|
||||||
len = s->read_packet(s->opaque, buf, size);
|
len = read_packet_wrapper(s, buf, size);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
s->pos += len;
|
s->pos += len;
|
||||||
return len;
|
return len;
|
||||||
|
@@ -79,6 +79,9 @@
|
|||||||
#ifndef FF_API_FORMAT_GET_SET
|
#ifndef FF_API_FORMAT_GET_SET
|
||||||
#define FF_API_FORMAT_GET_SET (LIBAVFORMAT_VERSION_MAJOR < 59)
|
#define FF_API_FORMAT_GET_SET (LIBAVFORMAT_VERSION_MAJOR < 59)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef FF_API_OLD_AVIO_EOF_0
|
||||||
|
#define FF_API_OLD_AVIO_EOF_0 (LIBAVFORMAT_VERSION_MAJOR < 59)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef FF_API_R_FRAME_RATE
|
#ifndef FF_API_R_FRAME_RATE
|
||||||
|
Reference in New Issue
Block a user