2 * Copyright 2012 Michael Chen <omxcodec@gmail.com>
3 * Copyright 2015 The CyanogenMod Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef FFMPEG_UTILS_H_
20 #define FFMPEG_UTILS_H_
25 #include <utils/Condition.h>
26 #include <utils/Errors.h>
27 #include <utils/Mutex.h>
34 #include "libavformat/avformat.h"
35 #include "libavcodec/avcodec.h"
37 #include "libavutil/avstring.h"
38 #include "libavutil/colorspace.h"
39 #include "libavutil/mathematics.h"
40 #include "libavutil/pixdesc.h"
41 #include "libavutil/imgutils.h"
42 #include "libavutil/dict.h"
43 #include "libavutil/parseutils.h"
44 #include "libavutil/samplefmt.h"
45 #include "libavutil/avassert.h"
46 #include "libavformat/avformat.h"
47 #include "libavdevice/avdevice.h"
48 #include "libswscale/swscale.h"
49 #include "libavutil/opt.h"
50 #include "libavutil/internal.h"
51 #include "libavcodec/avfft.h"
52 #include "libavcodec/xiph.h"
53 #include "libswresample/swresample.h"
55 #include <system/audio.h>
62 #define SF_NOPTS_VALUE ((uint64_t)AV_NOPTS_VALUE-1)
66 //////////////////////////////////////////////////////////////////////////////////
68 //////////////////////////////////////////////////////////////////////////////////
69 void nam_av_log_callback(void* ptr, int level, const char* fmt, va_list vl);
70 void nam_av_log_set_flags(int arg);
72 //////////////////////////////////////////////////////////////////////////////////
73 // constructor and destructor
74 //////////////////////////////////////////////////////////////////////////////////
75 status_t initFFmpeg();
78 //////////////////////////////////////////////////////////////////////////////////
80 //////////////////////////////////////////////////////////////////////////////////
81 int is_extradata_compatible_with_android(AVCodecContext *avctx);
82 int parser_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
84 //////////////////////////////////////////////////////////////////////////////////
86 //////////////////////////////////////////////////////////////////////////////////
88 typedef struct PacketQueue {
90 AVPacketList *first_pkt, *last_pkt;
99 void packet_queue_init(PacketQueue *q);
100 void packet_queue_destroy(PacketQueue *q);
101 void packet_queue_flush(PacketQueue *q);
102 void packet_queue_start(PacketQueue *q);
103 void packet_queue_abort(PacketQueue *q);
104 int packet_queue_is_wait_for_data(PacketQueue *q);
105 int packet_queue_put(PacketQueue *q, AVPacket *pkt);
106 int packet_queue_put_nullpacket(PacketQueue *q, int stream_index);
107 int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block);
109 //////////////////////////////////////////////////////////////////////////////////
111 //////////////////////////////////////////////////////////////////////////////////
112 bool setup_vorbis_extradata(uint8_t **extradata, int *extradata_size,
113 const uint8_t *header_start[3], const int header_len[3]);
115 int64_t get_timestamp(void);
117 audio_format_t to_android_audio_format(enum AVSampleFormat fmt);
119 } // namespace android
121 #endif // FFMPEG_UTILS_H_