X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fbroadcast_info.cc;h=c19d898b80af6f17e59e2b6d0a3fd38e00c532c8;hb=dce81aecc54b9ed286ec502a2e45f4da6200d056;hp=a08d2c7991c6b0044bea6625b0a7c969db05066b;hpb=7000afdc66c9e0ae8dcf9ec080517dabba1e7f34;p=ardour.git diff --git a/libs/ardour/broadcast_info.cc b/libs/ardour/broadcast_info.cc index a08d2c7991..c19d898b80 100644 --- a/libs/ardour/broadcast_info.cc +++ b/libs/ardour/broadcast_info.cc @@ -90,16 +90,40 @@ BroadcastInfo::set_originator_ref_from_session (Session const & /*session*/) /* Serial number is 12 chars */ std::ostringstream serial_number; - serial_number << "ARDOUR" << "r" << std::setfill('0') << std::right << std::setw(5) << revision; - - snprintf_bounded_null_filled (info->originator_reference, sizeof (info->originator_reference), "%2s%3s%12s%02d%02d%02d%9d", - SessionMetadata::Metadata()->country().c_str(), - SessionMetadata::Metadata()->organization().c_str(), - serial_number.str().c_str(), - _time.tm_hour, - _time.tm_min, - _time.tm_sec, - random_code); + serial_number << PROGRAM_NAME << revision; + + 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 .,-()/= + // possible, but not recommended: !"%&*;<> + + /* https://tech.ebu.ch/docs/r/r099.pdf + * CC Country code: (2 characters) based on the ISO 3166-1 standard + * OOO Organisation code: (3 characters) based on the EBU facility codes, Tech 3279 + * 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 field of the BWF. + * RRRRRRRRR Random Number (9 characters 0-9) Generated locally by the recorder using some reasonably random algorithm. + */ + 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); }