initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / indexfile.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef INDEXFILE_H
23 #define INDEXFILE_H
24
25 #include "cache.inc"
26 #include "edit.inc"
27 #include "file.inc"
28 #include "guicast.h"
29 #include "indexable.inc"
30 #include "indexstate.inc"
31 #include "indexthread.inc"
32 #include "mainprogress.inc"
33 #include "mwindow.inc"
34 #include "preferences.inc"
35 #include "renderengine.inc"
36 #include "resourcepixmap.inc"
37 #include "samples.inc"
38 #include "trackcanvas.inc"
39 #include "bctimer.inc"
40 #include "tracks.inc"
41
42
43
44 class IndexFile
45 {
46 public:
47         IndexFile(MWindow *mwindow);
48         IndexFile(MWindow *mwindow, Indexable *indexable);
49         ~IndexFile();
50
51         void reset();
52
53 // Get the index state object from the asset or the nested EDL
54         IndexState* get_state();
55         static const char* get_source_path(Indexable *indexable);
56
57         int open_index();
58         int create_index(MainProgressBar *progress);
59         int interrupt_index();
60         static void delete_index(Preferences *preferences, 
61                 Indexable *indexable, const char *suffix=0);
62         static int get_index_filename(char *source_filename,
63                 char *index_directory,
64                 char *index_filename,
65                 const char *input_filename,
66                 const char *suffix=0);
67         void update_edl_asset();
68         int redraw_edits(int force);
69         int draw_index(TrackCanvas *canvas,
70                 ResourcePixmap *pixmap, 
71                 Edit *edit, 
72                 int x, 
73                 int w);
74         int close_index();
75         int remove_index();
76         int read_info(Indexable *indexable = 0);
77         int write_info();
78
79         MWindow *mwindow;
80         char index_filename[BCTEXTLEN], source_filename[BCTEXTLEN];
81 // Object to create an index for
82         Indexable *indexable;
83         Timer *redraw_timer;
84
85         void update_mainasset();
86
87         int open_file();
88         int open_source();
89         void close_source();
90         int64_t get_required_scale();
91 // File descriptor for index file.
92         FILE *fd;
93 // File object for source if an asset
94         File *source;
95 // Render engine for source if the source is a nested EDL
96         RenderEngine *render_engine;
97 // Audio cache for render engine
98         CICache *cache;
99 // Number of samples in source.  Calculated in open_source.
100         int64_t source_length;
101 // Number of channels in source.  Calculated in open_source.
102         int source_channels;
103         int source_samplerate;
104         int64_t file_length;   // Length of index file in bytes
105         int interrupt_flag;    // Flag set when index building is interrupted
106 };
107
108 #endif