History

avio: Introduce avio_read_to_bprint(avioctx, bp, max_size)

Andrey Utkin committed 12 years ago

Commit 8a4c0861 parent 01b236b4 files · +32 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avio.h +9 −0
  3. libavformat/aviobuf.c +18 −0
  4. libavformat/version.h +2 −2
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2014-07-23 - XXXXXXX - lavf 55.49.100 - avio.h
19+ Add avio_read_to_bprint()
20+
1821 2014-07-14 - 62227a7 - lavf 55.47.100 - avformat.h
1922 Add av_stream_get_parser()
2023
libavformat/avio.h+9−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include "libavutil/common.h"
3232 #include "libavutil/dict.h"
3333 #include "libavutil/log.h"
34+#include "libavutil/bprint.h"
3435
3536 #include "libavformat/version.h"
3637
@@ -500,4 +501,12 @@ int avio_pause(AVIOContext *h, int pause); · 463 unmodified lines
500501 int64_t avio_seek_time(AVIOContext *h, int stream_index,
501502 int64_t timestamp, int flags);
502503
504+/**
505+ * Read contents of h into print buffer, up to max_size bytes, or up to EOF.
506+ *
507+ * @return 0 for success (max_size bytes read or EOF reached), negative error
508+ * code otherwise
509+ */
510+int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size);
511+
503512 #endif /* AVFORMAT_AVIO_H */
libavformat/aviobuf.c+18−0
@@ -953,6 +953,24 @@ int64_t avio_seek_time(AVIOContext *s, int stream_index, · 952 unmodified lines
953953 return ret;
954954 }
955955
956+int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
957+{
958+ int ret;
959+ char buf[1024];
960+ while (max_size) {
961+ ret = avio_read(h, buf, FFMIN(max_size, sizeof(buf)));
962+ if (ret == AVERROR_EOF)
963+ return 0;
964+ if (ret <= 0)
965+ return ret;
966+ av_bprint_append_data(pb, buf, ret);
967+ if (!av_bprint_is_complete(pb))
968+ return AVERROR(ENOMEM);
969+ max_size -= ret;
970+ }
971+ return 0;
972+}
973+
956974 /* output in a dynamic buffer */
957975
958976 typedef struct DynBuffer {
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
3030 #include "libavutil/version.h"
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 55
33−#define LIBAVFORMAT_VERSION_MINOR 48
34−#define LIBAVFORMAT_VERSION_MICRO 101
33+#define LIBAVFORMAT_VERSION_MINOR 49
34+#define LIBAVFORMAT_VERSION_MICRO 100
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t