rename TransportMasterManager::init() to ::set_default_configuration() to make its...
[ardour.git] / libs / ardour / ardour / export_handler.h
index e2c0a7b2b7548488440a7e640cba10df7ec6c13c..d9d268af014c96515f66c15eff862e2036381805 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;
 }
@@ -46,7 +50,7 @@ class ExportFilename;
 class ExportGraphBuilder;
 class Location;
 
-class ExportElementFactory
+class LIBARDOUR_API ExportElementFactory
 {
   public:
 
@@ -68,7 +72,8 @@ class ExportElementFactory
        Session & session;
 };
 
-class ExportHandler : public ExportElementFactory, public sigc::trackable
+/** Export Handler */
+class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::trackable
 {
   public:
        struct FileSpec {
@@ -113,15 +118,18 @@ class ExportHandler : public ExportElementFactory, public sigc::trackable
        PBD::Signal3<void, double, double, std::string> SoundcloudProgress;
 
        /* upload credentials & preferences */
-       std::string upload_username;
-       std::string upload_password;
-       bool upload_public;
-       bool upload_open;
+       std::string soundcloud_username;
+       std::string soundcloud_password;
+       bool soundcloud_make_public;
+       bool soundcloud_open_page;
+       bool soundcloud_downloadable;
+
+       void reset ();
 
   private:
 
        void handle_duplicate_format_extensions();
-       int process (framecnt_t frames);
+       int process (samplecnt_t samples);
 
        Session &          session;
        boost::shared_ptr<ExportGraphBuilder> graph_builder;
@@ -133,13 +141,13 @@ class ExportHandler : public ExportElementFactory, public sigc::trackable
        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  process_timespan (samplecnt_t samples);
+       int  post_process ();
        void finish_timespan ();
 
        typedef std::pair<ConfigMap::iterator, ConfigMap::iterator> TimespanBounds;
@@ -147,20 +155,38 @@ class ExportHandler : public ExportElementFactory, public sigc::trackable
        TimespanBounds        timespan_bounds;
 
        PBD::ScopedConnection process_connection;
-       framepos_t             process_position;
+       samplepos_t             process_position;
 
        /* CD Marker stuff */
 
        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_sample (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;
@@ -168,13 +194,13 @@ class ExportHandler : public ExportElementFactory, public sigc::trackable
 
                /* Track info */
                uint32_t        track_number;
-               framepos_t      track_position;
-               framepos_t      track_duration;
-               framepos_t      track_start_frame;
+               samplepos_t      track_position;
+               samplepos_t      track_duration;
+               samplepos_t      track_start_sample;
 
                /* Index info */
                uint32_t       index_number;
-               framepos_t      index_position;
+               samplepos_t      index_position;
        };
 
 
@@ -183,14 +209,19 @@ class ExportHandler : public ExportElementFactory, public sigc::trackable
 
        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 samples_to_cd_samples_string (char* buf, samplepos_t when);
+       void samples_to_chapter_marks_string (char* buf, samplepos_t when);
 
-       void frames_to_cd_frames_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);