1cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten/*
2cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * Copyright (C) 2010 The Android Open Source Project
3cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten *
4cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * Licensed under the Apache License, Version 2.0 (the "License");
5cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * you may not use this file except in compliance with the License.
6cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * You may obtain a copy of the License at
7cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten *
8cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten *      http://www.apache.org/licenses/LICENSE-2.0
9cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten *
10cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * Unless required by applicable law or agreed to in writing, software
11cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * distributed under the License is distributed on an "AS IS" BASIS,
12cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * See the License for the specific language governing permissions and
14cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten * limitations under the License.
15cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten */
16cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten
174e8fe8a60c3aa8085918f15f281e0979682aefdcPaul McLean#ifndef WILHELM_SRC_DATA_H
184e8fe8a60c3aa8085918f15f281e0979682aefdcPaul McLean#define WILHELM_SRC_DATA_H
194e8fe8a60c3aa8085918f15f281e0979682aefdcPaul McLean
20cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten/* Our own merged version of SLDataSource and SLDataSink */
21cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten
22cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kastentypedef union {
23cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLuint32 mLocatorType;
24cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_Address mAddress;
25cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_BufferQueue mBufferQueue;
26cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_IODevice mIODevice;
27cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_MIDIBufferQueue mMIDIBufferQueue;
28cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_OutputMix mOutputMix;
29cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_URI mURI;
308b8875067dd02b79361abb00c5d65b02a8ae72b0Glenn Kasten    XADataLocator_NativeDisplay mNativeDisplay;
31cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten#ifdef ANDROID
32cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataLocator_AndroidFD mFD;
33d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi    SLDataLocator_AndroidBufferQueue mABQ;
34cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten#endif
35cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten} DataLocator;
36cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten
37cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kastentypedef union {
38cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLuint32 mFormatType;
39cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataFormat_PCM mPCM;
40e57c13397185f9ad0f162855e9a8ebeb0c94bfc4Andy Hung    SLAndroidDataFormat_PCM_EX mPCMEx;
41cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    SLDataFormat_MIME mMIME;
428b8875067dd02b79361abb00c5d65b02a8ae72b0Glenn Kasten    XADataFormat_RawImage mRawImage;
43cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten} DataFormat;
44cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten
45cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kastentypedef struct {
46cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    union {
47cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten        SLDataSource mSource;
48cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten        SLDataSink mSink;
49cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten        struct {
50cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten            DataLocator *pLocator;
51cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten            DataFormat *pFormat;
52cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten        } mNeutral;
53cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    } u;
54cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    DataLocator mLocator;
55cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten    DataFormat mFormat;
56cafa51fdd8b3f29ebaa0682070100825a9cce2a8Glenn Kasten} DataLocatorFormat;
5794a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten
58a361b51914aeb5f8f65c7ecad719d1e01f90913bGlenn Kasten#define SL_DATALOCATOR_NULL 0   // application specified a NULL value for pLocator
59a361b51914aeb5f8f65c7ecad719d1e01f90913bGlenn Kasten                                // (not a valid value for mLocatorType)
60d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi#define XA_DATALOCATOR_NULL SL_DATALOCATOR_NULL
61a361b51914aeb5f8f65c7ecad719d1e01f90913bGlenn Kasten#define SL_DATAFORMAT_NULL 0    // application specified a NULL value for pFormat
62a361b51914aeb5f8f65c7ecad719d1e01f90913bGlenn Kasten                                // (not a valid value for mLocatorType)
63d158d31a6bbb06426b71c3d097b7768bc3fb79a3Jean-Michel Trivi#define XA_DATAFORMAT_NULL SL_DATAFORMAT_NULL
6494a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten
6594a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten// bit masks used to configure the allowed data locators for a given data source or data sink
6694a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_NONE            0L
6794a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_NULL            (1L << SL_DATALOCATOR_NULL)
6894a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_URI             (1L << SL_DATALOCATOR_URI)
6994a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_ADDRESS         (1L << SL_DATALOCATOR_ADDRESS)
7094a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_IODEVICE        (1L << SL_DATALOCATOR_IODEVICE)
7194a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_OUTPUTMIX       (1L << SL_DATALOCATOR_OUTPUTMIX)
7294a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_NATIVEDISPLAY   (1L << XA_DATALOCATOR_NATIVEDISPLAY)
7394a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_BUFFERQUEUE     (1L << SL_DATALOCATOR_BUFFERQUEUE)
7494a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_MIDIBUFFERQUEUE (1L << SL_DATALOCATOR_MIDIBUFFERQUEUE)
7594a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_ANDROIDFD                \
7694a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten                 (0x100L << (SL_DATALOCATOR_ANDROIDFD - SL_DATALOCATOR_ANDROIDFD))
7794a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE \
7894a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten                 (0x100L << (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
7994a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_ANDROIDBUFFERQUEUE       \
8094a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten                 (0x100L << (SL_DATALOCATOR_ANDROIDBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
8194a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATALOCATOR_MASK_ALL             0x7FFL
8294a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten
8394a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten// bit masks used to configure the allowed data formats for a given data source or data sink
8494a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_NONE             0L
8594a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_NULL             (1L << SL_DATAFORMAT_NULL)
8694a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_MIME             (1L << SL_DATAFORMAT_MIME)
8794a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_PCM              (1L << SL_DATAFORMAT_PCM)
88e57c13397185f9ad0f162855e9a8ebeb0c94bfc4Andy Hung#define DATAFORMAT_MASK_PCM_EX           (1L << SL_ANDROID_DATAFORMAT_PCM_EX)
8994a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_RAWIMAGE         (1L << XA_DATAFORMAT_RAWIMAGE)
9094a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten#define DATAFORMAT_MASK_ALL              0xFL
9194a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten
9294a37e8117fb72790882dfb815f99e2365754c74Glenn Kastenextern SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
9394a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten        DataLocatorFormat *myDataSourceLocator, SLuint32 allowedDataLocatorMask,
9494a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten        SLuint32 allowedDataFormatMask);
9594a37e8117fb72790882dfb815f99e2365754c74Glenn Kastenextern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
9694a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten        DataLocatorFormat *myDataSinkLocator, SLuint32 allowedDataLocatorMask,
9794a37e8117fb72790882dfb815f99e2365754c74Glenn Kasten        SLuint32 allowedDataFormatMask);
987965455f86c21d6e1f788b284f5fc829e82ff2b5Glenn Kastenextern SLresult checkSourceSinkVsInterfacesCompatibility(
997965455f86c21d6e1f788b284f5fc829e82ff2b5Glenn Kasten        const DataLocatorFormat *pSrcDataLocatorFormat,
1007965455f86c21d6e1f788b284f5fc829e82ff2b5Glenn Kasten        const DataLocatorFormat *pSinkDataLocatorFormat,
10105c7b2d09d54b9260ff7f3f5e491f38d0097c406Glenn Kasten        const ClassTable *clazz, unsigned requiredMask);
10294a37e8117fb72790882dfb815f99e2365754c74Glenn Kastenextern void freeDataLocatorFormat(DataLocatorFormat *dlf);
103321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi
104321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi
105321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi/* For stream information storage */
106321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivitypedef struct {
107321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi    XAuint32 domain;
108321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi    union {
109321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XAMediaContainerInformation containerInfo;
110321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XAVideoStreamInformation videoInfo;
111321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XAAudioStreamInformation audioInfo;
112321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XAImageStreamInformation imageInfo;
113321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XATimedTextStreamInformation textInfo;
114321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi        XAMIDIStreamInformation midiInfo;
11537dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi        XAVendorStreamInformation vendorInfo;
116321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi    };
117321f2cffd7dd560bf2e5c898be6953e19bed8496Jean-Michel Trivi} StreamInfo;
11837dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi
11937dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi// FIXME a terrible hack until OpenMAX AL spec is updated
12037dc2fccf3f122b79ebd554de209d0a3c94ae161Jean-Michel Trivi#define XA_DOMAINTYPE_CONTAINER 0
1214e8fe8a60c3aa8085918f15f281e0979682aefdcPaul McLean
1224e8fe8a60c3aa8085918f15f281e0979682aefdcPaul McLean#endif // WILHELM_SRC_DATA_H