LCOV - code coverage report
Current view: top level - dom/media/platforms/ffmpeg - FFmpegLibWrapper.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef __FFmpegLibWrapper_h__
       6             : #define __FFmpegLibWrapper_h__
       7             : 
       8             : #include "mozilla/Attributes.h"
       9             : #include "mozilla/Types.h"
      10             : 
      11             : struct AVCodec;
      12             : struct AVCodecContext;
      13             : struct AVFrame;
      14             : struct AVPacket;
      15             : struct AVDictionary;
      16             : struct AVCodecParserContext;
      17             : struct PRLibrary;
      18             : 
      19             : namespace mozilla
      20             : {
      21             : 
      22             : struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper
      23             : {
      24             :   // The class is used only in static storage and so is zero initialized.
      25           6 :   FFmpegLibWrapper() = default;
      26             :   // The libraries are not unloaded in the destructor, because doing so would
      27             :   // require a static constructor to register the static destructor.  As the
      28             :   // class is in static storage, the destructor would only run on shutdown
      29             :   // anyway.
      30             :   ~FFmpegLibWrapper() = default;
      31             : 
      32             :   enum class LinkResult
      33             :   {
      34             :     Success,
      35             :     NoProvidedLib,
      36             :     NoAVCodecVersion,
      37             :     CannotUseLibAV57,
      38             :     BlockedOldLibAVVersion,
      39             :     UnknownFutureLibAVVersion,
      40             :     UnknownFutureFFMpegVersion,
      41             :     UnknownOlderFFMpegVersion,
      42             :     MissingFFMpegFunction,
      43             :     MissingLibAVFunction,
      44             :   };
      45             :   // Examine mAVCodecLib and mAVUtilLib, and attempt to resolve all symbols.
      46             :   // Upon failure, the entire object will be reset and any attached libraries
      47             :   // will be unlinked.
      48             :   LinkResult Link();
      49             : 
      50             :   // Reset the wrapper and unlink all attached libraries.
      51             :   void Unlink();
      52             : 
      53             :   // indicate the version of libavcodec linked to.
      54             :   // 0 indicates that the function wasn't initialized with Link().
      55             :   int mVersion;
      56             : 
      57             :   // libavcodec
      58             :   unsigned (*avcodec_version)();
      59             :   int (*av_lockmgr_register)(int (*cb)(void** mutex, int op));
      60             :   AVCodecContext* (*avcodec_alloc_context3)(const AVCodec* codec);
      61             :   int (*avcodec_close)(AVCodecContext* avctx);
      62             :   int (*avcodec_decode_audio4)(AVCodecContext* avctx, AVFrame* frame, int* got_frame_ptr, const AVPacket* avpkt);
      63             :   int (*avcodec_decode_video2)(AVCodecContext* avctx, AVFrame* picture, int* got_picture_ptr, const AVPacket* avpkt);
      64             :   AVCodec* (*avcodec_find_decoder)(int id);
      65             :   void (*avcodec_flush_buffers)(AVCodecContext *avctx);
      66             :   int (*avcodec_open2)(AVCodecContext *avctx, const AVCodec* codec, AVDictionary** options);
      67             :   void (*avcodec_register_all)();
      68             :   void (*av_init_packet)(AVPacket* pkt);
      69             :   AVCodecParserContext* (*av_parser_init)(int codec_id);
      70             :   void (*av_parser_close)(AVCodecParserContext* s);
      71             :   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);
      72             : 
      73             :   // only used in libavcodec <= 54
      74             :   AVFrame* (*avcodec_alloc_frame)();
      75             :   void (*avcodec_get_frame_defaults)(AVFrame* pic);
      76             :   // libavcodec v54 only
      77             :   void (*avcodec_free_frame)(AVFrame** frame);
      78             : 
      79             :   // libavutil
      80             :   void (*av_log_set_level)(int level);
      81             :   void* (*av_malloc)(size_t size);
      82             :   void (*av_freep)(void *ptr);
      83             : 
      84             :   // libavutil v55 and later only
      85             :   AVFrame* (*av_frame_alloc)();
      86             :   void (*av_frame_free)(AVFrame** frame);
      87             :   void (*av_frame_unref)(AVFrame* frame);
      88             : 
      89             :   // libavutil optional
      90             :   int (*av_frame_get_colorspace)(const AVFrame *frame);
      91             : 
      92             :   PRLibrary* mAVCodecLib;
      93             :   PRLibrary* mAVUtilLib;
      94             : 
      95             : private:
      96             : };
      97             : 
      98             : } // namespace mozilla
      99             : 
     100             : #endif // FFmpegLibWrapper

Generated by: LCOV version 1.13