BufferQueueSource.h revision bb832e853d4afb11b0a3287b2eb0cad87696d631
1/*
2 * Copyright (C) 2011 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 BUFFERQUEUE_SOURCE_H_
18#define BUFFERQUEUE_SOURCE_H_
19
20#include <stdio.h>
21
22#include <media/stagefright/DataSource.h>
23#include <media/stagefright/MediaErrors.h>
24#include <utils/threads.h>
25#include <drm/DrmManagerClient.h>
26#include "include/AacAdtsExtractor.h"
27
28// number of SLuint32 fields to store a buffer event message in an item, by mapping each
29//   to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
30#define NB_BUFFEREVENT_ITEM_FIELDS 3
31
32namespace android {
33
34// a Stagefright DataSource that pulls data from an AndroidBufferQueue
35
36class BufferQueueSource : public DataSource {
37public:
38
39    // store an item structure to indicate a processed buffer
40    static const SLuint32 kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS];
41
42    BufferQueueSource(const void* user, void *context,  const void *caller);
43
44    virtual status_t initCheck() const;
45
46    virtual ssize_t readAt(off64_t offset, void *data, size_t size);
47
48    virtual status_t getSize(off64_t *size);
49
50    virtual ~BufferQueueSource();
51
52private:
53    // the Android Buffer Queue from which data is consumed
54    IAndroidBufferQueue* mAndroidBufferQueueSource;
55
56    // a monotonically increasing offset used to translate an offset from the beginning
57    // of the stream, to an offset in each buffer from the buffer queue source
58    off64_t mStreamToBqOffset;
59
60    BufferQueueSource(const BufferQueueSource &);
61    BufferQueueSource &operator=(const BufferQueueSource &);
62};
63
64}  // namespace android
65
66#endif  // BUFFERQUEUE_SOURCE_H_
67
68