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 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int cURLCamera::Capture( ZMPacket &zm_packet ) {
|
int cURLCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
||||||
bool frameComplete = false;
|
bool frameComplete = false;
|
||||||
|
|
||||||
/* MODE_STREAM specific variables */
|
/* MODE_STREAM specific variables */
|
||||||
|
@ -297,7 +297,7 @@ int cURLCamera::Capture( ZMPacket &zm_packet ) {
|
||||||
need_more_data = true;
|
need_more_data = true;
|
||||||
} else {
|
} else {
|
||||||
/* All good. decode the image */
|
/* 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;
|
frameComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ int cURLCamera::Capture( ZMPacket &zm_packet ) {
|
||||||
if (!single_offsets.empty()) {
|
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 */
|
/* 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();
|
single_offsets.pop_front();
|
||||||
frameComplete = true;
|
frameComplete = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
int PrimeCapture() override;
|
int PrimeCapture() override;
|
||||||
int PreCapture() override;
|
int PreCapture() override;
|
||||||
int Capture(ZMPacket &p)override;
|
int Capture(std::shared_ptr<ZMPacket> &p)override;
|
||||||
int PostCapture()override ;
|
int PostCapture()override ;
|
||||||
|
|
||||||
size_t data_callback(void *buffer, size_t size, size_t nmemb, void *userdata);
|
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.
|
// 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
|
// newImage is a mutex/condition based flag to tell us when there is an image available
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lck(mLibvlcData.newImageMutex);
|
std::unique_lock<std::mutex> lck(mLibvlcData.newImageMutex);
|
||||||
|
@ -288,9 +288,9 @@ int LibvlcCamera::Capture( ZMPacket &zm_packet ) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mLibvlcData.mutex.lock();
|
mLibvlcData.mutex.lock();
|
||||||
zm_packet.image->Assign(width, height, colours, subpixelorder, mLibvlcData.buffer, width * height * mBpp);
|
zm_packet->image->Assign(width, height, colours, subpixelorder, mLibvlcData.buffer, width * height * mBpp);
|
||||||
zm_packet.packet.stream_index = mVideoStreamId;
|
zm_packet->packet.stream_index = mVideoStreamId;
|
||||||
zm_packet.stream = mVideoStream;
|
zm_packet->stream = mVideoStream;
|
||||||
mLibvlcData.mutex.unlock();
|
mLibvlcData.mutex.unlock();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
|
|
||||||
int PrimeCapture() override;
|
int PrimeCapture() override;
|
||||||
int PreCapture() override;
|
int PreCapture() override;
|
||||||
int Capture(ZMPacket &p) override;
|
int Capture(std::shared_ptr<ZMPacket> &p) override;
|
||||||
int PostCapture() override;
|
int PostCapture() override;
|
||||||
int Close() override { return 0; };
|
int Close() override { return 0; };
|
||||||
};
|
};
|
||||||
|
|
|
@ -208,21 +208,21 @@ int VncCamera::PreCapture() {
|
||||||
return res == TRUE ? 1 : -1;
|
return res == TRUE ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VncCamera::Capture(ZMPacket &zm_packet) {
|
int VncCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
|
||||||
if (!mVncData.buffer) {
|
if (!mVncData.buffer) {
|
||||||
Debug(1, "No buffer");
|
Debug(1, "No buffer");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!zm_packet.image) {
|
if (!zm_packet->image) {
|
||||||
Debug(1, "Allocating image %dx%d %dcolours = %d", width, height, colours, colours*pixels);
|
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->keyframe = 1;
|
||||||
zm_packet.codec_type = AVMEDIA_TYPE_VIDEO;
|
zm_packet->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
zm_packet.packet.stream_index = mVideoStreamId;
|
zm_packet->packet.stream_index = mVideoStreamId;
|
||||||
zm_packet.stream = mVideoStream;
|
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,
|
Debug(1, "scale src %p, %d, dest %p %d %d %dx%d %dx%d", mVncData.buffer,
|
||||||
mRfb->si.framebufferWidth * mRfb->si.framebufferHeight * 4,
|
mRfb->si.framebufferWidth * mRfb->si.framebufferHeight * 4,
|
||||||
directbuffer,
|
directbuffer,
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
int PreCapture() override;
|
int PreCapture() override;
|
||||||
int PrimeCapture() override;
|
int PrimeCapture() override;
|
||||||
int Capture(ZMPacket &packet) override;
|
int Capture(std::shared_ptr<ZMPacket> &packet) override;
|
||||||
int PostCapture() override;
|
int PostCapture() override;
|
||||||
int Close() override;
|
int Close() override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue