1/******************************************************************************
2 *
3 *  Copyright (C) 2009-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19/*****************************************************************************
20 **
21 **  Name:           btif_av_api.h
22 **
23 **  Description:    This is the public interface file for the advanced
24 **                  audio/video streaming (AV) subsystem of BTIF, Broadcom's
25 **                  Bluetooth application layer for mobile phones.
26 **
27 *****************************************************************************/
28
29#ifndef BTIF_AV_API_H
30#define BTIF_AV_API_H
31
32#include "bt_target.h"
33#include "bta_av_api.h"
34#include "uipc.h"
35
36#include "btif_media.h"
37#include "a2d_api.h"
38#include "a2d_sbc.h"
39
40
41/*****************************************************************************
42 **  Constants and data types
43 *****************************************************************************/
44
45/* Codec type */
46#define BTIF_AV_CODEC_NONE       0xFF
47#define BTIF_AV_CODEC_SBC        A2D_MEDIA_CT_SBC        /* SBC media codec type */
48
49#define BTIF_AV_CODEC_PCM        0x5                     /* Raw PCM */
50
51typedef UINT8 tBTIF_AV_CODEC_ID;
52
53/* AV features masks */
54#define BTIF_AV_FEAT_RCTG        BTA_AV_FEAT_RCTG      /* remote control target */
55#define BTIF_AV_FEAT_RCCT        BTA_AV_FEAT_RCCT      /* remote control controller */
56#define BTIF_AV_FEAT_METADATA    BTA_AV_FEAT_METADATA  /* remote control Metadata Transfer command/response */
57
58typedef UINT16 tBTIF_AV_FEAT;
59
60/* AV channel values */
61#define BTIF_AV_CHNL_MSK         BTA_AV_CHNL_MSK
62#define BTIF_AV_CHNL_AUDIO       BTA_AV_CHNL_AUDIO       /* audio channel */
63#define BTIF_AV_CHNL_VIDEO       BTA_AV_CHNL_VIDEO       /* video channel */
64typedef UINT8 tBTIF_AV_CHNL;
65
66typedef UINT8 tBTIF_AV_HNDL;
67
68/* Operation id list for BTIF_AvRemoteCmd */
69#define BTIF_AV_ID_SELECT      0x00    /* select */
70#define BTIF_AV_ID_UP          0x01    /* up */
71#define BTIF_AV_ID_DOWN        0x02    /* down */
72#define BTIF_AV_ID_LEFT        0x03    /* left */
73#define BTIF_AV_ID_RIGHT       0x04    /* right */
74#define BTIF_AV_ID_RIGHT_UP    0x05    /* right-up */
75#define BTIF_AV_ID_RIGHT_DOWN  0x06    /* right-down */
76#define BTIF_AV_ID_LEFT_UP     0x07    /* left-up */
77#define BTIF_AV_ID_LEFT_DOWN   0x08    /* left-down */
78#define BTIF_AV_ID_ROOT_MENU   0x09    /* root menu */
79#define BTIF_AV_ID_SETUP_MENU  0x0A    /* setup menu */
80#define BTIF_AV_ID_CONT_MENU   0x0B    /* contents menu */
81#define BTIF_AV_ID_FAV_MENU    0x0C    /* favorite menu */
82#define BTIF_AV_ID_EXIT        0x0D    /* exit */
83#define BTIF_AV_ID_0           0x20    /* 0 */
84#define BTIF_AV_ID_1           0x21    /* 1 */
85#define BTIF_AV_ID_2           0x22    /* 2 */
86#define BTIF_AV_ID_3           0x23    /* 3 */
87#define BTIF_AV_ID_4           0x24    /* 4 */
88#define BTIF_AV_ID_5           0x25    /* 5 */
89#define BTIF_AV_ID_6           0x26    /* 6 */
90#define BTIF_AV_ID_7           0x27    /* 7 */
91#define BTIF_AV_ID_8           0x28    /* 8 */
92#define BTIF_AV_ID_9           0x29    /* 9 */
93#define BTIF_AV_ID_DOT         0x2A    /* dot */
94#define BTIF_AV_ID_ENTER       0x2B    /* enter */
95#define BTIF_AV_ID_CLEAR       0x2C    /* clear */
96#define BTIF_AV_ID_CHAN_UP     0x30    /* channel up */
97#define BTIF_AV_ID_CHAN_DOWN   0x31    /* channel down */
98#define BTIF_AV_ID_PREV_CHAN   0x32    /* previous channel */
99#define BTIF_AV_ID_SOUND_SEL   0x33    /* sound select */
100#define BTIF_AV_ID_INPUT_SEL   0x34    /* input select */
101#define BTIF_AV_ID_DISP_INFO   0x35    /* display information */
102#define BTIF_AV_ID_HELP        0x36    /* help */
103#define BTIF_AV_ID_PAGE_UP     0x37    /* page up */
104#define BTIF_AV_ID_PAGE_DOWN   0x38    /* page down */
105#define BTIF_AV_ID_POWER       0x40    /* power */
106#define BTIF_AV_ID_VOL_UP      0x41    /* volume up */
107#define BTIF_AV_ID_VOL_DOWN    0x42    /* volume down */
108#define BTIF_AV_ID_MUTE        0x43    /* mute */
109#define BTIF_AV_ID_PLAY        0x44    /* play */
110#define BTIF_AV_ID_STOP        0x45    /* stop */
111#define BTIF_AV_ID_PAUSE       0x46    /* pause */
112#define BTIF_AV_ID_RECORD      0x47    /* record */
113#define BTIF_AV_ID_REWIND      0x48    /* rewind */
114#define BTIF_AV_ID_FAST_FOR    0x49    /* fast forward */
115#define BTIF_AV_ID_EJECT       0x4A    /* eject */
116#define BTIF_AV_ID_FORWARD     0x4B    /* forward */
117#define BTIF_AV_ID_BACKWARD    0x4C    /* backward */
118#define BTIF_AV_ID_ANGLE       0x50    /* angle */
119#define BTIF_AV_ID_SUBPICT     0x51    /* subpicture */
120#define BTIF_AV_ID_F1          0x71    /* F1 */
121#define BTIF_AV_ID_F2          0x72    /* F2 */
122#define BTIF_AV_ID_F3          0x73    /* F3 */
123#define BTIF_AV_ID_F4          0x74    /* F4 */
124#define BTIF_AV_ID_F5          0x75    /* F5 */
125#define BTIF_AV_ID_VENDOR      0x7E    /* vendor unique */
126#define BTIF_AV_KEYPRESSED_RELEASE 0x80
127
128typedef UINT8 tBTIF_AV_RC;
129
130/* State flag for pass through command */
131#define BTIF_AV_STATE_PRESS      0    /* key pressed */
132#define BTIF_AV_STATE_RELEASE    1  /* key released */
133
134typedef UINT8 tBTIF_AV_STATE;
135
136typedef UINT8 tBTIF_AV_RC_HNDL;
137
138/* Command codes for BTIF_AvVendorCmd */
139#define BTIF_AV_CMD_CTRL         0
140#define BTIF_AV_CMD_STATUS       1
141#define BTIF_AV_CMD_SPEC_INQ     2
142#define BTIF_AV_CMD_NOTIF        3
143#define BTIF_AV_CMD_GEN_INQ      4
144
145typedef UINT8 tBTIF_AV_CMD;
146
147/* AV callback events */
148#define BTIF_AV_OPEN_EVT         0       /* connection opened */
149#define BTIF_AV_CLOSE_EVT        1       /* connection closed */
150#define BTIF_AV_START_EVT        2       /* stream data transfer started */
151#define BTIF_AV_STOP_EVT         3       /* stream data transfer stopped */
152#define BTIF_AV_RC_OPEN_EVT      4       /* remote control channel open */
153#define BTIF_AV_RC_CLOSE_EVT     5       /* remote control channel closed */
154#define BTIF_AV_REMOTE_CMD_EVT   6      /* remote control command */
155#define BTIF_AV_REMOTE_RSP_EVT   7      /* remote control response */
156#define BTIF_AV_META_MSG_EVT     8      /* metadata messages */
157
158typedef UINT8 tBTIF_AV_EVT;
159
160#define BTIF_AV_FEEDING_ASYNCHRONOUS 0   /* asynchronous feeding, use tx av timer */
161#define BTIF_AV_FEEDING_SYNCHRONOUS  1   /* synchronous feeding, no av tx timer */
162
163#define BTIF_AV_MAX_SYNCHRONOUS_LATENCY 80 /* max latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */
164#define BTIF_AV_MIN_SYNCHRONOUS_LATENCY 4 /* min latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */
165
166typedef UINT8 tBTIF_AV_FEEDING_MODE;
167
168#define BTIF_AV_CHANNEL_MODE_MONO    A2D_SBC_IE_CH_MD_MONO
169#define BTIF_AV_CHANNEL_MODE_STEREO  A2D_SBC_IE_CH_MD_STEREO
170#define BTIF_AV_CHANNEL_MODE_JOINT   A2D_SBC_IE_CH_MD_JOINT
171#define BTIF_AV_CHANNEL_MODE_DUAL    A2D_SBC_IE_CH_MD_DUAL
172
173typedef UINT8 tBTIF_AV_CHANNEL_MODE;
174
175/**
176 * Structure used to configure the AV codec capabilities/config
177 */
178typedef struct
179{
180    tBTIF_AV_CODEC_ID id;            /* Codec ID (in terms of BTIF) */
181    UINT8 info[AVDT_CODEC_SIZE];     /* Codec info (can be config or capabilities) */
182} tBTIF_AV_CODEC_INFO;
183
184/**
185 * Structure used to configure the AV media feeding
186 */
187typedef struct
188{
189    UINT16 sampling_freq;   /* 44100, 48000 etc */
190    UINT16 num_channel;     /* 1 for mono or 2 stereo */
191    UINT8  bit_per_sample;  /* Number of bits per sample (8, 16) */
192} tBTIF_AV_MEDIA_FEED_CFG_PCM;
193
194typedef union
195{
196    tBTIF_AV_MEDIA_FEED_CFG_PCM pcm;     /* Raw PCM feeding format */
197}tBTIF_AV_MEDIA_FEED_CFG;
198
199typedef struct
200{
201    tBTIF_AV_CODEC_ID format;        /* Media codec identifier */
202    tBTIF_AV_MEDIA_FEED_CFG cfg;     /* Media codec configuration */
203} tBTIF_AV_MEDIA_FEEDINGS;
204
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif /* BTIF_AV_API_H */
211