28 #include "libavutil/base64.h"
29 #include "libavutil/avstring.h"
30 #include "libavutil/intreadwrite.h"
57 if (chunksize > end - p)
99 if (
av_strstart(p,
"pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
103 int len = strlen(p) * 6 / 8;
109 "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
133 if (stream_index < 0)
138 s->
streams[stream_index]->
id = strtol(line, NULL, 10);
175 int res, mflags, len_off;
182 int off, out_len = 0;
206 if (!(mflags & 0x40)) {
219 if (!len_off && !asf->
pktbuf &&
240 int cur_len = start_off + len_off -
off;
241 int prev_len = out_len;
243 if (
FFMIN(cur_len, len - off) < 0)
247 memcpy(asf->
buf + prev_len, buf + off,
248 FFMIN(cur_len, len - off));
275 return res == 1 ? -1 :
res;
295 #define RTP_ASF_HANDLER(n, s, t) \
296 RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \
299 .codec_id = AV_CODEC_ID_NONE, \
300 .parse_sdp_a_line = asfrtp_parse_sdp_line, \
301 .alloc = asfrtp_new_context, \
302 .free = asfrtp_free_context, \
303 .parse_packet = asfrtp_parse_packet, \
const ff_asf_guid ff_asf_header
int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
Parse a Windows Media Server-specific SDP line.
void av_free_packet(AVPacket *pkt)
Free a packet.
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
RTP/JPEG specific private data.
AVCodecContext * codec
Codec context associated with this stream.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
uint8_t * buf
the temporary storage buffer
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int rtp_asf_fix_header(uint8_t *buf, int len)
From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not contain any padding...
static av_cold int end(AVCodecContext *avctx)
int id
Format-specific stream ID.
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Private data for the RTSP demuxer.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
#define RTP_FLAG_MARKER
RTP marker bit was set for this packet.
static int packetizer_read(void *opaque, uint8_t *buf, int buf_size)
The following code is basically a buffered AVIOContext, with the added benefit of returning -EAGAIN (...
void * priv_data
Format private data.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
unsigned char * buf_end
End of the data, may be less than buffer+buffer_size if the read function returned less data than req...
uint64_t asf_pb_pos
cache for position of the asf demuxer, since we load a new data packet in the bytecontext for each in...
unsigned int nb_streams
A list of all streams in the file.
AVFormatContext * asf_ctx
The following are used for RTP/ASF streams.
static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, PayloadContext *asf, const char *line)
static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
const ff_asf_guid ff_asf_file_header
#define RTP_FLAG_KEY
RTP packet contains a keyframe.
AVInputFormat ff_asf_demuxer
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static void asfrtp_free_context(PayloadContext *asf)
static PayloadContext * asfrtp_new_context(void)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
#define RTP_ASF_HANDLER(n, s, t)
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int64_t pos
position in the file of the current buffer
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int eof_reached
true if eof reached
int av_base64_decode(uint8_t *out, const char *in, int out_size)
Decode a base64-encoded string.
This structure stores compressed data.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...