00001 #ifndef FILE_H
00002 #define FILE_H
00003
00004 #include <stdlib.h>
00005
00006 #include "asset.inc"
00007 #include "condition.inc"
00008 #include "edit.inc"
00009 #include "filebase.inc"
00010 #include "file.inc"
00011 #include "filethread.inc"
00012 #include "filexml.inc"
00013 #include "formatwindow.inc"
00014 #include "formattools.h"
00015 #include "framecache.inc"
00016 #include "guicast.h"
00017 #include "mutex.inc"
00018 #include "pluginserver.inc"
00019 #include "preferences.inc"
00020 #include "resample.inc"
00021 #include "vframe.inc"
00022 #include "packagingengine.h"
00023
00024
00025
00026
00027
00028
00029 class File
00030 {
00031 public:
00032 File();
00033 ~File();
00034
00035
00036
00037 int get_options(FormatTools *format,
00038 int audio_options,
00039 int video_options);
00040
00041 int raise_window();
00042
00043 void close_window();
00044
00045
00046 int set_processors(int cpus);
00047
00048 int set_preload(int64_t size);
00049
00050 void set_subtitle(int value);
00051
00052 void set_interpolate_raw(int value);
00053
00054 void set_white_balance_raw(int value);
00055
00056 void set_asset(Asset *asset);
00057
00058
00059
00060
00061 void set_cache_frames(int value);
00062
00063
00064 int purge_cache();
00065
00066
00067 int open_file(Preferences *preferences,
00068 Asset *asset,
00069 int rd,
00070 int wr,
00071 int64_t base_samplerate,
00072 float base_framerate);
00073
00074
00075 int get_index(char *index_path);
00076
00077
00078 int start_audio_thread(int64_t buffer_size, int ring_buffers);
00079 int stop_audio_thread();
00080
00081
00082
00083
00084
00085
00086 int start_video_thread(int64_t buffer_size,
00087 int color_model,
00088 int ring_buffers,
00089 int compressed);
00090 int stop_video_thread();
00091
00092 int start_video_decode_thread();
00093
00094
00095
00096 FileThread* get_video_thread();
00097
00098
00099
00100 int close_file(int ignore_thread = 0);
00101
00102
00103 int64_t get_audio_length(int64_t base_samplerate = -1);
00104 int64_t get_video_length(float base_framerate = -1);
00105
00106
00107 int64_t get_audio_position(int64_t base_samplerate = -1);
00108 int64_t get_video_position(float base_framerate = -1);
00109
00110
00111
00112
00113
00114
00115
00116 int write_samples(double **buffer, int64_t len);
00117
00118
00119 int write_frames(VFrame ***frames, int len);
00120
00121
00122
00123
00124
00125 double** get_audio_buffer();
00126 VFrame*** get_video_buffer();
00127
00128
00129 FrameCache* get_frame_cache();
00130
00131
00132
00133 int write_audio_buffer(int64_t len);
00134 int write_video_buffer(int64_t len);
00135
00136
00137
00138
00139
00140 int set_channel(int channel);
00141
00142 int set_audio_position(int64_t position, float base_samplerate);
00143
00144
00145
00146
00147
00148
00149 int read_samples(double *buffer, int64_t len, int64_t base_samplerate, float *buffer_float = 0);
00150
00151
00152
00153
00154 int set_layer(int layer, int is_thread = 0);
00155
00156
00157 int set_video_position(int64_t position, float base_framerate = -1, int is_thread = 0);
00158
00159
00160
00161 int read_frame(VFrame *frame, int is_thread = 0);
00162
00163
00164
00165
00166 int can_copy_from(Edit *edit, int64_t position, int output_w, int output_h);
00167 int get_render_strategy(ArrayList<int>* render_strategies);
00168 int64_t compressed_frame_size();
00169 int read_compressed_frame(VFrame *buffer);
00170 int write_compressed_frame(VFrame *buffer);
00171
00172
00173
00174
00175
00176 int get_best_colormodel(int driver);
00177
00178
00179 static int get_best_colormodel(Asset *asset, int driver);
00180
00181
00182 int colormodel_supported(int colormodel);
00183
00184
00185
00186
00187
00188 int64_t get_memory_usage();
00189
00190 static int supports_video(ArrayList<PluginServer*> *plugindb, char *format);
00191 static int supports_audio(ArrayList<PluginServer*> *plugindb, char *format);
00192
00193 static char* get_tag(int format);
00194 static int supports_video(int format);
00195 static int supports_audio(int format);
00196 static int strtoformat(char *format);
00197 static char* formattostr(int format);
00198 static int strtoformat(ArrayList<PluginServer*> *plugindb, char *format);
00199 static char* formattostr(ArrayList<PluginServer*> *plugindb, int format);
00200 static int strtobits(char *bits);
00201 static char* bitstostr(int bits);
00202 static int str_to_byteorder(char *string);
00203 static char* byteorder_to_str(int byte_order);
00204 int bytes_per_sample(int bits);
00205
00206 Asset *asset;
00207 FileBase *file;
00208
00209 FileThread *audio_thread, *video_thread;
00210
00211
00212 VFrame *temp_frame;
00213
00214
00215 Resample *resample;
00216 Resample_float *resample_float;
00217
00218
00219
00220 Condition *write_lock;
00221 int cpus;
00222 int64_t playback_preload;
00223 int playback_subtitle;
00224 int interpolate_raw;
00225 int white_balance_raw;
00226
00227
00228
00229
00230
00231 int64_t current_sample;
00232 int64_t current_frame;
00233 int current_channel;
00234 int current_layer;
00235
00236
00237 int64_t normalized_sample;
00238 int64_t normalized_sample_rate;
00239 Preferences *preferences;
00240
00241 static PackagingEngine *new_packaging_engine(Asset *asset);
00242
00243 private:
00244 void reset_parameters();
00245
00246 int getting_options;
00247 BC_WindowBase *format_window;
00248 Mutex *format_completion;
00249 FrameCache *frame_cache;
00250
00251 int use_cache;
00252 };
00253
00254 #endif