data.h 4.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Our own merged version of SLDataSource and SLDataSink */

typedef union {
    SLuint32 mLocatorType;
    SLDataLocator_Address mAddress;
    SLDataLocator_BufferQueue mBufferQueue;
    SLDataLocator_IODevice mIODevice;
    SLDataLocator_MIDIBufferQueue mMIDIBufferQueue;
    SLDataLocator_OutputMix mOutputMix;
    SLDataLocator_URI mURI;
27
    XADataLocator_NativeDisplay mNativeDisplay;
28 29
#ifdef ANDROID
    SLDataLocator_AndroidFD mFD;
30
    SLDataLocator_AndroidBufferQueue mABQ;
31 32 33 34 35 36 37
#endif
} DataLocator;

typedef union {
    SLuint32 mFormatType;
    SLDataFormat_PCM mPCM;
    SLDataFormat_MIME mMIME;
38
    XADataFormat_RawImage mRawImage;
39 40 41 42 43 44 45 46 47 48 49 50 51 52
} DataFormat;

typedef struct {
    union {
        SLDataSource mSource;
        SLDataSink mSink;
        struct {
            DataLocator *pLocator;
            DataFormat *pFormat;
        } mNeutral;
    } u;
    DataLocator mLocator;
    DataFormat mFormat;
} DataLocatorFormat;
53

54 55
#define SL_DATALOCATOR_NULL 0   // application specified a NULL value for pLocator
                                // (not a valid value for mLocatorType)
56
#define XA_DATALOCATOR_NULL SL_DATALOCATOR_NULL
57 58
#define SL_DATAFORMAT_NULL 0    // application specified a NULL value for pFormat
                                // (not a valid value for mLocatorType)
59
#define XA_DATAFORMAT_NULL SL_DATAFORMAT_NULL
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

// bit masks used to configure the allowed data locators for a given data source or data sink
#define DATALOCATOR_MASK_NONE            0L
#define DATALOCATOR_MASK_NULL            (1L << SL_DATALOCATOR_NULL)
#define DATALOCATOR_MASK_URI             (1L << SL_DATALOCATOR_URI)
#define DATALOCATOR_MASK_ADDRESS         (1L << SL_DATALOCATOR_ADDRESS)
#define DATALOCATOR_MASK_IODEVICE        (1L << SL_DATALOCATOR_IODEVICE)
#define DATALOCATOR_MASK_OUTPUTMIX       (1L << SL_DATALOCATOR_OUTPUTMIX)
#define DATALOCATOR_MASK_NATIVEDISPLAY   (1L << XA_DATALOCATOR_NATIVEDISPLAY)
#define DATALOCATOR_MASK_BUFFERQUEUE     (1L << SL_DATALOCATOR_BUFFERQUEUE)
#define DATALOCATOR_MASK_MIDIBUFFERQUEUE (1L << SL_DATALOCATOR_MIDIBUFFERQUEUE)
#define DATALOCATOR_MASK_ANDROIDFD                \
                 (0x100L << (SL_DATALOCATOR_ANDROIDFD - SL_DATALOCATOR_ANDROIDFD))
#define DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE \
                 (0x100L << (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
#define DATALOCATOR_MASK_ANDROIDBUFFERQUEUE       \
                 (0x100L << (SL_DATALOCATOR_ANDROIDBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
#define DATALOCATOR_MASK_ALL             0x7FFL

// bit masks used to configure the allowed data formats for a given data source or data sink
#define DATAFORMAT_MASK_NONE             0L
#define DATAFORMAT_MASK_NULL             (1L << SL_DATAFORMAT_NULL)
#define DATAFORMAT_MASK_MIME             (1L << SL_DATAFORMAT_MIME)
#define DATAFORMAT_MASK_PCM              (1L << SL_DATAFORMAT_PCM)
#define DATAFORMAT_MASK_RAWIMAGE         (1L << XA_DATAFORMAT_RAWIMAGE)
#define DATAFORMAT_MASK_ALL              0xFL

extern SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
        DataLocatorFormat *myDataSourceLocator, SLuint32 allowedDataLocatorMask,
        SLuint32 allowedDataFormatMask);
extern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
        DataLocatorFormat *myDataSinkLocator, SLuint32 allowedDataLocatorMask,
        SLuint32 allowedDataFormatMask);
Glenn Kasten's avatar
Glenn Kasten committed
93 94 95
extern SLresult checkSourceSinkVsInterfacesCompatibility(
        const DataLocatorFormat *pSrcDataLocatorFormat,
        const DataLocatorFormat *pSinkDataLocatorFormat,
96
        const ClassTable *clazz, unsigned requiredMask);
97
extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
98 99 100 101 102 103 104 105 106 107 108 109


/* For stream information storage */
typedef struct {
    XAuint32 domain;
    union {
        XAMediaContainerInformation containerInfo;
        XAVideoStreamInformation videoInfo;
        XAAudioStreamInformation audioInfo;
        XAImageStreamInformation imageInfo;
        XATimedTextStreamInformation textInfo;
        XAMIDIStreamInformation midiInfo;
110
        XAVendorStreamInformation vendorInfo;
111 112
    };
} StreamInfo;
113 114 115

// FIXME a terrible hack until OpenMAX AL spec is updated
#define XA_DOMAINTYPE_CONTAINER 0