ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 /* Copyright (C) 2002 Jean-Marc Valin */
TMBOY 47:9e361da97763 2 /**
TMBOY 47:9e361da97763 3 @file speex_header.h
TMBOY 47:9e361da97763 4 @brief Describes the Speex header
TMBOY 47:9e361da97763 5 */
TMBOY 47:9e361da97763 6 /*
TMBOY 47:9e361da97763 7 Redistribution and use in source and binary forms, with or without
TMBOY 47:9e361da97763 8 modification, are permitted provided that the following conditions
TMBOY 47:9e361da97763 9 are met:
TMBOY 47:9e361da97763 10
TMBOY 47:9e361da97763 11 - Redistributions of source code must retain the above copyright
TMBOY 47:9e361da97763 12 notice, this list of conditions and the following disclaimer.
TMBOY 47:9e361da97763 13
TMBOY 47:9e361da97763 14 - Redistributions in binary form must reproduce the above copyright
TMBOY 47:9e361da97763 15 notice, this list of conditions and the following disclaimer in the
TMBOY 47:9e361da97763 16 documentation and/or other materials provided with the distribution.
TMBOY 47:9e361da97763 17
TMBOY 47:9e361da97763 18 - Neither the name of the Xiph.org Foundation nor the names of its
TMBOY 47:9e361da97763 19 contributors may be used to endorse or promote products derived from
TMBOY 47:9e361da97763 20 this software without specific prior written permission.
TMBOY 47:9e361da97763 21
TMBOY 47:9e361da97763 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
TMBOY 47:9e361da97763 23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
TMBOY 47:9e361da97763 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
TMBOY 47:9e361da97763 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
TMBOY 47:9e361da97763 26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
TMBOY 47:9e361da97763 27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
TMBOY 47:9e361da97763 28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
TMBOY 47:9e361da97763 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
TMBOY 47:9e361da97763 30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
TMBOY 47:9e361da97763 31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
TMBOY 47:9e361da97763 32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
TMBOY 47:9e361da97763 33
TMBOY 47:9e361da97763 34 */
TMBOY 47:9e361da97763 35
TMBOY 47:9e361da97763 36
TMBOY 47:9e361da97763 37 #ifndef SPEEX_HEADER_H
TMBOY 47:9e361da97763 38 #define SPEEX_HEADER_H
TMBOY 47:9e361da97763 39 /** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header
TMBOY 47:9e361da97763 40 * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP.
TMBOY 47:9e361da97763 41 * @{
TMBOY 47:9e361da97763 42 */
TMBOY 47:9e361da97763 43
TMBOY 47:9e361da97763 44 #include "speex/speex_types.h"
TMBOY 47:9e361da97763 45
TMBOY 47:9e361da97763 46 #ifdef __cplusplus
TMBOY 47:9e361da97763 47 extern "C" {
TMBOY 47:9e361da97763 48 #endif
TMBOY 47:9e361da97763 49
TMBOY 47:9e361da97763 50 struct SpeexMode;
TMBOY 47:9e361da97763 51
TMBOY 47:9e361da97763 52 /** Length of the Speex header identifier */
TMBOY 47:9e361da97763 53 #define SPEEX_HEADER_STRING_LENGTH 8
TMBOY 47:9e361da97763 54
TMBOY 47:9e361da97763 55 /** Maximum number of characters for encoding the Speex version number in the header */
TMBOY 47:9e361da97763 56 #define SPEEX_HEADER_VERSION_LENGTH 20
TMBOY 47:9e361da97763 57
TMBOY 47:9e361da97763 58 /** Speex header info for file-based formats */
TMBOY 47:9e361da97763 59 typedef struct SpeexHeader {
TMBOY 47:9e361da97763 60 char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */
TMBOY 47:9e361da97763 61 char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */
TMBOY 47:9e361da97763 62 spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */
TMBOY 47:9e361da97763 63 spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */
TMBOY 47:9e361da97763 64 spx_int32_t rate; /**< Sampling rate used */
TMBOY 47:9e361da97763 65 spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */
TMBOY 47:9e361da97763 66 spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */
TMBOY 47:9e361da97763 67 spx_int32_t nb_channels; /**< Number of channels encoded */
TMBOY 47:9e361da97763 68 spx_int32_t bitrate; /**< Bit-rate used */
TMBOY 47:9e361da97763 69 spx_int32_t frame_size; /**< Size of frames */
TMBOY 47:9e361da97763 70 spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */
TMBOY 47:9e361da97763 71 spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */
TMBOY 47:9e361da97763 72 spx_int32_t extra_headers; /**< Number of additional headers after the comments */
TMBOY 47:9e361da97763 73 spx_int32_t reserved1; /**< Reserved for future use, must be zero */
TMBOY 47:9e361da97763 74 spx_int32_t reserved2; /**< Reserved for future use, must be zero */
TMBOY 47:9e361da97763 75 } SpeexHeader;
TMBOY 47:9e361da97763 76
TMBOY 47:9e361da97763 77 /** Initializes a SpeexHeader using basic information */
TMBOY 47:9e361da97763 78 void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m);
TMBOY 47:9e361da97763 79
TMBOY 47:9e361da97763 80 /** Creates the header packet from the header itself (mostly involves endianness conversion) */
TMBOY 47:9e361da97763 81 char *speex_header_to_packet(SpeexHeader *header, int *size);
TMBOY 47:9e361da97763 82
TMBOY 47:9e361da97763 83 /** Creates a SpeexHeader from a packet */
TMBOY 47:9e361da97763 84 SpeexHeader *speex_packet_to_header(char *packet, int size);
TMBOY 47:9e361da97763 85
TMBOY 47:9e361da97763 86 #ifdef __cplusplus
TMBOY 47:9e361da97763 87 }
TMBOY 47:9e361da97763 88 #endif
TMBOY 47:9e361da97763 89
TMBOY 47:9e361da97763 90 /** @} */
TMBOY 47:9e361da97763 91 #endif