Home | History | Annotate | Download | only in src
      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 
     19 typedef 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 mABQ;
     31 #endif
     32 } DataLocator;
     33 
     34 typedef union {
     35     SLuint32 mFormatType;
     36     SLDataFormat_PCM mPCM;
     37     SLDataFormat_MIME mMIME;
     38     XADataFormat_RawImage mRawImage;
     39 } DataFormat;
     40 
     41 typedef 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                                 // (not a valid value for mLocatorType)
     56 #define XA_DATALOCATOR_NULL SL_DATALOCATOR_NULL
     57 #define SL_DATAFORMAT_NULL 0    // application specified a NULL value for pFormat
     58                                 // (not a valid value for mLocatorType)
     59 #define XA_DATAFORMAT_NULL SL_DATAFORMAT_NULL
     60 
     61 // bit masks used to configure the allowed data locators for a given data source or data sink
     62 #define DATALOCATOR_MASK_NONE            0L
     63 #define DATALOCATOR_MASK_NULL            (1L << SL_DATALOCATOR_NULL)
     64 #define DATALOCATOR_MASK_URI             (1L << SL_DATALOCATOR_URI)
     65 #define DATALOCATOR_MASK_ADDRESS         (1L << SL_DATALOCATOR_ADDRESS)
     66 #define DATALOCATOR_MASK_IODEVICE        (1L << SL_DATALOCATOR_IODEVICE)
     67 #define DATALOCATOR_MASK_OUTPUTMIX       (1L << SL_DATALOCATOR_OUTPUTMIX)
     68 #define DATALOCATOR_MASK_NATIVEDISPLAY   (1L << XA_DATALOCATOR_NATIVEDISPLAY)
     69 #define DATALOCATOR_MASK_BUFFERQUEUE     (1L << SL_DATALOCATOR_BUFFERQUEUE)
     70 #define DATALOCATOR_MASK_MIDIBUFFERQUEUE (1L << SL_DATALOCATOR_MIDIBUFFERQUEUE)
     71 #define DATALOCATOR_MASK_ANDROIDFD                \
     72                  (0x100L << (SL_DATALOCATOR_ANDROIDFD - SL_DATALOCATOR_ANDROIDFD))
     73 #define DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE \
     74                  (0x100L << (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
     75 #define DATALOCATOR_MASK_ANDROIDBUFFERQUEUE       \
     76                  (0x100L << (SL_DATALOCATOR_ANDROIDBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
     77 #define DATALOCATOR_MASK_ALL             0x7FFL
     78 
     79 // bit masks used to configure the allowed data formats for a given data source or data sink
     80 #define DATAFORMAT_MASK_NONE             0L
     81 #define DATAFORMAT_MASK_NULL             (1L << SL_DATAFORMAT_NULL)
     82 #define DATAFORMAT_MASK_MIME             (1L << SL_DATAFORMAT_MIME)
     83 #define DATAFORMAT_MASK_PCM              (1L << SL_DATAFORMAT_PCM)
     84 #define DATAFORMAT_MASK_RAWIMAGE         (1L << XA_DATAFORMAT_RAWIMAGE)
     85 #define DATAFORMAT_MASK_ALL              0xFL
     86 
     87 extern SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
     88         DataLocatorFormat *myDataSourceLocator, SLuint32 allowedDataLocatorMask,
     89         SLuint32 allowedDataFormatMask);
     90 extern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
     91         DataLocatorFormat *myDataSinkLocator, SLuint32 allowedDataLocatorMask,
     92         SLuint32 allowedDataFormatMask);
     93 extern SLresult checkSourceSinkVsInterfacesCompatibility(
     94         const DataLocatorFormat *pSrcDataLocatorFormat,
     95         const DataLocatorFormat *pSinkDataLocatorFormat,
     96         const ClassTable *clazz, unsigned requiredMask);
     97 extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
     98 
     99 
    100 /* For stream information storage */
    101 typedef struct {
    102     XAuint32 domain;
    103     union {
    104         XAMediaContainerInformation containerInfo;
    105         XAVideoStreamInformation videoInfo;
    106         XAAudioStreamInformation audioInfo;
    107         XAImageStreamInformation imageInfo;
    108         XATimedTextStreamInformation textInfo;
    109         XAMIDIStreamInformation midiInfo;
    110         XAVendorStreamInformation vendorInfo;
    111     };
    112 } StreamInfo;
    113 
    114 // FIXME a terrible hack until OpenMAX AL spec is updated
    115 #define XA_DOMAINTYPE_CONTAINER 0
    116