• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FFMPEG_FFMPEGEXTRACTOR_H
18 #define FFMPEG_FFMPEGEXTRACTOR_H
19 
20 
21 extern "C" {
22 #include <libavformat/avformat.h>
23 #include <libswresample/swresample.h>
24 #include <libavutil/opt.h>
25 }
26 
27 #include <cstdint>
28 #include <android/asset_manager.h>
29 #include <GameConstants.h>
30 
31 class FFMpegExtractor {
32 public:
33     static int64_t decode(AAsset *asset, uint8_t *targetData, AudioProperties targetProperties);
34 
35 private:
36     static bool createAVIOContext(AAsset *asset, uint8_t *buffer, uint32_t bufferSize,
37                                   AVIOContext **avioContext);
38 
39     static bool createAVFormatContext(AVIOContext *avioContext, AVFormatContext **avFormatContext);
40 
41     static bool openAVFormatContext(AVFormatContext *avFormatContext);
42 
43     static int32_t cleanup(AVIOContext *avioContext, AVFormatContext *avFormatContext);
44 
45     static bool getStreamInfo(AVFormatContext *avFormatContext);
46 
47     static AVStream *getBestAudioStream(AVFormatContext *avFormatContext);
48 
49     static AVCodec *findCodec(AVCodecID id);
50 
51     static void printCodecParameters(AVCodecParameters *params);
52 };
53 
54 
55 #endif //FFMPEG_FFMPEGEXTRACTOR_H
56