prepare region RMS (loudness) normalization
[ardour.git] / libs / ardour / ardour / export_handler.h
index 8336cea732aa896718445c15c4feedb7ecee4043..5ed1c0be1c3616b4ed51243f23b90f32d214219c 100644 (file)
 #define __ardour_export_handler_h__
 
 #include <map>
-#include <fstream>
 
 #include <boost/operators.hpp>
 #include <boost/shared_ptr.hpp>
 
+#include "pbd/gstdio_compat.h"
+
 #include "ardour/export_pointers.h"
 #include "ardour/session.h"
 #include "ardour/libardour_visibility.h"
 #include "ardour/types.h"
 #include "pbd/signals.h"
 
+#include "pbd/i18n.h"
+
 namespace AudioGrapher {
        class BroadcastInfo;
 }
@@ -69,6 +72,7 @@ class LIBARDOUR_API ExportElementFactory
        Session & session;
 };
 
+/** Export Handler */
 class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::trackable
 {
   public:
@@ -135,13 +139,13 @@ class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::tr
        typedef std::multimap<ExportTimespanPtr, FileSpec> ConfigMap;
        ConfigMap          config_map;
 
-       bool               normalizing;
+       bool               post_processing;
 
        /* Timespan management */
 
        void start_timespan ();
        int  process_timespan (framecnt_t frames);
-       int  process_normalize ();
+       int  post_process ();
        void finish_timespan ();
 
        typedef std::pair<ConfigMap::iterator, ConfigMap::iterator> TimespanBounds;
@@ -156,13 +160,31 @@ class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::tr
        struct CDMarkerStatus {
                CDMarkerStatus (std::string out_file, ExportTimespanPtr timespan,
                                ExportFormatSpecPtr format, std::string filename)
-                 : out (out_file.c_str()), timespan (timespan), format (format), filename (filename), marker(0)
-                 , track_number (1), track_position (0), track_duration (0), track_start_frame (0)
-                 , index_number (1), index_position (0)
+                 : path (out_file)
+                 , timespan (timespan)
+                 , format (format)
+                 , filename (filename)
+                 , marker(0)
+                 , track_number (1)
+                 , track_position (0)
+                 , track_duration (0)
+                 , track_start_frame (0)
+                 , index_number (1)
+                 , index_position (0)
                  {}
 
+               ~CDMarkerStatus () {
+                       if (!g_file_set_contents (path.c_str(), out.str().c_str(), -1, NULL)) {
+                               PBD::error << string_compose(_("Editor: cannot open \"%1\" as export file for CD marker file"), path) << endmsg;
+                       }
+
+               }
+
+               /* I/O */
+               std::string         path;
+               std::stringstream   out;
+
                /* General info */
-               std::ofstream  out;
                ExportTimespanPtr   timespan;
                ExportFormatSpecPtr format;
                std::string         filename;
@@ -185,14 +207,19 @@ class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::tr
 
        void write_cue_header (CDMarkerStatus & status);
        void write_toc_header (CDMarkerStatus & status);
+       void write_mp4ch_header (CDMarkerStatus & status);
 
        void write_track_info_cue (CDMarkerStatus & status);
        void write_track_info_toc (CDMarkerStatus & status);
+       void write_track_info_mp4ch (CDMarkerStatus & status);
 
        void write_index_info_cue (CDMarkerStatus & status);
        void write_index_info_toc (CDMarkerStatus & status);
+       void write_index_info_mp4ch (CDMarkerStatus & status);
 
        void frames_to_cd_frames_string (char* buf, framepos_t when);
+       void frames_to_chapter_marks_string (char* buf, framepos_t when);
+
        std::string toc_escape_cdtext (const std::string&);
        std::string toc_escape_filename (const std::string&);
        std::string cue_escape_cdtext (const std::string& txt);