Update AAF import UI

This commit is contained in:
agfline 2024-04-17 23:57:12 +02:00 committed by Robin Gareus
parent 41587d3c06
commit 8ea3a14cd6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 127 additions and 103 deletions

View File

@ -54,9 +54,15 @@ aaf_debug_callback (struct aafLog* log, void* ctxdata, int libid, int type, cons
if (libid != LOG_SRC_ID_TRACE && libid != LOG_SRC_ID_DUMP) { if (libid != LOG_SRC_ID_TRACE && libid != LOG_SRC_ID_DUMP) {
switch (type) { switch (type) {
case VERB_SUCCESS: PBD::info << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc); break; case VERB_SUCCESS:
case VERB_ERROR: PBD::error << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc); break; PBD::info << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc);
case VERB_WARNING: PBD::warning << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc); break; break;
case VERB_ERROR:
PBD::error << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc);
break;
case VERB_WARNING:
PBD::warning << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc);
break;
// case VERB_DEBUG: PBD::debug << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc); break; // case VERB_DEBUG: PBD::debug << string_compose ("[libaaf] %1:%2 in %3(): ", srcfile, lineno, srcfunc); break;
} }
} }
@ -66,9 +72,15 @@ aaf_debug_callback (struct aafLog* log, void* ctxdata, int libid, int type, cons
} }
switch (type) { switch (type) {
case VERB_SUCCESS: PBD::info << msg << eol; break; case VERB_SUCCESS:
case VERB_ERROR: PBD::error << msg << eol; break; PBD::info << msg << eol;
case VERB_WARNING: PBD::warning << msg << eol; break; break;
case VERB_ERROR:
PBD::error << msg << eol;
break;
case VERB_WARNING:
PBD::warning << msg << eol;
break;
// case VERB_DEBUG: PBD::debug << msg << eol; break; // case VERB_DEBUG: PBD::debug << msg << eol; break;
} }
@ -121,8 +133,15 @@ prepare_audio_track (aafiAudioTrack* aafTrack, Session* s)
} }
static bool static bool
import_sndfile_as_region (Session* s, struct aafiAudioEssencePointer* aafAudioEssencePtrList, SrcQuality quality, timepos_t& pos, SourceList& sources, ImportStatus& status, vector<std::shared_ptr<Region>>& regions) import_sndfile_as_region (Session* s, struct aafiAudioEssencePointer* aafAudioEssencePtrList, SrcQuality quality, timepos_t& pos, SourceList** oneClipSources, ImportStatus& status, vector<std::shared_ptr<Region>>& regions)
{ {
SourceList* sources = NULL;
if (aafAudioEssencePtrList->user) {
sources = (SourceList*)aafAudioEssencePtrList->user;
} else {
sources = new SourceList;
/* Import the source */ /* Import the source */
status.clear (); status.clear ();
@ -139,7 +158,8 @@ import_sndfile_as_region (Session* s, struct aafiAudioEssencePointer* aafAudioEs
int channelCount = 0; int channelCount = 0;
aafiAudioEssencePointer* aafAudioEssencePtr = NULL; aafiAudioEssencePointer* aafAudioEssencePtr = NULL;
AAFI_foreachEssencePointer (aafAudioEssencePtrList, aafAudioEssencePtr) { AAFI_foreachEssencePointer (aafAudioEssencePtrList, aafAudioEssencePtr)
{
if (aafAudioEssencePtr->essenceFile->usable_file_path) if (aafAudioEssencePtr->essenceFile->usable_file_path)
status.paths.push_back (aafAudioEssencePtr->essenceFile->usable_file_path); status.paths.push_back (aafAudioEssencePtr->essenceFile->usable_file_path);
else else
@ -152,7 +172,7 @@ import_sndfile_as_region (Session* s, struct aafiAudioEssencePointer* aafAudioEs
s->import_files (status); s->import_files (status);
status.progress = 1.0; status.progress = 1.0;
sources.clear (); sources->clear ();
/* FIXME: There is no way to tell if cancel button was pressed /* FIXME: There is no way to tell if cancel button was pressed
* or if the file failed to import, just that one of these occurred. * or if the file failed to import, just that one of these occurred.
@ -168,37 +188,41 @@ import_sndfile_as_region (Session* s, struct aafiAudioEssencePointer* aafAudioEs
} }
for (int i = 0; i < channelCount; i++) { for (int i = 0; i < channelCount; i++) {
sources.push_back (status.sources.at (i)); sources->push_back (status.sources.at (i));
} }
/* build peakfiles */ /* build peakfiles */
for (SourceList::iterator x = sources.begin (); x != sources.end (); ++x) { for (SourceList::iterator x = sources->begin (); x != sources->end (); ++x) {
SourceFactory::setup_peakfile (*x, true); SourceFactory::setup_peakfile (*x, true);
} }
aafAudioEssencePtrList->user = sources;
}
*oneClipSources = sources;
/* Put the source on a region */ /* Put the source on a region */
std::shared_ptr<Region> region; std::shared_ptr<Region> region;
string region_name; string region_name;
/* take all the sources we have and package them up as a region */ /* take all the sources we have and package them up as a region */
region_name = region_name_from_path (status.paths.front (), (sources.size () > 1), false); region_name = region_name_from_path (status.paths.front (), (sources->size () > 1), false);
/* we checked in import_sndfiles() that there were not too many */ /* we checked in import_sndfiles() that there were not too many */
while (RegionFactory::region_by_name (region_name)) { while (RegionFactory::region_by_name (region_name)) {
region_name = bump_name_once (region_name, '.'); region_name = bump_name_once (region_name, '.');
} }
PropertyList proplist; PropertyList proplist;
proplist.add (ARDOUR::Properties::start, 0); proplist.add (ARDOUR::Properties::start, 0);
proplist.add (ARDOUR::Properties::length, timecnt_t (sources[0]->length (), pos)); proplist.add (ARDOUR::Properties::length, timecnt_t ((*sources)[0]->length (), pos));
proplist.add (ARDOUR::Properties::name, aafAudioEssencePtrList->essenceFile->unique_name); proplist.add (ARDOUR::Properties::name, aafAudioEssencePtrList->essenceFile->unique_name);
proplist.add (ARDOUR::Properties::layer, 0); proplist.add (ARDOUR::Properties::layer, 0);
proplist.add (ARDOUR::Properties::whole_file, true); proplist.add (ARDOUR::Properties::whole_file, true);
proplist.add (ARDOUR::Properties::external, true); proplist.add (ARDOUR::Properties::external, true);
region = RegionFactory::create (sources, proplist); region = RegionFactory::create (*sources, proplist);
regions.push_back (region); regions.push_back (region);
return true; return true;
} }
@ -437,7 +461,6 @@ ARDOUR_UI::new_session_from_aaf (string const& aaf, string const& target_dir, st
aafi_set_debug (aafi, VERB_DEBUG, 0, NULL, &aaf_debug_callback, this); aafi_set_debug (aafi, VERB_DEBUG, 0, NULL, &aaf_debug_callback, this);
if (aafi_load_file (aafi, aaf.c_str ())) { if (aafi_load_file (aafi, aaf.c_str ())) {
error << "AAF: Could not load AAF file." << endmsg; error << "AAF: Could not load AAF file." << endmsg;
aafi_release (&aafi); aafi_release (&aafi);
@ -547,7 +570,7 @@ ARDOUR_UI::new_session_from_aaf (string const& aaf, string const& target_dir, st
/* Import Sources */ /* Import Sources */
SourceList oneClipSources; SourceList* oneClipSources;
ARDOUR::ImportStatus import_status; ARDOUR::ImportStatus import_status;
vector<std::shared_ptr<Region>> source_regions; vector<std::shared_ptr<Region>> source_regions;
timepos_t pos = timepos_t::max (Temporal::AudioTime); timepos_t pos = timepos_t::max (Temporal::AudioTime);
@ -579,8 +602,8 @@ ARDOUR_UI::new_session_from_aaf (string const& aaf, string const& target_dir, st
int essenceError = 0; int essenceError = 0;
char* essenceName = aafAudioClip->essencePointerList->essenceFile->name; char* essenceName = aafAudioClip->essencePointerList->essenceFile->name;
AAFI_foreachEssencePointer (aafAudioClip->essencePointerList, aafAudioEssencePtr) { AAFI_foreachEssencePointer (aafAudioClip->essencePointerList, aafAudioEssencePtr)
{
struct aafiAudioEssenceFile* audioEssenceFile = aafAudioEssencePtr->essenceFile; struct aafiAudioEssenceFile* audioEssenceFile = aafAudioEssencePtr->essenceFile;
if (!audioEssenceFile) { if (!audioEssenceFile) {
@ -607,24 +630,24 @@ ARDOUR_UI::new_session_from_aaf (string const& aaf, string const& target_dir, st
continue; continue;
} }
if (!import_sndfile_as_region (_session, aafAudioClip->essencePointerList, SrcBest, pos, oneClipSources, import_status, source_regions)) { if (!import_sndfile_as_region (_session, aafAudioClip->essencePointerList, SrcBest, pos, &oneClipSources, import_status, source_regions)) {
PBD::error << string_compose ("AAF: Could not import '%1' to session.", essenceName) << endmsg; PBD::error << string_compose ("AAF: Could not import '%1' to session.", essenceName) << endmsg;
continue; continue;
} } else {
else { AAFI_foreachEssencePointer (aafAudioClip->essencePointerList, aafAudioEssencePtr)
AAFI_foreachEssencePointer (aafAudioClip->essencePointerList, aafAudioEssencePtr) { {
if (aafAudioEssencePtr->essenceFile->is_embedded) { if (aafAudioEssencePtr->essenceFile->is_embedded) {
g_unlink (aafAudioEssencePtr->essenceFile->usable_file_path); g_unlink (aafAudioEssencePtr->essenceFile->usable_file_path);
} }
} }
} }
if (oneClipSources.size () == 0) { if (!oneClipSources || oneClipSources->size () == 0) {
error << string_compose (_ ("AAF: Could not create new region for clip '%1': Region has no source"), essenceName) << endmsg; error << string_compose (_ ("AAF: Could not create new region for clip '%1': Region has no source"), essenceName) << endmsg;
continue; continue;
} }
std::shared_ptr<Region> region = create_region (source_regions, aafAudioClip, oneClipSources, sessionStart, samplerate_r); std::shared_ptr<Region> region = create_region (source_regions, aafAudioClip, *oneClipSources, sessionStart, samplerate_r);
if (!region) { if (!region) {
error << string_compose (_ ("AAF: Could not create new region for clip '%1'"), essenceName) << endmsg; error << string_compose (_ ("AAF: Could not create new region for clip '%1'"), essenceName) << endmsg;
@ -643,11 +666,12 @@ ARDOUR_UI::new_session_from_aaf (string const& aaf, string const& target_dir, st
} }
} }
oneClipSources.clear (); // oneClipSources.clear ();
aafiMarker* marker = NULL; aafiMarker* marker = NULL;
AAFI_foreachMarker (aafi, marker) { AAFI_foreachMarker (aafi, marker)
{
aafPosition_t markerStart = sessionStart + aafi_convertUnit (marker->start, marker->edit_rate, &samplerate_r); aafPosition_t markerStart = sessionStart + aafi_convertUnit (marker->start, marker->edit_rate, &samplerate_r);
aafPosition_t markerEnd = sessionStart + aafi_convertUnit ((marker->start + marker->length), marker->edit_rate, &samplerate_r); aafPosition_t markerEnd = sessionStart + aafi_convertUnit ((marker->start + marker->length), marker->edit_rate, &samplerate_r);