|
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 #include "FFmpegRuntimeLinker.h" |
|
8 #include "FFmpegAACDecoder.h" |
|
9 #include "FFmpegH264Decoder.h" |
|
10 |
|
11 #include "FFmpegDecoderModule.h" |
|
12 |
|
13 namespace mozilla |
|
14 { |
|
15 |
|
16 PRLogModuleInfo* GetFFmpegDecoderLog() |
|
17 { |
|
18 static PRLogModuleInfo* sFFmpegDecoderLog = nullptr; |
|
19 if (!sFFmpegDecoderLog) { |
|
20 sFFmpegDecoderLog = PR_NewLogModule("FFmpegDecoderModule"); |
|
21 } |
|
22 return sFFmpegDecoderLog; |
|
23 } |
|
24 |
|
25 bool FFmpegDecoderModule::sFFmpegLinkDone = false; |
|
26 |
|
27 FFmpegDecoderModule::FFmpegDecoderModule() |
|
28 { |
|
29 MOZ_COUNT_CTOR(FFmpegDecoderModule); |
|
30 } |
|
31 |
|
32 FFmpegDecoderModule::~FFmpegDecoderModule() { |
|
33 MOZ_COUNT_DTOR(FFmpegDecoderModule); |
|
34 } |
|
35 |
|
36 bool |
|
37 FFmpegDecoderModule::Link() |
|
38 { |
|
39 if (sFFmpegLinkDone) { |
|
40 return true; |
|
41 } |
|
42 |
|
43 if (!FFmpegRuntimeLinker::Link()) { |
|
44 NS_WARNING("Failed to link FFmpeg shared libraries."); |
|
45 return false; |
|
46 } |
|
47 |
|
48 sFFmpegLinkDone = true; |
|
49 |
|
50 return true; |
|
51 } |
|
52 |
|
53 nsresult |
|
54 FFmpegDecoderModule::Shutdown() |
|
55 { |
|
56 // Nothing to do here. |
|
57 return NS_OK; |
|
58 } |
|
59 |
|
60 MediaDataDecoder* |
|
61 FFmpegDecoderModule::CreateH264Decoder( |
|
62 const mp4_demuxer::VideoDecoderConfig& aConfig, |
|
63 mozilla::layers::LayersBackend aLayersBackend, |
|
64 mozilla::layers::ImageContainer* aImageContainer, |
|
65 MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback) |
|
66 { |
|
67 FFMPEG_LOG("Creating FFmpeg H264 decoder."); |
|
68 return new FFmpegH264Decoder(aVideoTaskQueue, aCallback, aConfig, |
|
69 aImageContainer); |
|
70 } |
|
71 |
|
72 MediaDataDecoder* |
|
73 FFmpegDecoderModule::CreateAACDecoder( |
|
74 const mp4_demuxer::AudioDecoderConfig& aConfig, |
|
75 MediaTaskQueue* aAudioTaskQueue, MediaDataDecoderCallback* aCallback) |
|
76 { |
|
77 FFMPEG_LOG("Creating FFmpeg AAC decoder."); |
|
78 return new FFmpegAACDecoder(aAudioTaskQueue, aCallback, aConfig); |
|
79 } |
|
80 |
|
81 } // namespace mozilla |