FFVPXRuntimeLinker.h (1416B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef __FFVPXRuntimeLinker_h__ 8 #define __FFVPXRuntimeLinker_h__ 9 10 #include "PlatformDecoderModule.h" 11 #include "PlatformEncoderModule.h" 12 #include "ffvpx/tx.h" 13 #include "mozilla/StaticMutex.h" 14 #include "mozilla/ThreadSafety.h" 15 16 struct FFmpegFFTFuncs { 17 decltype(av_tx_init)* init; 18 decltype(av_tx_uninit)* uninit; 19 }; 20 21 namespace mozilla { 22 23 class FFVPXRuntimeLinker { 24 public: 25 static bool Init() MOZ_EXCLUDES(sMutex); 26 static already_AddRefed<PlatformDecoderModule> CreateDecoder(); 27 static already_AddRefed<PlatformEncoderModule> CreateEncoder(); 28 29 // Call (on any thread) after Init(). 30 static void GetFFTFuncs(FFmpegFFTFuncs* aOutFuncs); 31 32 private: 33 static void PrefCallbackLogLevel(const char* aPref, void* aData); 34 35 // Provide critical-section for Init() and sLinkStatus. 36 static StaticMutex sMutex; 37 38 // Set once on the main thread and then read from other threads. 39 static enum LinkStatus { 40 LinkStatus_INIT = 0, 41 LinkStatus_FAILED, 42 LinkStatus_SUCCEEDED 43 } sLinkStatus MOZ_GUARDED_BY(sMutex); 44 }; 45 46 } // namespace mozilla 47 48 #endif /* __FFVPXRuntimeLinker_h__ */