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);
560 //printf("Record::run 7\n");
562 new_edls.remove_all_objects();
563 //printf("Record::run 8\n");
565 mwindow->save_backup();
566 mwindow->undo->update_undo(_("record"), LOAD_ALL);
567 mwindow->restart_brender();
568 mwindow->update_plugin_guis();
569 mwindow->gui->update(1,
576 mwindow->sync_parameters(CHANGE_ALL);
578 mwindow->gui->unlock_window();
583 batches.remove_all_objects();
584 Garbage::delete_object(default_asset);
587 void Record::activate_batch(int number, int stop_operation)
589 if(number != current_batch)
591 if(stop_operation) this->stop_operation(1);
593 get_current_batch()->calculate_news();
595 current_batch = number;
596 record_gui->update_batches();
597 record_gui->update_position(current_display_position());
598 record_gui->update_batch_tools();
602 void Record::delete_batch()
604 // Abort if one batch left
605 if(batches.total > 1)
607 // Stop operation if active batch
608 if(current_batch == editing_batch)
610 if(current_batch < batches.total - 1)
611 activate_batch(current_batch + 1, 1);
613 activate_batch(current_batch - 1, 1);
615 delete batches.values[editing_batch];
616 batches.remove_number(editing_batch);
617 editing_batch = current_batch;
621 if(current_batch > editing_batch) current_batch--;
622 delete batches.values[editing_batch];
623 batches.remove_number(editing_batch);
624 if(editing_batch >= batches.total) editing_batch--;
626 record_gui->update_batch_tools();
630 void Record::change_editing_batch(int number)
632 this->editing_batch = number;
633 record_gui->update_batch_tools();
636 Batch* Record::new_batch()
638 Batch *result = new Batch(mwindow, this);
639 //printf("Record::new_batch 1\n");
640 result->create_objects();
641 batches.append(result);
642 result->get_current_asset()->copy_format(default_asset);
644 //printf("Record::new_batch 1\n");
646 result->create_default_path();
647 result->calculate_news();
648 if(get_editing_batch()) result->copy_from(get_editing_batch());
649 editing_batch = batches.total - 1;
650 //printf("Record::new_batch 1\n");
651 // Update GUI if created yet
652 if(record_gui) record_gui->update_batch_tools();
653 //printf("Record::new_batch 2\n");
657 int Record::delete_output_file()
666 Batch *batch = get_current_batch();
667 if(batch && (test = fopen(batch->get_current_asset()->path, "r")))
671 record_gui->lock_window("Record::delete_output_file");
674 sprintf(batch->news, _("Deleting"));
675 record_gui->update_batches();
677 // Remove it from disk
678 mwindow->remove_asset_from_caches(batch->get_current_asset());
679 mwindow->remove_thread->remove_file(batch->get_current_asset()->path);
680 // remove(batch->get_current_asset()->path);
683 sprintf(batch->news, _("OK"));
684 record_gui->update_batches();
686 record_gui->unlock_window();
692 int Record::open_output_file()
695 // Create initial file for the batch
698 Batch *batch = get_current_batch();
699 delete_output_file();
702 result = file->open_file(mwindow->preferences,
703 batch->get_current_asset(),
706 default_asset->sample_rate,
707 default_asset->frame_rate);
716 mwindow->sighandler->push_file(file);
717 IndexFile::delete_index(mwindow->preferences,
718 batch->get_current_asset());
719 file->set_processors(mwindow->preferences->real_processors);
720 batch->calculate_news();
721 record_gui->lock_window("Record::open_output_file");
722 record_gui->update_batches();
723 record_gui->unlock_window();
729 int Record::init_next_file()
731 Batch *batch = get_current_batch();
736 mwindow->sighandler->pull_file(file);
742 batch->current_asset++;
743 batch->assets.append(asset = new Asset);
744 *asset = *default_asset;
745 sprintf(asset->path, "%s%03d", asset->path, batch->current_asset);
746 int result = open_output_file();
750 // Rewind file at the end of a loop.
751 // This is called by RecordThread.
752 void Record::rewind_file()
756 if(default_asset->audio_data)
757 file->set_audio_position(0, default_asset->frame_rate);
758 if(default_asset->video_data)
759 file->set_video_position(0, default_asset->frame_rate);
762 get_current_batch()->current_sample = 0;
763 get_current_batch()->current_frame = 0;
764 record_gui->lock_window("Record::rewind_file");
765 record_gui->update_position(0);
766 record_gui->unlock_window();
769 void Record::start_over()
773 Batch *batch = get_current_batch();
776 mwindow->sighandler->pull_file(file);
782 get_current_batch()->start_over();
784 record_gui->lock_window("Record::start_over");
785 record_gui->update_position(0);
786 record_gui->update_batches();
787 record_gui->unlock_window();
790 void Record::close_output_file()
792 // Can't close until recordmonitor is done
793 //printf("Record::close_output_file 1\n");
796 mwindow->sighandler->pull_file(file);
801 //printf("Record::close_output_file 2\n");
804 void Record::toggle_label()
806 get_current_batch()->toggle_label(current_display_position());
807 record_gui->update_labels(current_display_position());
810 void Record::get_audio_write_length(int &buffer_size,
814 while(fragment_size < default_asset->sample_rate / mwindow->edl->session->record_speed)
817 CLAMP(fragment_size, 1024, 32768);
819 for(buffer_size = fragment_size;
820 buffer_size < mwindow->edl->session->record_write_length;
821 buffer_size += fragment_size)
825 Batch* Record::get_current_batch()
828 return batches.values[current_batch];
833 int Record::get_next_batch()
835 int i = current_batch;
836 while(i < batches.total - 1)
839 if(batches.values[i]->enabled) return i;
845 Batch* Record::get_editing_batch()
847 //printf("Record::get_editing_batch %d %d\n", batches.total, editing_batch);
850 return batches.values[editing_batch];
855 char* Record::current_mode()
857 return Batch::mode_to_text(get_current_batch()->record_mode);
860 int64_t Record::batch_video_offset()
862 return (int64_t)((double)get_current_batch()->file_offset *
863 default_asset->frame_rate + 0.5);
866 int64_t Record::current_audio_position()
870 return (int64_t)(file->get_audio_position(default_asset->sample_rate) +
871 get_current_batch()->file_offset + 0.5);
876 int64_t Record::current_video_position()
880 return file->get_video_position(default_asset->frame_rate) +
881 (int64_t)((double)get_current_batch()->file_offset /
882 default_asset->sample_rate *
883 default_asset->frame_rate +
889 double Record::current_display_position()
891 //printf("Record::current_display_position %d %d\n", get_current_batch()->current_sample, get_current_batch()->file_offset);
894 if(default_asset->video_data)
895 return (double)get_current_batch()->current_frame /
896 default_asset->frame_rate +
897 get_current_batch()->file_offset;
899 return (double)get_current_batch()->current_sample /
900 default_asset->sample_rate +
901 get_current_batch()->file_offset;
905 char* Record::current_source()
907 return get_current_batch()->get_source_text();
910 char* Record::current_news()
912 return batches.values[current_batch]->news;
915 Asset* Record::current_asset()
917 return batches.values[current_batch]->get_current_asset();
920 double* Record::current_start()
922 return &batches.values[current_batch]->start_time;
925 int Record::get_current_channel()
927 return get_current_batch()->channel;
930 int Record::get_editing_channel()
932 return get_editing_batch()->channel;
935 Channel* Record::get_current_channel_struct()
937 int channel = get_current_channel();
938 if(channel >= 0 && channel < channeldb->size())
940 return channeldb->get(channel);
945 double* Record::current_duration()
947 return &batches.values[current_batch]->duration;
950 int64_t Record::current_duration_samples()
952 return (int64_t)((float)batches.values[current_batch]->duration * default_asset->sample_rate + 0.5);
955 int64_t Record::current_duration_frames()
957 return (int64_t)((float)batches.values[current_batch]->duration * default_asset->frame_rate + 0.5);
960 int* Record::current_offset_type()
962 return &batches.values[current_batch]->start_type;
965 ArrayList<Channel*>* Record::get_video_inputs()
967 if(default_asset->video_data && vdevice)
968 return vdevice->get_inputs();
973 int64_t Record::sync_position()
975 switch(capture_state)
981 return monitor_engine->sync_position();
985 return record_engine->sync_position();
992 int Record::open_input_devices(int duplex, int context)
994 int audio_opened = 0;
995 int video_opened = 0;
996 AudioInConfig *aconfig_in = mwindow->edl->session->aconfig_in;
1000 if(default_asset->audio_data && context != CONTEXT_SINGLEFRAME)
1001 adevice = new AudioDevice(mwindow);
1005 if(default_asset->video_data)
1006 vdevice = new VideoDevice(mwindow);
1010 // Initialize sharing
1011 if(adevice && vdevice)
1013 vdevice->set_adevice(adevice);
1014 adevice->set_vdevice(vdevice);
1020 adevice->set_software_positioning(mwindow->edl->session->record_software_position);
1022 // Initialize full duplex
1023 // Duplex is only needed if the timeline and the recording have audio
1024 if(duplex && mwindow->edl->tracks->playable_audio_tracks())
1026 // Case 1: duplex device is identical to input device
1027 // if(AudioInConfig::is_duplex(aconfig_in, mwindow->edl->session->aconfig_duplex))
1029 // adevice->open_duplex(mwindow->edl->session->aconfig_duplex,
1030 // default_asset->sample_rate,
1032 // mwindow->edl->session->real_time_playback);
1033 // audio_opened = 1;
1036 // Case 2: two separate devices
1038 adevice->open_output(mwindow->edl->session->aconfig_duplex,
1039 default_asset->sample_rate,
1040 mwindow->edl->session->playback_buffer,
1041 mwindow->edl->session->audio_channels,
1042 mwindow->edl->session->real_time_playback);
1048 adevice->open_input(mwindow->edl->session->aconfig_in,
1049 mwindow->edl->session->vconfig_in,
1050 default_asset->sample_rate,
1052 default_asset->channels,
1053 mwindow->edl->session->real_time_record);
1054 adevice->start_recording();
1062 vdevice->set_quality(default_asset->jpeg_quality);
1063 vdevice->open_input(mwindow->edl->session->vconfig_in,
1067 default_asset->frame_rate);
1069 // Get configuration parameters from device probe
1070 color_model = vdevice->get_best_colormodel(default_asset);
1071 master_channel->copy_usage(vdevice->channel);
1072 picture->copy_usage(vdevice->picture);
1073 vdevice->set_field_order(reverse_interlace);
1075 // Set the device configuration
1076 set_channel(get_current_channel());
1082 int Record::close_input_devices(int is_monitor)
1084 if(is_monitor && capture_state != IS_MONITORING) return 0;
1088 vdevice->close_all();
1095 adevice->close_all();
1103 int Record::start_recording(int duplex, int context)
1105 if(capture_state != IS_RECORDING)
1109 // Want the devices closed during file deletion to avoid buffer overflow
1110 delete_output_file();
1112 // These two contexts need to open the device here to allow full duplex.
1113 // Batch context opens them in RecordThread::run
1114 if(context == CONTEXT_INTERACTIVE ||
1115 context == CONTEXT_SINGLEFRAME)
1116 open_input_devices(duplex, context);
1120 // start the duplex engine if necessary
1121 // OSS < 3.9 crashes if recording starts before playback
1122 // OSS >= 3.9 crashes if playback starts before recording
1125 capture_state = IS_DUPLEXING;
1128 capture_state = IS_RECORDING;
1130 // Toggle once to cue the user that we're not dead.
1131 if(context == CONTEXT_BATCH)
1133 record_gui->lock_window("Record::start_recording");
1134 record_gui->flash_batch();
1135 record_gui->unlock_window();
1137 record_engine->start_recording(0, context);
1142 int Record::start_monitor()
1144 monitor_timer.update();
1145 open_input_devices(0, CONTEXT_INTERACTIVE);
1146 monitor_engine->start_recording(1, CONTEXT_INTERACTIVE);
1147 capture_state = IS_MONITORING;
1151 int Record::stop_monitor()
1153 monitor_engine->stop_recording(0);
1157 int Record::pause_monitor()
1159 if(capture_state == IS_MONITORING)
1161 monitor_engine->pause_recording();
1166 int Record::resume_monitor()
1168 if(capture_state != IS_MONITORING)
1170 capture_state = IS_MONITORING;
1171 monitor_timer.update();
1172 open_input_devices(0, CONTEXT_INTERACTIVE);
1173 monitor_engine->resume_recording();
1178 int Record::stop_duplex()
1183 int Record::stop_operation(int resume_monitor)
1185 switch(capture_state)
1188 if(!resume_monitor) monitor_engine->stop_recording(0);
1191 record_engine->stop_recording(resume_monitor);
1202 // Remember to change meters if you change this.
1203 // Return the size of the fragments to read from the audio device.
1204 int Record::get_in_length()
1206 int64_t fragment_size = 1;
1207 while(fragment_size < default_asset->sample_rate /
1208 mwindow->edl->session->record_speed)
1211 fragment_size = MAX(fragment_size, 512);
1212 return fragment_size;
1215 int Record::set_video_picture()
1217 if(default_asset->video_data && vdevice)
1218 vdevice->set_picture(picture);
1222 void Record::set_translation(int x, int y)
1226 if(default_asset->video_data && vdevice)
1227 vdevice->set_translation(video_x, video_y);
1231 int Record::set_channel(int channel)
1233 if(channel >= 0 && channel < channeldb->size())
1235 char string[BCTEXTLEN];
1236 get_editing_batch()->channel = channel;
1237 source_to_text(string, get_editing_batch());
1240 record_gui->lock_window("Record::set_channel");
1241 record_gui->batch_source->update(string);
1242 record_monitor->window->channel_picker->channel_text->update(string);
1243 record_gui->update_batches();
1244 record_gui->unlock_window();
1249 vdevice->set_channel(channeldb->get(channel));
1250 set_video_picture();
1256 // Change to a channel not in the db for editing
1257 void Record::set_channel(Channel *channel)
1259 if(vdevice) vdevice->set_channel(channel);
1262 int Record::has_signal()
1264 if(vdevice) return vdevice->has_signal();
1268 void Record::get_current_time(double &seconds, int &day)
1270 time_t result = time(0) + 1;
1271 struct tm *struct_tm = localtime(&result);
1272 day = struct_tm->tm_wday;
1273 seconds = struct_tm->tm_hour * 3600 + struct_tm->tm_min * 60 + struct_tm->tm_sec;
1287 int Record::get_time_format()
1289 return mwindow->edl->session->time_format;
1292 float Record::get_frame_rate()
1295 // return mwindow->session->frame_rate;
1298 int Record::set_loop_duration(int64_t value)
1300 loop_duration = value;
1304 int Record::get_vu_format() { return mwindow->edl->session->meter_format; }
1305 float Record::get_min_db() { return mwindow->edl->session->min_meter_db; }
1307 int Record::get_rec_mode() { return record_mode; }
1308 int Record::set_rec_mode(int value) { record_mode = value; }
1310 int Record::get_video_buffersize() { return mwindow->edl->session->video_write_length; }
1311 int Record::get_everyframe() { return mwindow->edl->session->video_every_frame; }
1313 int Record::get_out_length() { return mwindow->edl->session->playback_buffer; }
1314 int Record::get_software_positioning() { return mwindow->edl->session->record_software_position; }
1315 int64_t Record::get_out_buffersize() { return mwindow->edl->session->playback_buffer; }
1316 int64_t Record::get_in_buffersize() { return mwindow->edl->session->record_write_length; }
1317 int Record::get_realtime() { return realtime; }
1318 int Record::get_meter_speed() { return mwindow->edl->session->record_speed; }
1320 int Record::enable_duplex() { return mwindow->edl->session->enable_duplex; }
1321 int64_t Record::get_playback_buffer() { return mwindow->edl->session->playback_buffer; }