@@ -16,51 +16,89 @@ namespace audio_tools {
16
16
*/
17
17
class ContainerM4A : public ContainerDecoder {
18
18
public:
19
+ /* *
20
+ * @brief Default constructor. Sets up the demuxer callback.
21
+ */
19
22
ContainerM4A () {
20
23
demux.setReference (this );
21
24
demux.setCallback (decodeAudio);
22
25
};
23
26
27
+ /* *
28
+ * @brief Constructor with decoder. Sets up the demuxer and decoder notification.
29
+ * @param decoder Reference to a MultiDecoder for PCM output.
30
+ */
24
31
ContainerM4A (MultiDecoder& decoder) : ContainerM4A() {
25
32
p_decoder = &decoder;
26
33
p_decoder->addNotifyAudioChange (*this );
27
34
}
28
35
36
+ /* *
37
+ * @brief Set the output stream for decoded or raw audio.
38
+ * @param out_stream Output AudioStream.
39
+ */
29
40
void setOutput (AudioStream& out_stream) override {
30
41
if (p_decoder != nullptr ) p_decoder->setOutput (out_stream);
31
42
ContainerDecoder::setOutput (out_stream);
32
43
}
33
44
45
+ /* *
46
+ * @brief Returns true if the result is PCM (decoder is present).
47
+ * @return true if PCM output, false otherwise.
48
+ */
34
49
bool isResultPCM () override { return p_decoder != nullptr ? true : false ; }
35
50
51
+ /* *
52
+ * @brief Initialize the demuxer and decoder.
53
+ * @return true on success.
54
+ */
36
55
bool begin () override {
37
56
demux.begin ();
38
57
if (p_decoder) p_decoder->begin ();
39
58
is_active = true ;
40
59
return true ;
41
60
}
42
61
62
+ /* *
63
+ * @brief End the demuxer and decoder, releasing resources.
64
+ */
43
65
void end () override {
44
66
TRACED ();
45
67
is_active = false ;
46
68
is_magic_cookie_processed = false ;
47
69
if (p_decoder) p_decoder->end ();
48
70
}
49
71
72
+ /* *
73
+ * @brief Feed data to the demuxer for parsing.
74
+ * @param data Pointer to input data.
75
+ * @param len Length of input data.
76
+ * @return Number of bytes processed (always len).
77
+ */
50
78
size_t write (const uint8_t * data, size_t len) override {
51
79
if (is_active == false ) return len;
52
80
demux.write (data, len);
53
81
return len;
54
82
}
55
83
84
+ /* *
85
+ * @brief Returns true if the demuxer is active.
86
+ * @return true if active, false otherwise.
87
+ */
56
88
operator bool () override { return is_active; }
57
89
58
90
protected:
59
- bool is_active = false ;
60
- bool is_magic_cookie_processed = false ;
61
- MultiDecoder* p_decoder = nullptr ;
62
- M4AAudioDemuxer demux;
91
+ bool is_active = false ; // /< True if demuxer is active.
92
+ bool is_magic_cookie_processed = false ;// /< True if ALAC magic cookie has been processed.
93
+ MultiDecoder* p_decoder = nullptr ; // /< Pointer to the MultiDecoder.
94
+ M4AAudioDemuxer demux; // /< Internal demuxer instance.
63
95
96
+ /* *
97
+ * @brief Static callback for demuxed audio frames.
98
+ * Handles decoder selection and magic cookie for ALAC.
99
+ * @param frame The demuxed audio frame.
100
+ * @param ref Reference to the ContainerM4A instance.
101
+ */
64
102
static void decodeAudio (const M4AAudioDemuxer::Frame& frame, void * ref) {
65
103
ContainerM4A* self = static_cast <ContainerM4A*>(ref);
66
104
if (self->p_decoder == nullptr ) {
0 commit comments