data.h revision bcc5c7225e3b7a1dbf2e9e830987f69167acf06f
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/* Our own merged version of SLDataSource and SLDataSink */
18
19typedef union {
20    SLuint32 mLocatorType;
21    SLDataLocator_Address mAddress;
22    SLDataLocator_BufferQueue mBufferQueue;
23    SLDataLocator_IODevice mIODevice;
24    SLDataLocator_MIDIBufferQueue mMIDIBufferQueue;
25    SLDataLocator_OutputMix mOutputMix;
26    SLDataLocator_URI mURI;
27    XADataLocator_NativeDisplay mNativeDisplay;
28#ifdef ANDROID
29    SLDataLocator_AndroidFD mFD;
30    SLDataLocator_AndroidBufferQueue mBQ;
31#endif
32} DataLocator;
33
34typedef union {
35    SLuint32 mFormatType;
36    SLDataFormat_PCM mPCM;
37    SLDataFormat_MIME mMIME;
38    XADataFormat_RawImage mRawImage;
39} DataFormat;
40
41typedef struct {
42    union {
43        SLDataSource mSource;
44        SLDataSink mSink;
45        struct {
46            DataLocator *pLocator;
47            DataFormat *pFormat;
48        } mNeutral;
49    } u;
50    DataLocator mLocator;
51    DataFormat mFormat;
52} DataLocatorFormat;
53
54#define SL_DATALOCATOR_NULL 0    // application specified a NULL value for pLocator
55#define SL_DATAFORMAT_NULL 0     // application specified a NULL or undefined value for pFormat
56
57// bit masks used to configure the allowed data locators for a given data source or data sink
58#define DATALOCATOR_MASK_NONE            0L
59#define DATALOCATOR_MASK_NULL            (1L << SL_DATALOCATOR_NULL)
60#define DATALOCATOR_MASK_URI             (1L << SL_DATALOCATOR_URI)
61#define DATALOCATOR_MASK_ADDRESS         (1L << SL_DATALOCATOR_ADDRESS)
62#define DATALOCATOR_MASK_IODEVICE        (1L << SL_DATALOCATOR_IODEVICE)
63#define DATALOCATOR_MASK_OUTPUTMIX       (1L << SL_DATALOCATOR_OUTPUTMIX)
64#define DATALOCATOR_MASK_NATIVEDISPLAY   (1L << XA_DATALOCATOR_NATIVEDISPLAY)
65#define DATALOCATOR_MASK_BUFFERQUEUE     (1L << SL_DATALOCATOR_BUFFERQUEUE)
66#define DATALOCATOR_MASK_MIDIBUFFERQUEUE (1L << SL_DATALOCATOR_MIDIBUFFERQUEUE)
67#define DATALOCATOR_MASK_ANDROIDFD                \
68                 (0x100L << (SL_DATALOCATOR_ANDROIDFD - SL_DATALOCATOR_ANDROIDFD))
69#define DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE \
70                 (0x100L << (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
71#define DATALOCATOR_MASK_ANDROIDBUFFERQUEUE       \
72                 (0x100L << (SL_DATALOCATOR_ANDROIDBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
73#define DATALOCATOR_MASK_ALL             0x7FFL
74
75// bit masks used to configure the allowed data formats for a given data source or data sink
76#define DATAFORMAT_MASK_NONE             0L
77#define DATAFORMAT_MASK_NULL             (1L << SL_DATAFORMAT_NULL)
78#define DATAFORMAT_MASK_MIME             (1L << SL_DATAFORMAT_MIME)
79#define DATAFORMAT_MASK_PCM              (1L << SL_DATAFORMAT_PCM)
80#define DATAFORMAT_MASK_RAWIMAGE         (1L << XA_DATAFORMAT_RAWIMAGE)
81#define DATAFORMAT_MASK_ALL              0xFL
82
83extern SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
84        DataLocatorFormat *myDataSourceLocator, SLuint32 allowedDataLocatorMask,
85        SLuint32 allowedDataFormatMask);
86extern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
87        DataLocatorFormat *myDataSinkLocator, SLuint32 allowedDataLocatorMask,
88        SLuint32 allowedDataFormatMask);
89extern SLresult checkSourceFormatVsInterfacesCompatibility(
90        const DataLocatorFormat *pDataLocatorFormat, const ClassTable *clazz,
91        unsigned exposedMask);
92extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
93
94
95/* For stream information storage */
96typedef struct {
97    XAuint32 domain;
98    union {
99        XAMediaContainerInformation containerInfo;
100        XAVideoStreamInformation videoInfo;
101        XAAudioStreamInformation audioInfo;
102        XAImageStreamInformation imageInfo;
103        XATimedTextStreamInformation textInfo;
104        XAMIDIStreamInformation midiInfo;
105    };
106} StreamInfo;
107