r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / recordmonitor.C
blob6ee7e93c7eb058e4b2b22d3103c36801bed8db10
1 #include "asset.h"
2 #include "channelpicker.h"
3 #include "cursors.h"
4 #include "libdv.h"
5 #include "edl.h"
6 #include "edlsession.h"
7 #include "keys.h"
8 #include "meterpanel.h"
9 #include "mwindow.h"
10 #include "playbackconfig.h"
11 #include "preferences.h"
12 #include "record.h"
13 #include "recordconfig.h"
14 #include "recordgui.h"
15 #include "recordtransport.h"
16 #include "recordmonitor.h"
17 #include "mainsession.h"
18 #include "theme.h"
19 #include "videodevice.inc"
20 #include "vframe.h"
21 #include "videodevice.h"
24 #include <libintl.h>
25 #define _(String) gettext(String)
26 #define gettext_noop(String) String
27 #define N_(String) gettext_noop (String)
29 RecordMonitor::RecordMonitor(MWindow *mwindow, Record *record)
30  : Thread(1)
32         this->mwindow = mwindow;
33         this->record = record;
34         device = 0;
35         thread = 0;
39 RecordMonitor::~RecordMonitor()
41 //printf("RecordMonitor::~RecordMonitor 1\n");
42         if(thread)
43         {
44                 thread->stop_playback();
45                 delete thread;
46         }
47 //printf("RecordMonitor::~RecordMonitor 1\n");
48         window->set_done(0);
49 //printf("RecordMonitor::~RecordMonitor 1\n");
50         Thread::join();
51 //printf("RecordMonitor::~RecordMonitor 1\n");
52         if(device) 
53         {
54                 device->close_all();
55                 delete device;
56         }
57 //printf("RecordMonitor::~RecordMonitor 1\n");
58         delete window;
59 //printf("RecordMonitor::~RecordMonitor 2\n");
62 int RecordMonitor::create_objects()
64 //printf("RecordMonitor::create_objects 1\n");
65         window = new RecordMonitorGUI(mwindow,
66                 record, 
67                 this);
68 //printf("RecordMonitor::create_objects 2\n");
69         window->create_objects();
70 //printf("RecordMonitor::create_objects 3\n");
72         if(record->default_asset->video_data)
73         {
74 // Configure the output for record monitoring
75                 VideoOutConfig config(PLAYBACK_LOCALHOST, 0);
76                 device = new VideoDevice;
77 //printf("RecordMonitor::create_objects 4\n");
81 // Override default device for X11 drivers
82                 if(mwindow->edl->session->playback_config[PLAYBACK_LOCALHOST].values[0]->vconfig->driver ==
83                         PLAYBACK_X11_XV) config.driver = PLAYBACK_X11_XV;
84                 config.x11_use_fields = 0;
87                 device->open_output(&config, 
88                                                 record->default_asset->frame_rate, 
89                                                 record->default_asset->width, 
90                                                 record->default_asset->height,
91                                                 window->canvas,
92                                                 0);
93 //printf("RecordMonitor::create_objects 5\n");
95                 thread = new RecordMonitorThread(mwindow, record, this);
96 //printf("RecordMonitor::create_objects 6\n");
97                 thread->start_playback();
98         }
100         Thread::start();
101         return 0;
105 void RecordMonitor::run()
107         window->run_window();
108         close_threads();
111 int RecordMonitor::close_threads()
113         if(window->channel_picker) window->channel_picker->close_threads();
116 int RecordMonitor::update(VFrame *vframe)
118         return thread->write_frame(vframe);
121 void RecordMonitor::update_channel(char *text)
123         if(window->channel_picker)
124                 window->channel_picker->channel_text->update(text);
127 int RecordMonitor::get_mbuttons_height()
129         return RECBUTTON_HEIGHT;
132 int RecordMonitor::fix_size(int &w, int &h, int width_given, float aspect_ratio)
134         w = width_given;
135         h = (int)((float)width_given / aspect_ratio);
138 float RecordMonitor::get_scale(int w)
140         if(mwindow->edl->get_aspect_ratio() > 
141                 (float)record->frame_w / record->frame_h)
142         {
143                 return (float)w / 
144                         ((float)record->frame_h * 
145                         mwindow->edl->get_aspect_ratio());
146         }
147         else
148         {
149                 return (float)w / record->frame_w;
150         }
153 int RecordMonitor::get_canvas_height()
155         return window->get_h() - get_mbuttons_height();
158 int RecordMonitor::get_channel_x()
160 //      return 240;
161         return 5;
164 int RecordMonitor::get_channel_y()
166         return 2;
178 RecordMonitorGUI::RecordMonitorGUI(MWindow *mwindow,
179         Record *record, 
180         RecordMonitor *thread)
181  : BC_Window(PROGRAM_NAME ": Video in", 
182                         mwindow->session->rmonitor_x,
183                         mwindow->session->rmonitor_y,
184                         mwindow->session->rmonitor_w, 
185                         mwindow->session->rmonitor_h, 
186                         150, 
187                         50, 
188                         1, 
189                         1,
190                         1)
192         this->mwindow = mwindow;
193         this->thread = thread;
194         this->record = record;
195         bitmap = 0;
196         channel_picker = 0;
197         reverse_interlace = 0;
198         meters = 0;
199         canvas = 0;
200         current_operation = MONITOR_NONE;
203 RecordMonitorGUI::~RecordMonitorGUI()
205         if(bitmap) delete bitmap;
206         if(channel_picker) delete channel_picker;
209 int RecordMonitorGUI::create_objects()
211 //printf("RecordMonitorGUI::create_objects 1\n");
212         mwindow->theme->get_rmonitor_sizes(record->default_asset->audio_data, 
213                 record->default_asset->video_data,
214                 (mwindow->edl->session->vconfig_in->driver == VIDEO4LINUX ||
215                         mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ),
216                 (mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ));
217         mwindow->theme->draw_rmonitor_bg(this);
218 //printf("RecordMonitorGUI::create_objects 1\n");
220 //      record_transport = new RecordTransport(mwindow, 
221 //              record, 
222 //              this, 
223 //              mwindow->theme->rmonitor_tx_x,
224 //              mwindow->theme->rmonitor_tx_y);
225 //      record_transport->create_objects();
226 //printf("RecordMonitorGUI::create_objects 1\n");
228         if(record->default_asset->video_data)
229         {
230                 canvas = new RecordMonitorCanvas(mwindow, 
231                         this,
232                         record, 
233                         mwindow->theme->rmonitor_canvas_x, 
234                         mwindow->theme->rmonitor_canvas_y, 
235                         mwindow->theme->rmonitor_canvas_w, 
236                         mwindow->theme->rmonitor_canvas_h);
237                 canvas->create_objects(0);
238 //printf("RecordMonitorGUI::create_objects 1\n");
240                 if(mwindow->edl->session->vconfig_in->driver == VIDEO4LINUX ||
241                         mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ)
242                 {
243                         channel_picker = new ChannelPicker(mwindow,
244                                 record,
245                                 thread,
246                                 record->current_channeldb(),
247                                 mwindow->theme->rmonitor_channel_x, 
248                                 mwindow->theme->rmonitor_channel_y);
249                         channel_picker->create_objects();
250                 }
251 //printf("RecordMonitorGUI::create_objects 1\n");
253                 if(mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ)
254                 {
255                         add_subwindow(reverse_interlace = new ReverseInterlace(record,
256                                 mwindow->theme->rmonitor_interlace_x, 
257                                 mwindow->theme->rmonitor_interlace_y));
258                 }
259 //printf("RecordMonitorGUI::create_objects 1\n");
260                 
261                 add_subwindow(monitor_menu = new BC_PopupMenu(0, 
262                         0, 
263                         0, 
264                         "", 
265                         0));
266                 monitor_menu->add_item(new RecordMonitorFullsize(mwindow, 
267                         this));
268 //printf("RecordMonitorGUI::create_objects 1\n");
269         }
270 //printf("RecordMonitorGUI::create_objects 1\n");
272         if(record->default_asset->audio_data)
273         {
274                 meters = new MeterPanel(mwindow, 
275                         this,
276                         mwindow->theme->rmonitor_meter_x,
277                         mwindow->theme->rmonitor_meter_y,
278                         mwindow->theme->rmonitor_meter_h,
279                         record->default_asset->channels,
280                         1);
281                 meters->create_objects();
282         }
283 //printf("RecordMonitorGUI::create_objects 2\n");
284         return 0;
287 int RecordMonitorGUI::button_press()
289         if(get_buttonpress() == 2)
290         {
291                 return 0;
292         }
293         else
294 // Right button
295         if(get_button_down() == 3)
296         {
297                 monitor_menu->activate_menu();
298                 return 1;
299         }
300         return 0;
303 int RecordMonitorGUI::button_release()
305         return 0;
308 int RecordMonitorGUI::get_virtual_center()
312 int RecordMonitorGUI::cursor_motion()
314         return 0;
317 int RecordMonitorGUI::keypress_event()
319         int result = 0;
320         switch(get_keypress())
321         {
322                 case LEFT:
323                         if(!ctrl_down()) 
324                         { 
325                                 record->record_gui->set_translation(--(record->video_x), record->video_y, record->video_zoom);
326                         }
327                         else
328                         {
329                                 record->video_zoom -= 0.1;
330                                 record->record_gui->set_translation(record->video_x, record->video_y, record->video_zoom);
331                         }
332                         result = 1;
333                         break;
334                 case RIGHT:
335                         if(!ctrl_down()) 
336                         { 
337                                 record->record_gui->set_translation(++(record->video_x), record->video_y, record->video_zoom);
338                         }
339                         else
340                         {
341                                 record->video_zoom += 0.1;
342                                 record->record_gui->set_translation(record->video_x, record->video_y, record->video_zoom);
343                         }
344                         result = 1;
345                         break;
346                 case UP:
347                         if(!ctrl_down()) 
348                         { 
349                                 record->record_gui->set_translation(record->video_x, --(record->video_y), record->video_zoom);
350                         }
351                         else
352                         {
353                                 record->video_zoom -= 0.1;
354                                 record->record_gui->set_translation(record->video_x, record->video_y, record->video_zoom);
355                         }
356                         result = 1;
357                         break;
358                 case DOWN:
359                         if(!ctrl_down()) 
360                         { 
361                                 record->record_gui->set_translation(record->video_x, ++(record->video_y), record->video_zoom);
362                         }
363                         else
364                         {
365                                 record->video_zoom += 0.1;
366                                 record->record_gui->set_translation(record->video_x, record->video_y, record->video_zoom);
367                         }
368                         result = 1;
369                         break;
370                 case 'w':
371                         close_event();
372                         break;
373                 default:
374 //                      result = record_transport->keypress_event();
375                         break;
376         }
377         return result;
381 int RecordMonitorGUI::translation_event()
383 //printf("MWindowGUI::translation_event 1 %d %d\n", get_x(), get_y());
384         mwindow->session->rmonitor_x = get_x();
385         mwindow->session->rmonitor_y = get_y();
386         return 0;
389 int RecordMonitorGUI::resize_event(int w, int h)
391 //printf("RecordMonitorGUI::resize_event %d %d\n", w, h);
392         mwindow->session->rmonitor_x = get_x();
393         mwindow->session->rmonitor_y = get_y();
394         mwindow->session->rmonitor_w = w;
395         mwindow->session->rmonitor_h = h;
397         mwindow->theme->get_rmonitor_sizes(record->default_asset->audio_data, 
398                 record->default_asset->video_data,
399                 (mwindow->edl->session->vconfig_in->driver == VIDEO4LINUX ||
400                         mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ),
401                 (mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ));
402         mwindow->theme->draw_rmonitor_bg(this);
403         flash();
406 //      record_transport->reposition_window(mwindow->theme->rmonitor_tx_x,
407 //              mwindow->theme->rmonitor_tx_y);
408         if(channel_picker) channel_picker->reposition();
409         if(reverse_interlace) reverse_interlace->reposition_window(reverse_interlace->get_x(),
410                 reverse_interlace->get_y());
411         if(record->default_asset->video_data)
412         {
413                 canvas->reposition_window(0,
414                         mwindow->theme->rmonitor_canvas_x, 
415                         mwindow->theme->rmonitor_canvas_y, 
416                         mwindow->theme->rmonitor_canvas_w, 
417                         mwindow->theme->rmonitor_canvas_h);
418         }
420         if(record->default_asset->audio_data)
421         {
422                 meters->reposition_window(mwindow->theme->rmonitor_meter_x, 
423                         mwindow->theme->rmonitor_meter_y, 
424                         mwindow->theme->rmonitor_meter_h);
425         }
427         set_title();
428         BC_WindowBase::resize_event(w, h);
429         flash();
430         flush();
431         return 1;
434 int RecordMonitorGUI::set_title()
436 return 0;
437         char string[1024];
438         int scale;
440         scale = (int)(thread->get_scale(thread->record->video_window_w) * 100 + 0.5);
442         sprintf(string, PROGRAM_NAME ": Video in %d%%", scale);
443         BC_Window::set_title(string);
444         return 0;
447 int RecordMonitorGUI::close_event()
449         thread->record->monitor_video = 0;
450         thread->record->monitor_audio = 0;
451         thread->record->video_window_open = 0;
452         if(record->record_gui->monitor_video) record->record_gui->monitor_video->update(0);
453         if(record->record_gui->monitor_audio) record->record_gui->monitor_audio->update(0);
454         hide_window();
455         record->record_gui->flush();
456         return 0;
459 int RecordMonitorGUI::create_bitmap()
461         if(bitmap && 
462                 (bitmap->get_w() != get_w() || 
463                         bitmap->get_h() != thread->get_canvas_height()))
464         {
465                 delete bitmap;
466                 bitmap = 0;
467         }
469         if(!bitmap)
470         {
471 //              bitmap = canvas->new_bitmap(get_w(), thread->get_canvas_height());
472         }
473         return 0;
476 ReverseInterlace::ReverseInterlace(Record *record, int x, int y)
477  : BC_CheckBox(x, y, record->reverse_interlace, _("Swap fields"))
479         this->record = record;
482 ReverseInterlace::~ReverseInterlace()
486 int ReverseInterlace::handle_event()
488         record->reverse_interlace = get_value();
489         return 0;
492 RecordMonitorCanvas::RecordMonitorCanvas(MWindow *mwindow, 
493         RecordMonitorGUI *window, 
494         Record *record, 
495         int x, 
496         int y, 
497         int w, 
498         int h)
499  : Canvas(window, 
500         x, 
501         y, 
502         w, 
503         h, 
504         record->default_asset->width,
505         record->default_asset->height,
506         0,
507         0,
508         1)
510         this->window = window;
511         this->mwindow = mwindow;
512         this->record = record;
513 //printf("RecordMonitorCanvas::RecordMonitorCanvas 1 %d\n", mwindow->edl->session->vconfig_in->driver);
514 //printf("RecordMonitorCanvas::RecordMonitorCanvas 2\n");
517 RecordMonitorCanvas::~RecordMonitorCanvas()
521 int RecordMonitorCanvas::get_output_w()
523         return record->default_asset->width;
526 int RecordMonitorCanvas::get_output_h()
528         return record->default_asset->height;
532 int RecordMonitorCanvas::button_press_event()
534         if(Canvas::button_press_event()) return 1;
535         
536         if(mwindow->edl->session->vconfig_in->driver == SCREENCAPTURE)
537         {
538                 window->current_operation = MONITOR_TRANSLATE;
539                 window->translate_x_origin = record->video_x;
540                 window->translate_y_origin = record->video_y;
541                 window->cursor_x_origin = get_cursor_x();
542                 window->cursor_y_origin = get_cursor_y();
543         }
545         return 0;
548 void RecordMonitorCanvas::zoom_resize_window(float percentage)
550         int canvas_w, canvas_h;
551         calculate_sizes(mwindow->edl->get_aspect_ratio(), 
552                 record->default_asset->width, 
553                 record->default_asset->height, 
554                 percentage,
555                 canvas_w,
556                 canvas_h);
557         int new_w, new_h;
558         new_w = canvas_w + (window->get_w() - mwindow->theme->rmonitor_canvas_w);
559         new_h = canvas_h + (window->get_h() - mwindow->theme->rmonitor_canvas_h);
560         window->resize_window(new_w, new_h);
561         window->resize_event(new_w, new_h);
564 int RecordMonitorCanvas::button_release_event()
566         window->current_operation = MONITOR_NONE;
567         return 0;
570 int RecordMonitorCanvas::cursor_motion_event()
572         if(window->current_operation == MONITOR_TRANSLATE)
573         {
574                 record->set_translation(
575                         get_cursor_x() - window->cursor_x_origin + window->translate_x_origin,
576                         get_cursor_y() - window->cursor_y_origin + window->translate_y_origin);
577         }
579         return 0;
582 int RecordMonitorCanvas::cursor_enter_event()
584         if(mwindow->edl->session->vconfig_in->driver == SCREENCAPTURE)
585                 set_cursor(MOVE_CURSOR);
586         return 0;
589 void RecordMonitorCanvas::reset_translation()
591         record->set_translation(0, 0);
594 int RecordMonitorCanvas::keypress_event()
596         int result = 0;
597         switch(canvas->get_keypress())
598         {
599                 case LEFT:
600                         record->set_translation(--record->video_x, record->video_y);
601                         break;
602                 case RIGHT:
603                         record->set_translation(++record->video_x, record->video_y);
604                         break;
605                 case UP:
606                         record->set_translation(record->video_x, --record->video_y);
607                         break;
608                 case DOWN:
609                         record->set_translation(record->video_x, ++record->video_y);
610                         break;
611         }
612         return result;
616 RecordMonitorFullsize::RecordMonitorFullsize(MWindow *mwindow, 
617         RecordMonitorGUI *window)
618  : BC_MenuItem(_("Zoom 100%"))
620         this->mwindow = mwindow;
621         this->window = window;
623 int RecordMonitorFullsize::handle_event()
625         return 1;
635 // ================================== slippery playback ============================
638 RecordMonitorThread::RecordMonitorThread(MWindow *mwindow, 
639         Record *record, 
640         RecordMonitor *record_monitor)
641  : Thread(1, 0, 0)
643         this->mwindow = mwindow;
644         this->record_monitor = record_monitor;
645         this->record = record;
646         reset_parameters();
650 void RecordMonitorThread::reset_parameters()
652         input_frame = 0;
653         output_frame[0] = 0;
654         shared_data = 0;
655         jpeg_engine = 0;
656         dv_engine = 0;
660 RecordMonitorThread::~RecordMonitorThread()
662         if(input_frame && !shared_data) delete input_frame;
665 void RecordMonitorThread::init_output_format()
667         long offset;
669 //printf("RecordMonitorThread::init_output_format 1\n");
670         switch(mwindow->edl->session->vconfig_in->driver)
671         {
672                 case SCREENCAPTURE:
673                         output_colormodel = record->vdevice->get_best_colormodel(record->default_asset);
674                         break;
675         
676         
677                 case CAPTURE_BUZ:
678                         jpeg_engine = new RecVideoMJPGThread(record, this);
679                         jpeg_engine->start_rendering();
680                         output_colormodel = BC_YUV422P;
681                         break;
683                 case CAPTURE_FIREWIRE:
684                         dv_engine = new RecVideoDVThread(record, this);
685                         dv_engine->start_rendering();
686                         output_colormodel = BC_YUV422P;
687                         break;
689                 case VIDEO4LINUX:
690                         output_colormodel = record->vdevice->get_best_colormodel(record->default_asset);
691 //printf("RecordMonitorThread::init_output_format 2 %d\n", output_colormodel);
692                         break;
693         }
696 int RecordMonitorThread::start_playback()
698         ready = 1;
699         done = 0;
700         output_lock.lock();
701         Thread::start();
702         return 0;
705 int RecordMonitorThread::stop_playback()
707         done = 1;
708         output_lock.unlock();
709         Thread::join();
710 //printf("RecordMonitorThread::stop_playback 1\n");
712         switch(mwindow->edl->session->vconfig_in->driver)
713         {
714                 case CAPTURE_BUZ:
715 //printf("RecordMonitorThread::stop_playback 2\n");
716                         if(jpeg_engine) 
717                         {
718                                 jpeg_engine->stop_rendering();
719 //printf("RecordMonitorThread::stop_playback 2\n");
720                                 delete jpeg_engine;
721                         }
722 //printf("RecordMonitorThread::stop_playback 3\n");
723                         break;
725                 case CAPTURE_FIREWIRE:
726                         if(dv_engine)
727                         {
728                                 dv_engine->stop_rendering();
729                                 delete dv_engine;
730                         }
731                         break;
732         }
733 //printf("RecordMonitorThread::stop_playback 4\n");
735         return 0;
738 int RecordMonitorThread::write_frame(VFrame *new_frame)
740         if(ready)
741         {
742                 ready = 0;
743                 shared_data = (new_frame->get_color_model() != BC_COMPRESSED);
744 // Need to wait until after Record creates the input device before starting monitor
745 // because the input device deterimes the output format.
746 // First time
747                 if(!output_frame[0]) init_output_format();
748                 if(!shared_data)
749                 {
750                         if(!input_frame) input_frame = new VFrame;
751                         input_frame->allocate_compressed_data(new_frame->get_compressed_size());
752                         memcpy(input_frame->get_data(), 
753                                 new_frame->get_data(), 
754                                 new_frame->get_compressed_size());
755                         input_frame->set_compressed_size(new_frame->get_compressed_size());
756                         input_frame->set_field2_offset(new_frame->get_field2_offset());
757                 }
758                 else
759                 {
760                         input_lock.lock();
761                         input_frame = new_frame;
762                 }
763                 output_lock.unlock();
764         }
765         return 0;
768 int RecordMonitorThread::render_jpeg()
770 //printf("RecordMonitorThread::render_jpeg 1\n");
771         jpeg_engine->render_frame(input_frame, input_frame->get_compressed_size());
772 //printf("RecordMonitorThread::render_jpeg 2\n");
773         return 0;
776 int RecordMonitorThread::render_dv()
778         dv_engine->render_frame(input_frame, input_frame->get_compressed_size());
779         return 0;
782 void RecordMonitorThread::render_uncompressed()
784 // printf("RecordMonitorThread::render_uncompressed 1 %p %p %p %p %p %p %p\n", 
785 //      output_frame[0],
786 //      output_frame[0]->get_y(), 
787 //      output_frame[0]->get_u(), 
788 //      output_frame[0]->get_v(),
789 //      input_frame->get_y(),
790 //      input_frame->get_u(),
791 //      input_frame->get_v());
793         output_frame[0]->copy_from(input_frame);
795 //printf("RecordMonitorThread::render_uncompressed 2\n");
798 void RecordMonitorThread::show_output_frame()
800         record_monitor->device->write_buffer(output_frame, record->edl);
803 void RecordMonitorThread::unlock_input()
805         if(shared_data) input_lock.unlock();
808 int RecordMonitorThread::render_frame()
810         switch(mwindow->edl->session->vconfig_in->driver)
811         {
812                 case CAPTURE_BUZ:
813                         render_jpeg();
814                         break;
816                 case CAPTURE_FIREWIRE:
817                         render_dv();
818                         break;
820                 default:
821                         render_uncompressed();
822                         break;
823         }
825         return 0;
828 void RecordMonitorThread::new_output_frame()
830         long offset;
831 //printf("RecordMonitorThread::new_output_frame %d %p %p\n", output_colormodel, record_monitor, record_monitor->device);
832         record_monitor->device->new_output_buffers(output_frame, output_colormodel);
833 //printf("RecordMonitorThread::new_output_frame 2\n");
836 void RecordMonitorThread::run()
838 //printf("RecordMonitorThread::run 1 %d\n", getpid());
839         while(!done)
840         {
841 // Wait for next frame
842                 output_lock.lock();
843                 if(done)
844                 {
845                         unlock_input();
846                         return;
847                 }
848 //printf("RecordMonitorThread::run 1\n");
849                 new_output_frame();
850 //printf("RecordMonitorThread::run 2\n");
851                 render_frame();
852 //printf("RecordMonitorThread::run 3\n");
853                 show_output_frame();
854 //printf("RecordMonitorThread::run 4\n");
855                 unlock_input();
856 // Get next frame
857                 ready = 1;
858         }
863 RecVideoMJPGThread::RecVideoMJPGThread(Record *record, RecordMonitorThread *thread)
865         this->record = record;
866         this->thread = thread;
867         mjpeg = 0;
870 RecVideoMJPGThread::~RecVideoMJPGThread()
874 int RecVideoMJPGThread::start_rendering()
876         mjpeg = mjpeg_new(record->default_asset->width, 
877                 record->default_asset->height, 
878                 2);
879 //printf("RecVideoMJPGThread::start_rendering 1 %p\n", mjpeg);
880         return 0;
883 int RecVideoMJPGThread::stop_rendering()
885 //printf("RecVideoMJPGThread::stop_rendering 1 %p\n", mjpeg);
886         if(mjpeg) mjpeg_delete(mjpeg);
887 //printf("RecVideoMJPGThread::stop_rendering 2\n");
888         return 0;
891 int RecVideoMJPGThread::render_frame(VFrame *frame, long size)
893 // printf("RecVideoMJPGThread::render_frame %d %02x%02x %02x%02x\n", frame->get_field2_offset(), 
894 //      frame->get_data()[0], 
895 //      frame->get_data()[1], 
896 //      frame->get_data()[frame->get_field2_offset()], 
897 //      frame->get_data()[frame->get_field2_offset() + 1]);
898 //frame->set_field2_offset(0);
899         mjpeg_decompress(mjpeg, 
900                 frame->get_data(), 
901                 frame->get_compressed_size(), 
902                 frame->get_field2_offset(), 
903                 thread->output_frame[0]->get_rows(), 
904                 thread->output_frame[0]->get_y(), 
905                 thread->output_frame[0]->get_u(), 
906                 thread->output_frame[0]->get_v(),
907                 thread->output_frame[0]->get_color_model(),
908                 record->mwindow->preferences->processors);
909         return 0;
915 RecVideoDVThread::RecVideoDVThread(Record *record, RecordMonitorThread *thread)
917         this->record = record;
918         this->thread = thread;
919         dv = 0;
922 RecVideoDVThread::~RecVideoDVThread()
927 int RecVideoDVThread::start_rendering()
929         ((dv_t*)dv) = dv_new();
930         return 0;
933 int RecVideoDVThread::stop_rendering()
935         if(dv) dv_delete(((dv_t*)dv));
936         return 0;
939 int RecVideoDVThread::render_frame(VFrame *frame, long size)
941         unsigned char *yuv_planes[3];
942         yuv_planes[0] = thread->output_frame[0]->get_y();
943         yuv_planes[1] = thread->output_frame[0]->get_u();
944         yuv_planes[2] = thread->output_frame[0]->get_v();
945         dv_read_video(((dv_t*)dv), 
946                 yuv_planes, 
947                 frame->get_data(), 
948                 frame->get_compressed_size(),
949                 thread->output_frame[0]->get_color_model());
950         return 0;