summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/platforms/ffmpeg/FFmpegLibWrapper.h')
-rw-r--r--dom/media/platforms/ffmpeg/FFmpegLibWrapper.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
new file mode 100644
index 000000000..d6944a1d8
--- /dev/null
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
@@ -0,0 +1,94 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef __FFmpegLibWrapper_h__
+#define __FFmpegLibWrapper_h__
+
+#include "mozilla/Types.h"
+
+struct AVCodec;
+struct AVCodecContext;
+struct AVFrame;
+struct AVPacket;
+struct AVDictionary;
+struct AVCodecParserContext;
+struct PRLibrary;
+
+namespace mozilla
+{
+
+struct FFmpegLibWrapper
+{
+ FFmpegLibWrapper();
+ ~FFmpegLibWrapper();
+
+ enum class LinkResult
+ {
+ Success,
+ NoProvidedLib,
+ NoAVCodecVersion,
+ CannotUseLibAV57,
+ BlockedOldLibAVVersion,
+ UnknownFutureLibAVVersion,
+ UnknownFutureFFMpegVersion,
+ UnknownOlderFFMpegVersion,
+ MissingFFMpegFunction,
+ MissingLibAVFunction,
+ };
+ // Examine mAVCodecLib and mAVUtilLib, and attempt to resolve all symbols.
+ // Upon failure, the entire object will be reset and any attached libraries
+ // will be unlinked.
+ LinkResult Link();
+
+ // Reset the wrapper and unlink all attached libraries.
+ void Unlink();
+
+ // indicate the version of libavcodec linked to.
+ // 0 indicates that the function wasn't initialized with Link().
+ int mVersion;
+
+ // libavcodec
+ unsigned (*avcodec_version)();
+ int (*av_lockmgr_register)(int (*cb)(void** mutex, int op));
+ AVCodecContext* (*avcodec_alloc_context3)(const AVCodec* codec);
+ int (*avcodec_close)(AVCodecContext* avctx);
+ int (*avcodec_decode_audio4)(AVCodecContext* avctx, AVFrame* frame, int* got_frame_ptr, const AVPacket* avpkt);
+ int (*avcodec_decode_video2)(AVCodecContext* avctx, AVFrame* picture, int* got_picture_ptr, const AVPacket* avpkt);
+ AVCodec* (*avcodec_find_decoder)(int id);
+ void (*avcodec_flush_buffers)(AVCodecContext *avctx);
+ int (*avcodec_open2)(AVCodecContext *avctx, const AVCodec* codec, AVDictionary** options);
+ void (*avcodec_register_all)();
+ void (*av_init_packet)(AVPacket* pkt);
+ AVCodecParserContext* (*av_parser_init)(int codec_id);
+ void (*av_parser_close)(AVCodecParserContext* s);
+ int (*av_parser_parse2)(AVCodecParserContext* s, AVCodecContext* avctx, uint8_t** poutbuf, int* poutbuf_size, const uint8_t* buf, int buf_size, int64_t pts, int64_t dts, int64_t pos);
+
+ // only used in libavcodec <= 54
+ AVFrame* (*avcodec_alloc_frame)();
+ void (*avcodec_get_frame_defaults)(AVFrame* pic);
+ // libavcodec v54 only
+ void (*avcodec_free_frame)(AVFrame** frame);
+
+ // libavutil
+ void (*av_log_set_level)(int level);
+ void* (*av_malloc)(size_t size);
+ void (*av_freep)(void *ptr);
+
+ // libavutil v55 and later only
+ AVFrame* (*av_frame_alloc)();
+ void (*av_frame_free)(AVFrame** frame);
+ void (*av_frame_unref)(AVFrame* frame);
+
+ // libavutil optional
+ int (*av_frame_get_colorspace)(const AVFrame *frame);
+
+ PRLibrary* mAVCodecLib;
+ PRLibrary* mAVUtilLib;
+
+private:
+};
+
+} // namespace mozilla
+
+#endif // FFmpegLibWrapper \ No newline at end of file