android_defs.h revision 13837cf3f7be0eb8b1a9552bd99a89f98c987720
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
56/**
57 * Structure to maintain the set of audio levels about a player
58 */
59typedef struct AndroidAudioLevels_struct {
60/** send level to aux effect, there's a single aux bus, so there's a single level */
61    SLmillibel mAuxSendLevel;
62    /**
63     * Amplification (can be attenuation) factor derived for the VolumeLevel
64     */
65    float mAmplFromVolLevel;
66    /**
67     * Left/right amplification (can be attenuations) factors derived for the StereoPosition
68     */
69    float mAmplFromStereoPos[STEREO_CHANNELS];
70    /**
71     * Attenuation factor derived from direct level
72     */
73    float mAmplFromDirectLevel;
74} AndroidAudioLevels;
75
76
77/**
78 * Event notification callback from Android to SL ES framework
79 */
80typedef void (*notif_cbf_t)(int event, int data1, void* notifUser);
81
82/**
83 * Audio data push callback from Android objects to SL ES framework
84 */
85typedef size_t (*data_push_cbf_t)(const uint8_t *data, size_t size, void* user);
86
87
88/**
89 * Events sent to mNotifyClient during prepare, prefetch, and playback
90 * used in APlayer::notify() and AMessage::findxxx()
91 */
92#define PLAYEREVENT_PREPARED                "prep"
93#define PLAYEREVENT_PREFETCHSTATUSCHANGE    "prsc"
94#define PLAYEREVENT_PREFETCHFILLLEVELUPDATE "pflu"
95#define PLAYEREVENT_ENDOFSTREAM             "eos"
96#define PLAYEREVENT_NEW_AUDIOTRACK          "nwat"
97
98
99/**
100 * Command parameters for AHandler commands
101 */
102#define WHATPARAM_SEEK_SEEKTIME_MS "seekTimeMs"
103#define WHATPARAM_LOOP_LOOPING     "looping"
104
105namespace android {
106
107enum {
108    kDataLocatorNone = 'none',
109    kDataLocatorUri  = 'uri',
110    kDataLocatorFd   = 'fd',
111    };
112
113struct FdInfo {
114    int fd;
115    int64_t offset;
116    int64_t length;
117};
118
119// TODO currently used by SfPlayer, to replace by DataLocator2
120union DataLocator {
121    char* uri;
122    FdInfo fdi;
123};
124
125union DataLocator2 {
126    const char* uriRef;
127    FdInfo fdi;
128};
129
130} // namespace android
131