android_defs.h revision 4ee246c55533bdab8ab5fa0f0581744fe58e7c91
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 or OpenMAX AL object to an Android
20 * media framework object
21 */
22enum AndroidObject_type {
23    INVALID_TYPE                              =-1,
24    // audio player, playing from a URI or FD data source
25    AUDIOPLAYER_FROM_URIFD                    = 0,
26    // audio player, playing PCM buffers in a buffer queue data source
27    AUDIOPLAYER_FROM_PCM_BUFFERQUEUE          = 1,
28    // audio player, playing transport stream packets in an Android buffer queue data source
29    AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE    = 2,
30    // audio player, decoding from a URI or FD data source to a buffer queue data sink in PCM format
31    AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE = 3,
32    // FIXME rename values below to something easier to read (following model from previous values)
33    AV_PLR_TS_ABQ    = 4, // audio video player, transport stream, Android buffer queue data source
34    AV_PLR_URIFD     = 5, // audio video player, URI or FD data source (as in android::MediaPlayer)
35    A_RCR_MIC_ASQ    = 6, // audio recorder, device data source,
36                          //    streamed into a PCM Android simple buffer queue data sink
37    NUM_AUDIOPLAYER_MAP_TYPES
38};
39
40
41/**
42 * Used to define the states of the OpenSL ES / OpenMAX AL object initialization and preparation
43 * with regards to the Android-side of the data
44 */
45enum AndroidObject_state {
46    ANDROID_UNINITIALIZED = -1,
47    ANDROID_PREPARING,
48    ANDROID_READY,
49    NUM_ANDROID_STATES
50};
51
52
53#define ANDROID_DEFAULT_OUTPUT_STREAM_TYPE android::AudioSystem::MUSIC
54
55#define PLAYER_SUCCESS 1
56
57#define PLAYER_FD_FIND_FILE_SIZE ((int64_t)0xFFFFFFFFFFFFFFFFll)
58
59#define MPEG2_TS_BLOCK_SIZE 188
60
61// FIXME separate the cases where we don't need an AudioTrack callback
62typedef struct AudioPlayback_Parameters_struct {
63    int streamType;
64    int sessionId;
65    android::AudioTrack::callback_t trackcb;
66    void* trackcbUser;
67} AudioPlayback_Parameters;
68
69/**
70 * Structure to maintain the set of audio levels about a player
71 */
72typedef struct AndroidAudioLevels_struct {
73    /**
74     * Is this player muted
75     */
76    bool mMute;
77    /**
78     * Send level to aux effect, there's a single aux bus, so there's a single level
79     */
80    // FIXME not used yet, will be used when supporting effects in OpenMAX AL
81    //SLmillibel mAuxSendLevel;
82    /**
83     * Attenuation factor derived from direct level
84     */
85    // FIXME not used yet, will be used when supporting effects in OpenMAX AL
86    //float mAmplFromDirectLevel;
87    /**
88     * Android Left/Right volume
89     * The final volume of an Android AudioTrack or MediaPlayer is a stereo amplification
90     * (or attenuation) represented as a float from 0.0f to 1.0f
91     */
92    float mFinalVolume[STEREO_CHANNELS];
93} AndroidAudioLevels;
94
95
96/**
97 * Event notification callback from Android to SL ES framework
98 */
99typedef void (*notif_cbf_t)(int event, int data1, int data2, void* notifUser);
100
101/**
102 * Audio data push callback from Android objects to SL ES framework
103 */
104typedef size_t (*data_push_cbf_t)(const uint8_t *data, size_t size, void* user);
105
106
107/**
108 * Events sent to mNotifyClient during prepare, prefetch, and playback
109 * used in APlayer::notify() and AMessage::findxxx()
110 */
111#define PLAYEREVENT_PREPARED                "prep"
112#define PLAYEREVENT_PREFETCHSTATUSCHANGE    "prsc"
113#define PLAYEREVENT_PREFETCHFILLLEVELUPDATE "pflu"
114#define PLAYEREVENT_ENDOFSTREAM             "eos"
115#define PLAYEREVENT_VIDEO_SIZE_UPDATE       "vsiz"
116
117
118/**
119 * Time value when time is unknown. Used for instance for duration or playback position
120 */
121#define ANDROID_UNKNOWN_TIME -1
122
123/**
124 * Event mask for MPEG-2 TS events associated with TS data
125 */
126#define ANDROID_MP2TSEVENT_NONE          ((SLuint32) 0x0)
127// buffer is at End Of Stream
128#define ANDROID_MP2TSEVENT_EOS           ((SLuint32) 0x1)
129// buffer marks a discontinuity with previous TS data, resume display as soon as possible
130#define ANDROID_MP2TSEVENT_DISCONTINUITY ((SLuint32) 0x1 << 1)
131// buffer marks a discontinuity with previous TS data, resume display upon reaching the
132// associated presentation time stamp
133#define ANDROID_MP2TSEVENT_DISCON_NEWPTS ((SLuint32) 0x1 << 2)
134
135/**
136 * Types of buffers stored in Android Buffer Queues, see IAndroidBufferQueue.mBufferType
137 */
138enum AndroidBufferType_type {
139    kAndroidBufferTypeInvalid = ((SLuint16) 0x0),
140    kAndroidBufferTypeMpeg2Ts = ((SLuint16) 0x1),
141};
142
143/**
144 * Notification thresholds relative to content duration in the cache
145 */
146#define DURATION_CACHED_HIGH_MS  30000 // 30s
147#define DURATION_CACHED_MED_MS   10000 // 10s
148#define DURATION_CACHED_LOW_MS    2000 //  2s
149
150
151namespace android {
152
153/**
154 * Prefetch cache status
155 */
156enum CacheStatus_t {
157        kStatusUnknown = -1,
158        kStatusEmpty   = 0,
159        kStatusLow,
160        kStatusIntermediate,
161        kStatusEnough,
162        kStatusHigh
163};
164
165enum {
166    kDataLocatorNone = 'none',
167    kDataLocatorUri  = 'uri',
168    kDataLocatorFd   = 'fd',
169};
170
171struct FdInfo {
172    int fd;
173    int64_t offset;
174    int64_t length;
175};
176
177// TODO currently used by SfPlayer, to replace by DataLocator2
178union DataLocator {
179    char* uri;
180    FdInfo fdi;
181};
182
183union DataLocator2 {
184    const char* uriRef;
185    FdInfo fdi;
186};
187
188} // namespace android
189