add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / vtracking.C
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 #include "asset.h"
23 #include "assets.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "localsession.h"
27 #include "mainclock.h"
28 #include "meterpanel.h"
29 #include "mwindow.h"
30 #include "renderengine.h"
31 #include "mainclock.h"
32 #include "vplayback.h"
33 #include "vrender.h"
34 #include "vtimebar.h"
35 #include "vtracking.h"
36 #include "vwindow.h"
37 #include "vwindowgui.h"
38
39
40 VTracking::VTracking(MWindow *mwindow, VWindow *vwindow)
41  : Tracking(mwindow)
42 {
43         this->vwindow = vwindow;
44 }
45
46 VTracking::~VTracking()
47 {
48 }
49
50 PlaybackEngine* VTracking::get_playback_engine()
51 {
52         return vwindow->playback_engine;
53 }
54
55 void VTracking::update_tracker(double position)
56 {
57         if( !vwindow->get_edl() ) return;
58         vwindow->gui->lock_window("VTracking::update_tracker");
59         vwindow->get_edl()->local_session->set_selectionstart(position);
60         vwindow->get_edl()->local_session->set_selectionend(position);
61
62         Asset *asset = vwindow->get_edl()->assets->first;
63         if( asset && asset->tcstart ) {
64                 double rate = asset->video_data ? asset->frame_rate :
65                         asset->audio_data ? asset->sample_rate : 0;
66                 if( rate > 0 )
67                         position += asset->tcstart / rate;
68         }
69         vwindow->gui->clock->update(position);
70
71 // This is going to boost the latency but we need to update the timebar
72         vwindow->gui->timebar->update(1);
73
74         vwindow->gui->unlock_window();
75
76         update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
77 }
78
79 int VTracking::start_playback(double new_position)
80 {
81
82         return Tracking::start_playback(new_position);
83 }
84
85 void VTracking::update_meters(int64_t position)
86 {
87         double output_levels[MAXCHANNELS];
88
89         int do_audio = get_playback_engine()->get_output_levels(output_levels,
90                 position);
91         if(do_audio)
92         {
93                 vwindow->gui->lock_window("VTracking::update_meters");
94                 vwindow->gui->meters->update(output_levels);
95                 vwindow->gui->unlock_window();
96         }
97 }
98
99 void VTracking::stop_meters()
100 {
101         vwindow->gui->lock_window("VTracking::stop_meters");
102         vwindow->gui->meters->stop_meters();
103         vwindow->gui->unlock_window();
104 }
105
106 void VTracking::draw()
107 {
108 }