Commit 646dd5cd authored by Edric Milaret's avatar Edric Milaret Committed by Stepan Salenikovich

sinkclient: move to smart_ptr for video frame

Also send the size for every frame

Refs #75280

Change-Id: I2bebd0f60b6a973efa70ea7bc7577d2786b99763
parent cd658a12
......@@ -160,14 +160,14 @@ registerSinkTarget_(const std::string& sinkId, T&& cb)
void
registerSinkTarget(const std::string& sinkId,
const std::function<void(unsigned char*)>& cb)
const std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>& cb)
{
registerSinkTarget_(sinkId, cb);
}
void
registerSinkTarget(const std::string& sinkId,
std::function<void(unsigned char*)>&& cb)
std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>&& cb)
{
registerSinkTarget_(sinkId, cb);
}
......
......@@ -59,8 +59,8 @@ void stopCamera();
bool hasCameraStarted();
bool switchInput(const std::string& resource);
bool switchToCamera();
void registerSinkTarget(const std::string& sinkId, const std::function<void(unsigned char*)>& cb);
void registerSinkTarget(const std::string& sinkId, std::function<void(unsigned char*)>&& cb);
void registerSinkTarget(const std::string& sinkId, const std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>& cb);
void registerSinkTarget(const std::string& sinkId, std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>&& cb);
#ifdef __ANDROID__
void addVideoDevice(const std::string &node);
void removeVideoDevice(const std::string &node);
......
......@@ -342,12 +342,15 @@ SinkClient::update(Observable<std::shared_ptr<VideoFrame>>* /*obs*/,
const int format = VIDEO_PIXFMT_RGBA;
const auto bytes = videoFrameSize(format, width, height);
targetData_.resize(bytes);
auto data = targetData_.data();
dst.setFromMemory(data, format, width, height);
scaler.scale(*f, dst);
target_(data);
if (bytes > 0) {
targetData_.resize(bytes);
auto data = targetData_.data();
dst.setFromMemory(data, format, width, height);
scaler.scale(*f, dst);
auto sp = std::make_shared<std::vector<unsigned char> >(targetData_);
target_(sp, width, height);
}
}
}
......
......@@ -77,7 +77,7 @@ class SinkClient : public VideoFramePassiveReader
private:
const std::string id_;
std::function<void(unsigned char*)> target_;
std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)> target_;
std::vector<unsigned char> targetData_;
#ifdef DEBUG_FPS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment