3 #include "audiodevice.h"
7 #include "channelpicker.h"
11 #include "edlsession.h"
16 #include "filesystem.h"
17 #include "filethread.h"
18 #include "formatcheck.h"
19 #include "indexfile.h"
21 #include "localsession.h"
25 #include "mwindowgui.h"
27 #include "playbackengine.h"
28 #include "preferences.h"
29 #include "quicktime.h"
31 #include "recordaudio.h"
32 #include "recordconfig.h"
33 #include "recordgui.h"
34 #include "recordlabel.h"
35 #include "recordmonitor.h"
36 #include "recordthread.h"
37 #include "recordvideo.h"
38 #include "recordwindow.h"
39 #include "removethread.h"
40 #include "mainsession.h"
41 #include "sighandler.h"
42 #include "testobject.h"
46 #include "videoconfig.h"
47 #include "videodevice.h"
53 RecordMenuItem::RecordMenuItem(MWindow *mwindow)
54 : BC_MenuItem(_("Record..."), "r", 'r')
56 this->mwindow = mwindow;
57 thread = new Record(mwindow, this);
58 current_state = RECORD_NOTHING;
61 RecordMenuItem::~RecordMenuItem()
66 int RecordMenuItem::handle_event()
73 thread->window_lock->lock("RecordMenuItem::handle_event 1");
74 if(thread->record_window)
76 thread->record_window->lock_window("RecordMenuItem::handle_event 1");
77 thread->record_window->raise_window();
78 thread->record_window->unlock_window();
80 thread->window_lock->unlock();
83 case RECORD_CAPTURING:
84 thread->window_lock->lock("RecordMenuItem::handle_event 2");
85 if(thread->record_gui)
87 thread->record_gui->lock_window("RecordMenuItem::handle_event 2");
88 thread->record_gui->raise_window();
89 thread->record_gui->unlock_window();
91 thread->window_lock->unlock();
110 Record::Record(MWindow *mwindow, RecordMenuItem *menu_item)
113 this->mwindow = mwindow;
114 this->menu_item = menu_item;
116 capture_state = IS_DONE;
123 picture = new PictureConfig(mwindow->defaults);
125 channeldb = new ChannelDB;
126 master_channel = new Channel;
127 window_lock = new Mutex("Record::window_lock");
134 delete master_channel;
139 int Record::load_defaults()
141 char string[BCTEXTLEN];
142 BC_Hash *defaults = mwindow->defaults;
145 // default_asset->load_defaults(defaults,
152 // This reads back everything that was saved in save_defaults.
153 default_asset->copy_from(mwindow->edl->session->recording_format, 0);
154 default_asset->channels = mwindow->edl->session->aconfig_in->channels;
155 default_asset->sample_rate = mwindow->edl->session->aconfig_in->in_samplerate;
156 default_asset->frame_rate = mwindow->edl->session->vconfig_in->in_framerate;
157 default_asset->width = mwindow->edl->session->vconfig_in->w;
158 default_asset->height = mwindow->edl->session->vconfig_in->h;
159 default_asset->layers = 1;
163 // Fix encoding parameters depending on driver.
164 // These are locked by a specific driver.
165 if(mwindow->edl->session->vconfig_in->driver == CAPTURE_LML ||
166 mwindow->edl->session->vconfig_in->driver == CAPTURE_BUZ ||
167 mwindow->edl->session->vconfig_in->driver == VIDEO4LINUX2JPEG)
168 strncpy(default_asset->vcodec, QUICKTIME_MJPA, 4);
170 if(mwindow->edl->session->vconfig_in->driver == CAPTURE_FIREWIRE ||
171 mwindow->edl->session->vconfig_in->driver == CAPTURE_IEC61883)
173 strncpy(default_asset->vcodec, QUICKTIME_DVSD, 4);
180 int total_batches = defaults->get("TOTAL_BATCHES", 1);
181 if(total_batches < 1) total_batches = 1;
182 for(int i = 0; i < total_batches; i++)
184 Batch *batch = new_batch();
185 Asset *asset = batch->assets.values[0];
187 sprintf(string, "RECORD_PATH_%d", i);
188 defaults->get(string, asset->path);
189 sprintf(string, "RECORD_CHANNEL_%d", i);
190 batch->channel = defaults->get(string, batch->channel);
191 sprintf(string, "RECORD_STARTTYPE_%d", i);
192 batch->start_type = defaults->get(string, batch->start_type);
193 sprintf(string, "RECORD_STARTDAY_%d", i);
194 batch->start_day = defaults->get(string, batch->start_day);
195 sprintf(string, "RECORD_STARTTIME_%d", i);
196 batch->start_time = defaults->get(string, batch->start_time);
197 sprintf(string, "RECORD_DURATION_%d", i);
198 batch->duration = defaults->get(string, batch->duration);
199 sprintf(string, "RECORD_MODE_%d", i);
200 batch->record_mode = defaults->get(string, batch->record_mode);
201 sprintf(string, "BATCH_ENABLED_%d", i);
202 batch->enabled = defaults->get(string, batch->enabled);
206 load_mode = defaults->get("RECORD_LOADMODE", LOAD_PASTE);
208 monitor_audio = defaults->get("RECORD_MONITOR_AUDIO", 1);
209 monitor_video = defaults->get("RECORD_MONITOR_VIDEO", 1);
210 video_window_open = defaults->get("RECORD_MONITOR_OPEN", 1);
211 video_x = defaults->get("RECORD_VIDEO_X", 0);
212 video_y = defaults->get("RECORD_VIDEO_Y", 0);
213 video_zoom = defaults->get("RECORD_VIDEO_Z", (float)1);
216 picture->load_defaults();
219 reverse_interlace = defaults->get("REVERSE_INTERLACE", 0);
220 for(int i = 0; i < MAXCHANNELS; i++)
222 sprintf(string, "RECORD_DCOFFSET_%d", i);
223 dc_offset[i] = defaults->get(string, 0);
225 fill_frames = defaults->get("FILL_DROPPED_FRAMES", 0);
229 int Record::save_defaults()
231 char string[BCTEXTLEN];
232 BC_Hash *defaults = mwindow->defaults;
235 // Save default asset path but not the format because that's
236 // overridden by the driver.
237 // The format is saved in preferences.
239 strcpy(default_asset->path, batches.values[0]->assets.values[0]->path);
240 default_asset->save_defaults(defaults,
248 // default_asset->save_defaults(defaults,
251 // !fixed_compression,
256 // defaults->update("RECORD_CHANNELS", default_asset->channels);
263 defaults->update("TOTAL_BATCHES", batches.total);
264 for(int i = 0; i < batches.total; i++)
266 Batch *batch = batches.values[i];
267 Asset *asset = batch->assets.values[0];
269 sprintf(string, "RECORD_PATH_%d", i);
270 defaults->update(string, asset->path);
271 sprintf(string, "RECORD_CHANNEL_%d", i);
272 defaults->update(string, batch->channel);
273 sprintf(string, "RECORD_STARTTYPE_%d", i);
274 defaults->update(string, batch->start_type);
275 sprintf(string, "RECORD_STARTDAY_%d", i);
276 defaults->update(string, batch->start_day);
277 sprintf(string, "RECORD_STARTTIME_%d", i);
278 defaults->update(string, batch->start_time);
279 sprintf(string, "RECORD_DURATION_%d", i);
280 defaults->update(string, batch->duration);
281 sprintf(string, "RECORD_MODE_%d", i);
282 defaults->update(string, batch->record_mode);
283 sprintf(string, "BATCH_ENABLED_%d", i);
284 defaults->update(string, batch->enabled);
288 defaults->update("RECORD_LOADMODE", load_mode);
289 defaults->update("RECORD_MONITOR_AUDIO", monitor_audio);
290 defaults->update("RECORD_MONITOR_VIDEO", monitor_video);
291 defaults->update("RECORD_MONITOR_OPEN", video_window_open);
292 defaults->update("RECORD_VIDEO_X", video_x);
293 defaults->update("RECORD_VIDEO_Y", video_y);
294 defaults->update("RECORD_VIDEO_Z", video_zoom);
297 picture->save_defaults();
299 defaults->update("REVERSE_INTERLACE", reverse_interlace);
300 for(int i = 0; i < MAXCHANNELS; i++)
302 sprintf(string, "RECORD_DCOFFSET_%d", i);
303 defaults->update(string, dc_offset[i]);
305 defaults->update("FILL_DROPPED_FRAMES", fill_frames);
310 void Record::configure_batches()
312 strcpy(batches.values[0]->assets.values[0]->path, default_asset->path);
313 for(int i = 0; i < batches.total; i++)
315 Batch *batch = batches.values[i];
317 batch->get_current_asset()->copy_format(default_asset);
320 batch->calculate_news();
324 void Record::source_to_text(char *string, Batch *batch)
327 strcpy(string, "Record::source_to_text: not implemented");
328 switch(mwindow->edl->session->vconfig_in->driver)
333 case VIDEO4LINUX2JPEG:
334 if(batch->channel < 0 || batch->channel >= channeldb->size())
335 sprintf(string, _("None"));
337 sprintf(string, channeldb->get(batch->channel)->title);
345 int result = 0, format_error = 0;
349 // Default asset forms the first path in the batch capture
350 // and the file format for all operations.
351 default_asset = new Asset;
354 // Determine information about the device.
355 VideoDevice::load_channeldb(channeldb, mwindow->edl->session->vconfig_in);
356 fixed_compression = VideoDevice::is_compressed(
357 mwindow->edl->session->vconfig_in->driver,
362 if(fixed_compression)
365 device.fix_asset(default_asset,
366 mwindow->edl->session->vconfig_in->driver);
370 menu_item->current_state = RECORD_INTRO;
372 // // Get information about the file format
375 // int x = mwindow->gui->get_root_w(0, 1) / 2 - RECORD_WINDOW_WIDTH / 2;
376 // int y = mwindow->gui->get_root_h(1) / 2 - RECORD_WINDOW_HEIGHT / 2;
378 // window_lock->lock("Record::run 1");
379 // record_window = new RecordWindow(mwindow, this, x, y);
380 // record_window->create_objects();
381 // window_lock->unlock();
384 // result = record_window->run_window();
385 // window_lock->lock("Record::run 2");
386 // delete record_window;
387 // record_window = 0;
388 // window_lock->unlock();
394 // FormatCheck check_format(default_asset);
395 // format_error = check_format.check_format();
397 // }while(format_error && !result);
399 default_asset->channels = mwindow->edl->session->aconfig_in->channels;
400 VideoDevice::save_channeldb(channeldb, mwindow->edl->session->vconfig_in);
402 mwindow->save_defaults();
412 edl->create_objects();
413 edl->session->output_w = default_asset->width;
414 edl->session->output_h = default_asset->height;
415 edl->session->aspect_w = mwindow->edl->session->aspect_w;
416 edl->session->aspect_h = mwindow->edl->session->aspect_h;
419 window_lock->lock("Record::run 3");
421 record_gui = new RecordGUI(mwindow, this);
422 record_gui->load_defaults();
423 record_gui->create_objects();
426 record_monitor = new RecordMonitor(mwindow, this);
428 record_monitor->create_objects();
430 record_gui->update_batch_sources();
433 menu_item->current_state = RECORD_CAPTURING;
434 record_engine = new RecordThread(mwindow, this);
435 record_engine->create_objects();
436 monitor_engine = new RecordThread(mwindow, this);
437 monitor_engine->create_objects();
441 record_gui->show_window();
443 if(video_window_open)
445 record_monitor->window->show_window();
446 record_monitor->window->raise_window();
447 record_monitor->window->flush();
454 window_lock->unlock();
456 result = record_gui->run_window();
457 // Must unlock to stop operation
458 record_gui->unlock_window();
460 // Force monitor to quit without resuming
461 if(monitor_engine->record_video)
462 monitor_engine->record_video->batch_done = 1;
463 else if (monitor_engine->record_audio)
464 monitor_engine->record_audio->batch_done = 1;
467 // stop_operation(0);
468 // Need to stop everything this time
469 monitor_engine->stop_recording(0);
471 record_engine->stop_recording(0);
477 window_lock->lock("Record::run 4");
480 delete record_monitor;
485 delete record_engine;
489 delete monitor_engine;
493 record_gui->save_defaults();
498 window_lock->unlock();
506 menu_item->current_state = RECORD_NOTHING;
508 // Save everything again
516 if(!result && load_mode != LOAD_NOTHING)
518 mwindow->gui->lock_window("Record::run");
519 ArrayList<EDL*> new_edls;
523 for(int i = 0; i < batches.total; i++)
525 Batch *batch = batches.values[i];
526 Asset *asset = batch->get_current_asset();
530 for(int j = 0; j < batch->assets.total; j++)
532 Asset *new_asset = batch->assets.values[j];
533 EDL *new_edl = new EDL;
534 mwindow->remove_asset_from_caches(new_asset);
535 new_edl->create_objects();
536 new_edl->copy_session(mwindow->edl);
537 mwindow->asset_to_edl(new_edl,
540 new_edls.append(new_edl);
548 // For pasting, clear the active region
549 if(load_mode == LOAD_PASTE)
554 mwindow->paste_edls(&new_edls,
558 mwindow->edl->session->labels_follow_edits,
559 mwindow->edl->session->plugins_follow_edits,
561 //printf("Record::run 7\n");
563 new_edls.remove_all_objects();
564 //printf("Record::run 8\n");
566 mwindow->save_backup();
567 mwindow->undo->update_undo(_("record"), LOAD_ALL);
568 mwindow->restart_brender();
569 mwindow->update_plugin_guis();
570 mwindow->gui->update(1,
577 mwindow->sync_parameters(CHANGE_ALL);
579 mwindow->gui->unlock_window();
584 batches.remove_all_objects();
585 Garbage::delete_object(default_asset);
588 void Record::activate_batch(int number, int stop_operation)
590 if(number != current_batch)
592 if(stop_operation) this->stop_operation(1);
594 get_current_batch()->calculate_news();
596 current_batch = number;
597 record_gui->update_batches();
598 record_gui->update_position(current_display_position());
599 record_gui->update_batch_tools();
603 void Record::delete_batch()
605 // Abort if one batch left
606 if(batches.total > 1)
608 // Stop operation if active batch
609 if(current_batch == editing_batch)
611 if(current_batch < batches.total - 1)
612 activate_batch(current_batch + 1, 1);
614 activate_batch(current_batch - 1, 1);
616 delete batches.values[editing_batch];
617 batches.remove_number(editing_batch);
618 editing_batch = current_batch;
622 if(current_batch > editing_batch) current_batch--;
623 delete batches.values[editing_batch];
624 batches.remove_number(editing_batch);
625 if(editing_batch >= batches.total) editing_batch--;
627 record_gui->update_batch_tools();
631 void Record::change_editing_batch(int number)
633 this->editing_batch = number;
634 record_gui->update_batch_tools();
637 Batch* Record::new_batch()
639 Batch *result = new Batch(mwindow, this);
640 //printf("Record::new_batch 1\n");
641 result->create_objects();
642 batches.append(result);
643 result->get_current_asset()->copy_format(default_asset);
645 //printf("Record::new_batch 1\n");
647 result->create_default_path();
648 result->calculate_news();
649 if(get_editing_batch()) result->copy_from(get_editing_batch());
650 editing_batch = batches.total - 1;
651 //printf("Record::new_batch 1\n");
652 // Update GUI if created yet
653 if(record_gui) record_gui->update_batch_tools();
654 //printf("Record::new_batch 2\n");
658 int Record::delete_output_file()
667 Batch *batch = get_current_batch();
668 if(batch && (test = fopen(batch->get_current_asset()->path, "r")))
672 record_gui->lock_window("Record::delete_output_file");
675 sprintf(batch->news, _("Deleting"));
676 record_gui->update_batches();
678 // Remove it from disk
679 mwindow->remove_asset_from_caches(batch->get_current_asset());
680 mwindow->remove_thread->remove_file(batch->get_current_asset()->path);
681 // remove(batch->get_current_asset()->path);
684 sprintf(batch->news, _("OK"));
685 record_gui->update_batches();
687 record_gui->unlock_window();
693 int Record::open_output_file()
696 // Create initial file for the batch
699 Batch *batch = get_current_batch();
700 delete_output_file();
703 result = file->open_file(mwindow->preferences,
704 batch->get_current_asset(),
707 default_asset->sample_rate,
708 default_asset->frame_rate);
717 mwindow->sighandler->push_file(file);
718 IndexFile::delete_index(mwindow->preferences,
719 batch->get_current_asset());
720 file->set_processors(mwindow->preferences->real_processors);
721 batch->calculate_news();
722 record_gui->lock_window("Record::open_output_file");
723 record_gui->update_batches();
724 record_gui->unlock_window();
730 int Record::init_next_file()
732 Batch *batch = get_current_batch();
737 mwindow->sighandler->pull_file(file);
743 batch->current_asset++;
744 batch->assets.append(asset = new Asset);
745 *asset = *default_asset;
746 sprintf(asset->path, "%s%03d", asset->path, batch->current_asset);
747 int result = open_output_file();
751 // Rewind file at the end of a loop.
752 // This is called by RecordThread.
753 void Record::rewind_file()
757 if(default_asset->audio_data)
758 file->set_audio_position(0, default_asset->frame_rate);
759 if(default_asset->video_data)
760 file->set_video_position(0, default_asset->frame_rate);
763 get_current_batch()->current_sample = 0;
764 get_current_batch()->current_frame = 0;
765 record_gui->lock_window("Record::rewind_file");
766 record_gui->update_position(0);
767 record_gui->unlock_window();
770 void Record::start_over()
774 Batch *batch = get_current_batch();
777 mwindow->sighandler->pull_file(file);
783 get_current_batch()->start_over();
785 record_gui->lock_window("Record::start_over");
786 record_gui->update_position(0);
787 record_gui->update_batches();
788 record_gui->unlock_window();
791 void Record::close_output_file()
793 // Can't close until recordmonitor is done
794 //printf("Record::close_output_file 1\n");
797 mwindow->sighandler->pull_file(file);
802 //printf("Record::close_output_file 2\n");
805 void Record::toggle_label()
807 get_current_batch()->toggle_label(current_display_position());
808 record_gui->update_labels(current_display_position());
811 void Record::get_audio_write_length(int &buffer_size,
815 while(fragment_size < default_asset->sample_rate / mwindow->edl->session->record_speed)
818 CLAMP(fragment_size, 1024, 32768);
820 for(buffer_size = fragment_size;
821 buffer_size < mwindow->edl->session->record_write_length;
822 buffer_size += fragment_size)
826 Batch* Record::get_current_batch()
829 return batches.values[current_batch];
834 int Record::get_next_batch()
836 int i = current_batch;
837 while(i < batches.total - 1)
840 if(batches.values[i]->enabled) return i;
846 Batch* Record::get_editing_batch()
848 //printf("Record::get_editing_batch %d %d\n", batches.total, editing_batch);
851 return batches.values[editing_batch];
856 char* Record::current_mode()
858 return Batch::mode_to_text(get_current_batch()->record_mode);
861 int64_t Record::batch_video_offset()
863 return (int64_t)((double)get_current_batch()->file_offset *
864 default_asset->frame_rate + 0.5);
867 int64_t Record::current_audio_position()
871 return (int64_t)(file->get_audio_position(default_asset->sample_rate) +
872 get_current_batch()->file_offset + 0.5);
877 int64_t Record::current_video_position()
881 return file->get_video_position(default_asset->frame_rate) +
882 (int64_t)((double)get_current_batch()->file_offset /
883 default_asset->sample_rate *
884 default_asset->frame_rate +
890 double Record::current_display_position()
892 //printf("Record::current_display_position %d %d\n", get_current_batch()->current_sample, get_current_batch()->file_offset);
895 if(default_asset->video_data)
896 return (double)get_current_batch()->current_frame /
897 default_asset->frame_rate +
898 get_current_batch()->file_offset;
900 return (double)get_current_batch()->current_sample /
901 default_asset->sample_rate +
902 get_current_batch()->file_offset;
906 char* Record::current_source()
908 return get_current_batch()->get_source_text();
911 char* Record::current_news()
913 return batches.values[current_batch]->news;
916 Asset* Record::current_asset()
918 return batches.values[current_batch]->get_current_asset();
921 double* Record::current_start()
923 return &batches.values[current_batch]->start_time;
926 int Record::get_current_channel()
928 return get_current_batch()->channel;
931 int Record::get_editing_channel()
933 return get_editing_batch()->channel;
936 Channel* Record::get_current_channel_struct()
938 int channel = get_current_channel();
939 if(channel >= 0 && channel < channeldb->size())
941 return channeldb->get(channel);
946 double* Record::current_duration()
948 return &batches.values[current_batch]->duration;
951 int64_t Record::current_duration_samples()
953 return (int64_t)((float)batches.values[current_batch]->duration * default_asset->sample_rate + 0.5);
956 int64_t Record::current_duration_frames()
958 return (int64_t)((float)batches.values[current_batch]->duration * default_asset->frame_rate + 0.5);
961 int* Record::current_offset_type()
963 return &batches.values[current_batch]->start_type;
966 ArrayList<Channel*>* Record::get_video_inputs()
968 if(default_asset->video_data && vdevice)
969 return vdevice->get_inputs();
974 int64_t Record::sync_position()
976 switch(capture_state)
982 return monitor_engine->sync_position();
986 return record_engine->sync_position();
993 int Record::open_input_devices(int duplex, int context)
995 int audio_opened = 0;
996 int video_opened = 0;
997 AudioInConfig *aconfig_in = mwindow->edl->session->aconfig_in;
1001 if(default_asset->audio_data && context != CONTEXT_SINGLEFRAME)
1002 adevice = new AudioDevice(mwindow);
1006 if(default_asset->video_data)
1007 vdevice = new VideoDevice(mwindow);
1011 // Initialize sharing
1012 if(adevice && vdevice)
1014 vdevice->set_adevice(adevice);
1015 adevice->set_vdevice(vdevice);
1021 adevice->set_software_positioning(mwindow->edl->session->record_software_position);
1023 // Initialize full duplex
1024 // Duplex is only needed if the timeline and the recording have audio
1025 if(duplex && mwindow->edl->tracks->playable_audio_tracks())
1027 // Case 1: duplex device is identical to input device
1028 // if(AudioInConfig::is_duplex(aconfig_in, mwindow->edl->session->aconfig_duplex))
1030 // adevice->open_duplex(mwindow->edl->session->aconfig_duplex,
1031 // default_asset->sample_rate,
1033 // mwindow->edl->session->real_time_playback);
1034 // audio_opened = 1;
1037 // Case 2: two separate devices
1039 adevice->open_output(mwindow->edl->session->aconfig_duplex,
1040 default_asset->sample_rate,
1041 mwindow->edl->session->playback_buffer,
1042 mwindow->edl->session->audio_channels,
1043 mwindow->edl->session->real_time_playback);
1049 adevice->open_input(mwindow->edl->session->aconfig_in,
1050 mwindow->edl->session->vconfig_in,
1051 default_asset->sample_rate,
1053 default_asset->channels,
1054 mwindow->edl->session->real_time_record);
1055 adevice->start_recording();
1063 vdevice->set_quality(default_asset->jpeg_quality);
1064 vdevice->open_input(mwindow->edl->session->vconfig_in,
1068 default_asset->frame_rate);
1070 // Get configuration parameters from device probe
1071 color_model = vdevice->get_best_colormodel(default_asset);
1072 master_channel->copy_usage(vdevice->channel);
1073 picture->copy_usage(vdevice->picture);
1074 vdevice->set_field_order(reverse_interlace);
1076 // Set the device configuration
1077 set_channel(get_current_channel());
1083 int Record::close_input_devices(int is_monitor)
1085 if(is_monitor && capture_state != IS_MONITORING) return 0;
1089 vdevice->close_all();
1096 adevice->close_all();
1104 int Record::start_recording(int duplex, int context)
1106 if(capture_state != IS_RECORDING)
1110 // Want the devices closed during file deletion to avoid buffer overflow
1111 delete_output_file();
1113 // These two contexts need to open the device here to allow full duplex.
1114 // Batch context opens them in RecordThread::run
1115 if(context == CONTEXT_INTERACTIVE ||
1116 context == CONTEXT_SINGLEFRAME)
1117 open_input_devices(duplex, context);
1121 // start the duplex engine if necessary
1122 // OSS < 3.9 crashes if recording starts before playback
1123 // OSS >= 3.9 crashes if playback starts before recording
1126 capture_state = IS_DUPLEXING;
1129 capture_state = IS_RECORDING;
1131 // Toggle once to cue the user that we're not dead.
1132 if(context == CONTEXT_BATCH)
1134 record_gui->lock_window("Record::start_recording");
1135 record_gui->flash_batch();
1136 record_gui->unlock_window();
1138 record_engine->start_recording(0, context);
1143 int Record::start_monitor()
1145 monitor_timer.update();
1146 open_input_devices(0, CONTEXT_INTERACTIVE);
1147 monitor_engine->start_recording(1, CONTEXT_INTERACTIVE);
1148 capture_state = IS_MONITORING;
1152 int Record::stop_monitor()
1154 monitor_engine->stop_recording(0);
1158 int Record::pause_monitor()
1160 if(capture_state == IS_MONITORING)
1162 monitor_engine->pause_recording();
1167 int Record::resume_monitor()
1169 if(capture_state != IS_MONITORING)
1171 capture_state = IS_MONITORING;
1172 monitor_timer.update();
1173 open_input_devices(0, CONTEXT_INTERACTIVE);
1174 monitor_engine->resume_recording();
1179 int Record::stop_duplex()
1184 int Record::stop_operation(int resume_monitor)
1186 switch(capture_state)
1189 if(!resume_monitor) monitor_engine->stop_recording(0);
1192 record_engine->stop_recording(resume_monitor);
1203 // Remember to change meters if you change this.
1204 // Return the size of the fragments to read from the audio device.
1205 int Record::get_in_length()
1207 int64_t fragment_size = 1;
1208 while(fragment_size < default_asset->sample_rate /
1209 mwindow->edl->session->record_speed)
1212 fragment_size = MAX(fragment_size, 512);
1213 return fragment_size;
1216 int Record::set_video_picture()
1218 if(default_asset->video_data && vdevice)
1219 vdevice->set_picture(picture);
1223 void Record::set_translation(int x, int y)
1227 if(default_asset->video_data && vdevice)
1228 vdevice->set_translation(video_x, video_y);
1232 int Record::set_channel(int channel)
1234 if(channel >= 0 && channel < channeldb->size())
1236 char string[BCTEXTLEN];
1237 get_editing_batch()->channel = channel;
1238 source_to_text(string, get_editing_batch());
1241 record_gui->lock_window("Record::set_channel");
1242 record_gui->batch_source->update(string);
1243 record_monitor->window->channel_picker->channel_text->update(string);
1244 record_gui->update_batches();
1245 record_gui->unlock_window();
1250 vdevice->set_channel(channeldb->get(channel));
1251 set_video_picture();
1257 // Change to a channel not in the db for editing
1258 void Record::set_channel(Channel *channel)
1260 if(vdevice) vdevice->set_channel(channel);
1263 int Record::has_signal()
1265 if(vdevice) return vdevice->has_signal();
1269 void Record::get_current_time(double &seconds, int &day)
1271 time_t result = time(0) + 1;
1272 struct tm *struct_tm = localtime(&result);
1273 day = struct_tm->tm_wday;
1274 seconds = struct_tm->tm_hour * 3600 + struct_tm->tm_min * 60 + struct_tm->tm_sec;
1288 int Record::get_time_format()
1290 return mwindow->edl->session->time_format;
1293 float Record::get_frame_rate()
1296 // return mwindow->session->frame_rate;
1299 int Record::set_loop_duration(int64_t value)
1301 loop_duration = value;
1305 int Record::get_vu_format() { return mwindow->edl->session->meter_format; }
1306 float Record::get_min_db() { return mwindow->edl->session->min_meter_db; }
1308 int Record::get_rec_mode() { return record_mode; }
1309 int Record::set_rec_mode(int value) { record_mode = value; }
1311 int Record::get_video_buffersize() { return mwindow->edl->session->video_write_length; }
1312 int Record::get_everyframe() { return mwindow->edl->session->video_every_frame; }
1314 int Record::get_out_length() { return mwindow->edl->session->playback_buffer; }
1315 int Record::get_software_positioning() { return mwindow->edl->session->record_software_position; }
1316 int64_t Record::get_out_buffersize() { return mwindow->edl->session->playback_buffer; }
1317 int64_t Record::get_in_buffersize() { return mwindow->edl->session->record_write_length; }
1318 int Record::get_realtime() { return realtime; }
1319 int Record::get_meter_speed() { return mwindow->edl->session->record_speed; }
1321 int Record::enable_duplex() { return mwindow->edl->session->enable_duplex; }
1322 int64_t Record::get_playback_buffer() { return mwindow->edl->session->playback_buffer; }