blob: 04882926bc2bde769bc780c5b2d2006f05f7db3f [file] [log] [blame]
Andreas Hubere46b7be2009-07-14 16:56:47 -07001/*
2 * Copyright (C) 2009 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 MEDIA_BUFFER_GROUP_H_
18
19#define MEDIA_BUFFER_GROUP_H_
20
Andreas Huber09daada2009-08-18 11:27:32 -070021#include <media/stagefright/MediaBuffer.h>
Andreas Hubere46b7be2009-07-14 16:56:47 -070022#include <utils/Errors.h>
23#include <utils/threads.h>
24
25namespace android {
26
27class MediaBuffer;
28class MetaData;
29
30class MediaBufferGroup : public MediaBufferObserver {
31public:
32 MediaBufferGroup();
33 ~MediaBufferGroup();
34
35 void add_buffer(MediaBuffer *buffer);
36
37 // Blocks until a buffer is available and returns it to the caller,
38 // the returned buffer will have a reference count of 1.
39 status_t acquire_buffer(MediaBuffer **buffer);
40
41protected:
42 virtual void signalBufferReturned(MediaBuffer *buffer);
43
44private:
45 friend class MediaBuffer;
46
47 Mutex mLock;
48 Condition mCondition;
49
50 MediaBuffer *mFirstBuffer, *mLastBuffer;
51
52 MediaBufferGroup(const MediaBufferGroup &);
53 MediaBufferGroup &operator=(const MediaBufferGroup &);
54};
55
56} // namespace android
57
58#endif // MEDIA_BUFFER_GROUP_H_