34 bytestream_put_byte(dst, val);
46 bytestream_put_be16(dst, strlen(str));
52 int len1 = 0, len2 = 0;
58 bytestream_put_be16(dst, len1 + len2);
75 bytestream_put_be16(dst, strlen(str));
91 *val = bytestream2_get_byte(bc);
100 read = bytestream2_get_be64(bc);
106 int strsize,
int *length)
112 stringlen = bytestream2_get_be16(bc);
113 if (stringlen + 1 > strsize)
116 if (readsize != stringlen) {
118 "Unable to read as many bytes as AMF string signaled\n");
120 str[readsize] =
'\0';
121 *length =
FFMIN(stringlen, readsize);
148 int channel_id, timestamp, data_size,
offset = 0;
155 channel_id = hdr & 0x3F;
157 if (channel_id < 2) {
161 size += channel_id + 1;
162 channel_id =
AV_RL16(buf) + 64;
164 data_size = prev_pkt[channel_id].
data_size;
165 type = prev_pkt[channel_id].
type;
166 extra = prev_pkt[channel_id].
extra;
170 timestamp = prev_pkt[channel_id].
ts_delta;
192 if (timestamp == 0xFFFFFF) {
199 timestamp += prev_pkt[channel_id].
timestamp;
207 prev_pkt[channel_id].
type = type;
208 prev_pkt[channel_id].
data_size = data_size;
210 prev_pkt[channel_id].
timestamp = timestamp;
211 prev_pkt[channel_id].
extra = extra;
212 while (data_size > 0) {
213 int toread =
FFMIN(data_size, chunk_size);
218 data_size -= chunk_size;
219 offset += chunk_size;
227 if (t != (0xC0 + channel_id))
237 uint8_t pkt_hdr[16], *p = pkt_hdr;
259 bytestream_put_byte(&p, pkt->
channel_id | (mode << 6));
261 bytestream_put_byte(&p, 0 | (mode << 6));
262 bytestream_put_byte(&p, pkt->
channel_id - 64);
264 bytestream_put_byte(&p, 1 | (mode << 6));
265 bytestream_put_le16(&p, pkt->
channel_id - 64);
271 bytestream_put_be24(&p, timestamp >= 0xFFFFFF ? 0xFFFFFF : timestamp);
274 bytestream_put_byte(&p, pkt->
type);
276 bytestream_put_le32(&p, pkt->
extra);
278 if (timestamp >= 0xFFFFFF)
279 bytestream_put_be32(&p, timestamp);
293 if ((ret =
ffurl_write(h, pkt_hdr, p - pkt_hdr)) < 0)
296 while (off < pkt->data_size) {
301 if (off < pkt->data_size) {
312 int timestamp,
int size)
341 if (data >= data_end)
353 int size = bytestream_get_be16(&data);
359 if (size < 0 || size >= data_end - data)
363 if (t < 0 || t >= data_end - data)
376 int namelen = strlen(name);
382 len = data_end -
data;
385 if (data_end - data < 3)
389 int size = bytestream_get_be16(&data);
392 if (size < 0 || size >= data_end - data)
395 if (size == namelen && !memcmp(data-size, name, namelen)) {
401 snprintf(dst, dst_size,
"%s", *data ?
"true" :
"false");
404 len = bytestream_get_be16(&data);
413 if (len < 0 || len >= data_end - data)
437 default:
return "unknown";
446 if (data >= data_end)
458 size = bytestream_get_be16(&data);
460 size = bytestream_get_be32(&data);
462 size =
FFMIN(size,
sizeof(buf) - 1);
463 memcpy(buf, data, size);
476 size = bytestream_get_be16(&data);
483 if (size >= data_end - data)
489 if (t < 0 || t >= data_end - data)
504 av_log(ctx,
AV_LOG_DEBUG,
"RTMP packet type '%s'(%d) for channel %d, timestamp %d, extra field %d size %d\n",
508 while (src < src_end) {