• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
21 #include <media/stagefright/MediaBuffer.h>
22 #include <utils/Errors.h>
23 #include <utils/threads.h>
24 
25 namespace android {
26 
27 class MediaBuffer;
28 class MetaData;
29 
30 class MediaBufferGroup : public MediaBufferObserver {
31 public:
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 
41 protected:
42     virtual void signalBufferReturned(MediaBuffer *buffer);
43 
44 private:
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_
59