Commit 36c6d857 authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin

media: fix compilation warnings

Change-Id: I86d2bfcf88a2a2b0eac50e4bb2b1c74359f84f76
parent 59d6bf50
......@@ -120,7 +120,7 @@ AudioSender::setup(SocketPair& socketPair)
/* Encoder setup */
RING_DBG("audioEncoder_->openOutput %s", dest_.c_str());
audioEncoder_->setMuted(muteState_);
audioEncoder_->openOutput(dest_.c_str(), args_);
audioEncoder_->openOutput(dest_, args_);
audioEncoder_->setInitSeqVal(seqVal_);
audioEncoder_->setIOContext(muxContext_);
audioEncoder_->startIO();
......
......@@ -37,6 +37,7 @@
namespace ring { namespace libav_utils {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
// protect libav/ffmpeg access
static int
avcodecManageMutex(void **data, enum AVLockOp op)
......@@ -70,6 +71,7 @@ avcodecManageMutex(void **data, enum AVLockOp op)
}
return AVERROR(ret);
}
#endif
static constexpr const char* AVLOGLEVEL = "AVLOGLEVEL";
......@@ -134,11 +136,15 @@ androidAvLogCb(void* ptr, int level, const char* fmt, va_list vl)
static void
init_once()
{
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
avdevice_register_all();
avformat_network_init();
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_lockmgr_register(avcodecManageMutex);
#endif
if (getDebugMode())
setAvLogLevel();
......
......@@ -123,21 +123,26 @@ MediaEncoder::getEncoderName() const
}
void
MediaEncoder::openOutput(const char *filename,
MediaEncoder::openOutput(const std::string& filename,
const ring::MediaDescription& args)
{
setOptions(args);
AVOutputFormat *oformat = av_guess_format("rtp", filename, nullptr);
AVOutputFormat *oformat = av_guess_format("rtp", filename.c_str(), nullptr);
if (!oformat) {
RING_ERR("Unable to find a suitable output format for %s", filename);
RING_ERR("Unable to find a suitable output format for %s", filename.c_str());
throw MediaEncoderException("No output format");
}
outputCtx_->oformat = oformat;
strncpy(outputCtx_->filename, filename, sizeof(outputCtx_->filename));
// guarantee that buffer is NULL terminated
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
// c_str guarantees NULL termination
outputCtx_->url = av_strdup(filename.c_str()); // must be compatible with av_free
#else
strncpy(outputCtx_->filename, filename.c_str(), sizeof(outputCtx_->filename));
// in case our filename is longer than the space reserved for AVFormatContext.filename
outputCtx_->filename[sizeof(outputCtx_->filename) - 1] = '\0';
#endif
/* find the video encoder */
if (args.codec->systemCodecInfo.avcodecId == AV_CODEC_ID_H263)
......@@ -265,7 +270,11 @@ MediaEncoder::startIO()
throw MediaEncoderException("Failed to write output file header");
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
av_dump_format(outputCtx_, 0, outputCtx_->url, 1);
#else
av_dump_format(outputCtx_, 0, outputCtx_->filename, 1);
#endif
}
#ifdef RING_VIDEO
......
......@@ -63,7 +63,7 @@ public:
void setInterruptCallback(int (*cb)(void*), void *opaque);
void setDeviceOptions(const DeviceParams& args);
void openOutput(const char *filename, const MediaDescription& args);
void openOutput(const std::string& filename, const MediaDescription& args);
void startIO();
void setIOContext(const std::unique_ptr<MediaIOHandle> &ioctx);
......
......@@ -44,7 +44,7 @@ VideoSender::VideoSender(const std::string& dest, const DeviceParams& dev,
{
videoEncoder_->setDeviceOptions(dev);
keyFrameFreq_ = dev.framerate.numerator() * KEY_FRAME_PERIOD;
videoEncoder_->openOutput(dest.c_str(), args);
videoEncoder_->openOutput(dest, args);
videoEncoder_->setInitSeqVal(seqVal);
videoEncoder_->setIOContext(muxContext_);
videoEncoder_->startIO();
......
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