2 Copyright (C) 2008 Paul Davis
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/broadcast_info.h"
28 #include "ardour/svn_revision.h"
29 #include "ardour/ardour.h"
30 #include "ardour/session.h"
32 #include "pbd/convert.h"
40 snprintf_bounded_null_filled (char* target, size_t target_size, char const * fmt, ...)
42 char buf[target_size+1];
46 vsnprintf (buf, target_size+1, fmt, ap);
49 memset (target, 0, target_size);
50 memcpy (target, buf, target_size);
54 BroadcastInfo::BroadcastInfo ()
60 BroadcastInfo::set_from_session (Session const & session, int64_t time_ref)
62 set_description (session.name());
63 set_time_reference (time_ref);
64 set_origination_time ();
66 set_originator_ref_from_session (session);
70 BroadcastInfo::set_originator (std::string const & str)
75 AudioGrapher::BroadcastInfo::set_originator (str);
79 snprintf_bounded_null_filled (info->originator, sizeof (info->originator), Glib::get_real_name().c_str());
83 BroadcastInfo::set_originator_ref_from_session (Session const & session)
87 /* random code is 9 digits */
89 int random_code = random() % 999999999;
91 /* Serial number is 12 chars */
93 std::ostringstream serial_number;
94 serial_number << "ARDOUR" << "r" << std::setfill('0') << std::right << std::setw(5) << svn_revision;
96 snprintf_bounded_null_filled (info->originator_reference, sizeof (info->originator_reference), "%2s%3s%12s%02d%02d%02d%9d",
97 session.config.get_bwf_country_code().c_str(),
98 session.config.get_bwf_organization_code().c_str(),
99 serial_number.str().c_str(),
107 } // namespace ARDOUR