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