Commit 0f6ffcac authored by Adrien Béraud's avatar Adrien Béraud

dring/call: send video codec to client

Change-Id: I919aa2607b1d0dcc33b7b02f90b97b1b8fd1ef98
parent 18669df2
......@@ -298,8 +298,11 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
void onTextMessage(std::map<std::string, std::string>&& messages);
virtual bool useVideoCodec(const AccountVideoCodecInfo* /*codec*/) const {
return false;
virtual std::shared_ptr<AccountCodecInfo> getAudioCodec() const {
return {};
}
virtual std::shared_ptr<AccountCodecInfo> getVideoCodec() const {
return {};
}
virtual void restartMediaSender() = 0;
......
......@@ -505,7 +505,7 @@ setCodecDetails(const std::string& accountID,
JAMI_WARN("parameters for %s changed ",
foundCodec->systemCodecInfo.name.c_str());
if (auto call = jami::Manager::instance().getCurrentCall()) {
if (call->useVideoCodec(foundCodec.get())) {
if (call->getVideoCodec() == foundCodec) {
JAMI_WARN("%s running. Need to restart encoding",
foundCodec->systemCodecInfo.name.c_str());
call->restartMediaSender();
......
......@@ -58,6 +58,8 @@ constexpr static char AUDIO_MUTED [] = "AUDIO_MUTED" ;
constexpr static char VIDEO_MUTED [] = "VIDEO_MUTED" ;
constexpr static char VIDEO_SOURCE [] = "VIDEO_SOURCE" ;
constexpr static char AUDIO_ONLY [] = "AUDIO_ONLY" ;
constexpr static char AUDIO_CODEC [] = "AUDIO_CODEC" ;
constexpr static char VIDEO_CODEC [] = "VIDEO_CODEC" ;
}
......
......@@ -83,7 +83,7 @@ AudioSender::setup(SocketPair& socketPair)
return false;
}
Smartools::getInstance().setLocalAudioCodec(audioEncoder_->getEncoderName());
Smartools::getInstance().setLocalAudioCodec(audioEncoder_->getAudioCodec());
#ifdef DEBUG_SDP
audioEncoder_->print_sdp();
......
......@@ -134,15 +134,6 @@ MediaEncoder::getLastSeqValue()
return 0;
}
std::string
MediaEncoder::getEncoderName() const
{
if (videoOpts_.isValid())
return videoCodec_;
else
return audioCodec_;
}
void
MediaEncoder::openOutput(const std::string& filename, const std::string& format)
{
......@@ -700,15 +691,6 @@ MediaEncoder::extractProfileLevelID(const std::string &parameters,
JAMI_DBG("Using profile %x and level %d", ctx->profile, ctx->level);
}
bool
MediaEncoder::useCodec(const jami::AccountCodecInfo* codec) const noexcept
{
if (codec->systemCodecInfo.mediaType == MEDIA_VIDEO)
return videoCodec_ == codec->systemCodecInfo.name;
else
return audioCodec_ == codec->systemCodecInfo.name;
}
#ifdef RING_ACCEL
void
MediaEncoder::enableAccel(bool enableAccel)
......
......@@ -96,9 +96,9 @@ public:
void setInitSeqVal(uint16_t seqVal);
uint16_t getLastSeqValue();
std::string getEncoderName() const;
bool useCodec(const AccountCodecInfo* codec) const noexcept;
const std::string& getAudioCodec() const { return audioCodec_; }
const std::string& getVideoCodec() const { return videoCodec_; }
#ifdef RING_ACCEL
void enableAccel(bool enableAccel);
......
......@@ -58,6 +58,8 @@ public:
virtual void initRecorder(std::shared_ptr<MediaRecorder>& rec) = 0;
virtual void deinitRecorder(std::shared_ptr<MediaRecorder>& rec) = 0;
std::shared_ptr<AccountCodecInfo> getCodec() const { return send_.codec; }
protected:
std::recursive_mutex mutex_;
std::unique_ptr<SocketPair> socketPair_;
......
......@@ -336,13 +336,6 @@ void VideoRtpSession::exitConference()
conference_ = nullptr;
}
bool
VideoRtpSession::useCodec(const jami::AccountVideoCodecInfo* codec) const
{
return sender_->useCodec(codec);
}
float
VideoRtpSession::checkPeerPacketLoss()
{
......
......@@ -19,8 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __VIDEO_RTP_SESSION_H__
#define __VIDEO_RTP_SESSION_H__
#pragma once
#include "media/rtp_session.h"
#include "media/media_device.h"
......@@ -92,9 +91,6 @@ public:
}
void setChangeOrientationCallback(std::function<void(int)> cb);
bool useCodec(const AccountVideoCodecInfo* codec) const;
void initRecorder(std::shared_ptr<MediaRecorder>& rec) override;
void deinitRecorder(std::shared_ptr<MediaRecorder>& rec) override;
......@@ -158,5 +154,3 @@ private:
};
}} // namespace jami::video
#endif // __VIDEO_RTP_SESSION_H__
......@@ -60,7 +60,7 @@ VideoSender::VideoSender(const std::string& dest, const DeviceParams& dev,
videoEncoder_->setIOContext(muxContext_->getContext());
// Send local video codec in SmartInfo
Smartools::getInstance().setLocalVideoCodec(videoEncoder_->getEncoderName());
Smartools::getInstance().setLocalVideoCodec(videoEncoder_->getVideoCodec());
// Send the resolution in smartInfo
Smartools::getInstance().setResolution("local", dev.width, dev.height);
......@@ -135,12 +135,6 @@ VideoSender::getLastSeqValue()
return videoEncoder_->getLastSeqValue();
}
bool
VideoSender::useCodec(const jami::AccountVideoCodecInfo* codec) const
{
return videoEncoder_->useCodec(codec);
}
void
VideoSender::setChangeOrientationCallback(std::function<void(int)> cb)
{
......
......@@ -19,8 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __VIDEO_SENDER_H__
#define __VIDEO_SENDER_H__
#pragma once
#include "noncopyable.h"
#include "media_encoder.h"
......@@ -60,8 +59,6 @@ public:
uint16_t getLastSeqValue();
bool useCodec(const AccountVideoCodecInfo* codec) const;
void setChangeOrientationCallback(std::function<void(int)> cb);
private:
......@@ -85,5 +82,3 @@ private:
std::function<void(int)> changeOrientationCallback_;
};
}} // namespace jami::video
#endif // __VIDEO_SENDER_H__
......@@ -873,14 +873,19 @@ SIPCall::getAllRemoteCandidates()
return rem_candidates;
}
bool
SIPCall::useVideoCodec(const AccountVideoCodecInfo* codec) const
std::shared_ptr<AccountCodecInfo>
SIPCall::getVideoCodec() const
{
#ifdef ENABLE_VIDEO
if (videortp_->isSending())
return videortp_->useCodec(codec);
return videortp_->getCodec();
#endif
return false;
return {};
}
std::shared_ptr<AccountCodecInfo>
SIPCall::getAudioCodec() const
{
return avformatrtp_->getCodec();
}
void
......@@ -1210,6 +1215,8 @@ SIPCall::getDetails() const
#ifdef ENABLE_VIDEO
// If Video is not enabled return an empty string
details.emplace(DRing::Call::Details::VIDEO_SOURCE, acc.isVideoEnabled() ? mediaInput_ : "");
if (auto codec = videortp_->getCodec())
details.emplace(DRing::Call::Details::VIDEO_CODEC, codec->systemCodecInfo.name);
#endif
#if HAVE_RINGNS
......
......@@ -109,7 +109,9 @@ public: // overridden
void removeCall() override;
void muteMedia(const std::string& mediaType, bool isMuted) override;
void restartMediaSender() override;
bool useVideoCodec(const AccountVideoCodecInfo* codec) const override;
std::shared_ptr<AccountCodecInfo> getAudioCodec() const override;
std::shared_ptr<AccountCodecInfo> getVideoCodec() const override;
void sendKeyframe() override;
std::map<std::string, std::string> getDetails() const override;
......
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