MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / handle_notify

Function handle_notify

libavformat/rtmpproto.c:2333–2388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2331}
2332
2333static int handle_notify(URLContext *s, RTMPPacket *pkt)
2334{
2335 RTMPContext *rt = s->priv_data;
2336 uint8_t commandbuffer[64];
2337 char statusmsg[128];
2338 int stringlen, ret, skip = 0;
2339 GetByteContext gbc;
2340
2341 bytestream2_init(&gbc, pkt->data, pkt->size);
2342 if (ff_amf_read_string(&gbc, commandbuffer, sizeof(commandbuffer),
2343 &stringlen))
2344 return AVERROR_INVALIDDATA;
2345
2346 if (!strcmp(commandbuffer, "onMetaData")) {
2347 // metadata properties should be stored in a mixed array
2348 if (bytestream2_get_byte(&gbc) == AMF_DATA_TYPE_MIXEDARRAY) {
2349 // We have found a metaData Array so flv can determine the streams
2350 // from this.
2351 rt->received_metadata = 1;
2352 // skip 32-bit max array index
2353 bytestream2_skip(&gbc, 4);
2354 while (bytestream2_get_bytes_left(&gbc) > 3) {
2355 if (ff_amf_get_string(&gbc, statusmsg, sizeof(statusmsg),
2356 &stringlen))
2357 return AVERROR_INVALIDDATA;
2358 // We do not care about the content of the property (yet).
2359 stringlen = ff_amf_tag_size(gbc.buffer, gbc.buffer_end);
2360 if (stringlen < 0)
2361 return AVERROR_INVALIDDATA;
2362 bytestream2_skip(&gbc, stringlen);
2363
2364 // The presence of the following properties indicates that the
2365 // respective streams are present.
2366 if (!strcmp(statusmsg, "videocodecid")) {
2367 rt->has_video = 1;
2368 }
2369 if (!strcmp(statusmsg, "audiocodecid")) {
2370 rt->has_audio = 1;
2371 }
2372 }
2373 if (bytestream2_get_be24(&gbc) != AMF_END_OF_OBJECT)
2374 return AVERROR_INVALIDDATA;
2375 }
2376 }
2377
2378 // Skip the @setDataFrame string and validate it is a notification
2379 if (!strcmp(commandbuffer, "@setDataFrame")) {
2380 skip = gbc.buffer - pkt->data;
2381 ret = ff_amf_read_string(&gbc, statusmsg,
2382 sizeof(statusmsg), &stringlen);
2383 if (ret < 0)
2384 return AVERROR_INVALIDDATA;
2385 }
2386
2387 return append_flv_data(rt, pkt, skip);
2388}
2389
2390/**

Callers 1

get_packetFunction · 0.85

Calls 7

bytestream2_initFunction · 0.85
ff_amf_read_stringFunction · 0.85
bytestream2_skipFunction · 0.85
ff_amf_get_stringFunction · 0.85
ff_amf_tag_sizeFunction · 0.85
append_flv_dataFunction · 0.85

Tested by

no test coverage detected