本文整理汇总了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);
}
}
//.........这里部分代码省略.........