当前位置: 首页>>代码示例>>C++>>正文


C++ IOBuffer::ReadFromInputBuffer方法代码示例

本文整理汇总了C++中IOBuffer::ReadFromInputBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBuffer::ReadFromInputBuffer方法的具体用法?C++ IOBuffer::ReadFromInputBuffer怎么用?C++ IOBuffer::ReadFromInputBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOBuffer的用法示例。


在下文中一共展示了IOBuffer::ReadFromInputBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Serialize

bool RTMPProtocolSerializer::Serialize(Channel &channel,
		Variant &message, IOBuffer &buffer, uint32_t chunkSize) {
	bool result = false;
	_internalBuffer.Ignore(GETAVAILABLEBYTESCOUNT(_internalBuffer));

	switch ((uint32_t) VH_MT(message)) {
		case RM_HEADER_MESSAGETYPE_INVOKE:
		{
			result = SerializeInvoke(_internalBuffer, message[RM_INVOKE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_NOTIFY:
		{
			result = SerializeNotify(_internalBuffer, message[RM_NOTIFY]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_FLEXSTREAMSEND:
		{
			result = SerializeFlexStreamSend(_internalBuffer, message[RM_FLEXSTREAMSEND]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_FLEXSHAREDOBJECT:
		{
			result = SerializeFlexSharedObject(_internalBuffer, message[RM_SHAREDOBJECT]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_SHAREDOBJECT:
		{
			result = SerializeSharedObject(_internalBuffer, message[RM_SHAREDOBJECT]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_ACK:
		{
			result = SerializeAck(_internalBuffer, message[RM_ACK]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_USRCTRL:
		{
			result = SerializeUsrCtrl(_internalBuffer, message[RM_USRCTRL]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_CHUNKSIZE:
		{
			result = SerializeChunkSize(_internalBuffer, message[RM_CHUNKSIZE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_WINACKSIZE:
		{
			result = SerializeWinAckSize(_internalBuffer, message[RM_WINACKSIZE]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_PEERBW:
		{
			result = SerializeClientBW(_internalBuffer, message[RM_PEERBW]);
			break;
		}
		case RM_HEADER_MESSAGETYPE_ABORTMESSAGE:
		{
			result = SerializeAbortMessage(_internalBuffer, message[RM_ABORTMESSAGE]);
			break;
		}
		default:
		{
			FATAL("Invalid message type:\n%s", STR(message.ToString()));
		}
	}

	//2. Check out the result
	if (!result) {
		FATAL("Unable to serialize message body");
		return false;
	}

	//3. Update the message length
	VH_ML(message) = GETAVAILABLEBYTESCOUNT(_internalBuffer);

	//4. Extract the header
	Header header;
	if (!Header::GetFromVariant(header, message[RM_HEADER])) {
		FATAL("Unable to read RTMP header: %s", STR(message.ToString()));
		return false;
	}

	//5. Chunk and send the data
	uint32_t available = 0;
	while ((available = GETAVAILABLEBYTESCOUNT(_internalBuffer)) != 0) {
		if (!header.Write(channel, buffer)) {
			FATAL("Unable to serialize message header");
			result = false;
		}
		if (available >= chunkSize) {
			buffer.ReadFromInputBuffer(&_internalBuffer, 0, chunkSize);
			channel.lastOutProcBytes += chunkSize;
			_internalBuffer.Ignore(chunkSize);
		} else {
			buffer.ReadFromInputBuffer(&_internalBuffer, 0, available);
			channel.lastOutProcBytes += available;
			_internalBuffer.Ignore(available);
		}
	}
//.........这里部分代码省略.........
开发者ID:2php,项目名称:crtmpserver,代码行数:101,代码来源:rtmpprotocolserializer.cpp


注:本文中的IOBuffer::ReadFromInputBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。