Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

playbackprefs.C

Go to the documentation of this file.
00001 #include "adeviceprefs.h"
00002 #include "audioconfig.h"
00003 #include "audiodevice.inc"
00004 #include "clip.h"
00005 #include "defaults.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "language.h"
00009 #include "mwindow.h"
00010 #include "overlayframe.inc"
00011 #include "playbackprefs.h"
00012 #include "preferences.h"
00013 #include "theme.h"
00014 #include "vdeviceprefs.h"
00015 #include "videodevice.inc"
00016 
00017 
00018 
00019 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
00020  : PreferencesDialog(mwindow, pwindow)
00021 {
00022         video_device = 0;
00023 }
00024 
00025 PlaybackPrefs::~PlaybackPrefs()
00026 {
00027         delete audio_device;
00028         delete video_device;
00029 }
00030 
00031 int PlaybackPrefs::create_objects()
00032 {
00033         int x, y, x2;
00034         char string[BCTEXTLEN];
00035         BC_PopupTextBox *popup;
00036         BC_Resources *resources = BC_WindowBase::get_resources();
00037 
00038         playback_config = pwindow->thread->edl->session->playback_config;
00039 
00040 // Audio
00041         add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, 
00042                 mwindow->theme->preferencestitle_y, 
00043                 _("Audio Out"), 
00044                 LARGEFONT, 
00045                 resources->text_default));
00046         x = mwindow->theme->preferencesoptions_x;
00047         y = mwindow->theme->preferencesoptions_y;
00048 
00049 
00050 
00051         BC_Title *title1, *title2;
00052         add_subwindow(title2 = new BC_Title(x, y, _("Samples to send to console at a time:"), MEDIUMFONT, resources->text_default));
00053         x2 = MAX(title2->get_w(), title2->get_w()) + 10;
00054 
00055         sprintf(string, "%d", playback_config->aconfig->fragment_size);
00056         PlaybackModuleFragment *menu;
00057         add_subwindow(menu = new PlaybackModuleFragment(x2, 
00058                 y, 
00059                 pwindow, 
00060                 this, 
00061                 string));
00062         menu->add_item(new BC_MenuItem("2048"));
00063         menu->add_item(new BC_MenuItem("4096"));
00064         menu->add_item(new BC_MenuItem("8192"));
00065         menu->add_item(new BC_MenuItem("16384"));
00066         menu->add_item(new BC_MenuItem("32768"));
00067         menu->add_item(new BC_MenuItem("65536"));
00068         menu->add_item(new BC_MenuItem("131072"));
00069         menu->add_item(new BC_MenuItem("262144"));
00070 
00071         y += menu->get_h() + 5;
00072         x2 = x;
00073         add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
00074         x2 += title1->get_w() + 5;
00075         PlaybackAudioOffset *audio_offset = new PlaybackAudioOffset(pwindow,
00076                 this,
00077                 x2,
00078                 y);
00079         audio_offset->create_objects();
00080         y += audio_offset->get_h() + 5;
00081 
00082         add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
00083         y += 30;
00084         add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
00085         y += 30;
00086         add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
00087         y += 40;
00088         add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
00089         audio_device = new ADevicePrefs(x + 100, 
00090                 y, 
00091                 pwindow, 
00092                 this, 
00093                 playback_config->aconfig, 
00094                 0,
00095                 MODEPLAY);
00096         audio_device->initialize();
00097 
00098 
00099 
00100 
00101 // Video
00102         y += audio_device->get_h();
00103 
00104         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
00105         y += 5;
00106 
00107         add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT, resources->text_default));
00108         y += 30;
00109 
00110         add_subwindow(new VideoEveryFrame(pwindow, x, y));
00111 
00112         add_subwindow(new BC_Title(x + 200, y + 10, _("Framerate achieved:")));
00113         add_subwindow(framerate_title = new BC_Title(x + 350, y + 10, _("--"), MEDIUMFONT, RED));
00114         draw_framerate();
00115 
00116         y += 35;
00117         add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
00118         y += 20;
00119         add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow, 
00120                 this, 
00121                 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR, 
00122                 10, 
00123                 y));
00124         y += 20;
00125         add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow, 
00126                 this, 
00127                 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR, 
00128                 10, 
00129                 y));
00130         y += 20;
00131         add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow, 
00132                 this, 
00133                 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR, 
00134                 10, 
00135                 y));
00136 
00137         y += 35;
00138         add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT, resources->text_default));
00139         sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
00140         add_subwindow(new PlaybackPreload(x + 210, y, pwindow, this, string));
00141 
00142 //      y += 30;
00143 //      add_subwindow(new PlaybackDeblock(pwindow, 10, y));
00144 
00145         y += 30;
00146         add_subwindow(new BC_Title(x, y, _("Timecode offset:"), MEDIUMFONT, BLACK));
00147         sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[3]);
00148         add_subwindow(new TimecodeOffset(x + 120, y, pwindow, this, string, 3));
00149         add_subwindow(new BC_Title(x + 152, y, _(":"), MEDIUMFONT, BLACK));
00150         sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[2]);
00151         add_subwindow(new TimecodeOffset(x + 160, y, pwindow, this, string, 2));
00152         add_subwindow(new BC_Title(x + 192, y, _(":"), MEDIUMFONT, BLACK));
00153         sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[1]);
00154         add_subwindow(new TimecodeOffset(x + 200, y, pwindow, this, string, 1));
00155         add_subwindow(new BC_Title(x + 232, y, _(":"), MEDIUMFONT, BLACK));
00156         sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[0]);
00157         add_subwindow(new TimecodeOffset(x + 240, y, pwindow, this, string, 0));
00158 
00159         y += 35;
00160         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
00161         video_device = new VDevicePrefs(x + 100, 
00162                 y, 
00163                 pwindow, 
00164                 this, 
00165                 playback_config->vconfig, 
00166                 0,
00167                 MODEPLAY);
00168         video_device->initialize();
00169 
00170 // Strategic playback options created here
00171 //      set_strategy(pwindow->thread->edl->session->playback_strategy, y);
00172         
00173 
00174         return 0;
00175 }
00176 
00177 
00178 void PlaybackPrefs::update(int interpolation)
00179 {
00180         pwindow->thread->edl->session->interpolation_type = interpolation;
00181         nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
00182 //      cubic_cubic->update(interpolation == CUBIC_CUBIC);
00183         cubic_linear->update(interpolation == CUBIC_LINEAR);
00184         linear_linear->update(interpolation == LINEAR_LINEAR);
00185 }
00186 
00187 
00188 int PlaybackPrefs::get_buffer_bytes()
00189 {
00190 //      return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
00191 }
00192 
00193 int PlaybackPrefs::draw_framerate()
00194 {
00195 //printf("PlaybackPrefs::draw_framerate 1 %f\n", pwindow->thread->edl->session->actual_frame_rate);
00196         char string[BCTEXTLEN];
00197         sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
00198         framerate_title->update(string);
00199         return 0;
00200 }
00201 
00202 
00203 
00204 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow, 
00205         PlaybackPrefs *playback, 
00206         int x, 
00207         int y)
00208  : BC_TumbleTextBox(playback,
00209         playback->playback_config->aconfig->audio_offset,
00210         -10.0,
00211         10.0,
00212         x,
00213         y,
00214         100)
00215 {
00216         this->pwindow = pwindow;
00217         this->playback = playback;
00218         set_precision(2);
00219         set_increment(0.1);
00220 }
00221 
00222 int PlaybackAudioOffset::handle_event()
00223 {
00224         playback->playback_config->aconfig->audio_offset = atof(get_text());
00225         return 1;
00226 }
00227 
00228 
00229 
00230 
00231 PlaybackModuleFragment::PlaybackModuleFragment(int x, 
00232         int y, 
00233         PreferencesWindow *pwindow, 
00234         PlaybackPrefs *playback, 
00235         char *text)
00236  : BC_PopupMenu(x, 
00237         y, 
00238         100, 
00239         text,
00240         1)
00241 { 
00242         this->pwindow = pwindow;
00243         this->playback = playback;
00244 }
00245 
00246 int PlaybackModuleFragment::handle_event() 
00247 {
00248         playback->playback_config->aconfig->fragment_size = atol(get_text()); 
00249         return 1;
00250 }
00251 
00252 
00253 
00254 
00255 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
00256  : BC_CheckBox(10, y, value, _("View follows playback"))
00257 { 
00258         this->pwindow = pwindow; 
00259 }
00260 
00261 int PlaybackViewFollows::handle_event() 
00262 { 
00263         pwindow->thread->edl->session->view_follows_playback = get_value(); 
00264         return 1;
00265 }
00266 
00267 
00268 
00269 
00270 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
00271  : BC_CheckBox(10, y, value, _("Use software for positioning information"))
00272 { 
00273         this->pwindow = pwindow; 
00274 }
00275 
00276 int PlaybackSoftwareTimer::handle_event() 
00277 { 
00278         pwindow->thread->edl->session->playback_software_position = get_value(); 
00279         return 1;
00280 }
00281 
00282 
00283 
00284 
00285 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
00286  : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
00287 { 
00288         this->pwindow = pwindow; 
00289 }
00290 
00291 int PlaybackRealTime::handle_event() 
00292 { 
00293         pwindow->thread->edl->session->real_time_playback = get_value(); 
00294         return 1;
00295 }
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00304  : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
00305 {
00306         this->pwindow = pwindow;
00307         this->prefs = prefs;
00308 }
00309 int PlaybackNearest::handle_event()
00310 {
00311         prefs->update(NEAREST_NEIGHBOR);
00312         return 1;
00313 }
00314 
00315 
00316 
00317 
00318 
00319 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00320  : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
00321 {
00322         this->pwindow = pwindow;
00323         this->prefs = prefs;
00324 }
00325 int PlaybackBicubicBicubic::handle_event()
00326 {
00327         prefs->update(CUBIC_CUBIC);
00328         return 1;
00329 }
00330 
00331 
00332 
00333 
00334 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00335  : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
00336 {
00337         this->pwindow = pwindow;
00338         this->prefs = prefs;
00339 }
00340 int PlaybackBicubicBilinear::handle_event()
00341 {
00342         prefs->update(CUBIC_LINEAR);
00343         return 1;
00344 }
00345 
00346 
00347 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow, 
00348         PlaybackPrefs *prefs, 
00349         int value, 
00350         int x, 
00351         int y)
00352  : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
00353 {
00354         this->pwindow = pwindow;
00355         this->prefs = prefs;
00356 }
00357 int PlaybackBilinearBilinear::handle_event()
00358 {
00359         prefs->update(LINEAR_LINEAR);
00360         return 1;
00361 }
00362 
00363 
00364 PlaybackPreload::PlaybackPreload(int x, 
00365         int y, 
00366         PreferencesWindow *pwindow, 
00367         PlaybackPrefs *playback, 
00368         char *text)
00369  : BC_TextBox(x, y, 100, 1, text)
00370 { 
00371         this->pwindow = pwindow; 
00372         this->playback = playback; 
00373 }
00374 
00375 int PlaybackPreload::handle_event() 
00376 { 
00377         pwindow->thread->edl->session->playback_preload = atol(get_text()); 
00378         return 1;
00379 }
00380 
00381 
00382 
00383 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow, int x, int y)
00384  : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
00385 {
00386         this->pwindow = pwindow;
00387 }
00388 
00389 int VideoEveryFrame::handle_event()
00390 {
00391         pwindow->thread->edl->session->video_every_frame = get_value();
00392         return 1;
00393 }
00394 
00395 
00396 
00397 
00398 
00399 // PlaybackDeblock::PlaybackDeblock(PreferencesWindow *pwindow, int x, int y)
00400 //  : BC_CheckBox(x, 
00401 //      y, 
00402 //      pwindow->thread->edl->session->mpeg4_deblock, 
00403 //      _("MPEG-4 Deblocking"))
00404 // {
00405 //      this->pwindow = pwindow;
00406 // }
00407 // 
00408 // int PlaybackDeblock::handle_event()
00409 // {
00410 //      pwindow->thread->edl->session->mpeg4_deblock = get_value();
00411 //      return 1;
00412 // }
00413 // 
00414 
00415 
00416 
00417 TimecodeOffset::TimecodeOffset(int x, int y, PreferencesWindow *pwindow, 
00418       PlaybackPrefs *playback, char *text, int unit)
00419  : BC_TextBox(x, y, 30, 1, text)
00420 {
00421    this->pwindow = pwindow;
00422    this->playback = playback;
00423         this->unit = unit;
00424 }
00425 
00426 int TimecodeOffset::handle_event()
00427 {
00428         pwindow->thread->edl->session->timecode_offset[unit] = atol(get_text());
00429         return 1;
00430 }
00431 
00432 
00433 
00434 

Generated on Sun Jan 8 13:38:58 2006 for Cinelerra-svn by  doxygen 1.4.4