从crtmpserver中看具体处理rtmp协议的流程4

在接收到客户端发送的34bytes

再去掉12bytes的头剩下22bytes

Deserialize来解码

switch (H_MT(header)) {
	...
	case RM_HEADER_MESSAGETYPE_FLEX:
		{
			message[RM_INVOKE][RM_INVOKE_IS_FLEX] =
					(bool)(H_MT(header) == RM_HEADER_MESSAGETYPE_FLEX);
			return DeserializeInvoke(buffer, message[RM_INVOKE]);
		}
}


 

bool RTMPProtocolSerializer::DeserializeInvoke(IOBuffer &buffer, Variant &message) {
	if (message[RM_INVOKE_IS_FLEX]) {
		if (!buffer.Ignore(1)) {
			FATAL("Unable to ignore 1 byte");
			return false;
		}
	}

	if (!_amf0.ReadShortString(buffer, message[RM_INVOKE_FUNCTION])) {
		FATAL("Unable to read %s", STR(RM_INVOKE_FUNCTION));
		return false;
	}

	if (!_amf0.ReadDouble(buffer, message[RM_INVOKE_ID])) {
		FATAL("Unable to read %s", STR(RM_INVOKE_ID));
		return false;
	}

	for (uint32_t i = 0; GETAVAILABLEBYTESCOUNT(buffer) > 0; i++) {
		if (!_amf0.Read(buffer, message[RM_INVOKE_PARAMS][i])) {
			FATAL("Unable to de-serialize invoke parameter %u", i);
			return false;
		}
	}

	return true;
}


 

完全的数据在这里被消耗了

 

bool BaseRTMPAppProtocolHandler::InboundMessageAvailable(BaseRTMPProtocol *pFrom,
		Variant &request) {
	switch ((uint8_t) VH_MT(request)) {
	case RM_HEADER_MESSAGETYPE_FLEX:
			{
				return ProcessInvoke(pFrom, request);
	}
	}
}

中进行处理

 

bool BaseRTMPAppProtocolHandler::ProcessInvoke(BaseRTMPProtocol *pFrom,
		Variant &request) {
	...
else if (functionName == RM_INVOKE_FUNCTION_PLAY) {
			return ProcessInvokePlay(pFrom, request);
}


 

这里多N多事情

bool BaseRTMPAppProtocolHandler::ProcessInvokePlay(BaseRTMPProtocol *pFrom,
		Variant & request) {
	...在这里生成meta文件,生成seek文件
}

 

然后最核心的是这里

void BaseOutNetRTMPStream::SignalAttachedToInStream() {
	//1. Store the attached stream type to know how we should proceed on detach
	...
	//2. Mirror the feeder chunk size
	...
	//3. Fix the time base
	...
	//4. Store the metadata
	...
	//5. Send abort messages on audio/video channels
	...
	//6. Stream is recorded
	...
	//7. Stream begin
	...
	if (_sendOnStatusPlayMessages) {
		//8. Send NetStream.Play.Reset
		...
		//9. NetStream.Play.Start
		...
		//10. notify |RtmpSampleAccess
		...
	}
	//11. notify onStatus code="NetStream.Data.Start"
	...
	//12. notify onMetaData
	...
}


 

bool BaseInStream::Play(double absoluteTimestamp, double length) {
	if (!SignalPlay(absoluteTimestamp, length)) {
		FATAL("Unable to signal play");
		return false;
	}
	LinkedListNode<BaseOutStream *> *pTemp = _pOutStreams;
	while (pTemp != NULL) {
		if (!pTemp->info->SignalPlay(absoluteTimestamp, length)) {
			WARN("Unable to signal play on an outbound stream");
		}
		pTemp = pTemp->pPrev;
	}
	return true;
}


 

这次写了8192的数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值