4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
27 #include "recordgui.h"
28 #include "recordtransport.h"
33 RecordTransport::RecordTransport(MWindow *mwindow, Record *record,
34 BC_WindowBase *window, int x, int y)
36 this->mwindow = mwindow;
37 this->record = record;
38 this->window = window;
45 void RecordTransport::create_objects()
47 int x = this->x, y = this->y;
49 window->add_subwindow(rewind_button = new RecordGUIRewind(this, x, y));
50 x += rewind_button->get_w(); y_end = y+rewind_button->get_h();
51 window->add_subwindow(record_button = new RecordGUIRec(this, x, y));
52 x += record_button->get_w(); y_end = max(y_end,y+record_button->get_h());
54 if(record->default_asset->video_data) {
55 window->add_subwindow(
56 record_frame = new RecordGUIRecFrame(this, x, y));
57 x += record_frame->get_w(); y_end = max(y_end,y+record_button->get_h());
59 window->add_subwindow(stop_button = new RecordGUIStop(this, x, y));
60 x += stop_button->get_w(); y_end = max(y_end,y+record_button->get_h());
61 // window->add_subwindow(pause_button = new RecordGUIPause(this, x, y));
62 // x += pause_button->get_w(); y_end = max(y_end,y+record_button->get_h());
66 x = this->x; y = y_end;
67 window->add_subwindow(back_button = new RecordGUIBack(this, x, y));
68 x += back_button->get_w(); x_end = max(x, x_end);
69 y_end = max(y + back_button->get_h(), y_end);
70 window->add_subwindow(play_button = new RecordGUIPlay(this, x, y));
71 x += play_button->get_w(); x_end = max(x, x_end);
72 y_end = max(y + play_button->get_h(), y_end);
73 window->add_subwindow(fwd_button = new RecordGUIFwd(this, x, y));
74 x += fwd_button->get_w(); x_end = max(x, x_end);
75 y_end = max(y + fwd_button->get_h(), y_end);
76 window->add_subwindow(end_button = new RecordGUIEnd(this, x, y));
77 x += end_button->get_w(); x_end = max(x, x_end);
78 y_end = max(y + end_button->get_h(), y_end);
80 x_end += 10; y_end += 10;
83 void RecordTransport::reposition_window(int x, int y)
85 this->x = x; this->y = y;
86 rewind_button->reposition_window(x, y);
87 x += rewind_button->get_w(); y_end = y+rewind_button->get_h();
88 record_button->reposition_window(x, y);
89 x += record_button->get_w(); y_end = max(y_end,y+record_button->get_h());
90 if(record->default_asset->video_data) {
91 record_frame->reposition_window(x, y);
92 x += record_frame->get_w(); y_end = max(y_end,y+record_button->get_h());
94 stop_button->reposition_window(x, y);
95 x += stop_button->get_w(); y_end = max(y_end,y+record_button->get_h());
96 // pause_button->reposition_window(x, y);
97 // x += pause_button->get_w(); y_end = max(y_end,y+record_button->get_h());
101 x = this->x; y = y_end;
102 back_button->reposition_window(x, y);
103 x += back_button->get_w(); x_end = max(x, x_end);
104 y_end = max(y + back_button->get_h(), y_end);
105 play_button->reposition_window(x, y);
106 x += play_button->get_w(); x_end = max(x, x_end);
107 y_end = max(y + play_button->get_h(), y_end);
108 fwd_button->reposition_window(x, y);
109 x += fwd_button->get_w(); x_end = max(x, x_end);
110 y_end = max(y + fwd_button->get_h(), y_end);
111 end_button->reposition_window(x, y);
112 x += end_button->get_w(); x_end = max(x, x_end);
113 y_end = max(y + end_button->get_h(), y_end);
115 x_end += 10; y_end += 10;
118 int RecordTransport::get_h()
123 int RecordTransport::get_w()
129 RecordTransport::~RecordTransport()
132 void RecordTransport::
133 start_writing_file(int single_frame)
135 if( !record->writing_file ) {
136 record->pause_input_threads();
137 record->update_position();
138 record->single_frame = single_frame;
139 record->start_writing_file();
140 record->resume_input_threads();
144 void RecordTransport::
147 record->stop_cron_thread(_("Interrupted"));
148 record->stop_writing();
151 int RecordTransport::keypress_event()
153 if( record->cron_active() > 0 ) return 0;
154 if( window->get_keypress() == ' ' ) {
155 //printf("RecordTransport::keypress_event 1\n");
156 if( record->writing_file ) {
157 window->unlock_window();
159 window->lock_window("RecordTransport::keypress_event 1");
162 window->unlock_window();
163 start_writing_file();
164 window->lock_window("RecordTransport::keypress_event 2");
166 //printf("RecordTransport::keypress_event 2\n");
173 RecordGUIRec::RecordGUIRec(RecordTransport *record_transport, int x, int y)
174 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("record"))
176 this->record_transport = record_transport;
177 set_tooltip(_("Start recording\nfrom current position"));
180 RecordGUIRec::~RecordGUIRec()
184 int RecordGUIRec::handle_event()
186 if( record_transport->record->cron_active() > 0 ) return 0;
188 record_transport->start_writing_file();
189 lock_window("RecordGUIRec::handle_event");
193 int RecordGUIRec::keypress_event()
198 RecordGUIRecFrame::RecordGUIRecFrame(RecordTransport *record_transport, int x, int y)
199 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("recframe"))
201 this->record_transport = record_transport;
202 set_tooltip(_("RecordTransport single frame"));
205 RecordGUIRecFrame::~RecordGUIRecFrame()
209 int RecordGUIRecFrame::handle_event()
211 if( record_transport->record->cron_active() > 0 ) return 0;
213 record_transport->start_writing_file(1);
214 lock_window("RecordGUIRecFrame::handle_event");
218 int RecordGUIRecFrame::keypress_event()
223 RecordGUIPlay::RecordGUIPlay(RecordTransport *record_transport, int x, int y)
224 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("play"))
226 this->record_transport = record_transport;
227 set_tooltip(_("Preview recording"));
230 RecordGUIPlay::~RecordGUIPlay()
234 int RecordGUIPlay::handle_event()
241 int RecordGUIPlay::keypress_event()
247 RecordGUIStop::RecordGUIStop(RecordTransport *record_transport, int x, int y)
248 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("stoprec"))
250 this->record_transport = record_transport;
251 set_tooltip(_("Stop operation"));
254 RecordGUIStop::~RecordGUIStop()
258 int RecordGUIStop::handle_event()
261 record_transport->stop_writing();
262 lock_window("RecordGUIStop::handle_event");
266 int RecordGUIStop::keypress_event()
273 RecordGUIPause::RecordGUIPause(RecordTransport *record_transport, int x, int y)
274 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("pause"))
276 this->record_transport = record_transport;
277 set_tooltip(_("Pause"));
280 RecordGUIPause::~RecordGUIPause()
284 int RecordGUIPause::handle_event()
289 int RecordGUIPause::keypress_event()
296 RecordGUIRewind::RecordGUIRewind(RecordTransport *record_transport, int x, int y)
297 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("rewind"))
299 this->record_transport = record_transport;
300 set_tooltip(_("Start over"));
303 RecordGUIRewind::~RecordGUIRewind()
307 int RecordGUIRewind::handle_event()
309 RecordGUI *record_gui = record_transport->record->record_gui;
310 if( !record_gui->startover_thread->running() )
311 record_gui->startover_thread->start();
315 int RecordGUIRewind::keypress_event()
322 RecordGUIBack::RecordGUIBack(RecordTransport *record_transport, int x, int y)
323 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("fastrev"))
325 this->record_transport = record_transport;
326 set_tooltip(_("Fast rewind"));
329 RecordGUIBack::~RecordGUIBack()
333 int RecordGUIBack::handle_event()
338 int RecordGUIBack::button_press()
343 int RecordGUIBack::button_release()
345 unset_repeat(repeat_id);
349 int RecordGUIBack::repeat_event()
355 int RecordGUIBack::keypress_event()
362 RecordGUIFwd::RecordGUIFwd(RecordTransport *record_transport, int x, int y)
363 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("fastfwd"))
365 this->record_transport = record_transport;
366 set_tooltip(_("Fast forward"));
369 RecordGUIFwd::~RecordGUIFwd()
373 int RecordGUIFwd::handle_event()
378 int RecordGUIFwd::button_press()
383 int RecordGUIFwd::button_release()
385 unset_repeat(repeat_id);
389 int RecordGUIFwd::repeat_event()
394 int RecordGUIFwd::keypress_event()
401 RecordGUIEnd::RecordGUIEnd(RecordTransport *record_transport, int x, int y)
402 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("end"))
404 this->record_transport = record_transport;
405 set_tooltip(_("Seek to end of recording"));
408 RecordGUIEnd::~RecordGUIEnd()
412 int RecordGUIEnd::handle_event()
417 int RecordGUIEnd::keypress_event()