replace plugin icon data with CV ver for merge, replace manual.pdf
[goodguy/history.git] / cinelerra-5.0 / cinelerra / fileffmpeg.h
1 #ifndef __FILEFFMPEG_H__
2 #define __FILEFFMPEG_H__
3
4 #include "asset.inc" 
5 #include "bcwindowbase.inc"
6 #include "bcprogressbox.inc"
7 #include "bitspopup.inc" 
8 #include "filebase.h"
9 #include "fileffmpeg.inc"
10 #include "mutex.h"
11 #include "thread.h"
12 #include "vframe.inc"
13
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <unistd.h>
18 #include <string.h>
19
20 class FileFFMPEG;
21 class FFMpegConfigNum;
22 class FFMpegAudioNum;
23 class FFMpegVideoNum;
24 class FFOkButton;
25 class FFOptions;
26 class FFMPEGConfigAudio;
27 class FFAudioOptions;
28 class FFMPEGConfigAudioPopup;
29 class FFMPEGConfigAudioToggle;
30 class FFMPEGConfigVideo;
31 class FFVideoOptions;
32 class FFMPEGConfigVideoPopup;
33 class FFMPEGConfigVideoToggle;
34
35 class FileFFMPEG : public FileBase
36 {
37 public:
38         FFMPEG *ff;
39
40         FileFFMPEG(Asset *asset, File *file);
41         ~FileFFMPEG();
42         static void ff_lock(const char *cp=0);
43         static void ff_unlock();
44
45         static void get_parameters(BC_WindowBase *parent_window,Asset *asset,
46            BC_WindowBase *&format_window,int audio_options,int video_options);
47         static int check_sig(Asset *asset);
48         int get_video_info(int track, int &pid, double &framerate,
49                 int &width, int &height, char *title=0);
50         int get_audio_for_video(int vstream, int astream, int64_t &channel_mask);
51         static void get_info(char *path,char *text,int len);
52         int open_file(int rd,int wr);
53         int get_index(char *index_filename);
54         int close_file(void);
55         int set_video_position(int64_t pos);
56         int set_audio_position(int64_t pos);
57         int write_samples(double **buffer,int64_t len);
58         int write_frames(VFrame ***frames,int len);
59         int read_samples(double *buffer,int64_t len);
60         int read_frame(VFrame *frame);
61         int64_t get_memory_usage(void);
62         int colormodel_supported(int colormodel);
63         int get_best_colormodel(Asset *asset,int driver);
64         int select_video_stream(Asset *asset, int vstream);
65         int select_audio_stream(Asset *asset, int astream);
66 };
67
68 class FFMpegConfigNum : public BC_TumbleTextBox
69 {
70 public:
71         FFMpegConfigNum(BC_Window *window, int x, int y,
72                 char *title_text, int *output);
73         ~FFMpegConfigNum();
74
75         void create_objects();
76         int handle_event();
77         int *output;
78         BC_Window *window;
79         BC_Title *title;
80         char *title_text;
81         int x, y;
82 };
83
84 class FFMpegAudioNum : public FFMpegConfigNum
85 {
86 public:
87         FFMpegAudioNum(BC_Window *window, int x, int y, char *title_text, int *output);
88         ~FFMpegAudioNum() {}
89
90         FFMPEGConfigAudio *window() { return (FFMPEGConfigAudio *)FFMpegConfigNum::window; }
91 };
92
93 class FFMpegAudioBitrate : public FFMpegAudioNum
94 {
95 public:
96         FFMpegAudioBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
97           : FFMpegAudioNum(window, x, y, title_text, output) {}
98         int handle_event();
99 };
100
101 class FFMpegVideoNum : public FFMpegConfigNum
102 {
103 public:
104         FFMpegVideoNum(BC_Window *window, int x, int y, char *title_text, int *output);
105         ~FFMpegVideoNum() {}
106
107         FFMPEGConfigVideo *window() { return (FFMPEGConfigVideo *)FFMpegConfigNum::window; }
108 };
109
110 class FFMpegVideoBitrate : public FFMpegVideoNum
111 {
112 public:
113         FFMpegVideoBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
114           : FFMpegVideoNum(window, x, y, title_text, output) {}
115         int handle_event();
116 };
117
118 class FFMpegVideoQuality : public FFMpegVideoNum
119 {
120 public:
121         FFMpegVideoQuality(BC_Window *window, int x, int y, char *title_text, int *output)
122           : FFMpegVideoNum(window, x, y, title_text, output) {}
123         int handle_event();
124 };
125
126 class FFMPEGConfigAudio : public BC_Window
127 {
128 public:
129         FFMPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
130         ~FFMPEGConfigAudio();
131
132         void create_objects();
133         int close_event();
134
135         ArrayList<BC_ListBoxItem*> presets;
136         FFMPEGConfigAudioPopup *preset_popup;
137         FFMpegAudioBitrate *bitrate;
138         FFAudioOptions *audio_options;
139         BC_WindowBase *parent_window;
140         Asset *asset;
141 };
142
143 class FFAudioOptions : public BC_TextBox
144 {
145 public:
146         FFAudioOptions(FFMPEGConfigAudio *audio_popup,
147                 int x, int y, int w, int rows, int size, char *text);
148         int handle_event();
149
150         FFMPEGConfigAudio *audio_popup;
151 };
152
153
154 class FFMPEGConfigAudioPopup : public BC_PopupTextBox
155 {
156 public:
157         FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y);
158         int handle_event();
159         FFMPEGConfigAudio *popup;
160 };
161
162
163 class FFMPEGConfigAudioToggle : public BC_CheckBox
164 {
165 public:
166         FFMPEGConfigAudioToggle(FFMPEGConfigAudio *popup,
167                 char *title_text, int x, int y, int *output);
168         int handle_event();
169         int *output;
170         FFMPEGConfigAudio *popup;
171 };
172
173 class FFMPEGConfigVideo : public BC_Window
174 {
175 public:
176         FFMPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset);
177         ~FFMPEGConfigVideo();
178
179         void create_objects();
180         int close_event();
181
182         ArrayList<BC_ListBoxItem*> presets;
183         FFMPEGConfigVideoPopup *preset_popup;
184         BC_WindowBase *parent_window;
185         FFMpegVideoBitrate *bitrate;
186         FFMpegVideoQuality *quality;
187         FFVideoOptions *video_options;
188         Asset *asset;
189 };
190
191 class FFVideoOptions : public BC_TextBox
192 {
193 public:
194         FFVideoOptions(FFMPEGConfigVideo *video_popup,
195                 int x, int y, int w, int rows, int size, char *text);
196         int handle_event();
197
198         FFMPEGConfigVideo *video_popup;
199 };
200
201 class FFMPEGConfigVideoPopup : public BC_PopupTextBox
202 {
203 public:
204         FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y);
205         int handle_event();
206         FFMPEGConfigVideo *popup;
207 };
208
209 class FFMPEGConfigVideoToggle : public BC_CheckBox
210 {
211 public:
212         FFMPEGConfigVideoToggle(FFMPEGConfigVideo *popup,
213                 char *title_text, int x, int y, int *output);
214         int handle_event();
215         int *output;
216         FFMPEGConfigVideo *popup;
217 };
218
219 class FFMPEGScanProgress : public Thread
220 {
221 public:
222         char progress_title[BCTEXTLEN];
223         BC_ProgressBox *progress;
224         int64_t length, *position;
225         int done, *canceled;
226
227         FFMPEGScanProgress(const char *title, int64_t length, int64_t *position, int *canceled);
228         ~FFMPEGScanProgress();
229         void run();
230 };
231
232 #endif