Skip to content

Commit

Permalink
Support 2076-2-style structures in reassignIds (#184)
Browse files Browse the repository at this point in the history
The approach has been to process ACFs stemming from ATUIDs in the `reassignAudioTrackUidIds`. If an ACF is found, apply an available ACF ID.
The whole "reassignIds" logic has been wrapped in a class, with an `IdIssuer` class used to track IDs and ensure only unique ID's are issued to elements. This avoids the need for lookups and reduces to linear complexity. Note that a common ID value is used for groups of ACF, ATF and ASF elements so that the ADM XML is more readable and easy to follow.
  • Loading branch information
firthm01 committed Dec 14, 2023
1 parent 9955fbd commit 3f94a9b
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 204 deletions.
11 changes: 10 additions & 1 deletion include/adm/detail/id_assigner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ namespace adm {
class Document;

namespace detail {

/**
* @brief Assigns a unique ID to elements.
*
* Uses lookups to find the next available element ID.
*
* @note This class differs from IdReassigner in that it can
* operate on a Document which already has elements with ID's
* which you wish to maintain. However, the trade-off is that
* it is less efficient.
*/
class IdAssigner {
public:
ADM_EXPORT AudioProgrammeId assignId(AudioProgramme& programme);
Expand Down
22 changes: 13 additions & 9 deletions include/adm/utilities/id_assignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@
#include "adm/document.hpp"
#include "adm/export.h"

#include <map>
#include <memory>

namespace adm {

/**
* @brief Reassign ids of an Document
* @brief Reassign ID's of a Document
*
* Assigns new ids to all the elements wihtin an Document. Unreferenced
* audioTrackFormats and audioChannelFormats which are not referenced by an
* audioStreamFormat get an Id with the value zero and are thereby marked as
* Assigns new IDs to all the elements within an Document.
* AudioTrackFormats which are not referenced by an AudioStreamFormat get an
* ID with the value zero and are thereby marked as ADM elements which
* should be ignored.
* AudioChannelFormats which are not referenced by an AudioStreamFormat or
* an AudioTrackUid get an ID with the value zero and are thereby marked as
* ADM elements which should be ignored.
*
* @note
* Element that already have Ids with a value in the range 0x0001-0x0fff
* will not get new Ids assigned, as they are considered to be common
* Elements that already have ID's with a value in the range 0x0001-0x0fff
* will not get new ID's assigned, as they are considered to be common
* definitions.
*/
ADM_EXPORT void reassignIds(std::shared_ptr<Document> document);

/** @name Check if id is a common definitions id
/** @name Check if ID is a common definitions ID
*/
///@{
inline bool isCommonDefinitionsId(AudioProgrammeId id) {
Expand Down Expand Up @@ -61,9 +65,9 @@ namespace adm {
}
///@}

/** @name Check if id is undefined
/** @name Check if ID is undefined
*
* An id is undefined if type, value and counter are 0u.
* An ID is undefined if type, value and counter are 0u.
*/
///@{
inline bool isUndefined(AudioProgrammeId id) {
Expand Down
27 changes: 26 additions & 1 deletion include/adm/utilities/object_creation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace adm {
};

/**
* @brief Create `AudioObject` hierarchie for single
* @brief Create `AudioObject` hierarchy for single
* `TypeDefinition::OBJECTS`-type element
*
* Creates an `AudioObject` including referenced `AudioPackFormat` and
Expand All @@ -66,6 +66,31 @@ namespace adm {
ADM_EXPORT SimpleObjectHolder addSimpleObjectTo(
std::shared_ptr<Document> document, const std::string& name);

/**
* @brief Create `AudioObject` hierarchy for single
* `TypeDefinition::OBJECTS`-type element
*
* Creates an `AudioObject` including referenced `AudioPackFormat` and
* `AudioChannelFormat` of type `TypeDefinition::OBJECTS`, as well an
* `AudioTrackUid`. The audioTrackUID references the audioChannelFormat
* directly, without an audioTrackFormat and audioStreamFormat, as
* supported by BS.2076-2.
*
* @param name Name that will be used for the created
* `Audio{Object,PackFormat,ChannelFormat}`.
*/
ADM_EXPORT SimpleObjectHolder
createSimpleObjectShortStructure(const std::string& name);

/**
* @brief Create and add `AudioObject` hierarchy for single
* `TypeDefinition::OBJECTS`-type element
*
* same as `createSimpleObjectShortStructure`, but the elements
* are automatically added to the given document
*/
ADM_EXPORT SimpleObjectHolder addSimpleObjectShortStructureTo(
std::shared_ptr<Document> document, const std::string& name);
/**
* @brief Create and add `AudioObject` with common definitions direct speakers
* channel bed to document
Expand Down
2 changes: 1 addition & 1 deletion src/elements/audio_channel_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace adm {
assignNewIdValue<AudioBlockFormatBinaural>();
} else {
std::stringstream errorString;
errorString << "missmatch between TypeDefinition of AudioChannelFormat ("
errorString << "mismatch between TypeDefinition of AudioChannelFormat ("
<< formatTypeDefinition(get<TypeDescriptor>())
<< ") and AudioChannelFormatId ("
<< formatTypeDefinition(id.get<TypeDescriptor>()) << ")";
Expand Down
2 changes: 1 addition & 1 deletion src/elements/audio_pack_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace adm {
id_ = id;
} else {
std::stringstream errorString;
errorString << "missmatch between TypeDefinition of AudioPackFormat ("
errorString << "mismatch between TypeDefinition of AudioPackFormat ("
<< formatTypeDefinition(get<TypeDescriptor>())
<< ") and AudioPackFormatId ("
<< formatTypeDefinition(id.get<TypeDescriptor>()) << ")";
Expand Down
Loading

0 comments on commit 3f94a9b

Please sign in to comment.