c32065d2c42e64cc8f5e942f8b37f60c8dae3b92
[ardour.git] / libs / audiographer / audiographer / broadcast_info.h
1 /*
2  * Copyright (C) 2008 Sakari Bergen <sakari.bergen@beatwaves.net>
3  * Copyright (C) 2013-2014 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19
20 #ifndef AUDIOGRAPHER_BROADCAST_INFO_H
21 #define AUDIOGRAPHER_BROADCAST_INFO_H
22
23 #include <stdint.h>
24
25 #include <string>
26 #include <ctime>
27
28 #include <sndfile.h>
29
30 #include "audiographer/visibility.h"
31
32 namespace AudioGrapher
33 {
34
35 class SndfileHandle;
36
37 class LIBAUDIOGRAPHER_API BroadcastInfo
38 {
39   public:
40
41         /// Construct empty broadcast info
42         BroadcastInfo ();
43         virtual ~BroadcastInfo ();
44
45         /// Returns last error sring from libsndfile
46         std::string get_error () const { return error; }
47
48         /* Reading */
49
50         bool load_from_file (std::string const & filename);
51         bool load_from_file (SNDFILE* sf);
52
53         std::string get_description () const;
54         int64_t get_time_reference () const;
55         struct tm get_origination_time () const;
56         std::string get_originator () const;
57         std::string get_originator_ref () const;
58
59         /* Writing */
60
61         bool write_to_file (std::string const & filename);
62         bool write_to_file (SNDFILE* sf);
63         bool write_to_file (SndfileHandle* sf);
64
65         void set_description (std::string const & desc);
66         void set_time_reference (int64_t when);
67         void set_origination_time (struct tm * now = 0); // if 0, use time generated at construction
68         virtual void set_originator (std::string const & str = "");
69         void set_originator_ref (std::string const & str = "");
70
71         /* State info */
72
73         /// Returns true if a info has been succesfully loaded or anything has been manually set
74         bool has_info () const { return _has_info; }
75
76 protected:
77
78         SF_BROADCAST_INFO * info;
79         struct tm _time;
80
81         void update_error ();
82         std::string error;
83
84         bool _has_info;
85 };
86
87 } // namespace AudioGrapher
88
89 #endif /* AUDIOGRAPHER_BROADCAST_INFO_H */