android_defs.h revision 37dc2fccf3f122b79ebd554de209d0a3c94ae161
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18/**
19 * Used to define the mapping from an OpenSL ES audio player to an Android
20 * media framework object
21 */
22enum AndroidObject_type {
23    INVALID_TYPE     =-1,
24    A_PLR_URIFD      = 0, // audio player, compressed data, URI or FD data source
25    A_PLR_PCM_BQ     = 1, // audio player, PCM, buffer queue data source
26    A_PLR_TS_ABQ     = 2, // audio player, transport stream, Android simple buffer queue data source
27    A_PLR_URIFD_ASQ  = 3, // audio player, URI or FD data source (as in android::MediaPlayer),
28                          //    decoded to a PCM Android simple buffer queue data sink
29    AV_PLR_TS_ABQ    = 4, // audio video player, transport stream, Android buffer queue data source
30    AV_PLR_URIFD     = 5, // audio video player, URI or FD data source (as in android::MediaPlayer)
31    A_RCR_MIC_ASQ    = 6, // audio recorder, device data source,
32                          //    streamed into a PCM Android simple buffer queue data sink
33    NUM_AUDIOPLAYER_MAP_TYPES
34};
35
36
37/**
38 * Used to define the states of the OpenSL ES / OpenMAX AL object initialization and preparation
39 * with regards to the Android-side of the data
40 */
41enum AndroidObject_state {
42    ANDROID_UNINITIALIZED = -1,
43    ANDROID_PREPARING,
44    ANDROID_READY,
45    NUM_ANDROID_STATES
46};
47
48
49#define ANDROID_DEFAULT_OUTPUT_STREAM_TYPE android::AudioSystem::MUSIC
50
51#define PLAYER_SUCCESS 1
52
53#define PLAYER_FD_FIND_FILE_SIZE ((int64_t)0xFFFFFFFFFFFFFFFFll)
54
55#define MPEG2_TS_BLOCK_SIZE 188
56
57
58/**
59 * Structure to maintain the set of audio levels about a player
60 */
61typedef struct AndroidAudioLevels_struct {
62    /**
63     * Is this player muted
64     */
65    bool mMute;
66    /**
67     * Send level to aux effect, there's a single aux bus, so there's a single level
68     */
69    // FIXME not used yet, will be used when supporting effects in OpenMAX AL
70    //SLmillibel mAuxSendLevel;
71    /**
72     * Attenuation factor derived from direct level
73     */
74    // FIXME not used yet, will be used when supporting effects in OpenMAX AL
75    //float mAmplFromDirectLevel;
76    /**
77     * Android Left/Right volume
78     * The final volume of an Android AudioTrack or MediaPlayer is a stereo amplification
79     * (or attenuation) represented as a float from 0.0f to 1.0f
80     */
81    float mFinalVolume[STEREO_CHANNELS];
82} AndroidAudioLevels;
83
84
85/**
86 * Event notification callback from Android to SL ES framework
87 */
88typedef void (*notif_cbf_t)(int event, int data1, int data2, void* notifUser);
89
90/**
91 * Audio data push callback from Android objects to SL ES framework
92 */
93typedef size_t (*data_push_cbf_t)(const uint8_t *data, size_t size, void* user);
94
95
96/**
97 * Events sent to mNotifyClient during prepare, prefetch, and playback
98 * used in APlayer::notify() and AMessage::findxxx()
99 */
100#define PLAYEREVENT_PREPARED                "prep"
101#define PLAYEREVENT_PREFETCHSTATUSCHANGE    "prsc"
102#define PLAYEREVENT_PREFETCHFILLLEVELUPDATE "pflu"
103#define PLAYEREVENT_ENDOFSTREAM             "eos"
104#define PLAYEREVENT_NEW_AUDIOTRACK          "nwat"
105#define PLAYEREVENT_VIDEO_SIZE_UPDATE       "vsiz"
106
107
108/**
109 * Command parameters for AHandler commands
110 */
111#define WHATPARAM_SEEK_SEEKTIME_MS "seekTimeMs"
112#define WHATPARAM_LOOP_LOOPING     "looping"
113
114/**
115 * Event mask for MPEG-2 TS events associated with TS data
116 */
117#define ANDROID_MP2TSEVENT_NONE          ((SLuint32) 0x0)
118// buffer is at End Of Stream
119#define ANDROID_MP2TSEVENT_EOS           ((SLuint32) 0x1)
120// buffer marks a discontinuity with previous TS data, resume display as soon as possible
121#define ANDROID_MP2TSEVENT_DISCONTINUITY ((SLuint32) 0x1 << 1)
122// buffer marks a discontinuity with previous TS data, resume display upon reaching the
123// associated presentation time stamp
124#define ANDROID_MP2TSEVENT_DISCON_NEWPTS ((SLuint32) 0x1 << 2)
125
126/**
127 * Types of buffers stored in Android Buffer Queues, see IAndroidBufferQueue.mBufferType
128 */
129enum AndroidBufferType_type {
130    kAndroidBufferTypeInvalid = ((SLuint16) 0x0),
131    kAndroidBufferTypeMpeg2Ts = ((SLuint16) 0x1),
132};
133
134namespace android {
135
136enum {
137    kDataLocatorNone = 'none',
138    kDataLocatorUri  = 'uri',
139    kDataLocatorFd   = 'fd',
140};
141
142struct FdInfo {
143    int fd;
144    int64_t offset;
145    int64_t length;
146};
147
148// TODO currently used by SfPlayer, to replace by DataLocator2
149union DataLocator {
150    char* uri;
151    FdInfo fdi;
152};
153
154union DataLocator2 {
155    const char* uriRef;
156    FdInfo fdi;
157};
158
159} // namespace android
160