2008-09-17 08:58:33 -04:00
|
|
|
|
/*
|
2019-08-02 22:01:25 -04:00
|
|
|
|
* Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
|
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
2008-09-17 08:58:33 -04:00
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
|
#include "ardour/broadcast_info.h"
|
2010-03-13 14:22:34 -05:00
|
|
|
|
#include <iostream>
|
2008-09-17 08:58:33 -04:00
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <iomanip>
|
2013-08-04 10:17:19 -04:00
|
|
|
|
#include <vector>
|
2008-09-17 08:58:33 -04:00
|
|
|
|
|
|
|
|
|
#include <glibmm.h>
|
|
|
|
|
|
2013-03-17 09:53:30 -04:00
|
|
|
|
#include "ardour/revision.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
|
#include "ardour/session.h"
|
2012-04-18 13:46:29 -04:00
|
|
|
|
#include "ardour/session_metadata.h"
|
2008-09-17 08:58:33 -04:00
|
|
|
|
|
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
|
|
namespace ARDOUR
|
|
|
|
|
{
|
|
|
|
|
|
2008-09-17 16:34:31 -04:00
|
|
|
|
static void
|
|
|
|
|
snprintf_bounded_null_filled (char* target, size_t target_size, char const * fmt, ...)
|
|
|
|
|
{
|
2013-08-04 10:17:19 -04:00
|
|
|
|
std::vector<char> buf(target_size+1);
|
2008-09-17 16:34:31 -04:00
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
|
|
va_start (ap, fmt);
|
2013-08-04 10:17:19 -04:00
|
|
|
|
vsnprintf (&buf[0], target_size+1, fmt, ap);
|
2008-09-17 16:34:31 -04:00
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
|
|
memset (target, 0, target_size);
|
2013-08-04 10:17:19 -04:00
|
|
|
|
memcpy (target, &buf[0], target_size);
|
2008-09-17 16:34:31 -04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-19 10:58:54 -04:00
|
|
|
|
BroadcastInfo::BroadcastInfo ()
|
2008-09-17 08:58:33 -04:00
|
|
|
|
{
|
2011-06-01 12:50:12 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-09-17 16:34:31 -04:00
|
|
|
|
BroadcastInfo::set_from_session (Session const & session, int64_t time_ref)
|
2008-09-17 08:58:33 -04:00
|
|
|
|
{
|
|
|
|
|
set_description (session.name());
|
2008-09-17 16:34:31 -04:00
|
|
|
|
set_time_reference (time_ref);
|
2008-09-17 08:58:33 -04:00
|
|
|
|
set_origination_time ();
|
|
|
|
|
set_originator ();
|
2010-08-19 10:58:54 -04:00
|
|
|
|
set_originator_ref_from_session (session);
|
2008-09-17 08:58:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2009-05-12 13:03:42 -04:00
|
|
|
|
BroadcastInfo::set_originator (std::string const & str)
|
2008-09-17 08:58:33 -04:00
|
|
|
|
{
|
|
|
|
|
_has_info = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
if (!str.empty()) {
|
2010-08-19 10:58:54 -04:00
|
|
|
|
AudioGrapher::BroadcastInfo::set_originator (str);
|
2008-09-17 08:58:33 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 16:34:31 -04:00
|
|
|
|
snprintf_bounded_null_filled (info->originator, sizeof (info->originator), Glib::get_real_name().c_str());
|
2008-09-17 08:58:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-05-02 16:45:17 -04:00
|
|
|
|
BroadcastInfo::set_originator_ref_from_session (Session const & /*session*/)
|
2008-09-17 08:58:33 -04:00
|
|
|
|
{
|
|
|
|
|
_has_info = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
/* random code is 9 digits */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2013-07-11 11:38:46 -04:00
|
|
|
|
int random_code = g_random_int() % 999999999;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
/* Serial number is 12 chars */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
std::ostringstream serial_number;
|
2015-09-28 19:20:09 -04:00
|
|
|
|
serial_number << PROGRAM_NAME << revision;
|
|
|
|
|
|
2017-08-06 11:55:33 -04:00
|
|
|
|
std::string country = SessionMetadata::Metadata()->country().substr (0, 2).c_str(); // ISO 3166-1 2 digits
|
|
|
|
|
if (country.empty ()) {
|
|
|
|
|
/* "ZZ" is reserved and may be user-assigned.
|
|
|
|
|
* EBU Tech 3279 chapter 4.2.4 recommends "ZZ" for unregistered organizations
|
|
|
|
|
*/
|
|
|
|
|
country = "ZZ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* https://tech.ebu.ch/docs/tech/tech3279.pdf */
|
|
|
|
|
std::string organization = SessionMetadata::Metadata()->organization().substr (0, 3).c_str(); // EBU assigned Organisation code
|
|
|
|
|
if (organization.empty ()) {
|
|
|
|
|
organization = "---";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO sanitize to allowed char set: tech3279.pdf chapter 1.6
|
|
|
|
|
// allowed: A-Z 0-9 <space> .,-()/=
|
|
|
|
|
// possible, but not recommended: !"%&*;<>
|
|
|
|
|
|
2015-09-28 19:20:09 -04:00
|
|
|
|
/* https://tech.ebu.ch/docs/r/r099.pdf
|
|
|
|
|
* CC Country code: (2 characters) based on the ISO 3166-1 standard
|
2015-10-04 14:51:05 -04:00
|
|
|
|
* OOO Organisation code: (3 characters) based on the EBU facility codes, Tech 3279
|
2015-09-28 19:20:09 -04:00
|
|
|
|
* NNNNNNNNNNNN Serial number: (12 characters extracted from the recorder model and serial number) This should identify the machine’s type and serial number.
|
|
|
|
|
* HHMMSS OriginationTime (6 characters,) from the <OriginationTime> field of the BWF.
|
2015-10-04 14:51:05 -04:00
|
|
|
|
* RRRRRRRRR Random Number (9 characters 0-9) Generated locally by the recorder using some reasonably random algorithm.
|
2015-09-28 19:20:09 -04:00
|
|
|
|
*/
|
2017-08-06 11:55:33 -04:00
|
|
|
|
snprintf_bounded_null_filled (info->originator_reference, sizeof (info->originator_reference), "%2s%3s%12s%02d%02d%02d%09d",
|
|
|
|
|
country.c_str (), organization.c_str(),
|
|
|
|
|
serial_number.str().substr (0, 12).c_str(),
|
|
|
|
|
_time.tm_hour,
|
|
|
|
|
_time.tm_min,
|
|
|
|
|
_time.tm_sec,
|
|
|
|
|
random_code);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
2008-09-17 08:58:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ARDOUR
|
|
|
|
|
|