4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include "wsutil/codecs.h"
17 #include "ws_attributes.h"
19 void codec_register_g722(void);
22 codec_g722_init(codec_context_t
*ctx _U_
)
24 g722_decode_state_t
*state
;
26 /* Valid values for bit_rate for G.722 are 48000, 56000, 64000, but RTP/AVP
27 * profile requires 64kbps, aligned at octets. */
28 state
= g722_decode_init(NULL
, 64000, 0);
34 codec_g722_release(codec_context_t
*ctx
)
36 g722_decode_state_t
*state
= (g722_decode_state_t
*)ctx
->priv
;
39 return; /* out-of-memory; */
42 /* Note: replaces g722_decode_release since SpanDSP 20090211 */
43 g722_decode_free(state
);
47 codec_g722_get_channels(codec_context_t
*ctx _U_
)
49 /* G.722 has only one channel. */
54 codec_g722_get_frequency(codec_context_t
*ctx _U_
)
56 /* Note: RTP Clock rate is 8kHz due to a historic error, but actual sampling
57 * rate is 16kHz (RFC 3551, section 4.5.2). */
62 codec_g722_decode(codec_context_t
*ctx
, const void *inputBytes
,
63 size_t inputBytesSize
, void *outputSamples
, size_t *outputSamplesSize
)
65 g722_decode_state_t
*state
= (g722_decode_state_t
*)ctx
->priv
;
68 return 0; /* out-of-memory; */
71 if (!outputSamples
|| !outputSamplesSize
) {
72 return 4 * inputBytesSize
;
75 /* g722_decode returns the number of 16-bit samples. */
76 *outputSamplesSize
= 2 * g722_decode(state
, (int16_t *)outputSamples
,
77 (const uint8_t *)inputBytes
, (int)inputBytesSize
);
78 return *outputSamplesSize
;
82 codec_register_g722(void)
84 register_codec("g722", codec_g722_init
, codec_g722_release
,
85 codec_g722_get_channels
, codec_g722_get_frequency
, codec_g722_decode
);
89 * Editor modelines - https://www.wireshark.org/tools/modelines.html
94 * indent-tabs-mode: nil
97 * vi: set shiftwidth=4 tabstop=8 expandtab:
98 * :indentSize=4:tabSize=8:noTabs=true: