X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fexport_handler.cc;h=46cd247d20496d8fd8cef872ba180ea720c3035d;hb=ca25a664d31aa4d16121aa4b41dad8ac04eafb16;hp=b44c46e54902983e98f89c406483a023ff3c9bcf;hpb=91fac4c96dc6210dcc056da70dc608700d7eb570;p=ardour.git diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index b44c46e549..46cd247d20 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -118,7 +118,7 @@ ExportHandler::ExportHandler (Session & session) ExportHandler::~ExportHandler () { - // TODO remove files that were written but not finished + graph_builder->cleanup (export_status->aborted () ); } /** Add an export to the `to-do' list */ @@ -305,6 +305,10 @@ ExportHandler::finish_timespan () export_cd_marker_file (current_timespan, fmt, filename, CDMarkerTOC); } + if (fmt->with_mp4chaps()) { + export_cd_marker_file (current_timespan, fmt, filename, MP4Chaps); + } + if (fmt->tag()) { AudiofileTagger::tag_file(filename, *SessionMetadata::Metadata()); } @@ -403,6 +407,11 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp track_func = &ExportHandler::write_track_info_cue; index_func = &ExportHandler::write_index_info_cue; break; + case MP4Chaps: + header_func = &ExportHandler::write_mp4ch_header; + track_func = &ExportHandler::write_track_info_mp4ch; + index_func = &ExportHandler::write_index_info_mp4ch; + break; default: return; } @@ -500,17 +509,22 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp string ExportHandler::get_cd_marker_filename(std::string filename, CDMarkerFormat format) { - /* do not strip file suffix because there may be more than one format, + /* do not strip file suffix because there may be more than one format, and we do not want the CD marker file from one format to overwrite another (e.g. foo.wav.cue > foo.aiff.cue) */ switch (format) { - case CDMarkerTOC: + case CDMarkerTOC: return filename + ".toc"; - case CDMarkerCUE: + case CDMarkerCUE: return filename + ".cue"; - default: + case MP4Chaps: + { + unsigned lastdot = filename.find_last_of('.'); + return filename.substr(0,lastdot) + ".chapters.txt"; + } + default: return filename + ".marker"; // Should not be reached when actually creating a file } } @@ -577,7 +591,7 @@ ExportHandler::write_toc_header (CDMarkerStatus & status) string album_title = SessionMetadata::Metadata()->album(); if (barcode != "") - status.out << "CATALOG " << barcode << endl; + status.out << "CATALOG \"" << barcode << "\"" << endl; if (album_title != "") title = album_title; @@ -585,10 +599,16 @@ ExportHandler::write_toc_header (CDMarkerStatus & status) status.out << "CD_DA" << endl; status.out << "CD_TEXT {" << endl << " LANGUAGE_MAP {" << endl << " 0 : EN" << endl << " }" << endl; status.out << " LANGUAGE 0 {" << endl << " TITLE " << toc_escape_cdtext (title) << endl ; - status.out << " PERFORMER \"" << toc_escape_cdtext (album_artist) << "\"" << endl; + status.out << " PERFORMER " << toc_escape_cdtext (album_artist) << endl; status.out << " }" << endl << "}" << endl; } +void +ExportHandler::write_mp4ch_header (CDMarkerStatus & status) +{ + status.out << "00:00:00.000 Intro" << endl; +} + void ExportHandler::write_track_info_cue (CDMarkerStatus & status) { @@ -693,6 +713,14 @@ ExportHandler::write_track_info_toc (CDMarkerStatus & status) status.out << "START" << buf << endl; } +void ExportHandler::write_track_info_mp4ch (CDMarkerStatus & status) +{ + gchar buf[18]; + + frames_to_chapter_marks_string(buf, status.track_start_frame); + status.out << buf << " " << status.marker->name() << endl; +} + void ExportHandler::write_index_info_cue (CDMarkerStatus & status) { @@ -715,6 +743,11 @@ ExportHandler::write_index_info_toc (CDMarkerStatus & status) status.out << "INDEX" << buf << endl; } +void +ExportHandler::write_index_info_mp4ch (CDMarkerStatus & status) +{ +} + void ExportHandler::frames_to_cd_frames_string (char* buf, framepos_t when) { @@ -730,6 +763,23 @@ ExportHandler::frames_to_cd_frames_string (char* buf, framepos_t when) sprintf (buf, " %02d:%02d:%02d", mins, secs, frames); } +void +ExportHandler::frames_to_chapter_marks_string (char* buf, framepos_t when) +{ + framecnt_t remainder; + framecnt_t fr = session.nominal_frame_rate(); + int hours, mins, secs, msecs; + + hours = when / (3600 * fr); + remainder = when - (hours * 3600 * fr); + mins = remainder / (60 * fr); + remainder -= mins * 60 * fr; + secs = remainder / fr; + remainder -= secs * fr; + msecs = (remainder * 1000) / fr; + sprintf (buf, "%02d:%02d:%02d.%03d", hours, mins, secs, msecs); +} + std::string ExportHandler::toc_escape_cdtext (const std::string& txt) {