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

Function get_packet

libavformat/rtmpproto.c:2504–2587  ·  view source on GitHub ↗

* Interact with the server by receiving and sending RTMP packets until * there is some significant data (media data or expected status notification). * * @param s reading context * @param for_header non-zero value tells function to work until it * gets notification from the server that playing has been started, * otherwise function will work until some media data is received (or *

Source from the content-addressed store, hash-verified

2502 * @return 0 for successful operation, negative value in case of error
2503 */
2504static int get_packet(URLContext *s, int for_header)
2505{
2506 RTMPContext *rt = s->priv_data;
2507 int ret;
2508
2509 if (rt->state == STATE_STOPPED)
2510 return AVERROR_EOF;
2511
2512 for (;;) {
2513 RTMPPacket rpkt = { 0 };
2514 if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt,
2515 rt->in_chunk_size, &rt->prev_pkt[0],
2516 &rt->nb_prev_pkt[0])) <= 0) {
2517 if (ret == 0) {
2518 return AVERROR(EAGAIN);
2519 } else {
2520 return AVERROR(EIO);
2521 }
2522 }
2523
2524 // Track timestamp for later use
2525 rt->last_timestamp = rpkt.timestamp;
2526
2527 rt->bytes_read += ret;
2528 if (rt->bytes_read - rt->last_bytes_read > rt->receive_report_size) {
2529 av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n");
2530 if ((ret = gen_bytes_read(s, rt, rpkt.timestamp + 1)) < 0) {
2531 ff_rtmp_packet_destroy(&rpkt);
2532 return ret;
2533 }
2534 rt->last_bytes_read = rt->bytes_read;
2535 }
2536
2537 ret = rtmp_parse_result(s, rt, &rpkt);
2538
2539 // At this point we must check if we are in the seek state and continue
2540 // with the next packet. handle_invoke will get us out of this state
2541 // when the right message is encountered
2542 if (rt->state == STATE_SEEKING) {
2543 ff_rtmp_packet_destroy(&rpkt);
2544 // We continue, let the natural flow of things happen:
2545 // AVERROR(EAGAIN) or handle_invoke gets us out of here
2546 continue;
2547 }
2548
2549 if (ret < 0) {//serious error in current packet
2550 ff_rtmp_packet_destroy(&rpkt);
2551 return ret;
2552 }
2553 if (rt->do_reconnect && for_header) {
2554 ff_rtmp_packet_destroy(&rpkt);
2555 return 0;
2556 }
2557 if (rt->state == STATE_STOPPED) {
2558 ff_rtmp_packet_destroy(&rpkt);
2559 return AVERROR_EOF;
2560 }
2561 if (for_header && (rt->state == STATE_PLAYING ||

Callers 2

rtmp_openFunction · 0.70
rtmp_readFunction · 0.70

Calls 8

ff_rtmp_packet_readFunction · 0.85
av_logFunction · 0.85
gen_bytes_readFunction · 0.85
ff_rtmp_packet_destroyFunction · 0.85
rtmp_parse_resultFunction · 0.85
append_flv_dataFunction · 0.85
handle_notifyFunction · 0.85
handle_metadataFunction · 0.85

Tested by

no test coverage detected