finish converting Capture to std::shared_ptr
This commit is contained in:
parent
e970c46f7b
commit
01834d4ddc
|
@ -165,7 +165,7 @@ int cURLCamera::PreCapture() {
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
int cURLCamera::Capture( ZMPacket &zm_packet ) {
|
||||
int cURLCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
||||
bool frameComplete = false;
|
||||
|
||||
/* MODE_STREAM specific variables */
|
||||
|
@ -297,27 +297,27 @@ int cURLCamera::Capture( ZMPacket &zm_packet ) {
|
|||
need_more_data = true;
|
||||
} else {
|
||||
/* All good. decode the image */
|
||||
zm_packet.image->DecodeJpeg(databuffer.extract(frame_content_length), frame_content_length, colours, subpixelorder);
|
||||
zm_packet->image->DecodeJpeg(databuffer.extract(frame_content_length), frame_content_length, colours, subpixelorder);
|
||||
frameComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attempt to get more data */
|
||||
if(need_more_data) {
|
||||
if (need_more_data) {
|
||||
nRet = pthread_cond_wait(&data_available_cond,&shareddata_mutex);
|
||||
if(nRet != 0) {
|
||||
if (nRet != 0) {
|
||||
Error("Failed waiting for available data condition variable: %s",strerror(nRet));
|
||||
return -1;
|
||||
}
|
||||
need_more_data = false;
|
||||
}
|
||||
|
||||
} else if(mode == MODE_SINGLE) {
|
||||
} else if (mode == MODE_SINGLE) {
|
||||
/* Check if we have anything */
|
||||
if (!single_offsets.empty()) {
|
||||
if( (single_offsets.front() > 0) && (databuffer.size() >= single_offsets.front()) ) {
|
||||
if ((single_offsets.front() > 0) && (databuffer.size() >= single_offsets.front())) {
|
||||
/* Extract frame */
|
||||
zm_packet.image->DecodeJpeg(databuffer.extract(single_offsets.front()), single_offsets.front(), colours, subpixelorder);
|
||||
zm_packet->image->DecodeJpeg(databuffer.extract(single_offsets.front()), single_offsets.front(), colours, subpixelorder);
|
||||
single_offsets.pop_front();
|
||||
frameComplete = true;
|
||||
} else {
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
int PrimeCapture() override;
|
||||
int PreCapture() override;
|
||||
int Capture(ZMPacket &p)override;
|
||||
int Capture(std::shared_ptr<ZMPacket> &p)override;
|
||||
int PostCapture()override ;
|
||||
|
||||
size_t data_callback(void *buffer, size_t size, size_t nmemb, void *userdata);
|
||||
|
|
|
@ -276,7 +276,7 @@ int LibvlcCamera::PreCapture() {
|
|||
}
|
||||
|
||||
// Should not return -1 as cancels capture. Always wait for image if available.
|
||||
int LibvlcCamera::Capture( ZMPacket &zm_packet ) {
|
||||
int LibvlcCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
||||
// newImage is a mutex/condition based flag to tell us when there is an image available
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(mLibvlcData.newImageMutex);
|
||||
|
@ -288,9 +288,9 @@ int LibvlcCamera::Capture( ZMPacket &zm_packet ) {
|
|||
return 0;
|
||||
|
||||
mLibvlcData.mutex.lock();
|
||||
zm_packet.image->Assign(width, height, colours, subpixelorder, mLibvlcData.buffer, width * height * mBpp);
|
||||
zm_packet.packet.stream_index = mVideoStreamId;
|
||||
zm_packet.stream = mVideoStream;
|
||||
zm_packet->image->Assign(width, height, colours, subpixelorder, mLibvlcData.buffer, width * height * mBpp);
|
||||
zm_packet->packet.stream_index = mVideoStreamId;
|
||||
zm_packet->stream = mVideoStream;
|
||||
mLibvlcData.mutex.unlock();
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
int PrimeCapture() override;
|
||||
int PreCapture() override;
|
||||
int Capture(ZMPacket &p) override;
|
||||
int Capture(std::shared_ptr<ZMPacket> &p) override;
|
||||
int PostCapture() override;
|
||||
int Close() override { return 0; };
|
||||
};
|
||||
|
|
|
@ -208,21 +208,21 @@ int VncCamera::PreCapture() {
|
|||
return res == TRUE ? 1 : -1;
|
||||
}
|
||||
|
||||
int VncCamera::Capture(ZMPacket &zm_packet) {
|
||||
int VncCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
||||
if (!mVncData.buffer) {
|
||||
Debug(1, "No buffer");
|
||||
return 0;
|
||||
}
|
||||
if (!zm_packet.image) {
|
||||
if (!zm_packet->image) {
|
||||
Debug(1, "Allocating image %dx%d %dcolours = %d", width, height, colours, colours*pixels);
|
||||
zm_packet.image = new Image(width, height, colours, subpixelorder);
|
||||
zm_packet->image = new Image(width, height, colours, subpixelorder);
|
||||
}
|
||||
zm_packet.keyframe = 1;
|
||||
zm_packet.codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
zm_packet.packet.stream_index = mVideoStreamId;
|
||||
zm_packet.stream = mVideoStream;
|
||||
zm_packet->keyframe = 1;
|
||||
zm_packet->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
zm_packet->packet.stream_index = mVideoStreamId;
|
||||
zm_packet->stream = mVideoStream;
|
||||
|
||||
uint8_t *directbuffer = zm_packet.image->WriteBuffer(width, height, colours, subpixelorder);
|
||||
uint8_t *directbuffer = zm_packet->image->WriteBuffer(width, height, colours, subpixelorder);
|
||||
Debug(1, "scale src %p, %d, dest %p %d %d %dx%d %dx%d", mVncData.buffer,
|
||||
mRfb->si.framebufferWidth * mRfb->si.framebufferHeight * 4,
|
||||
directbuffer,
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
int PreCapture() override;
|
||||
int PrimeCapture() override;
|
||||
int Capture(ZMPacket &packet) override;
|
||||
int Capture(std::shared_ptr<ZMPacket> &packet) override;
|
||||
int PostCapture() override;
|
||||
int Close() override;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue