improve AU Latency PropertyChange Events
[ardour.git] / libs / ardour / ardour / export_profile_manager.h
index dc4b6b006016559a6f0a661fe8abf115ff374a0e..b0285f8ecce11733b6a2d4582ee61bce19468ab0 100644 (file)
@@ -28,7 +28,6 @@
 #include <string>
 
 #include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
 
 #include "pbd/uuid.h"
 #include "pbd/file_utils.h"
 
 #include "ardour/filesystem_paths.h"
 #include "ardour/location.h"
+#include "ardour/libardour_visibility.h"
 #include "ardour/types.h"
+#include "ardour/export_handler.h"
 
 namespace ARDOUR
 {
 
 class ExportHandler;
-class ExportTimespan;
-class ExportChannelConfiguration;
-class ExportFormatSpecification;
-class ExportFilename;
-class ExportPreset;
 class Location;
 class Session;
 
 /// Manages (de)serialization of export profiles and related classes
-class ExportProfileManager
+class LIBARDOUR_API ExportProfileManager
 {
   public:
 
-       ExportProfileManager (Session & s, std::string xml_node_name);
+       enum ExportType {
+               RegularExport,
+               RangeExport,
+               SelectionExport,
+               RegionExport,
+               StemExport
+       };
+
+       ExportProfileManager (Session & s, ExportType type);
        ~ExportProfileManager ();
 
        void load_profile ();
        void prepare_for_export ();
 
-       typedef boost::shared_ptr<ExportPreset> PresetPtr;
-       typedef std::list<PresetPtr> PresetList;
+       ExportType type () const { return _type; }
+
+       typedef std::list<ExportPresetPtr> PresetList;
 
        PresetList const & get_presets () { return preset_list; }
-       bool load_preset (PresetPtr preset);
-       PresetPtr save_preset (std::string const & name);
+       bool load_preset (ExportPresetPtr preset);
+       ExportPresetPtr new_preset (std::string const & name);
+       ExportPresetPtr save_preset (std::string const & name);
        void remove_preset ();
 
   private:
        typedef boost::shared_ptr<ExportHandler> HandlerPtr;
 
-       typedef std::pair<PBD::UUID, PBD::sys::path> FilePair;
-       typedef std::map<PBD::UUID, PBD::sys::path> FileMap;
+       typedef std::pair<PBD::UUID, std::string> FilePair;
+       typedef std::map<PBD::UUID, std::string> FileMap;
 
-       std::string const xml_node_name;
+       ExportType  _type;
+       std::string xml_node_name;
        HandlerPtr  handler;
        Session &   session;
 
+       std::string preset_filename (std::string const & preset_name);
        void load_presets ();
-       void load_preset_from_disk (PBD::sys::path const & path);
+       void load_preset_from_disk (std::string const & path);
 
        bool set_state (XMLNode const & root);
        bool set_global_state (XMLNode const & root);
@@ -90,20 +98,19 @@ class ExportProfileManager
        void serialize_global_profile (XMLNode & root);
        void serialize_local_profile (XMLNode & root);
 
-       PresetList preset_list;
-       PresetPtr  current_preset;
-       FileMap    preset_file_map;
+       PresetList      preset_list;
+       ExportPresetPtr current_preset;
+       FileMap         preset_file_map;
 
-       std::vector<PBD::sys::path> find_file (std::string const & pattern);
+       std::vector<std::string> find_file (std::string const & pattern);
 
-       PBD::sys::path  export_config_dir;
-       PBD::SearchPath search_path;
+       std::string  export_config_dir;
+       PBD::Searchpath search_path;
 
 /* Timespans */
   public:
 
-       typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
-       typedef std::list<TimespanPtr> TimespanList;
+       typedef std::list<ExportTimespanPtr> TimespanList;
        typedef boost::shared_ptr<TimespanList> TimespanListPtr;
        typedef std::list<Location *> LocationList;
 
@@ -112,23 +119,19 @@ class ExportProfileManager
                BBT,
                MinSec,
                Frames,
-               Off
        };
 
        struct TimespanState {
                TimespanListPtr timespans;
                TimeFormat      time_format;
 
-               boost::shared_ptr<Location> session_range;
                boost::shared_ptr<Location> selection_range;
                boost::shared_ptr<LocationList> ranges;
 
-               TimespanState (boost::shared_ptr<Location> session_range,
-                              boost::shared_ptr<Location> selection_range,
+               TimespanState (boost::shared_ptr<Location> selection_range,
                               boost::shared_ptr<LocationList> ranges)
                  : timespans (new TimespanList ())
                  , time_format (Timecode)
-                 , session_range (session_range)
                  , selection_range (selection_range)
                  , ranges (ranges)
                {}
@@ -154,7 +157,6 @@ class ExportProfileManager
 
        void update_ranges ();
 
-       boost::shared_ptr<Location>     session_range;
        boost::shared_ptr<Location>     selection_range;
        boost::shared_ptr<LocationList> ranges;
 
@@ -164,12 +166,10 @@ class ExportProfileManager
 /* Channel Configs */
   public:
 
-       typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
-
        struct ChannelConfigState {
-               ChannelConfigPtr config;
+               ExportChannelConfigPtr config;
 
-               ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
+               ChannelConfigState (ExportChannelConfigPtr ptr) : config (ptr) {}
        };
        typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
        typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
@@ -187,14 +187,13 @@ class ExportProfileManager
 /* Formats */
   public:
 
-       typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
-       typedef std::list<FormatPtr> FormatList;
+       typedef std::list<ExportFormatSpecPtr> FormatList;
 
        struct FormatState {
                boost::shared_ptr<FormatList const> list;
-               FormatPtr                           format;
+               ExportFormatSpecPtr                     format;
 
-               FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
+               FormatState (boost::shared_ptr<FormatList const> list, ExportFormatSpecPtr format) :
                  list (list), format (format) {}
        };
        typedef boost::shared_ptr<FormatState> FormatStatePtr;
@@ -204,9 +203,9 @@ class ExportProfileManager
        FormatStatePtr duplicate_format_state (FormatStatePtr state);
        void remove_format_state (FormatStatePtr state);
 
-       PBD::sys::path save_format_to_disk (FormatPtr format);
-       void remove_format_profile (FormatPtr format);
-       FormatPtr get_new_format (FormatPtr original);
+       std::string save_format_to_disk (ExportFormatSpecPtr format);
+       void remove_format_profile (ExportFormatSpecPtr format);
+       ExportFormatSpecPtr get_new_format (ExportFormatSpecPtr original);
 
        PBD::Signal0<void> FormatListChanged;
 
@@ -220,8 +219,8 @@ class ExportProfileManager
 
        void load_formats ();
 
-       FormatPtr load_format (XMLNode & node);
-       void load_format_from_disk (PBD::sys::path const & path);
+       ExportFormatSpecPtr load_format (XMLNode & node);
+       void load_format_from_disk (std::string const & path);
 
        boost::shared_ptr<FormatList> format_list;
        FileMap                       format_file_map;
@@ -229,12 +228,10 @@ class ExportProfileManager
 /* Filenames */
   public:
 
-       typedef boost::shared_ptr<ExportFilename> FilenamePtr;
-
        struct FilenameState {
-               FilenamePtr  filename;
+               ExportFilenamePtr  filename;
 
-               FilenameState (FilenamePtr ptr) : filename (ptr) {}
+               FilenameState (ExportFilenamePtr ptr) : filename (ptr) {}
        };
        typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
        typedef std::list<FilenameStatePtr> FilenameStateList;
@@ -243,12 +240,14 @@ class ExportProfileManager
        FilenameStatePtr duplicate_filename_state (FilenameStatePtr state);
        void remove_filename_state (FilenameStatePtr state);
 
+       std::string get_sample_filename_for_format (ExportFilenamePtr filename, ExportFormatSpecPtr format);
+
   private:
 
        FilenameStateList filenames;
 
        bool init_filenames (XMLNodeList nodes);
-       FilenamePtr load_filename (XMLNode & node);
+       ExportFilenamePtr load_filename (XMLNode & node);
 
 /* Warnings */
   public:
@@ -266,12 +265,16 @@ class ExportProfileManager
                           ChannelConfigStatePtr channel_config_state,
                           FormatStatePtr format_state,
                           FilenameStatePtr filename_state);
-       
-       bool check_format (FormatPtr format, uint32_t channels);
-       bool check_sndfile_format (FormatPtr format, unsigned int channels);
+
+       bool check_format (ExportFormatSpecPtr format, uint32_t channels);
+       bool check_sndfile_format (ExportFormatSpecPtr format, unsigned int channels);
 
  /* Utilities */
 
+       void build_filenames(std::list<std::string> & result, ExportFilenamePtr filename,
+                            TimespanListPtr timespans, ExportChannelConfigPtr channel_config,
+                            ExportFormatSpecPtr format);
+
        /* Element state lists should never be empty, this is used to check them */
        template<typename T>
        std::list<T> const &