ireader / media-server

RTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
MIT License
3.11k stars 1.08k forks source link

Assert being thrown #281

Open rcvangemert opened 1 year ago

rcvangemert commented 1 year ago

Regarding assert(packer->pkt.rtp.timestamp != timestamp || !packer->pkt.payload /first packet/);

I think the timestamp is set after assert so it may fail. see packer->pkt.rtp.timestamp = timestamp; // (uint32_t)time * packer->frequency / 1000; // ms -> 8KHZ

The payload also failed but have not located the reason.

int rtp_pack_input(void* p, const void* data, int bytes, uint32_t timestamp)
{
    int r, n;
    uint8_t *rtp;
    const uint8_t *ptr;
    struct rtp_packer_t *packer;

    r = 0;
    packer = (struct rtp_packer_t *)p;

    assert(packer->pkt.rtp.timestamp != timestamp || !packer->pkt.payload /*first packet*/);

    packer->pkt.rtp.timestamp = timestamp; // (uint32_t)time * packer->frequency / 1000; // ms -> 8KHZ
    packer->pkt.rtp.m = 0; // marker bit alway 0

    for(ptr = (const uint8_t *)data; 0 == r && bytes > 0; ++packer->pkt.rtp.seq)
    {
        packer->pkt.payload = ptr;
        packer->pkt.payloadlen = (bytes + RTP_FIXED_HEADER) <= packer->size ? bytes : (packer->size - RTP_FIXED_HEADER);
        ptr += packer->pkt.payloadlen;
        bytes -= packer->pkt.payloadlen;

        n = RTP_FIXED_HEADER + packer->pkt.payloadlen;
        rtp = (uint8_t*)packer->handler.alloc(packer->cbparam, n);
        if (!rtp) return -ENOMEM;

        n = rtp_packet_serialize(&packer->pkt, rtp, n);
        if (n != RTP_FIXED_HEADER + packer->pkt.payloadlen)
        {
            assert(0);
            return -1;
        }

        r = packer->handler.packet(packer->cbparam, rtp, n, packer->pkt.rtp.timestamp, 0);
        packer->handler.free(packer->cbparam, rtp);

        //packer->pkt.rtp.timestamp += packer->pkt.payloadlen * packer->frequency / 1000;
    }

    return r;
}