OSDN Git Service

[BUILD] Set SOVERSION and GIT hash automatically.
[csp-qt/common_source_project-fm7.git] / source / src / qt / avio / sound_loader.h
1 /*
2  * Common Source Code Project for Qt : movie saver.
3  * (C) 2016 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4  *  License: GPLv2
5  *  History: Oct 02, 2016 : Initial. 
6  */
7
8 #ifndef _QT_OSD_SOUND_LOADER_H
9 #define _QT_OSD_SOUND_LOADER_H
10
11 #include <QString>
12
13 #if defined(USE_LIBAV)
14 extern "C" {
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"
24 }
25 #endif
26
27 #include "config.h"
28 class CSP_Logger;
29 class DLL_PREFIX SOUND_LOADER
30 {
31 private:
32         CSP_Logger *p_logger;
33 #if defined(USE_LIBAV)
34         AVFormatContext *fmt_ctx; // = NULL;
35         AVCodecContext *audio_dec_ctx;
36         AVStream *audio_stream; // NULL
37         
38         int audio_stream_idx; //int video_stream_idx = -1, audio_stream_idx = -1;
39         AVFrame *frame; //AVFrame *frame = NULL;
40         AVPacket pkt;
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);
45 #endif
46         int sound_rate;
47         bool _opened;
48 protected:
49         QString _filename;
50         int _dst_size;
51         int _dataptr;
52         int _data_size;
53         uint8_t* _data[4];
54         int16_t *sound_buffer;
55         
56         void *prev_loader;
57         int this_id;
58 public:
59         SOUND_LOADER(void *prev_sound_loader, CSP_Logger *logger);
60         ~SOUND_LOADER();
61         
62         bool open(int id, QString filename);
63         void close();
64         int do_decode_frames(void);
65
66         const int16_t *get_sound_buffer(void);
67         const int get_id(void);
68         void set_id(int id);
69         const void *get_prev_sound_loader(void);
70         const int get_dst_size(void);
71         void set_sound_rate(int rate);
72         
73         void free_sound_buffer(int16_t *p);
74 };
75 #endif