| 1 | /* Copyright (C) 2002 Jean-Marc Valin */cxx . . $ `<file>/src/plugins/audiobridge-deps/speex/speex_jitter.h`/ |
| 2 | /** |
| 3 | @file speex_jitter.h |
| 4 | @brief Adaptive jitter buffer for Speex |
| 5 | */ |
| 6 | /* |
| 7 | Redistribution and use in source and binary forms, with or without |
| 8 | modification, are permitted provided that the following conditions |
| 9 | are met: |
| 10 | |
| 11 | - Redistributions of source code must retain the above copyright |
| 12 | notice, this list of conditions and the following disclaimer. |
| 13 | |
| 14 | - Redistributions in binary form must reproduce the above copyright |
| 15 | notice, this list of conditions and the following disclaimer in the |
| 16 | documentation and/or other materials provided with the distribution. |
| 17 | |
| 18 | - Neither the name of the Xiph.org Foundation nor the names of its |
| 19 | contributors may be used to endorse or promote products derived from |
| 20 | this software without specific prior written permission. |
| 21 | |
| 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | |
| 34 | */ |
| 35 | |
| 36 | #ifndef SPEEX_JITTER_H |
| 37 | #define SPEEX_JITTER_Hcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:37:9`! |
| 38 | /** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer |
| 39 | * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size |
| 40 | * to maintain good quality and low latency. |
| 41 | * @{ |
| 42 | */ |
| 43 | |
| 44 | #include "speexdsp_types.h"cxx . . $ `<file>/src/plugins/audiobridge-deps/speex/speexdsp_types.h`/ |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | extern "C" { |
| 48 | #endif |
| 49 | |
| 50 | /** Generic adaptive jitter buffer state */ |
| 51 | struct JitterBuffer_cxx . . $ JitterBuffer_#; |
| 52 | |
| 53 | /** Generic adaptive jitter buffer state */ |
| 54 | typedef struct JitterBuffer_cxx . . $ JitterBuffer_# JitterBuffercxx . . $ JitterBuffer#; |
| 55 | |
| 56 | /** Definition of an incoming packet */ |
| 57 | typedef struct _JitterBufferPacketcxx . . $ _JitterBufferPacket# JitterBufferPacketcxx . . $ JitterBufferPacket#; |
| 58 | |
| 59 | /** Definition of an incoming packet */ |
| 60 | struct _JitterBufferPacketcxx . . $ _JitterBufferPacket# { |
| 61 | char *datacxx . . $ _JitterBufferPacket#data.; /**< Data bytes contained in the packet */ |
| 62 | spx_uint32_tcxx . . $ spx_uint32_t# lencxx . . $ _JitterBufferPacket#len.; /**< Length of the packet in bytes */ |
| 63 | spx_uint32_tcxx . . $ spx_uint32_t# timestampcxx . . $ _JitterBufferPacket#timestamp.; /**< Timestamp for the packet */ |
| 64 | spx_uint32_tcxx . . $ spx_uint32_t# spancxx . . $ _JitterBufferPacket#span.; /**< Time covered by the packet (same units as timestamp) */ |
| 65 | spx_uint16_tcxx . . $ spx_uint16_t# sequencecxx . . $ _JitterBufferPacket#sequence.; /**< RTP Sequence number if available (0 otherwise) */ |
| 66 | spx_uint32_tcxx . . $ spx_uint32_t# user_datacxx . . $ _JitterBufferPacket#user_data.; /**< Put whatever data you like here (it's ignored by the jitter buffer) */ |
| 67 | }; |
| 68 | |
| 69 | /** Packet has been retrieved */ |
| 70 | #define JITTER_BUFFER_OKcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:70:9`! 0 |
| 71 | /** Packet is lost or is late */ |
| 72 | #define JITTER_BUFFER_MISSINGcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:72:9`! 1 |
| 73 | /** A "fake" packet is meant to be inserted here to increase buffering */ |
| 74 | #define JITTER_BUFFER_INSERTIONcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:74:9`! 2 |
| 75 | /** There was an error in the jitter buffer */ |
| 76 | #define JITTER_BUFFER_INTERNAL_ERRORcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:76:9`! -1 |
| 77 | /** Invalid argument */ |
| 78 | #define JITTER_BUFFER_BAD_ARGUMENTcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:78:9`! -2 |
| 79 | |
| 80 | |
| 81 | /** Set minimum amount of extra buffering required (margin) */ |
| 82 | #define JITTER_BUFFER_SET_MARGINcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:82:9`! 0 |
| 83 | /** Get minimum amount of extra buffering required (margin) */ |
| 84 | #define JITTER_BUFFER_GET_MARGINcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:84:9`! 1 |
| 85 | /* JITTER_BUFFER_SET_AVAILABLE_COUNT wouldn't make sense */ |
| 86 | |
| 87 | /** Get the amount of available packets currently buffered */ |
| 88 | #define JITTER_BUFFER_GET_AVAILABLE_COUNTcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:88:9`! 3 |
| 89 | /** Included because of an early misspelling (will remove in next release) */ |
| 90 | #define JITTER_BUFFER_GET_AVALIABLE_COUNTcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:90:9`! 3 |
| 91 | |
| 92 | /** Assign a function to destroy unused packet. When setting that, the jitter |
| 93 | buffer no longer copies packet data. */ |
| 94 | #define JITTER_BUFFER_SET_DESTROY_CALLBACKcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:94:9`! 4 |
| 95 | /** */ |
| 96 | #define JITTER_BUFFER_GET_DESTROY_CALLBACKcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:96:9`! 5 |
| 97 | |
| 98 | /** Tell the jitter buffer to only adjust the delay in multiples of the step parameter provided */ |
| 99 | #define JITTER_BUFFER_SET_DELAY_STEPcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:99:9`! 6 |
| 100 | /** */ |
| 101 | #define JITTER_BUFFER_GET_DELAY_STEPcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:101:9`! 7 |
| 102 | |
| 103 | /** Tell the jitter buffer to only do concealment in multiples of the size parameter provided */ |
| 104 | #define JITTER_BUFFER_SET_CONCEALMENT_SIZEcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:104:9`! 8 |
| 105 | #define JITTER_BUFFER_GET_CONCEALMENT_SIZEcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:105:9`! 9 |
| 106 | |
| 107 | /** Absolute max amount of loss that can be tolerated regardless of the delay. Typical loss |
| 108 | should be half of that or less. */ |
| 109 | #define JITTER_BUFFER_SET_MAX_LATE_RATEcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:109:9`! 10 |
| 110 | #define JITTER_BUFFER_GET_MAX_LATE_RATEcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:110:9`! 11 |
| 111 | |
| 112 | /** Equivalent cost of one percent late packet in timestamp units */ |
| 113 | #define JITTER_BUFFER_SET_LATE_COSTcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:113:9`! 12 |
| 114 | #define JITTER_BUFFER_GET_LATE_COSTcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:114:9`! 13 |
| 115 | |
| 116 | #define JITTER_BUFFER_SET_LIMITcxx . . $ `src/plugins/audiobridge-deps/speex/speex_jitter.h:116:9`! 101 |
| 117 | |
| 118 | |
| 119 | /** Initialises jitter buffer |
| 120 | * |
| 121 | * @param step_size Starting value for the size of concleanment packets and delay |
| 122 | adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP |
| 123 | and JITTER_BUFFER_GET_CONCEALMENT_SIZE. |
| 124 | * @return Newly created jitter buffer state |
| 125 | */ |
| 126 | JitterBuffercxx . . $ JitterBuffer# *jitter_buffer_initcxx . . $ jitter_buffer_init(3570ab61cffe4e09).(int step_size); |
| 127 | |
| 128 | /** Restores jitter buffer to its original state |
| 129 | * |
| 130 | * @param jitter Jitter buffer state |
| 131 | */ |
| 132 | void jitter_buffer_resetcxx . . $ jitter_buffer_reset(3a8554c1f2873ad0).(JitterBuffercxx . . $ JitterBuffer# *jitter); |
| 133 | |
| 134 | /** Destroys jitter buffer |
| 135 | * |
| 136 | * @param jitter Jitter buffer state |
| 137 | */ |
| 138 | void jitter_buffer_destroycxx . . $ jitter_buffer_destroy(3a8554c1f2873ad0).(JitterBuffercxx . . $ JitterBuffer# *jitter); |
| 139 | |
| 140 | /** Put one packet into the jitter buffer |
| 141 | * |
| 142 | * @param jitter Jitter buffer state |
| 143 | * @param packet Incoming packet |
| 144 | */ |
| 145 | void jitter_buffer_putcxx . . $ jitter_buffer_put(ee2db586c239dca0).(JitterBuffercxx . . $ JitterBuffer# *jitter, const JitterBufferPacketcxx . . $ JitterBufferPacket# *packet); |
| 146 | |
| 147 | /** Get one packet from the jitter buffer |
| 148 | * |
| 149 | * @param jitter Jitter buffer state |
| 150 | * @param packet Returned packet |
| 151 | * @param desired_span Number of samples (or units) we wish to get from the buffer (no guarantee) |
| 152 | * @param current_timestamp Timestamp for the returned packet |
| 153 | */ |
| 154 | int jitter_buffer_getcxx . . $ jitter_buffer_get(f97b6518c3e6fe85).(JitterBuffercxx . . $ JitterBuffer# *jitter, JitterBufferPacketcxx . . $ JitterBufferPacket# *packet, spx_int32_tcxx . . $ spx_int32_t# desired_span, spx_int32_tcxx . . $ spx_int32_t# *start_offset); |
| 155 | |
| 156 | /** Used right after jitter_buffer_get() to obtain another packet that would have the same timestamp. |
| 157 | * This is mainly useful for media where a single "frame" can be split into several packets. |
| 158 | * |
| 159 | * @param jitter Jitter buffer state |
| 160 | * @param packet Returned packet |
| 161 | */ |
| 162 | int jitter_buffer_get_anothercxx . . $ jitter_buffer_get_another(97b0ec357323efdb).(JitterBuffercxx . . $ JitterBuffer# *jitter, JitterBufferPacketcxx . . $ JitterBufferPacket# *packet); |
| 163 | |
| 164 | /** Get pointer timestamp of jitter buffer |
| 165 | * |
| 166 | * @param jitter Jitter buffer state |
| 167 | */ |
| 168 | int jitter_buffer_get_pointer_timestampcxx . . $ jitter_buffer_get_pointer_timestamp(e6d23be9c12cd49).(JitterBuffercxx . . $ JitterBuffer# *jitter); |
| 169 | |
| 170 | /** Advance by one tick |
| 171 | * |
| 172 | * @param jitter Jitter buffer state |
| 173 | */ |
| 174 | void jitter_buffer_tickcxx . . $ jitter_buffer_tick(3a8554c1f2873ad0).(JitterBuffercxx . . $ JitterBuffer# *jitter); |
| 175 | |
| 176 | /** Telling the jitter buffer about the remaining data in the application buffer |
| 177 | * @param jitter Jitter buffer state |
| 178 | * @param rem Amount of data buffered by the application (timestamp units) |
| 179 | */ |
| 180 | void jitter_buffer_remaining_spancxx . . $ jitter_buffer_remaining_span(5ad21d6bfbd122c6).(JitterBuffercxx . . $ JitterBuffer# *jitter, spx_uint32_tcxx . . $ spx_uint32_t# rem); |
| 181 | |
| 182 | /** Used like the ioctl function to control the jitter buffer parameters |
| 183 | * |
| 184 | * @param jitter Jitter buffer state |
| 185 | * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) |
| 186 | * @param ptr Data exchanged to-from function |
| 187 | * @return 0 if no error, -1 if request in unknown |
| 188 | */ |
| 189 | int jitter_buffer_ctlcxx . . $ jitter_buffer_ctl(134837fd2a1dc66f).(JitterBuffercxx . . $ JitterBuffer# *jitter, int request, void *ptr); |
| 190 | |
| 191 | int jitter_buffer_update_delaycxx . . $ jitter_buffer_update_delay(27bbffe03b515f26).(JitterBuffercxx . . $ JitterBuffer# *jitter, JitterBufferPacketcxx . . $ JitterBufferPacket# *packet, spx_int32_tcxx . . $ spx_int32_t# *start_offset); |
| 192 | |
| 193 | /* @} */ |
| 194 | |
| 195 | #ifdef __cplusplus |
| 196 | } |
| 197 | #endif |
| 198 | |
| 199 | #endif |