mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
video API: unify SinkTarget and AVSinkTarget
Change-Id: I6cbbdc1ec6953c1c9ec47a57acf8ac4d8995468d
This commit is contained in:

committed by
Andreas Traczyk

parent
24dd4150c8
commit
4af0279fa2
@ -2,7 +2,7 @@ dnl Jami - configure.ac
|
|||||||
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([Jami Daemon],[12.0.0],[jami@gnu.org],[jami])
|
AC_INIT([Jami Daemon],[13.0.0],[jami@gnu.org],[jami])
|
||||||
|
|
||||||
dnl Clear the implicit flags that default to '-g -O2', otherwise they
|
dnl Clear the implicit flags that default to '-g -O2', otherwise they
|
||||||
dnl take precedence over the values we set via the
|
dnl take precedence over the values we set via the
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
project('jami-daemon', ['c', 'cpp'],
|
project('jami-daemon', ['c', 'cpp'],
|
||||||
version: '11.0.2',
|
version: '13.0.0',
|
||||||
license: 'GPL3+',
|
license: 'GPL3+',
|
||||||
default_options: ['cpp_std=gnu++17', 'buildtype=debugoptimized'],
|
default_options: ['cpp_std=gnu++17', 'buildtype=debugoptimized'],
|
||||||
meson_version:'>= 0.56'
|
meson_version:'>= 0.56'
|
||||||
|
@ -58,10 +58,7 @@ extern "C" {
|
|||||||
namespace DRing {
|
namespace DRing {
|
||||||
|
|
||||||
MediaFrame::MediaFrame()
|
MediaFrame::MediaFrame()
|
||||||
: frame_ {av_frame_alloc(),
|
: frame_ {av_frame_alloc()}
|
||||||
[](AVFrame* frame) {
|
|
||||||
av_frame_free(&frame);
|
|
||||||
}}
|
|
||||||
, packet_(nullptr, [](AVPacket* p) {
|
, packet_(nullptr, [](AVPacket* p) {
|
||||||
if (p) {
|
if (p) {
|
||||||
av_packet_unref(p);
|
av_packet_unref(p);
|
||||||
@ -526,11 +523,11 @@ stopLocalRecorder(const std::string& filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
registerSinkTarget(const std::string& sinkId, const SinkTarget& target)
|
registerSinkTarget(const std::string& sinkId, SinkTarget target)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_VIDEO
|
#ifdef ENABLE_VIDEO
|
||||||
if (auto sink = jami::Manager::instance().getSinkClient(sinkId))
|
if (auto sink = jami::Manager::instance().getSinkClient(sinkId))
|
||||||
sink->registerTarget(target);
|
sink->registerTarget(std::move(target));
|
||||||
else
|
else
|
||||||
JAMI_WARN("No sink found for id '%s'", sinkId.c_str());
|
JAMI_WARN("No sink found for id '%s'", sinkId.c_str());
|
||||||
#endif
|
#endif
|
||||||
@ -549,17 +546,6 @@ startShmSink(const std::string& sinkId, bool value)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VIDEO
|
|
||||||
if (auto sink = jami::Manager::instance().getSinkClient(sinkId))
|
|
||||||
sink->registerAVTarget(target);
|
|
||||||
else
|
|
||||||
JAMI_WARN("No sink found for id '%s'", sinkId.c_str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, std::string>
|
std::map<std::string, std::string>
|
||||||
getRenderer(const std::string& callId)
|
getRenderer(const std::string& callId)
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,12 @@ namespace DRing {
|
|||||||
[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerVideoHandlers(
|
[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerVideoHandlers(
|
||||||
const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
|
const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
|
||||||
|
|
||||||
|
struct DRING_PUBLIC AVFrame_deleter {
|
||||||
|
void operator()(AVFrame* frame) const { av_frame_free(&frame); }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::unique_ptr<AVFrame, AVFrame_deleter> FrameBuffer;
|
||||||
|
|
||||||
class DRING_PUBLIC MediaFrame
|
class DRING_PUBLIC MediaFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -80,10 +86,10 @@ public:
|
|||||||
// Reset internal buffers (return to an empty MediaFrame)
|
// Reset internal buffers (return to an empty MediaFrame)
|
||||||
virtual void reset() noexcept;
|
virtual void reset() noexcept;
|
||||||
|
|
||||||
std::unique_ptr<AVFrame, void (*)(AVFrame*)> getFrame() { return std::move(frame_); }
|
FrameBuffer getFrame() { return std::move(frame_); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<AVFrame, void (*)(AVFrame*)> frame_;
|
FrameBuffer frame_;
|
||||||
std::unique_ptr<AVPacket, void (*)(AVPacket*)> packet_;
|
std::unique_ptr<AVPacket, void (*)(AVPacket*)> packet_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,21 +163,10 @@ private:
|
|||||||
void setGeometry(int format, int width, int height) noexcept;
|
void setGeometry(int format, int width, int height) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DRING_PUBLIC AVFrame_deleter {
|
|
||||||
void operator()(AVFrame* frame) const { av_frame_free(&frame); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::unique_ptr<AVFrame, AVFrame_deleter> FrameBuffer;
|
|
||||||
|
|
||||||
struct DRING_PUBLIC SinkTarget
|
struct DRING_PUBLIC SinkTarget
|
||||||
{
|
{
|
||||||
std::function<FrameBuffer()> pull;
|
std::function<FrameBuffer()> pull;
|
||||||
std::function<void(FrameBuffer)> push;
|
std::function<void(FrameBuffer)> push;
|
||||||
};
|
|
||||||
|
|
||||||
struct DRING_PUBLIC AVSinkTarget
|
|
||||||
{
|
|
||||||
std::function<void(std::unique_ptr<VideoFrame>)> push;
|
|
||||||
int /* AVPixelFormat */ preferredFormat {-1 /* AV_PIX_FMT_NONE */};
|
int /* AVPixelFormat */ preferredFormat {-1 /* AV_PIX_FMT_NONE */};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,8 +194,7 @@ DRING_PUBLIC bool mutePlayerAudio(const std::string& id, bool mute);
|
|||||||
DRING_PUBLIC bool playerSeekToTime(const std::string& id, int time);
|
DRING_PUBLIC bool playerSeekToTime(const std::string& id, int time);
|
||||||
int64_t getPlayerPosition(const std::string& id);
|
int64_t getPlayerPosition(const std::string& id);
|
||||||
|
|
||||||
DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, const SinkTarget& target);
|
DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, SinkTarget target);
|
||||||
DRING_PUBLIC void registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target);
|
|
||||||
#if HAVE_SHM
|
#if HAVE_SHM
|
||||||
DRING_PUBLIC void startShmSink(const std::string& sinkId, bool value);
|
DRING_PUBLIC void startShmSink(const std::string& sinkId, bool value);
|
||||||
#endif
|
#endif
|
||||||
|
@ -354,23 +354,23 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(mtx_);
|
std::unique_lock<std::mutex> lock(mtx_);
|
||||||
if (avTarget_.push) {
|
if (target_.push and not target_.pull) {
|
||||||
auto outFrame = std::make_unique<VideoFrame>();
|
VideoFrame outFrame;
|
||||||
outFrame->copyFrom(*std::static_pointer_cast<VideoFrame>(frame_p));
|
outFrame.copyFrom(*std::static_pointer_cast<VideoFrame>(frame_p));
|
||||||
if (crop_.w || crop_.h) {
|
if (crop_.w || crop_.h) {
|
||||||
outFrame->pointer()->crop_top = crop_.y;
|
outFrame.pointer()->crop_top = crop_.y;
|
||||||
outFrame->pointer()->crop_bottom = (size_t) outFrame->height() - crop_.y - crop_.h;
|
outFrame.pointer()->crop_bottom = (size_t) outFrame.height() - crop_.y - crop_.h;
|
||||||
outFrame->pointer()->crop_left = crop_.x;
|
outFrame.pointer()->crop_left = crop_.x;
|
||||||
outFrame->pointer()->crop_right = (size_t) outFrame->width() - crop_.x - crop_.w;
|
outFrame.pointer()->crop_right = (size_t) outFrame.width() - crop_.x - crop_.w;
|
||||||
av_frame_apply_cropping(outFrame->pointer(), AV_FRAME_CROP_UNALIGNED);
|
av_frame_apply_cropping(outFrame.pointer(), AV_FRAME_CROP_UNALIGNED);
|
||||||
}
|
}
|
||||||
if (outFrame->height() != height_ || outFrame->width() != width_) {
|
if (outFrame.height() != height_ || outFrame.width() != width_) {
|
||||||
setFrameSize(0, 0);
|
setFrameSize(0, 0);
|
||||||
setFrameSize(outFrame->width(), outFrame->height());
|
setFrameSize(outFrame.width(), outFrame.height());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
notify(std::static_pointer_cast<MediaFrame>(frame_p));
|
notify(std::static_pointer_cast<MediaFrame>(frame_p));
|
||||||
avTarget_.push(std::move(outFrame));
|
target_.push(outFrame.getFrame());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
AVPixelFormat getPreferredFormat() const noexcept
|
AVPixelFormat getPreferredFormat() const noexcept
|
||||||
{
|
{
|
||||||
return (AVPixelFormat) avTarget_.preferredFormat;
|
return (AVPixelFormat) target_.preferredFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// as VideoFramePassiveReader
|
// as VideoFramePassiveReader
|
||||||
@ -76,12 +76,11 @@ public:
|
|||||||
void setFrameSize(int width, int height);
|
void setFrameSize(int width, int height);
|
||||||
void setCrop(int x, int y, int w, int h);
|
void setCrop(int x, int y, int w, int h);
|
||||||
|
|
||||||
void registerTarget(const DRing::SinkTarget& target) noexcept
|
void registerTarget(DRing::SinkTarget target) noexcept
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx_);
|
std::lock_guard<std::mutex> lock(mtx_);
|
||||||
target_ = target;
|
target_ = std::move(target);
|
||||||
}
|
}
|
||||||
void registerAVTarget(const DRing::AVSinkTarget& target) noexcept { avTarget_ = target; }
|
|
||||||
|
|
||||||
#if HAVE_SHM
|
#if HAVE_SHM
|
||||||
void enableShm(bool value) { doShmTransfer_.store(value); }
|
void enableShm(bool value) { doShmTransfer_.store(value); }
|
||||||
@ -103,7 +102,6 @@ private:
|
|||||||
bool started_ {false}; // used to arbitrate client's stop signal.
|
bool started_ {false}; // used to arbitrate client's stop signal.
|
||||||
int rotation_ {0};
|
int rotation_ {0};
|
||||||
DRing::SinkTarget target_;
|
DRing::SinkTarget target_;
|
||||||
DRing::AVSinkTarget avTarget_;
|
|
||||||
std::unique_ptr<VideoScaler> scaler_;
|
std::unique_ptr<VideoScaler> scaler_;
|
||||||
std::unique_ptr<MediaFilter> filter_;
|
std::unique_ptr<MediaFilter> filter_;
|
||||||
std::mutex mtx_;
|
std::mutex mtx_;
|
||||||
|
Reference in New Issue
Block a user