summaryrefslogtreecommitdiffstats
path: root/stack/include/a2d_m12.h
blob: 2cc5ef9b57cb925ff429aa0a7975d044ea2f8da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*****************************************************************************
**
**  Name:       a2d_m12.h
**
**  Description:Interface to MPEG-1, 2 Audio
**
**  Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
**  WIDCOMM Bluetooth Core. Proprietary and confidential.
**
*****************************************************************************/
#ifndef A2D_M12_H
#define A2D_M12_H

/*****************************************************************************
**  Constants
*****************************************************************************/
/* the length of the MPEG_1, 2 Audio Media Payload header. */
#define A2D_M12_MPL_HDR_LEN         4

/* the LOSC of MPEG_1, 2 Audio media codec capabilitiy */
#define A2D_M12_INFO_LEN          6

/* for Codec Specific Information Element */
#define A2D_M12_IE_LAYER_MSK        0xE0    /* b7-b5 layer */
#define A2D_M12_IE_LAYER1           0x80    /* b7: layer1 (mp1) */
#define A2D_M12_IE_LAYER2           0x40    /* b6: layer2 (mp2) */
#define A2D_M12_IE_LAYER3           0x20    /* b5: layer3 (mp3) */

#define A2D_M12_IE_CRC_MSK          0x10    /* b4: CRC */

#define A2D_M12_IE_CH_MD_MSK        0x0F    /* b3-b0 channel mode */
#define A2D_M12_IE_CH_MD_MONO       0x08    /* b3: mono */
#define A2D_M12_IE_CH_MD_DUAL       0x04    /* b2: dual */
#define A2D_M12_IE_CH_MD_STEREO     0x02    /* b1: stereo */
#define A2D_M12_IE_CH_MD_JOINT      0x01    /* b0: joint stereo */

#define A2D_M12_IE_MPF_MSK          0x40    /* b6: MPF */

#define A2D_M12_IE_SAMP_FREQ_MSK    0x3F    /* b5-b0 sampling frequency */
#define A2D_M12_IE_SAMP_FREQ_16     0x20    /* b5:16  kHz */
#define A2D_M12_IE_SAMP_FREQ_22     0x10    /* b4:22.05kHz */
#define A2D_M12_IE_SAMP_FREQ_24     0x08    /* b3:24  kHz */
#define A2D_M12_IE_SAMP_FREQ_32     0x04    /* b2:32  kHz */
#define A2D_M12_IE_SAMP_FREQ_44     0x02    /* b1:44.1kHz */
#define A2D_M12_IE_SAMP_FREQ_48     0x01    /* b0:48  kHz */

#define A2D_M12_IE_VBR_MSK          0x80    /* b7: VBR */

#define A2D_M12_IE_BITRATE_MSK      0x7FFF  /* b6-b0 of octect 2, all of octect3*/
#define A2D_M12_IE_BITRATE_0        0x0001  /* 0000 */
#define A2D_M12_IE_BITRATE_1        0x0002  /* 0001 */
#define A2D_M12_IE_BITRATE_2        0x0004  /* 0010 */
#define A2D_M12_IE_BITRATE_3        0x0008  /* 0011 */
#define A2D_M12_IE_BITRATE_4        0x0010  /* 0100 */
#define A2D_M12_IE_BITRATE_5        0x0020  /* 0101 */
#define A2D_M12_IE_BITRATE_6        0x0040  /* 0110 */
#define A2D_M12_IE_BITRATE_7        0x0080  /* 0111 */
#define A2D_M12_IE_BITRATE_8        0x0100  /* 1000 */
#define A2D_M12_IE_BITRATE_9        0x0200  /* 1001 */
#define A2D_M12_IE_BITRATE_10       0x0400  /* 1010 */
#define A2D_M12_IE_BITRATE_11       0x0800  /* 1011 */
#define A2D_M12_IE_BITRATE_12       0x1000  /* 1100 */
#define A2D_M12_IE_BITRATE_13       0x2000  /* 1101 */
#define A2D_M12_IE_BITRATE_14       0x4000  /* 1110 */

#define A2D_BLD_M12_PML_HDR(p_dst,frag_offset) {UINT16_TO_BE_STREAM(p_dst, 0); \
                                                UINT16_TO_BE_STREAM(p_dst, frag_offset); }

#define A2D_PARS_M12_PML_HDR(p_src,frag_offset) {BE_STREAM_TO_UINT16(frag_offset, p_src); \
                                                 BE_STREAM_TO_UINT16(frag_offset, p_src); }


/*****************************************************************************
**  Type Definitions
*****************************************************************************/

/* data type for the MPEG-1, 2 Audio Codec Information Element*/
typedef struct
{
    UINT8   layer;      /* layers */
    BOOLEAN crc;        /* Support of CRC protection or not */
    UINT8   ch_mode;    /* Channel mode */
    UINT8   mpf;        /* 1, if MPF-2 is supported. 0, otherwise */
    UINT8   samp_freq;  /* Sampling frequency */
    BOOLEAN vbr;        /* Variable Bit Rate */
    UINT16  bitrate;    /* Bit rate index */
} tA2D_M12_CIE;

/*****************************************************************************
**  External Function Declarations
*****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
**
** Function         A2D_BldM12Info
**
** Description      This function is called by an application to build  
**                  the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
**                  beginning from the LOSC octet.
**                  Input Parameters:
**                      media_type:  Indicates Audio, or Multimedia.
**
**                      p_ie:  The MPEG-1, 2 Audio Codec Information Element
**                             information.
**
**                  Output Parameters:
**                      p_result:  the resulting codec info byte sequence.
**
** Returns          A2D_SUCCESS if function execution succeeded.
**                  Error status code, otherwise.
******************************************************************************/
A2D_API extern tA2D_STATUS A2D_BldM12Info(UINT8 media_type, tA2D_M12_CIE *p_ie,
                                          UINT8 *p_result);

/******************************************************************************
**
** Function         A2D_ParsM12Info
**
** Description      This function is called by an application to parse 
**                  the MPEG-1, 2 Audio Media Codec Capabilities byte sequence
**                  beginning from the LOSC octet.
**                  Input Parameters:
**                      p_info:  the byte sequence to parse.
**
**                      for_caps:  TRUE, if the byte sequence is for get capabilities
**                                 response.
**
**                  Output Parameters:
**                      p_ie:  The MPEG-1, 2 Audio Codec Information Element
**                             information.
**
** Returns          A2D_SUCCESS if function execution succeeded.
**                  Error status code, otherwise.
******************************************************************************/
A2D_API extern tA2D_STATUS A2D_ParsM12Info(tA2D_M12_CIE *p_ie, UINT8 *p_info,
                                           BOOLEAN for_caps);

#ifdef __cplusplus
}
#endif

#endif /* A2D_M12_H */