Skip to content

Commit 3f94a9b

Browse files
authored
Support 2076-2-style structures in reassignIds (#184)
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.
1 parent 9955fbd commit 3f94a9b

12 files changed

+523
-204
lines changed

include/adm/detail/id_assigner.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ namespace adm {
99
class Document;
1010

1111
namespace detail {
12-
12+
/**
13+
* @brief Assigns a unique ID to elements.
14+
*
15+
* Uses lookups to find the next available element ID.
16+
*
17+
* @note This class differs from IdReassigner in that it can
18+
* operate on a Document which already has elements with ID's
19+
* which you wish to maintain. However, the trade-off is that
20+
* it is less efficient.
21+
*/
1322
class IdAssigner {
1423
public:
1524
ADM_EXPORT AudioProgrammeId assignId(AudioProgramme& programme);

include/adm/utilities/id_assignment.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@
44
#include "adm/document.hpp"
55
#include "adm/export.h"
66

7+
#include <map>
78
#include <memory>
89

910
namespace adm {
1011

1112
/**
12-
* @brief Reassign ids of an Document
13+
* @brief Reassign ID's of a Document
1314
*
14-
* Assigns new ids to all the elements wihtin an Document. Unreferenced
15-
* audioTrackFormats and audioChannelFormats which are not referenced by an
16-
* audioStreamFormat get an Id with the value zero and are thereby marked as
15+
* Assigns new IDs to all the elements within an Document.
16+
* AudioTrackFormats which are not referenced by an AudioStreamFormat get an
17+
* ID with the value zero and are thereby marked as ADM elements which
18+
* should be ignored.
19+
* AudioChannelFormats which are not referenced by an AudioStreamFormat or
20+
* an AudioTrackUid get an ID with the value zero and are thereby marked as
1721
* ADM elements which should be ignored.
1822
*
1923
* @note
20-
* Element that already have Ids with a value in the range 0x0001-0x0fff
21-
* will not get new Ids assigned, as they are considered to be common
24+
* Elements that already have ID's with a value in the range 0x0001-0x0fff
25+
* will not get new ID's assigned, as they are considered to be common
2226
* definitions.
2327
*/
2428
ADM_EXPORT void reassignIds(std::shared_ptr<Document> document);
2529

26-
/** @name Check if id is a common definitions id
30+
/** @name Check if ID is a common definitions ID
2731
*/
2832
///@{
2933
inline bool isCommonDefinitionsId(AudioProgrammeId id) {
@@ -61,9 +65,9 @@ namespace adm {
6165
}
6266
///@}
6367

64-
/** @name Check if id is undefined
68+
/** @name Check if ID is undefined
6569
*
66-
* An id is undefined if type, value and counter are 0u.
70+
* An ID is undefined if type, value and counter are 0u.
6771
*/
6872
///@{
6973
inline bool isUndefined(AudioProgrammeId id) {

include/adm/utilities/object_creation.hpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace adm {
4343
};
4444

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

69+
/**
70+
* @brief Create `AudioObject` hierarchy for single
71+
* `TypeDefinition::OBJECTS`-type element
72+
*
73+
* Creates an `AudioObject` including referenced `AudioPackFormat` and
74+
* `AudioChannelFormat` of type `TypeDefinition::OBJECTS`, as well an
75+
* `AudioTrackUid`. The audioTrackUID references the audioChannelFormat
76+
* directly, without an audioTrackFormat and audioStreamFormat, as
77+
* supported by BS.2076-2.
78+
*
79+
* @param name Name that will be used for the created
80+
* `Audio{Object,PackFormat,ChannelFormat}`.
81+
*/
82+
ADM_EXPORT SimpleObjectHolder
83+
createSimpleObjectShortStructure(const std::string& name);
84+
85+
/**
86+
* @brief Create and add `AudioObject` hierarchy for single
87+
* `TypeDefinition::OBJECTS`-type element
88+
*
89+
* same as `createSimpleObjectShortStructure`, but the elements
90+
* are automatically added to the given document
91+
*/
92+
ADM_EXPORT SimpleObjectHolder addSimpleObjectShortStructureTo(
93+
std::shared_ptr<Document> document, const std::string& name);
6994
/**
7095
* @brief Create and add `AudioObject` with common definitions direct speakers
7196
* channel bed to document

src/elements/audio_channel_format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace adm {
5454
assignNewIdValue<AudioBlockFormatBinaural>();
5555
} else {
5656
std::stringstream errorString;
57-
errorString << "missmatch between TypeDefinition of AudioChannelFormat ("
57+
errorString << "mismatch between TypeDefinition of AudioChannelFormat ("
5858
<< formatTypeDefinition(get<TypeDescriptor>())
5959
<< ") and AudioChannelFormatId ("
6060
<< formatTypeDefinition(id.get<TypeDescriptor>()) << ")";

src/elements/audio_pack_format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace adm {
4646
id_ = id;
4747
} else {
4848
std::stringstream errorString;
49-
errorString << "missmatch between TypeDefinition of AudioPackFormat ("
49+
errorString << "mismatch between TypeDefinition of AudioPackFormat ("
5050
<< formatTypeDefinition(get<TypeDescriptor>())
5151
<< ") and AudioPackFormatId ("
5252
<< formatTypeDefinition(id.get<TypeDescriptor>()) << ")";

0 commit comments

Comments
 (0)