void RDD9ContentPackageManager::SetStartTimecode(Timecode start_timecode) { if (!start_timecode.IsInvalid() && start_timecode.GetRoundedTCBase() == get_rounded_tc_base(mFrameRate)) mStartTimecode = start_timecode; else mStartTimecode.SetInvalid(); }
bool bmx::parse_position(const char *position_str, Timecode start_timecode, Rational frame_rate, int64_t *position) { if (position_str[0] == 'o') { // ignore drop frame indictor for offset Rational nondrop_rate; if (frame_rate.denominator == 1001) { nondrop_rate.numerator = get_rounded_tc_base(frame_rate); nondrop_rate.denominator = 1; } else { nondrop_rate = frame_rate; } Timecode timecode; if (!parse_timecode(position_str + 1, nondrop_rate, &timecode)) return false; *position = timecode.GetOffset(); return true; } Timecode timecode; if (!parse_timecode(position_str, frame_rate, &timecode)) return false; *position = timecode.GetOffset() - start_timecode.GetOffset(); return true; }
bool Database::saveToFile(const std::string &fileName , const char delim ) const { std::ofstream file; file.open( fileName.c_str() ); if ( !file.is_open() ) return false; Date now; Timecode t; t.setToCurrentTime(); file << "########## Database file generated on " << now.toString().c_str() << " at " << t.getString(true,true,true,false).c_str() << " ##########" ; file << "\n"; file << "\n"; for (const DataPair &pair : _dataList ) { file << pair.first << " " << delim << " " << pair.second.getString(); file << "\n"; file << "\n"; } file.close(); return true; }
static void write_segmentation_framework(AppInfoWriter *info_writer, DMSegment *seg, Timecode start_timecode, int64_t offset, Rational edit_rate) { AS11SegmentationFramework *framework = dynamic_cast<AS11SegmentationFramework*>(seg->getDMFramework()); Timecode som = start_timecode; som.AddOffset(offset, edit_rate); AppTextInfoWriter *text_writer = dynamic_cast<AppTextInfoWriter*>(info_writer); if (text_writer) text_writer->PushItemValueIndent(strlen("part_number ")); info_writer->WriteIntegerItem("part_number", framework->GetPartNumber()); info_writer->WriteIntegerItem("part_total", framework->GetPartNumber()); info_writer->WriteTimecodeItem("som", som); info_writer->WriteDurationItem("duration", seg->getDuration(), edit_rate); if (text_writer) text_writer->PopItemValueIndent(); }
static string timecode_to_string(Timecode timecode) { char buffer[64]; sprintf(buffer, "%02d:%02d:%02d%c%02d (@ %dfps)", timecode.GetHour(), timecode.GetMin(), timecode.GetSec(), timecode.IsDropFrame() ? ';' : ':', timecode.GetFrame(), timecode.GetRoundedTCBase()); return buffer; }
KeyframeImport::KeyframeImport(ItemInfo srcInfo, ItemInfo dstInfo, QMap<QString, QString> data, const Timecode &tc, QDomElement xml, ProfileInfo profile, QWidget *parent) : QDialog(parent) , m_xml(xml) , m_profile(profile) , m_supportsAnim(false) { QVBoxLayout *lay = new QVBoxLayout(this); QHBoxLayout *l1 = new QHBoxLayout; QLabel *lab = new QLabel(i18n("Data to import: "), this); l1->addWidget(lab); m_dataCombo = new QComboBox(this); l1->addWidget(m_dataCombo); l1->addStretch(10); lay->addLayout(l1); // Set up data int ix = 0; QMap<QString, QString>::const_iterator i = data.constBegin(); while (i != data.constEnd()) { m_dataCombo->insertItem(ix, i.key()); m_dataCombo->setItemData(ix, i.value(), Qt::UserRole); ++i; ix++; } m_previewLabel = new QLabel(this); m_previewLabel->setMinimumSize(100, 150); m_previewLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_previewLabel->setScaledContents(true); lay->addWidget(m_previewLabel); m_keyframeView = new KeyframeView(0, this); // Zone in / out m_inPoint = new PositionEdit(i18n("In"), srcInfo.cropStart.frames(tc.fps()), srcInfo.cropStart.frames(tc.fps()), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), tc, this); connect(m_inPoint, SIGNAL(parameterChanged(int)), this, SLOT(updateDisplay())); lay->addWidget(m_inPoint); m_outPoint = new PositionEdit(i18n("Out"), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), srcInfo.cropStart.frames(tc.fps()), (srcInfo.cropStart + srcInfo.cropDuration).frames(tc.fps()), tc, this); connect(m_outPoint, SIGNAL(parameterChanged(int)), this, SLOT(updateDisplay())); lay->addWidget(m_outPoint); // Check what kind of parameters are in our target QDomNodeList params = xml.elementsByTagName(QStringLiteral("parameter")); for (int i = 0; i < params.count(); i++) { QDomElement e = params.at(i).toElement(); QString pType = e.attribute(QStringLiteral("type")); if (pType == QLatin1String("animatedrect") || pType == QLatin1String("geometry")) { if (pType == QLatin1String("animatedrect")) m_supportsAnim = true; QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = na.isNull() ? e.attribute(QStringLiteral("name")) : i18n(na.text().toUtf8().data()); m_geometryTargets.insert(paramName, e.attribute(QStringLiteral("name"))); } else if (pType == QLatin1String("animated")) { QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = na.isNull() ? e.attribute(QStringLiteral("name")) : i18n(na.text().toUtf8().data()); m_simpleTargets.insert(paramName, e.attribute(QStringLiteral("name"))); } } l1 = new QHBoxLayout; m_targetCombo = new QComboBox(this); m_sourceCombo = new QComboBox(this); ix = 0; if (!m_geometryTargets.isEmpty()) { m_sourceCombo->insertItem(ix, i18n("Geometry")); m_sourceCombo->setItemData(ix, QString::number(10), Qt::UserRole); ix++; } if (!m_simpleTargets.isEmpty()) { m_sourceCombo->insertItem(ix, i18n("X")); m_sourceCombo->setItemData(ix, QString::number(0), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Y")); m_sourceCombo->setItemData(ix, QString::number(1), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Width")); m_sourceCombo->setItemData(ix, QString::number(2), Qt::UserRole); ix++; m_sourceCombo->insertItem(ix, i18n("Height")); m_sourceCombo->setItemData(ix, QString::number(3), Qt::UserRole); ix++; } connect(m_sourceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRange())); lab = new QLabel(i18n("Map "), this); QLabel *lab2 = new QLabel(i18n(" to "), this); l1->addWidget(lab); l1->addWidget(m_sourceCombo); l1->addWidget(lab2); l1->addWidget(m_targetCombo); l1->addStretch(10); ix = 0; QMap<QString, QString>::const_iterator j = m_geometryTargets.constBegin(); while (j != m_geometryTargets.constEnd()) { m_targetCombo->insertItem(ix, j.key()); m_targetCombo->setItemData(ix, j.value(), Qt::UserRole); ++j; ix++; } ix = 0; j = m_simpleTargets.constBegin(); while (j != m_simpleTargets.constEnd()) { m_targetCombo->insertItem(ix, j.key()); m_targetCombo->setItemData(ix, j.value(), Qt::UserRole); ++j; ix++; } if (m_simpleTargets.count() + m_geometryTargets.count() > 1) { // Target contains several animatable parameters, propose choice } lay->addLayout(l1); // Output offset m_offsetPoint = new PositionEdit(i18n("Offset"), 0, 0, dstInfo.cropDuration.frames(tc.fps()), tc, this); lay->addWidget(m_offsetPoint); // Source range m_sourceRangeLabel = new QLabel(i18n("Source range %1 to %2", 0, 100), this); lay->addWidget(m_sourceRangeLabel); // update range info connect(m_targetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDestinationRange())); // Destination range l1 = new QHBoxLayout; lab = new QLabel(i18n("Destination range"), this); l1->addWidget(lab); l1->addWidget(&m_destMin); l1->addWidget(&m_destMax); lay->addLayout(l1); l1 = new QHBoxLayout; m_limitRange = new QCheckBox(i18n("Actual range only"), this); connect(m_limitRange, SIGNAL(toggled(bool)), this, SLOT(updateRange())); connect(m_limitRange, SIGNAL(toggled(bool)), this, SLOT(updateDisplay())); l1->addWidget(m_limitRange); l1->addStretch(10); lay->addLayout(l1); l1 = new QHBoxLayout; m_limitKeyframes = new QCheckBox(i18n("Limit keyframe number"), this); m_limitKeyframes->setChecked(true); m_limitNumber = new QSpinBox(this); m_limitNumber->setMinimum(1); m_limitNumber->setValue(20); l1->addWidget(m_limitKeyframes); l1->addWidget(m_limitNumber); l1->addStretch(10); lay->addLayout(l1); connect(m_limitKeyframes, &QCheckBox::toggled, m_limitNumber, &QSpinBox::setEnabled); connect(m_limitKeyframes, SIGNAL(toggled(bool)), this, SLOT(updateDisplay())); connect(m_limitNumber, SIGNAL(valueChanged(int)), this, SLOT(updateDisplay())); connect(m_dataCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDataDisplay())); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); lay->addWidget(buttonBox); updateDestinationRange(); updateDataDisplay(); }
RecordingDevice::ReturnCode RecordingDevice::StopRecording(const Timecode & tc) { bool ok_so_far = true; ReturnCode return_code = OK; if(CORBA::is_nil(mRecorder)) { ok_so_far = false; return_code = NO_DEVICE; } if (ok_so_far) { // Sort out parameters to be passed ProdAuto::MxfTimecode stop_tc_mxf; stop_tc_mxf.undefined = false; stop_tc_mxf.samples = tc.FramesSinceMidnight(); //::Duration post_roll_dur; //post_roll_dur.TotalFrames(post_roll_frames); ProdAuto::MxfDuration post_roll_mxf; post_roll_mxf.undefined = false; post_roll_mxf.samples = post_roll_frames; ::ProdAuto::Recorder::ReturnCode result; CORBA::StringSeq_var files; ::ProdAuto::LocatorSeq locators; try { result = mRecorder->Stop(stop_tc_mxf, post_roll_mxf, "", "", locators, files.out()); } catch (const CORBA::Exception &) { result = ProdAuto::Recorder::FAILURE; } if(ProdAuto::Recorder::SUCCESS == result) { //stop_tc += post_roll_dur; //mOutTime = stop_tc.Text(); // store the stop timecode //::Duration dur_tc; //dur_tc = Timecode(mOutTime.c_str()) - Timecode(mInTime.c_str()); //mDuration = dur_tc.Text(); // store the duration // need to store paths //for(int i = 0; i < SDI_RECORDER_CHANNELS; ++i) //{ //mFilename[i] = path.in()[i].in(); //} mIsRecording = false; mHasRecorded = true; } else { ok_so_far = false; return_code = FAILED; } } return return_code; }
/** Get remote device to start recording. For the moment, we enable all tracks. */ RecordingDevice::ReturnCode RecordingDevice::StartRecording(const Timecode & tc, const std::string & description) { bool ok_so_far = true; ReturnCode return_code = OK; mHasRecorded = false; ProdAuto::MxfTimecode start_tc_mxf; #if 1 // Normal operation start_tc_mxf.undefined = false; #else // Crash record for testing start_tc_mxf.undefined = true; #endif start_tc_mxf.samples = tc.FramesSinceMidnight(); ProdAuto::MxfDuration pre_roll_mxf; pre_roll_mxf.undefined = false; pre_roll_mxf.samples = pre_roll_frames; if(CORBA::is_nil(mRecorder)) { ok_so_far = false; return_code = NO_DEVICE; } if(ok_so_far) { // Sort out parameters to be passed CORBA::BooleanSeq rec_enable; rec_enable.length(mTrackCount); //::ProdAuto::StringArray tape_number; //::ProdAuto::StringList_var files; for(int i = 0; i < mTrackCount; ++i) { //tape_number[i] = CORBA::string_dup(tape[i]); rec_enable[i] = 1; } ProdAuto::Recorder::ReturnCode result; CORBA::StringSeq tapes; // Attempt operation on remote recorder try { result = mRecorder->Start( start_tc_mxf, pre_roll_mxf, rec_enable, false ); if(ProdAuto::Recorder::SUCCESS == result) { return_code = RecordingDevice::OK; } else { return_code = RecordingDevice::FAILED; } } catch (const CORBA::Exception &) { result = ProdAuto::Recorder::FAILURE; return_code = RecordingDevice::NO_DEVICE; } if(ProdAuto::Recorder::SUCCESS == result) { //start_tc -= pre_roll_dur; //mInTime = start_tc.Text(); // store the start timecode //mDuration = ""; //for(CORBA::ULong i = 0; i < files->length(); ++i) //{ // mFilename[i] = (const char *) files[i]; //} mIsRecording = true; } else { ok_so_far = false; } } return return_code; }
int main(int argc, const char **argv) { bool output_set = false; bool output_timecode = false; bool drop_frame = false; Rational frame_rate = FRAME_RATE_25; const char *value_str = 0; int cmdln_index = 1; for (cmdln_index = 1; cmdln_index < argc; cmdln_index++) { if (strcmp(argv[cmdln_index], "--output") == 0) { if (cmdln_index + 1 >= argc) { usage(argv[0]); return 1; } if (strcmp(argv[cmdln_index + 1], "tc-drop") == 0) { output_timecode = true; drop_frame = true; } else if (strcmp(argv[cmdln_index + 1], "tc-non-drop") == 0) { output_timecode = true; drop_frame = false; } else if (strcmp(argv[cmdln_index + 1], "count") == 0) { output_timecode = false; } else { usage(argv[0]); return 1; } output_set = true; cmdln_index++; } else if (strcmp(argv[cmdln_index], "--rate") == 0) { if (cmdln_index + 1 >= argc) { usage(argv[0]); return 1; } if (!::parse_frame_rate(argv[cmdln_index + 1], &frame_rate)) { usage(argv[0]); return 1; } cmdln_index++; } else { break; } } if (cmdln_index + 1 != argc) { usage(argv[0]); return 1; } if (strcmp(argv[cmdln_index], "all") != 0) value_str = argv[cmdln_index]; if (value_str) { Timecode timecode; if (parse_timecode(value_str, frame_rate, &timecode)) { if (!output_set) output_timecode = false; if (output_timecode) timecode.Init(frame_rate, drop_frame, timecode.GetOffset()); } else { int64_t offset; if (sscanf(value_str, "%" PRId64, &offset) != 1) { fprintf(stderr, "Failed to parse timecode or frame offset\n"); return 1; } timecode.Init(frame_rate, drop_frame, offset); if (!output_set) output_timecode = true; } if (output_timecode) printf("%s\n", get_timecode_string(timecode).c_str()); else printf("%" PRId64 "\n", timecode.GetOffset()); } else { Timecode timecode(frame_rate, drop_frame, 0); int64_t max_offset = timecode.GetMaxOffset(); int64_t i; for (i = 0; i < max_offset; i++) { timecode.Init(frame_rate, drop_frame, i); printf("%8" PRId64 ": %s\n", i, get_timecode_string(timecode).c_str()); } } return 0; }