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
00023
00024
00025
00026
00027
00028 class File
00029 {
00030 public:
00031 File();
00032 ~File();
00033
00034
00035
00036 int get_options(FormatTools *format,
00037 int audio_options,
00038 int video_options,
00039 int lock_compressor);
00040
00041 int raise_window();
00042
00043 void close_window();
00044
00045
00046 int set_processors(int cpus);
00047 int set_preload(int64_t size);
00048
00049 void set_asset(Asset *asset);
00050
00051
00052
00053
00054 void set_cache_frames(int value);
00055
00056
00057 int purge_cache();
00058
00059
00060 int open_file(Preferences *preferences,
00061 Asset *asset,
00062 int rd,
00063 int wr,
00064 int64_t base_samplerate,
00065 float base_framerate);
00066
00067
00068 int get_index(char *index_path);
00069
00070
00071 int start_audio_thread(int64_t buffer_size, int ring_buffers);
00072 int stop_audio_thread();
00073
00074
00075
00076
00077
00078
00079 int start_video_thread(int64_t buffer_size,
00080 int color_model,
00081 int ring_buffers,
00082 int compressed);
00083 int stop_video_thread();
00084 int lock_read();
00085 int unlock_read();
00086
00087
00088
00089 int close_file(int ignore_thread = 0);
00090
00091
00092 int set_channel(int channel);
00093
00094
00095 int set_layer(int layer);
00096
00097
00098 int64_t get_audio_length(int64_t base_samplerate = -1);
00099 int64_t get_video_length(float base_framerate = -1);
00100
00101
00102 int64_t get_audio_position(int64_t base_samplerate = -1);
00103 int64_t get_video_position(float base_framerate = -1);
00104
00105
00106
00107 int set_audio_position(int64_t position, float base_samplerate);
00108
00109 int set_video_position(int64_t position, float base_framerate);
00110
00111
00112
00113
00114
00115 int write_samples(double **buffer, int64_t len);
00116
00117
00118 int write_frames(VFrame ***frames, int len);
00119
00120
00121
00122 double** get_audio_buffer();
00123 VFrame*** get_video_buffer();
00124
00125
00126 FrameCache* get_frame_cache();
00127
00128
00129
00130 int write_audio_buffer(int64_t len);
00131 int write_video_buffer(int64_t len);
00132
00133
00134
00135
00136
00137
00138 int read_samples(double *buffer, int64_t len, int64_t base_samplerate, float *buffer_float = 0);
00139
00140
00141
00142 int File::read_frame(VFrame *frame);
00143
00144
00145
00146
00147 int can_copy_from(Edit *edit, int64_t position, int output_w, int output_h);
00148 int get_render_strategy(ArrayList<int>* render_strategies);
00149 int64_t compressed_frame_size();
00150 int read_compressed_frame(VFrame *buffer);
00151 int write_compressed_frame(VFrame *buffer);
00152
00153
00154
00155
00156 int get_best_colormodel(int driver);
00157 static int get_best_colormodel(Asset *asset, int driver);
00158
00159
00160 int colormodel_supported(int colormodel);
00161
00162
00163
00164
00165
00166 int get_memory_usage();
00167
00168 static int supports_video(ArrayList<PluginServer*> *plugindb, char *format);
00169 static int supports_audio(ArrayList<PluginServer*> *plugindb, char *format);
00170 static int supports_video(int format);
00171 static int supports_audio(int format);
00172 static int strtoformat(char *format);
00173 static char* formattostr(int format);
00174 static int strtoformat(ArrayList<PluginServer*> *plugindb, char *format);
00175 static char* formattostr(ArrayList<PluginServer*> *plugindb, int format);
00176 static int strtobits(char *bits);
00177 static char* bitstostr(int bits);
00178 static int str_to_byteorder(char *string);
00179 static char* byteorder_to_str(int byte_order);
00180 int bytes_per_sample(int bits);
00181
00182 Asset *asset;
00183 FileBase *file;
00184
00185 FileThread *audio_thread, *video_thread;
00186
00187
00188 VFrame *temp_frame;
00189
00190
00191 Resample *resample;
00192 Resample_float *resample_float;
00193
00194
00195
00196 Condition *write_lock;
00197 int cpus;
00198 int64_t playback_preload;
00199
00200
00201
00202
00203
00204 int64_t current_sample;
00205 int64_t current_frame;
00206 int current_channel;
00207 int current_layer;
00208
00209
00210 int64_t normalized_sample;
00211 int64_t normalized_sample_rate;
00212 Preferences *preferences;
00213
00214
00215 private:
00216 void reset_parameters();
00217
00218 int getting_options;
00219 BC_WindowBase *format_window;
00220 Mutex *format_completion;
00221 FrameCache *frame_cache;
00222
00223 int use_cache;
00224 };
00225
00226 #endif