r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / videooutprefs.C
blob8f670b21e3986d83d332ee13d4b5a01f5f2ca21c
1 #include "vdeviceprefs.h"
2 #include "videodevice.inc"
3 #include "defaults.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "mwindow.h"
7 #include "videooutprefs.h"
8 #include "preferences.h"
10 #include <string.h>
11 #include <libintl.h>
12 #define _(String) gettext(String)
13 #define gettext_noop(String) String
14 #define N_(String) gettext_noop (String)
16 VideoOutPrefs::VideoOutPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
17  : PreferencesDialog(mwindow, pwindow)
19         head_text = 0;
20         head_count_text = 0;
21         host_text = 0;
22         video_device = 0;
25 VideoOutPrefs::~VideoOutPrefs()
27         delete_strategy();
28         mwindow->defaults->update("PLAYBACK_HEAD", current_head);
29         delete video_device;
32 int VideoOutPrefs::create_objects()
34         int x = 5, y = 5;
35         char string[1024];
36         BC_PopupTextBox *popup;
38 //printf("VideoOutPrefs::create_objects 1\n");
39         current_head = mwindow->defaults->get("PLAYBACK_HEAD", 0);
40         strategies.append(new BC_ListBoxItem(_("Local Host")));
41         strategies.append(new BC_ListBoxItem(_("Multihead")));
42         strategies.append(new BC_ListBoxItem(_("Blond Symphony")));
44 //      add_subwindow(new BC_Title(x, y, _("Playback"), LARGEFONT, BLACK));
45 //      x += 200;
46 //      add_subwindow(new BC_Title(x, y, _("Strategy:")));
47 //      popup = new PlaybackStrategy(this, x + 70, y);
48 //      popup->create_objects();
49 //      x = 10;
50 //      y += popup->get_h() + 30;
52 // Global playback options
54 // All strategies use these
55         add_subwindow(new BC_Title(x, y, _("Video"), LARGEFONT, BLACK));
56         y += 30;
58         add_subwindow(new BC_Title(x, y, _("Framerate achieved:")));
59         add_subwindow(framerate_title = new BC_Title(x + 200, y, _("--"), RED));
60         y += 30;
62         add_subwindow(new VideoEveryFrame(pwindow, x, y));
63         y += 35;
64         add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
65         y += 20;
66         add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow, 
67                 this, 
68                 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR, 
69                 x, 
70                 y));
71         y += 20;
72         add_subwindow(bicubic = new PlaybackBicubic(pwindow, 
73                 this, 
74                 pwindow->thread->edl->session->interpolation_type == CUBIC_INTERPOLATE, 
75                 x, 
76                 y));
78         y += 35;
79         add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT, BLACK));
80         sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
81         add_subwindow(new PlaybackPreload(x + 210, y, pwindow, this, string));
82         y += 35;
84 // Strategic playback options created here
85         set_strategy(pwindow->thread->edl->session->playback_strategy, y);
86 // 
87 //      add_subwindow(new BC_Title(x, y, _("Playback driver:"), MEDIUMFONT, BLACK));
88 //      add_subwindow(new AudioDriverMenu(x, y + 20, out_device, &(pwindow->thread->preferences->aconfig->audio_out_driver), 0, 1));
89 //      y += 70;
90 // 
91         return 0;
94 void VideoOutPrefs::update(int interpolation)
96         pwindow->thread->edl->session->interpolation_type = interpolation;
97         nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
98         bicubic->update(interpolation == CUBIC_INTERPOLATE);
101 char* VideoOutPrefs::strategy_to_string(int strategy)
103         switch(strategy)
104         {
105                 case PLAYBACK_LOCALHOST:
106                         return _("Local Host");
107                         break;
108                 case PLAYBACK_MULTIHEAD:
109                         return _("Multihead");
110                         break;
111                 case PLAYBACK_BLONDSYMPHONY:
112                         return _("Blond Symphony");
113                         break;
114         }
115         return _("Local Host");
118 // Delete strategy dependant objects
119 void VideoOutPrefs::delete_strategy()
121         if(head_text) 
122         {
123 //              delete head_text;
124                 delete head_title;
125                 head_text = 0;
126         }
127         if(host_text)
128         {
129                 delete host_title;
130 //              delete host_text;
131                 host_text = 0;
132         }
133         if(head_count_text)
134         {
135                 delete head_count_title;
136 //              delete head_count_text;
137                 head_count_text = 0;
138         }
139         if(video_device)
140         {
141                 delete vdevice_title;
142                 delete video_device;
143                 video_device = 0;
144         }
147 int VideoOutPrefs::set_strategy(int strategy, int y)
149         int x = 5, x1 = 450;
150         delete_strategy();
152         pwindow->thread->edl->session->playback_strategy = strategy;
153         switch(strategy)
154         {
155                 case PLAYBACK_LOCALHOST:
156                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
157                         video_device = new VDevicePrefs(x + 100, 
158                                 y, 
159                                 pwindow, 
160                                 this, 
161                                 current_config()->vconfig, 
162                                 0,
163                                 MODEPLAY);
164                         video_device->initialize();
165                         break;
166                 case PLAYBACK_MULTIHEAD:
167                         add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
168 //                      head_text = new PlaybackHead(this, x1, y);
169 //                      head_text->create_objects();
170                         y += 25;
171 //                      add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
172 //                      head_count_text = new PlaybackHeadCount(this, x1, y);
173 //                      head_count_text->create_objects();
174                         x = 10;
175                         y = 390;
176                         break;
177                 case PLAYBACK_BLONDSYMPHONY:
178                         add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
179 //                      head_text = new PlaybackHead(this, x1, y);
180 //                      head_text->create_objects();
181                         y += 25;
182 //                      add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
183 //                      head_count_text = new PlaybackHeadCount(this, x1, y);
184 //                      head_count_text->create_objects();
185                         y += 25;
186 //                      add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
187 //                      add_subwindow(host_text = new PlaybackHost(this, x1, y));
188                         x = 10;
189                         y = 390;
190                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
191                         video_device = new VDevicePrefs(x + 100, 
192                                 y, 
193                                 pwindow, 
194                                 this, 
195                                 current_config()->vconfig, 
196                                 0,
197                                 MODEPLAY);
198                         video_device->initialize();
199                         break;
200         }
201         
202         return 1;
205 ArrayList<PlaybackConfig*>* VideoOutPrefs::current_config_list()
207         return &pwindow->thread->edl->session->playback_config[pwindow->thread->edl->session->playback_strategy];
210 PlaybackConfig* VideoOutPrefs::current_config()
212         return current_config_list()->values[current_head];
217 int VideoOutPrefs::get_buffer_bytes()
219 //      return pwindow->thread->edl->session->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
223 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, VideoOutPrefs *prefs, int value, int x, int y)
224  : BC_Radial(x, y, value, _("Nearest neighbor"))
226         this->pwindow = pwindow;
227         this->prefs = prefs;
229 int PlaybackNearest::handle_event()
231         prefs->update(NEAREST_NEIGHBOR);
232         return 1;
239 PlaybackBicubic::PlaybackBicubic(PreferencesWindow *pwindow, VideoOutPrefs *prefs, int value, int x, int y)
240  : BC_Radial(x, y, value, _("Bicubic"))
242         this->pwindow = pwindow;
243         this->prefs = prefs;
245 int PlaybackBicubic::handle_event()
247         prefs->update(CUBIC_INTERPOLATE);
248         return 1;
253 PlaybackPreload::PlaybackPreload(int x, 
254         int y, 
255         PreferencesWindow *pwindow, 
256         VideoOutPrefs *playback, 
257         char *text)
258  : BC_TextBox(x, y, 100, 1, text)
260         this->pwindow = pwindow; 
261         this->playback = playback; 
264 int PlaybackPreload::handle_event() 
266         pwindow->thread->edl->session->playback_preload = atol(get_text()); 
267         return 1;
272 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow, int x, int y)
273  : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
275         this->pwindow = pwindow;
278 VideoEveryFrame::~VideoEveryFrame()
282 int VideoEveryFrame::handle_event()
284         pwindow->thread->edl->session->video_every_frame = get_value();
285         return 1;