Commit 9af60e1d authored by Adrien Béraud's avatar Adrien Béraud Committed by Philippe Gorley

videomanager: add AVSinkTarget

Allows clients to retrieve an AVFrame instead of a FrameBuffer

Change-Id: I19ca0935fa08b46e0261713e842e1b4f156bdbe7
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent c75a7cd7
......@@ -493,6 +493,15 @@ registerSinkTarget(const std::string& sinkId, const SinkTarget& target)
RING_WARN("No sink found for id '%s'", sinkId.c_str());
}
void
registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target)
{
if (auto sink = ring::Manager::instance().getSinkClient(sinkId))
sink->registerAVTarget(target);
else
RING_WARN("No sink found for id '%s'", sinkId.c_str());
}
std::map<std::string, std::string>
getRenderer(const std::string& callId)
{
......
......@@ -151,6 +151,11 @@ private:
void setGeometry(int format, int width, int height) noexcept;
};
struct DRING_PUBLIC AVSinkTarget {
std::function<void(std::unique_ptr<VideoFrame>)> push;
int /* AVPixelFormat */ preferredFormat {-1 /* AV_PIX_FMT_NONE */};
};
using VideoCapabilities = std::map<std::string, std::map<std::string, std::vector<std::string>>>;
DRING_PUBLIC std::vector<std::string> getDeviceList();
......@@ -171,6 +176,7 @@ DRING_PUBLIC void stopAudioDevice();
DRING_PUBLIC bool switchInput(const std::string& resource);
DRING_PUBLIC bool switchToCamera();
DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, const SinkTarget& target);
DRING_PUBLIC void registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target);
DRING_PUBLIC std::map<std::string, std::string> getRenderer(const std::string& callId);
DRING_PUBLIC std::string startLocalRecorder(const bool& audioOnly, const std::string& filepath);
......
......@@ -336,9 +336,13 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
shm_->renderFrame(f);
#endif
if (avTarget_.push) {
auto outFrame = std::make_unique<VideoFrame>();
outFrame->copyFrom(f);
avTarget_.push(std::move(outFrame));
}
if (target_.pull) {
VideoFrame dst;
VideoScaler scaler;
const int width = f.width();
const int height = f.height();
#if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_IPHONE)
......
......@@ -62,6 +62,10 @@ class SinkClient : public VideoFramePassiveReader
return height_;
}
AVPixelFormat getPreferredFormat() const noexcept {
return (AVPixelFormat)avTarget_.preferredFormat;
}
// as VideoFramePassiveReader
void update(Observable<std::shared_ptr<ring::MediaFrame>>*,
const std::shared_ptr<ring::MediaFrame>&) override;
......@@ -74,6 +78,9 @@ class SinkClient : public VideoFramePassiveReader
void registerTarget(const DRing::SinkTarget& target) noexcept {
target_ = target;
}
void registerAVTarget(const DRing::AVSinkTarget& target) noexcept {
avTarget_ = target;
}
private:
const std::string id_;
......@@ -82,6 +89,7 @@ class SinkClient : public VideoFramePassiveReader
int height_ {0};
bool started_ {false}; // used to arbitrate client's stop signal.
DRing::SinkTarget target_;
DRing::AVSinkTarget avTarget_;
std::unique_ptr<VideoScaler> scaler_;
#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