aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormark a. foltz <mfoltz@chromium.org>2021-05-26 16:05:13 -0700
committerOpenscreen LUCI CQ <openscreen-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-05-28 04:20:33 +0000
commitcacde3327295076c1e93d772ca38b115cf93bbd4 (patch)
tree79a768363c27d7b648ecac5b298be65cb7f7c2ad
parent425c136fda4898f5f768842df9aed8529bdcec9e (diff)
downloadopenscreen-cacde3327295076c1e93d772ca38b115cf93bbd4.tar.gz
[Open Screen] Allow deprecated ffmpeg initialization.
This is an updated version of https://chromium-review.googlesource.com/c/openscreen/+/2658659. Original commit description: Call av_register_all, avcodec_register_all for < ffmpeg 4 In ubuntu, `apt` installs ffmpeg 3.x (In 20.04, ffmpeg 3.4 installed). Before ffmpeg 4, without av_register_all(), avcodec_register_all() ffmpeg's api should fail. Change-Id: I7cde9b90b968a5d03bd7317974fab30a9d548e36 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2920374 Reviewed-by: Jordan Bayles <jophba@chromium.org> Commit-Queue: Jordan Bayles <jophba@chromium.org>
-rw-r--r--cast/standalone_receiver/decoder.cc11
-rw-r--r--cast/standalone_sender/ffmpeg_glue.cc9
2 files changed, 19 insertions, 1 deletions
diff --git a/cast/standalone_receiver/decoder.cc b/cast/standalone_receiver/decoder.cc
index 9a2324e3..92cdc901 100644
--- a/cast/standalone_receiver/decoder.cc
+++ b/cast/standalone_receiver/decoder.cc
@@ -4,6 +4,8 @@
#include "cast/standalone_receiver/decoder.h"
+#include <libavcodec/version.h>
+
#include <algorithm>
#include <sstream>
#include <thread>
@@ -44,7 +46,14 @@ absl::Span<uint8_t> Decoder::Buffer::GetSpan() {
Decoder::Client::Client() = default;
Decoder::Client::~Client() = default;
-Decoder::Decoder(const std::string& codec_name) : codec_name_(codec_name) {}
+Decoder::Decoder(const std::string& codec_name) : codec_name_(codec_name) {
+#if LIBAVCODEC_VERSION_MAJOR < 59
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ avcodec_register_all();
+#pragma GCC diagnostic pop
+#endif // LIBAVCODEC_VERSION_MAJOR < 59
+}
Decoder::~Decoder() = default;
diff --git a/cast/standalone_sender/ffmpeg_glue.cc b/cast/standalone_sender/ffmpeg_glue.cc
index a6645886..7f476582 100644
--- a/cast/standalone_sender/ffmpeg_glue.cc
+++ b/cast/standalone_sender/ffmpeg_glue.cc
@@ -4,6 +4,8 @@
#include "cast/standalone_sender/ffmpeg_glue.h"
+#include <libavcodec/version.h>
+
#include "util/osp_logging.h"
namespace openscreen {
@@ -12,6 +14,13 @@ namespace internal {
AVFormatContext* CreateAVFormatContextForFile(const char* path) {
AVFormatContext* format_context = nullptr;
+#if LIBAVCODEC_VERSION_MAJOR < 59
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ av_register_all();
+#pragma GCC diagnostic pop
+#endif // LIBAVCODEC_VERSION_MAJOR < 59
+
int result = avformat_open_input(&format_context, path, nullptr, nullptr);
if (result < 0) {
OSP_LOG_ERROR << "Cannot open " << path << ": " << av_err2str(result);