android_defs.h revision 70c49ae2867094072a4365423417ea452bf82231
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/** send level to aux effect, there's a single aux bus, so there's a single level */
63    SLmillibel mAuxSendLevel;
64    /**
65     * Amplification (can be attenuation) factor derived for the VolumeLevel
66     */
67    float mAmplFromVolLevel;
68    /**
69     * Left/right amplification (can be attenuations) factors derived for the StereoPosition
70     */
71    float mAmplFromStereoPos[STEREO_CHANNELS];
72    /**
73     * Attenuation factor derived from direct level
74     */
75    float mAmplFromDirectLevel;
76} AndroidAudioLevels;
77
78
79/**
80 * Event notification callback from Android to SL ES framework
81 */
82typedef void (*notif_cbf_t)(int event, int data1, void* notifUser);
83
84/**
85 * Audio data push callback from Android objects to SL ES framework
86 */
87typedef size_t (*data_push_cbf_t)(const uint8_t *data, size_t size, void* user);
88
89
90/**
91 * Events sent to mNotifyClient during prepare, prefetch, and playback
92 * used in APlayer::notify() and AMessage::findxxx()
93 */
94#define PLAYEREVENT_PREPARED                "prep"
95#define PLAYEREVENT_PREFETCHSTATUSCHANGE    "prsc"
96#define PLAYEREVENT_PREFETCHFILLLEVELUPDATE "pflu"
97#define PLAYEREVENT_ENDOFSTREAM             "eos"
98#define PLAYEREVENT_NEW_AUDIOTRACK          "nwat"
99
100
101/**
102 * Command parameters for AHandler commands
103 */
104#define WHATPARAM_SEEK_SEEKTIME_MS "seekTimeMs"
105#define WHATPARAM_LOOP_LOOPING     "looping"
106
107/**
108 * Event mask for MPEG-2 TS events associated with TS data
109 */
110#define ANDROID_MP2TSEVENT_NONE          ((SLuint32) 0x0)
111// buffer is at End Of Stream
112#define ANDROID_MP2TSEVENT_EOS           ((SLuint32) 0x1)
113// buffer marks a discontinuity with previous TS data, resume display as soon as possible
114#define ANDROID_MP2TSEVENT_DISCONTINUITY ((SLuint32) 0x1 << 1)
115// buffer marks a discontinuity with previous TS data, resume display upon reaching the
116// associated presentation time stamp
117#define ANDROID_MP2TSEVENT_DISCON_NEWPTS ((SLuint32) 0x1 << 2)
118
119/**
120 * Types of buffers stored in Android Buffer Queues, see IAndroidBufferQueue.mBufferType
121 */
122enum AndroidBufferType_type {
123    kAndroidBufferTypeInvalid = ((SLuint16) 0x0),
124    kAndroidBufferTypeMpeg2Ts = ((SLuint16) 0x1),
125};
126
127namespace android {
128
129enum {
130    kDataLocatorNone = 'none',
131    kDataLocatorUri  = 'uri',
132    kDataLocatorFd   = 'fd',
133};
134
135struct FdInfo {
136    int fd;
137    int64_t offset;
138    int64_t length;
139};
140
141// TODO currently used by SfPlayer, to replace by DataLocator2
142union DataLocator {
143    char* uri;
144    FdInfo fdi;
145};
146
147union DataLocator2 {
148    const char* uriRef;
149    FdInfo fdi;
150};
151
152} // namespace android
153