73 while (*p !=
'\0' && *p !=
':') {
99 const char* expected_boundary,
116 if (p->buf_size < 2 || p->buf[0] !=
'-' || p->buf[1] !=
'-')
129 char boundary[70 + 2 + 1] = {0};
134 ret =
get_line(
s->pb, boundary,
sizeof(boundary));
137 }
while (!boundary[0]);
139 if (strncmp(boundary,
"--", 2))
160 if (
val == LONG_MIN ||
val == LONG_MAX)
169 const char* expected_boundary,
173 int found_content_type = 0;
196 "Expected boundary '%s' not found, instead found a line of %zu bytes\n",
226 "Unexpected %s : %s\n",
230 found_content_type = 1;
236 "Invalid Content-Length value : %s\n",
246 uint8_t *mime_type =
NULL;
255 while (start !=
NULL && *start !=
'\0') {
256 start = strchr(start,
';');
266 end = strchr(start,
';');
268 len = end - start - 1;
274 if (
len>2 && *start ==
'"' && start[
len-1] ==
'"' ) {
294 uint8_t* boundary =
NULL;
298 if (boundary !=
NULL) {
359#define OFFSET(x) offsetof(MPJPEGDemuxContext, x)
360#define DEC AV_OPT_FLAG_DECODING_PARAM
362 {
"strict_mime_boundary",
"require MIME boundaries match",
OFFSET(strict_mime_boundary),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DEC },
367 .class_name =
"MPJPEG demuxer",
376 .p.mime_type =
"multipart/x-mixed-replace",
377 .p.extensions =
"mjpg",
static double val(void *priv, double ch)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
char * av_asprintf(const char *fmt,...)
static int read_probe(const AVProbeData *p)
static int read_chunk(AVFormatContext *s)
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
#define LIBAVUTIL_VERSION_INT
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
Memory handling functions.
static int parse_content_length(const char *value)
static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
static int split_tag_value(char **tag, char **value, char *line)
static int mpjpeg_read_header(AVFormatContext *s)
static const AVOption mpjpeg_options[]
static int mpjpeg_read_probe(const AVProbeData *p)
static char * mpjpeg_get_boundary(AVIOContext *pb)
static void trim_right(char *p)
static int get_line(AVIOContext *pb, char *line, int line_size)
static int mpjpeg_read_close(AVFormatContext *s)
static int parse_multipart_header(AVIOContext *pb, int *size, const char *expected_boundary, void *log_ctx)
static const AVClass mpjpeg_demuxer_class
Describe the class of an AVClass context structure.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int eof_reached
true if was unable to read due to error or eof
int error
contains the error code or 0 if no error happened
This structure stores compressed data.
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.