本文整理汇总了C++中VideoStream::decode方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoStream::decode方法的具体用法?C++ VideoStream::decode怎么用?C++ VideoStream::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoStream
的用法示例。
在下文中一共展示了VideoStream::decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtpSessionThread
// Thread function for RTP session.
static void* rtpSessionThread(void *arg)
{
VideoStream* video = reinterpret_cast<VideoStream*>(arg);
u_int8_t bigBuffer[MAX_FRAME_SIZE];
unsigned int lastPacketTimestamp = 0;
unsigned int currentIndex = 0;
double last_time = 0;
RTPSession session = createRtpSession(video->getMulticastIP(),
video->getPort());
while (1) {
session.Poll();
// Distribute data from the session to connected clients if we've
// got anything
session.BeginDataAccess();
if (session.GotoFirstSourceWithData()) {
do {
RTPPacket *packet = NULL;
while ((packet = session.GetNextPacket()) != NULL) {
if ((packet->GetPayloadLength() > sizeof(bigBuffer)) ||
(packet->GetPayloadLength() == 0)) {
// Free the packet, we're not going to use it.
session.DeletePacket(packet);
continue; // Exit this level of the loop and drop it
}
// Check timestamps for new data. A new timestamp means
// this is from a different time.
if (packet->GetTimestamp() != lastPacketTimestamp) {
video->decode((uint8_t*)&bigBuffer[0], currentIndex);
currentIndex = 0;
memset(&bigBuffer[0], 0, sizeof(bigBuffer));
} // End new timestamp optimization.
// Copy data into buffer
if (currentIndex + packet->GetPayloadLength() > sizeof(bigBuffer)) {
throw std::runtime_error("Frame buffer overflow");
}
memcpy(&bigBuffer[currentIndex], packet->GetPayloadData(),
packet->GetPayloadLength());
currentIndex += packet->GetPayloadLength();
// Mark our last timestamp
lastPacketTimestamp = packet->GetTimestamp();
// Free the packet.
session.DeletePacket(packet);
}
} while (session.GotoNextSourceWithData());
}
session.EndDataAccess();
RTPTime delay(0, 100); // 100usec
// Update More Data
bool moreData;
session.WaitForIncomingData(delay, &moreData);
}
// Leave the session while sending BYE.
RTPTime timeout(0.75f); // Wait briefly.
const char* reason = "Session Destroyed.";
unsigned int reasonlen = strlen(reason);
if (session.IsActive())
session.BYEDestroy(timeout, reason, reasonlen);
}