#include "ardour/export_handler.h"
-#include <glib/gstdio.h>
+#include <pbd/gstdio_compat.h>
#include <glibmm.h>
#include <glibmm/convert.h>
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 */
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()) {
+ /* close file first, otherwise TagLib enounters an ERROR_SHARING_VIOLATION
+ * The process cannot access the file because it is being used.
+ *
+ * TODO: check Umlauts and encoding in filename.
+ * TagLib eventually calls CreateFileA(),
+ */
+ graph_builder->reset ();
AudiofileTagger::tag_file(filename, *SessionMetadata::Metadata());
}
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;
}
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
}
}
string album_title = SessionMetadata::Metadata()->album();
if (barcode != "")
- status.out << "CATALOG " << barcode << endl;
+ status.out << "CATALOG \"" << barcode << "\"" << endl;
if (album_title != "")
title = album_title;
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)
{
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)
{
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)
{
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)
{