Commit e5c191fa authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Adrien Béraud

autoadapt: add signal to set bitrate dynamically for MediaCodec

Change-Id: Iba619f891d0412ca4abe4e03e4b2a11d5a3b2488
parent f65a6529
......@@ -286,6 +286,7 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM
const std::map<std::string, SharedCallback> videoEvHandlers = {
exportable_callback<VideoSignal::GetCameraInfo>(bind(&VideoCallback::getCameraInfo, videoM, _1, _2, _3, _4)),
exportable_callback<VideoSignal::SetParameters>(bind(&VideoCallback::setParameters, videoM, _1, _2, _3, _4, _5)),
exportable_callback<VideoSignal::SetBitrate>(bind(&VideoCallback::setBitrate, videoM, _1, _2)),
exportable_callback<VideoSignal::RequestKeyFrame>(bind(&VideoCallback::requestKeyFrame, videoM)),
exportable_callback<VideoSignal::StartCapture>(bind(&VideoCallback::startCapture, videoM, _1)),
exportable_callback<VideoSignal::StopCapture>(bind(&VideoCallback::stopCapture, videoM)),
......
......@@ -43,7 +43,8 @@ class VideoCallback {
public:
virtual ~VideoCallback(){}
virtual void getCameraInfo(const std::string& device, std::vector<int> *formats, std::vector<unsigned> *sizes, std::vector<unsigned> *rates) {}
virtual void setParameters(const std::string, const int format, const int width, const int height, const int rate) {}
virtual void setParameters(const std::string&, const int format, const int width, const int height, const int rate) {}
virtual void setBitrate(const std::string&, const int bitrate) {}
virtual void requestKeyFrame(){}
virtual void startCapture(const std::string& camid) {}
virtual void stopCapture() {}
......@@ -421,7 +422,8 @@ class VideoCallback {
public:
virtual ~VideoCallback(){}
virtual void getCameraInfo(const std::string& device, std::vector<int> *formats, std::vector<unsigned> *sizes, std::vector<unsigned> *rates){}
virtual void setParameters(const std::string, const int format, const int width, const int height, const int rate) {}
virtual void setParameters(const std::string&, const int format, const int width, const int height, const int rate) {}
virtual void setBitrate(const std::string&, const int bitrate) {}
virtual void requestKeyFrame(){}
virtual void startCapture(const std::string& camid) {}
virtual void stopCapture() {}
......
......@@ -110,6 +110,7 @@ getSignalHandlers()
exported_callback<DRing::VideoSignal::GetCameraInfo>(),
exported_callback<DRing::VideoSignal::SetParameters>(),
exported_callback<DRing::VideoSignal::RequestKeyFrame>(),
exported_callback<DRing::VideoSignal::SetBitrate>(),
#endif
exported_callback<DRing::VideoSignal::StartCapture>(),
exported_callback<DRing::VideoSignal::StopCapture>(),
......
......@@ -224,6 +224,10 @@ struct DRING_PUBLIC VideoSignal {
constexpr static const char* name = "RequestKeyFrame";
using cb_type = void();
};
struct DRING_PUBLIC SetBitrate {
constexpr static const char* name = "SetBitrate";
using cb_type = void(const std::string& device, const int bitrate);
};
#endif
struct DRING_PUBLIC StartCapture {
constexpr static const char* name = "StartCapture";
......
......@@ -482,7 +482,8 @@ VideoInput::switchInput(const std::string& resource)
return futureDecOpts_;
}
DeviceParams VideoInput::getParams() const
const DeviceParams&
VideoInput::getParams() const
{ return decOpts_; }
MediaStream
......
......@@ -67,7 +67,7 @@ public:
int getWidth() const;
int getHeight() const;
AVPixelFormat getPixelFormat() const;
DeviceParams getParams() const;
const DeviceParams& getParams() const;
MediaStream getInfo() const;
std::shared_future<DeviceParams> switchInput(const std::string& resource);
......
......@@ -447,6 +447,11 @@ VideoRtpSession::adaptQualityAndBitrate()
if(oldBitrate != videoBitrateInfo_.videoBitrateCurrent) {
storeVideoBitrateInfo();
#if __ANDROID__
auto input_device = std::static_pointer_cast<VideoInput>(videoLocal_);
emitSignal<DRing::VideoSignal::SetBitrate>(input_device->getParams().name, (int)videoBitrateInfo_.videoBitrateCurrent);
#endif
// If encoder no longer exist do nothing
if(sender_ && sender_->setBitrate(videoBitrateInfo_.videoBitrateCurrent) == 0)
lastMediaRestart_ = now;
......
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