Bug 1209806: Remove dependency on libavformat. r=edwin
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 30 Sep 2015 11:45:41 +1000
changeset 607018 0f0c80770df0e00c745a6b217adf52281acc5f52
parent 607017 e7f024256858ad39d3a97ca1954d0b4629c804dc
child 607019 89d11d15d401dfce53000ff41c7bd314b49a8ea5
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
reviewersedwin
bugs1209806
milestone43.0a2
Bug 1209806: Remove dependency on libavformat. r=edwin
dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
dom/media/platforms/ffmpeg/FFmpegFunctionList.h
dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
@@ -70,17 +70,17 @@ ChoosePixelFormat(AVCodecContext* aCodec
 nsresult
 FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
 {
   StaticMutexAutoLock mon(sMonitor);
 
   FFMPEG_LOG("Initialising FFmpeg decoder.");
 
   if (!sFFmpegInitDone) {
-    av_register_all();
+    avcodec_register_all();
 #ifdef DEBUG
     av_log_set_level(AV_LOG_DEBUG);
 #endif
     sFFmpegInitDone = true;
   }
 
   AVCodec* codec = avcodec_find_decoder(mCodecID);
   if (!codec) {
--- a/dom/media/platforms/ffmpeg/FFmpegFunctionList.h
+++ b/dom/media/platforms/ffmpeg/FFmpegFunctionList.h
@@ -1,15 +1,12 @@
 /* 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/. */
 
-/* libavformat */
-AV_FUNC(av_register_all, 0)
-
 /* libavcodec */
 AV_FUNC(avcodec_align_dimensions2, 0)
 AV_FUNC(avcodec_get_frame_defaults, 0)
 AV_FUNC(avcodec_close, 0)
 AV_FUNC(avcodec_decode_audio4, 0)
 AV_FUNC(avcodec_decode_video2, 0)
 AV_FUNC(avcodec_default_get_buffer, 0)
 AV_FUNC(avcodec_default_release_buffer, 0)
@@ -19,16 +16,17 @@ AV_FUNC(avcodec_alloc_context3, 0)
 AV_FUNC(avcodec_get_edge_width, 0)
 AV_FUNC(avcodec_open2, 0)
 AV_FUNC(av_init_packet, 0)
 AV_FUNC(av_dict_get, 0)
 AV_FUNC(av_parser_init, 0)
 AV_FUNC(av_parser_close, 0)
 AV_FUNC(av_parser_parse2, 0)
 AV_FUNC(avcodec_version, 0)
+AV_FUNC(avcodec_register_all, 0)
 
 /* libavutil */
 AV_FUNC(av_image_fill_linesizes, 0)
 AV_FUNC(av_image_fill_pointers, 0)
 AV_FUNC(av_log_set_level, 0)
 AV_FUNC(av_malloc, 0)
 AV_FUNC(av_freep, 0)
 
--- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
@@ -13,43 +13,43 @@
 #define NUM_ELEMENTS(X) (sizeof(X) / sizeof((X)[0]))
 
 namespace mozilla
 {
 
 FFmpegRuntimeLinker::LinkStatus FFmpegRuntimeLinker::sLinkStatus =
   LinkStatus_INIT;
 
-struct AvFormatLib
+struct AvCodecLib
 {
   const char* Name;
   already_AddRefed<PlatformDecoderModule> (*Factory)();
   uint32_t Version;
 };
 
 template <int V> class FFmpegDecoderModule
 {
 public:
   static already_AddRefed<PlatformDecoderModule> Create();
 };
 
-static const AvFormatLib sLibs[] = {
-  { "libavformat-ffmpeg.so.56", FFmpegDecoderModule<55>::Create, 55 },
-  { "libavformat.so.56", FFmpegDecoderModule<55>::Create, 55 },
-  { "libavformat.so.55", FFmpegDecoderModule<55>::Create, 55 },
-  { "libavformat.so.54", FFmpegDecoderModule<54>::Create, 54 },
-  { "libavformat.so.53", FFmpegDecoderModule<53>::Create, 53 },
-  { "libavformat.56.dylib", FFmpegDecoderModule<55>::Create, 55 },
-  { "libavformat.55.dylib", FFmpegDecoderModule<55>::Create, 55 },
-  { "libavformat.54.dylib", FFmpegDecoderModule<54>::Create, 54 },
-  { "libavformat.53.dylib", FFmpegDecoderModule<53>::Create, 53 },
+static const AvCodecLib sLibs[] = {
+  { "libavcodec-ffmpeg.so.56", FFmpegDecoderModule<55>::Create, 55 },
+  { "libavcodec.so.56", FFmpegDecoderModule<55>::Create, 55 },
+  { "libavcodec.so.55", FFmpegDecoderModule<55>::Create, 55 },
+  { "libavcodec.so.54", FFmpegDecoderModule<54>::Create, 54 },
+  { "libavcodec.so.53", FFmpegDecoderModule<53>::Create, 53 },
+  { "libavcodec.56.dylib", FFmpegDecoderModule<55>::Create, 55 },
+  { "libavcodec.55.dylib", FFmpegDecoderModule<55>::Create, 55 },
+  { "libavcodec.54.dylib", FFmpegDecoderModule<54>::Create, 54 },
+  { "libavcodec.53.dylib", FFmpegDecoderModule<53>::Create, 53 },
 };
 
 void* FFmpegRuntimeLinker::sLinkedLib = nullptr;
-const AvFormatLib* FFmpegRuntimeLinker::sLib = nullptr;
+const AvCodecLib* FFmpegRuntimeLinker::sLib = nullptr;
 
 #define AV_FUNC(func, ver) void (*func)();
 #define LIBAVCODEC_ALLVERSION
 #include "FFmpegFunctionList.h"
 #undef LIBAVCODEC_ALLVERSION
 #undef AV_FUNC
 
 /* static */ bool
@@ -57,17 +57,17 @@ FFmpegRuntimeLinker::Link()
 {
   if (sLinkStatus) {
     return sLinkStatus == LinkStatus_SUCCEEDED;
   }
 
   MOZ_ASSERT(NS_IsMainThread());
 
   for (size_t i = 0; i < ArrayLength(sLibs); i++) {
-    const AvFormatLib* lib = &sLibs[i];
+    const AvCodecLib* lib = &sLibs[i];
     sLinkedLib = dlopen(lib->Name, RTLD_NOW | RTLD_LOCAL);
     if (sLinkedLib) {
       if (Bind(lib->Name, lib->Version)) {
         sLib = lib;
         sLinkStatus = LinkStatus_SUCCEEDED;
         return true;
       }
       // Shouldn't happen but if it does then we try the next lib..
--- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h
+++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h
@@ -8,28 +8,28 @@
 #define __FFmpegRuntimeLinker_h__
 
 #include "PlatformDecoderModule.h"
 #include <stdint.h>
 
 namespace mozilla
 {
 
-struct AvFormatLib;
+struct AvCodecLib;
 
 class FFmpegRuntimeLinker
 {
 public:
   static bool Link();
   static void Unlink();
   static already_AddRefed<PlatformDecoderModule> CreateDecoderModule();
 
 private:
   static void* sLinkedLib;
-  static const AvFormatLib* sLib;
+  static const AvCodecLib* sLib;
 
   static bool Bind(const char* aLibName, uint32_t Version);
 
   static enum LinkStatus {
     LinkStatus_INIT = 0,
     LinkStatus_FAILED,
     LinkStatus_SUCCEEDED
   } sLinkStatus;