Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uint32_t capacity = rtmpMsg.length + rtmpMsg.length/m_outChunkSize*5 + 1024; 这里是怎么算的? #4

Open
o-u-p opened this issue Dec 31, 2019 · 2 comments

Comments

@o-u-p
Copy link

o-u-p commented Dec 31, 2019

如题, 大神请教一下这里是怎么算的, 有相关参考资料么, 谢谢!

@PHZ76
Copy link
Owner

PHZ76 commented Dec 31, 2019

这个没有啥复杂的逻辑,5 是每个块的所需的包头最大大小。就是计算一下当前帧需要分成多少块,每个块需要多少额外空间。1024 是我自己预留的,可以不用。至于块的包头大小你可以看看rtmp的文档,每种类型块的包头都有介绍。

@o-u-p
Copy link
Author

o-u-p commented Jan 1, 2020

元旦快乐啊, 老哥!我看了下文档,似乎Basic Header(1-3字节)和Message Header(0,3,7,11字节)加起来也不止5个字节啊, 还有这里

if (fmt <= 2) 
    {
        if(rtmpMsg._timestamp < 0xffffff)
        {
           writeUint24BE((char*)buf, (uint32_t)rtmpMsg._timestamp);
        }
        else
        {
            writeUint24BE((char*)buf, 0xffffff);    
        }
        len += 3;
    }

    if (fmt <= 1) 
    {
        writeUint24BE((char*)buf + len, rtmpMsg.length);
        len += 3;
        buf[len++] = rtmpMsg.typeId;
    }

    if (fmt == 0) 
    {
        writeUint32LE((char*)buf + len, rtmpMsg.streamId);    
        len += 4;
    }

fmt==1 || 2 的时候存的是timestamp delta, 似乎是和上一个chunk timestamp的差值。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants