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

Function read_connect

libavformat/rtmpproto.c:472–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470#define RTMP_CTRL_ABORT_MESSAGE (2)
471
472static int read_connect(URLContext *s, RTMPContext *rt)
473{
474 RTMPPacket pkt = { 0 };
475 uint8_t *p;
476 const uint8_t *cp;
477 int ret;
478 char command[64];
479 int stringlen;
480 double seqnum;
481 uint8_t tmpstr[256];
482 GetByteContext gbc;
483
484 // handle RTMP Protocol Control Messages
485 for (;;) {
486 if ((ret = ff_rtmp_packet_read(rt->stream, &pkt, rt->in_chunk_size,
487 &rt->prev_pkt[0], &rt->nb_prev_pkt[0])) < 0)
488 return ret;
489#ifdef DEBUG
490 ff_rtmp_packet_dump(s, &pkt);
491#endif
492 if (pkt.type == RTMP_PT_CHUNK_SIZE) {
493 if ((ret = handle_chunk_size(s, &pkt)) < 0) {
494 ff_rtmp_packet_destroy(&pkt);
495 return ret;
496 }
497 } else if (pkt.type == RTMP_CTRL_ABORT_MESSAGE) {
498 av_log(s, AV_LOG_ERROR, "received abort message\n");
499 ff_rtmp_packet_destroy(&pkt);
500 return AVERROR_UNKNOWN;
501 } else if (pkt.type == RTMP_PT_BYTES_READ) {
502 av_log(s, AV_LOG_TRACE, "received acknowledgement\n");
503 } else if (pkt.type == RTMP_PT_WINDOW_ACK_SIZE) {
504 if ((ret = handle_window_ack_size(s, &pkt)) < 0) {
505 ff_rtmp_packet_destroy(&pkt);
506 return ret;
507 }
508 } else if (pkt.type == RTMP_PT_SET_PEER_BW) {
509 if ((ret = handle_set_peer_bw(s, &pkt)) < 0) {
510 ff_rtmp_packet_destroy(&pkt);
511 return ret;
512 }
513 } else if (pkt.type == RTMP_PT_INVOKE) {
514 // received RTMP Command Message
515 break;
516 } else {
517 av_log(s, AV_LOG_ERROR, "Unknown control message type (%d)\n", pkt.type);
518 }
519 ff_rtmp_packet_destroy(&pkt);
520 }
521
522 cp = pkt.data;
523 bytestream2_init(&gbc, cp, pkt.size);
524 if (ff_amf_read_string(&gbc, command, sizeof(command), &stringlen)) {
525 av_log(s, AV_LOG_ERROR, "Unable to read command string\n");
526 ff_rtmp_packet_destroy(&pkt);
527 return AVERROR_INVALIDDATA;
528 }
529 if (strcmp(command, "connect")) {

Callers 1

rtmp_openFunction · 0.85

Calls 15

ff_rtmp_packet_readFunction · 0.85
ff_rtmp_packet_dumpFunction · 0.85
handle_chunk_sizeFunction · 0.85
ff_rtmp_packet_destroyFunction · 0.85
av_logFunction · 0.85
handle_window_ack_sizeFunction · 0.85
handle_set_peer_bwFunction · 0.85
bytestream2_initFunction · 0.85
ff_amf_read_stringFunction · 0.85
ff_amf_read_numberFunction · 0.85
ff_amf_get_field_valueFunction · 0.85

Tested by

no test coverage detected