void MainWindow::setSubtitleTrack() { QString path; QString filter = "*.mxf"; char *file; path = QFileDialog::getOpenFileName(this, tr("Choose an file to open"),QString::null,filter); if (path.isEmpty()) { return; } file = new char [path.toStdString().size()+1]; strcpy(file, path.toStdString().c_str()); if (get_file_essence_class(file) != ACT_TIMED_TEXT) { QMessageBox::critical(this, tr("Not a Subtitle Track"), tr("The selected file is not a valid MXF subtitle track.")); } else { ui->reelSubtitleEdit->setProperty("text", path); strcpy(subtitleAsset.filename, ui->reelSubtitleEdit->text().toStdString().c_str()); read_asset_info(&subtitleAsset); ui->reelSubtitleDurationSpinBox->setValue(subtitleAsset.duration); ui->reelSubtitleDurationSpinBox->setMaximum(subtitleAsset.intrinsic_duration); ui->reelSubtitleOffsetSpinBox->setMaximum(subtitleAsset.intrinsic_duration-1); } delete[] file; return; }
int add_reel(opendcp_t *opendcp, cpl_t *cpl, asset_list_t reel) { int result; int x,r; FILE *fp; char *filename; asset_t asset; struct stat st; char uuid_s[40]; dcp_log(LOG_INFO,"Adding Reel"); r = cpl->reel_count; /* add reel uuid */ uuid_random(uuid_s); sprintf(cpl->reel[r].uuid,"%.36s",uuid_s); /* parse argument and read asset information */ for (x=0;x<reel.asset_count;x++) { filename=reel.asset_list[x].filename; init_asset(&asset); sprintf(asset.filename,"%s",filename); sprintf(asset.annotation,"%s",basename(filename)); /* check if file exists */ if ((fp = fopen(filename, "r")) == NULL) { dcp_log(LOG_ERROR,"add_reel: Could not open file: %s",filename); return DCP_FILE_OPEN_ERROR; } else { fclose (fp); } /* get file size */ stat(filename, &st); sprintf(asset.size,"%"PRIu64, st.st_size); /* read asset information */ dcp_log(LOG_INFO,"add_reel: Reading %s asset information",filename); result = read_asset_info(&asset); if (result == DCP_FATAL) { dcp_log(LOG_ERROR,"%s is not a proper essence file",filename); return DCP_INVALID_ESSENCE; } if (x == 0) { opendcp->ns = asset.xml_ns; dcp_log(LOG_DEBUG,"add_reel: Label type detected: %d",opendcp->ns); } else { if (opendcp->ns != asset.xml_ns) { dcp_log(LOG_ERROR,"Warning DCP specification mismatch in assets. Please make sure all assets are MXF Interop or SMPTE"); return DCP_SPECIFCATION_MISMATCH; } } /* force aspect ratio, if specified */ if (strcmp(opendcp->xml.aspect_ratio,"") ) { sprintf(asset.aspect_ratio,"%s",opendcp->xml.aspect_ratio); } /* Set duration, if specified */ if (opendcp->duration) { if (opendcp->duration<asset.duration) { asset.duration = opendcp->duration; } else { dcp_log(LOG_WARN,"Desired duration %d cannot be greater than assset duration %d, ignoring value",opendcp->duration,asset.duration); } } /* Set entry point, if specified */ if (opendcp->entry_point) { if (opendcp->entry_point<asset.duration) { asset.entry_point = opendcp->entry_point; } else { dcp_log(LOG_WARN,"Desired entry point %d cannot be greater than assset duration %d, ignoring value",opendcp->entry_point,asset.duration); } } /* calculate digest */ calculate_digest(filename,asset.digest); /* get asset type */ result = get_asset_type(asset); /* add asset to cpl */ cpl->reel[r].asset[x] = asset; cpl->reel[r].asset_count++; } cpl->reel_count++; return DCP_SUCCESS; }