2 * Common Source Code Project for Qt : movie saver.
3 * (C) 2016 K.Ohta <whatisthis.sowhat _at_ gmail.com>
5 * History: Oct 02, 2016 : Initial.
8 #ifndef _QT_OSD_SOUND_LOADER_H
9 #define _QT_OSD_SOUND_LOADER_H
13 #if defined(USE_LIBAV)
15 #include "libavutil/channel_layout.h"
16 #include "libavutil/opt.h"
17 #include "libavutil/mathematics.h"
18 #include "libavutil/timestamp.h"
19 #include "libavutil/imgutils.h"
20 #include "libavutil/samplefmt.h"
21 #include "libavformat/avformat.h"
22 #include "libswscale/swscale.h"
23 #include "libswresample/swresample.h"
29 class DLL_PREFIX SOUND_LOADER
33 #if defined(USE_LIBAV)
34 AVFormatContext *fmt_ctx; // = NULL;
35 AVCodecContext *audio_dec_ctx;
36 AVStream *audio_stream; // NULL
38 int audio_stream_idx; //int video_stream_idx = -1, audio_stream_idx = -1;
39 AVFrame *frame; //AVFrame *frame = NULL;
41 struct SwrContext *swr_context;
42 int get_format_from_sample_fmt(const char **fmt, enum AVSampleFormat sample_fmt);
43 int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type);
44 int decode_packet(int *got_frame, int cached);
54 int16_t *sound_buffer;
59 SOUND_LOADER(void *prev_sound_loader, CSP_Logger *logger);
62 bool open(int id, QString filename);
64 int do_decode_frames(void);
66 const int16_t *get_sound_buffer(void);
67 const int get_id(void);
69 const void *get_prev_sound_loader(void);
70 const int get_dst_size(void);
71 void set_sound_rate(int rate);
73 void free_sound_buffer(int16_t *p);