Add Stream Reader Thread
This commit is contained in:
60
StreamReader.cpp
Normal file
60
StreamReader.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "StreamReader.hpp"
|
||||
|
||||
StreamReader::StreamReader(PvDevice *Device, PvStream *Stream, PvPipeline *Pipeline)
|
||||
{
|
||||
this->Device = Device;
|
||||
this->Stream = Stream;
|
||||
this->Pipeline = Pipeline;
|
||||
}
|
||||
|
||||
void StreamReader::run()
|
||||
{
|
||||
while (!isInterruptionRequested())
|
||||
{
|
||||
PvBuffer *lBuffer = NULL;
|
||||
PvResult lOperationResult;
|
||||
|
||||
// wait for this to unblock before called in event loop
|
||||
// Retrieve next buffer
|
||||
PvResult lResult = Stream->RetrieveBuffer(&lBuffer, &lOperationResult, 1000);
|
||||
if (lResult.IsOK())
|
||||
{
|
||||
if (lOperationResult.IsOK())
|
||||
{
|
||||
PvPayloadType lType;
|
||||
|
||||
// If the buffer contains an image, display width and height.
|
||||
uint32_t lWidth = 0, lHeight = 0;
|
||||
lType = lBuffer->GetPayloadType();
|
||||
|
||||
if (lType == PvPayloadTypeImage)
|
||||
{
|
||||
// Get image specific buffer interface.
|
||||
PvImage *lImage = lBuffer->GetImage();
|
||||
|
||||
// Read width, height.
|
||||
lWidth = lImage->GetWidth();
|
||||
lHeight = lImage->GetHeight();
|
||||
|
||||
NewImage(lWidth, lHeight, lImage->GetDataPointer());
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << " (buffer does not contain image)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qInfo() << lOperationResult.GetCodeString().GetAscii() << "\r";
|
||||
}
|
||||
|
||||
// Re-queue the buffer in the stream object
|
||||
Stream->QueueBuffer(lBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Retrieve buffer failure
|
||||
qCritical() << lResult.GetCodeString().GetAscii() << "\r";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user