从crtmpserver中看具体处理rtmp协议
在读到18bytes
同样的去掉12bytes的头
[cpp]
bool RTMPProtocolSerializer::Deserialize(Header &header, IOBuffer &buffer,
Variant &message) {
switch (H_MT(header)) {
case RM_HEADER_MESSAGETYPE_USRCTRL:
{
return DeserializeUsrCtrl(buffer, message[RM_USRCTRL]);
}
}
}
[cpp]
bool RTMPProtocolSerializer::DeserializeUsrCtrl(IOBuffer &buffer, Variant &message) {
...
switch ((uint16_t) message[RM_USRCTRL_TYPE]) {
...
case RM_USRCTRL_TYPE_STREAM_SET_BUFFER_LENGTH:
{
AMF_CHECK_BOUNDARIES(buffer, 8);
message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG---
if (!buffer.Ignore(4)) {
FATAL("Unable to ignore 4 bytes");
return false;
}
message[RM_USRCTRL_BUFFLEN] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG---
if (!buffer.Ignore(4)) {
FATAL("Unable to ignore 4 bytes");
return false;
}
return true;
}
}
}
在InboundMessageAvailable中进行回应
[cpp]
bool BaseRTMPAppProtocolHandler::InboundMessageAvailable(BaseRTMPProtocol *pFrom,
Variant &request) {
...
switch ((uint8_t) VH_MT(request)) {
case RM_HEADER_MESSAGETYPE_USRCTRL:
{
return ProcessUsrCtrl(pFrom, request);
}
}
}
[cpp]
bool BaseRTMPAppProtocolHandler::ProcessUsrCtrl(BaseRTMPProtocol *pFrom,
Variant &request) {
switch ((uint16_t) M_USRCTRL_TYPE(request)) {
case RM_USRCTRL_TYPE_PING_RESPONSE:
{
这个函数说他啥都没干= =
return true;
}
}
}
还是回复了468bytes的数据,但暂时没清楚
6.直接发送音视频了
7.好了,博主准备太监了,带着一大堆朦胧的概念,准备完成一个更小的rtmpserver(写代码能力有限,估计这个server不会超过1K行),遇到困难,只能从crtmpserver中抽取代码了~~~~(>_<)~~~~
补充:软件开发 , C++ ,