Commit b99f1a0b authored by Vladimir Stoiakin's avatar Vladimir Stoiakin Committed by Adrien Béraud

build: fix some issues for building without video

Change-Id: I9d1d1a53070228b93728655021cdf1764b5eb6b2
Gitlab: #238
parent 3a72e386
......@@ -113,7 +113,14 @@ if get_option('video')
if get_option('hw_acceleration')
conf.set('RING_ACCEL', true)
conf.set('ENABLE_VIDEOTOOLBOX', host_machine.system() == 'darwin')
else
conf.set('RING_ACCEL', false)
conf.set('ENABLE_VIDEOTOOLBOX', false)
endif
else
conf.set('ENABLE_VIDEO', false)
conf.set('RING_ACCEL', false)
conf.set('ENABLE_VIDEOTOOLBOX', false)
endif
if get_option('plugins')
......
......@@ -102,10 +102,10 @@ getSignalHandlers()
/* DataTransfer */
exported_callback<DRing::DataTransferSignal::DataTransferEvent>(),
#ifdef ENABLE_VIDEO
/* MediaPlayer */
exported_callback<DRing::MediaPlayerSignal::FileOpened>(),
#ifdef ENABLE_VIDEO
/* Video */
exported_callback<DRing::VideoSignal::DeviceEvent>(),
exported_callback<DRing::VideoSignal::DecodingStarted>(),
......
......@@ -467,10 +467,14 @@ MediaDecoder::setupStream()
JAMI_DBG() << "Using framerate emulation";
startTime_ = av_gettime(); // used to set pts after decoding, and for rate emulation
#ifdef RING_ACCEL
if(!accel_) {
JAMI_WARN("Not using hardware decoding for %s", avcodec_get_name(decoderCtx_->codec_id));
ret = avcodec_open2(decoderCtx_, inputDecoder_, nullptr);
}
#else
ret = avcodec_open2(decoderCtx_, inputDecoder_, nullptr);
#endif
if (ret < 0) {
JAMI_ERR() << "Could not open codec: " << libav_utils::getError(ret);
return -1;
......@@ -516,14 +520,17 @@ MediaDecoder::decode(AVPacket& packet)
{
int frameFinished = 0;
auto ret = avcodec_send_packet(decoderCtx_, &packet);
if ( accel_ && (ret < 0 && ret != AVERROR(EAGAIN)) ) {
JAMI_WARN("Decoding error falling back to software");
fallback_ = true;
accel_.reset();
avcodec_flush_buffers(decoderCtx_);
setupStream();
return DecodeStatus::FallBack;
} else if (ret < 0 && ret != AVERROR(EAGAIN)) {
if (ret < 0 && ret != AVERROR(EAGAIN)) {
#ifdef RING_ACCEL
if (accel_) {
JAMI_WARN("Decoding error falling back to software");
fallback_ = true;
accel_.reset();
avcodec_flush_buffers(decoderCtx_);
setupStream();
return DecodeStatus::FallBack;
} else
#endif
return ret == AVERROR_EOF ? DecodeStatus::Success : DecodeStatus::DecodeError;
}
......
......@@ -62,6 +62,7 @@ class AudioFrame;
namespace jami {
using AudioFrame = DRing::AudioFrame;
using VideoFrame = DRing::VideoFrame;
struct AudioFormat;
class RingBuffer;
class Resampler;
......
......@@ -602,6 +602,7 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video)
void
MediaEncoder::forcePresetX2645(AVCodecContext* encoderCtx)
{
#ifdef RING_ACCEL
if(accel_ && accel_->getName() == "nvenc") {
if (av_opt_set(encoderCtx, "preset", "fast", AV_OPT_SEARCH_CHILDREN))
JAMI_WARN("Failed to set preset to 'fast'");
......@@ -609,8 +610,9 @@ MediaEncoder::forcePresetX2645(AVCodecContext* encoderCtx)
JAMI_WARN("Failed to set level to 'auto'");
if (av_opt_set_int(encoderCtx, "zerolatency", 1, AV_OPT_SEARCH_CHILDREN))
JAMI_WARN("Failed to set zerolatency to '1'");
}
else {
} else
#endif
{
#if (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
const char *speedPreset = "ultrafast";
#else
......@@ -965,12 +967,15 @@ MediaEncoder::stopEncoder()
bool
MediaEncoder::isDynBitrateSupported(AVCodecID codecid)
{
#ifdef RING_ACCEL
if (accel_) {
return accel_->dynBitrate();
} else {
if (codecid != AV_CODEC_ID_VP8)
return true;
}
#endif
if (codecid != AV_CODEC_ID_VP8)
return true;
return false;
}
void
......
......@@ -200,7 +200,7 @@ MediaFilter::readOutput()
std::unique_ptr<MediaFrame> frame;
switch (av_buffersink_get_type(output_)) {
case AVMEDIA_TYPE_VIDEO:
frame = std::make_unique<VideoFrame>();
frame = std::make_unique<DRing::VideoFrame>();
break;
case AVMEDIA_TYPE_AUDIO:
frame = std::make_unique<AudioFrame>();
......
......@@ -11,12 +11,10 @@ libjami_sources = files(
'client/datatransfer.cpp',
'client/presencemanager.cpp',
'client/ring_signal.cpp',
'client/videomanager.cpp',
'config/yamlparser.cpp',
'hooks/urlhook.cpp',
'im/instant_messaging.cpp',
'im/message_engine.cpp',
'jamidht/channeled_transfers.cpp',
'jamidht/eth/libdevcore/Common.cpp',
'jamidht/eth/libdevcore/CommonData.cpp',
'jamidht/eth/libdevcore/FixedHash.cpp',
......@@ -25,6 +23,7 @@ libjami_sources = files(
'jamidht/accountarchive.cpp',
'jamidht/account_manager.cpp',
'jamidht/archive_account_manager.cpp',
'jamidht/channeled_transfers.cpp',
'jamidht/channeled_transport.cpp',
'jamidht/connectionmanager.cpp',
'jamidht/contact_list.cpp',
......@@ -205,6 +204,7 @@ endif
if conf.get('ENABLE_VIDEO')
libjami_sources += files(
'client/videomanager.cpp',
'media/video/filter_transpose.cpp',
'media/video/sinkclient.cpp',
'media/video/video_base.cpp',
......
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