huangcm
2025-02-28 c32b2f9505927d6bf06b1d06d5ddd3cd1d245faf
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * 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.
 */
 
#ifndef WILHELM_SRC_DATA_H
#define WILHELM_SRC_DATA_H
 
/* 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;
    XADataLocator_NativeDisplay mNativeDisplay;
#ifdef ANDROID
    SLDataLocator_AndroidFD mFD;
    SLDataLocator_AndroidBufferQueue mABQ;
#endif
} DataLocator;
 
typedef union {
    SLuint32 mFormatType;
    SLDataFormat_PCM mPCM;
    SLAndroidDataFormat_PCM_EX mPCMEx;
    SLDataFormat_MIME mMIME;
    XADataFormat_RawImage mRawImage;
} DataFormat;
 
typedef struct {
    union {
        SLDataSource mSource;
        SLDataSink mSink;
        struct {
            DataLocator *pLocator;
            DataFormat *pFormat;
        } mNeutral;
    } u;
    DataLocator mLocator;
    DataFormat mFormat;
} DataLocatorFormat;
 
#define SL_DATALOCATOR_NULL 0   // application specified a NULL value for pLocator
                                // (not a valid value for mLocatorType)
#define XA_DATALOCATOR_NULL SL_DATALOCATOR_NULL
#define SL_DATAFORMAT_NULL 0    // application specified a NULL value for pFormat
                                // (not a valid value for mLocatorType)
#define XA_DATAFORMAT_NULL SL_DATAFORMAT_NULL
 
// 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_PCM_EX           (1L << SL_ANDROID_DATAFORMAT_PCM_EX)
#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);
extern SLresult checkSourceSinkVsInterfacesCompatibility(
        const DataLocatorFormat *pSrcDataLocatorFormat,
        const DataLocatorFormat *pSinkDataLocatorFormat,
        const ClassTable *clazz, unsigned requiredMask);
extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
 
 
/* For stream information storage */
typedef struct {
    XAuint32 domain;
    union {
        XAMediaContainerInformation containerInfo;
        XAVideoStreamInformation videoInfo;
        XAAudioStreamInformation audioInfo;
        XAImageStreamInformation imageInfo;
        XATimedTextStreamInformation textInfo;
        XAMIDIStreamInformation midiInfo;
        XAVendorStreamInformation vendorInfo;
    };
} StreamInfo;
 
// FIXME a terrible hack until OpenMAX AL spec is updated
#define XA_DOMAINTYPE_CONTAINER 0
 
#endif // WILHELM_SRC_DATA_H