• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /*********************************************************************************/
19 /*     -------------------------------------------------------------------       */
20 /*                     MPEG-4 Util: MediaBufferManager Class                     */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This MediaBufferManager Class is responsible for maintaining list of used
25     and free MediaBuffers.  This is promarily used by the Mpeg4File class when
26     it is retrieving media data from disk.  It needs buffers to store data and
27     to pass to the consumers of the media data - namesly PVServer and PVPlayer.
28 */
29 
30 
31 #ifndef MEDIABUFFERMANAGER_H_INCLUDED
32 #define MEDIABUFFERMANAGER_H_INCLUDED
33 
34 #ifndef OSCL_BASE_H_INCLUDED
35 #include "oscl_base.h"
36 #endif
37 
38 #ifndef OSCL_FILE_IO_H_INCLUDED
39 #include "oscl_file_io.h"
40 #endif
41 
42 #ifndef MEDIABUFFER_H_INCLUDED
43 #include "mediabuffer.h"
44 #endif
45 
46 #ifndef IMEDIABUFFER_H_INCLUDED
47 #include "imediabuffer.h"
48 #endif
49 
50 #ifndef OSCL_VECTOR_H_INCLUDED
51 #include "oscl_vector.h"
52 #endif
53 
54 #ifndef OSCL_MEM_H_INCLUDED
55 #include "oscl_mem.h"
56 #endif
57 
58 
59 class MediaBuffer; // Forward declaration for circular includes
60 
61 class MediaBufferManager
62 {
63 
64     public:
65         MediaBufferManager(int32 bufSize = 32728, uint32 numBufs = 1); // Constructor
66         // Create 'numBufs' initial buffers each of size 'bufSize'
67 
68         virtual ~MediaBufferManager();
69 
70         void freeBuf(MediaBuffer *buf); // Called by buffer when it is freed
71         MediaBuffer *getBuf();
72 
73 
74     private:
75         MediaBuffer *newBuf(); // By default create a 32KB buffer
76 
77         Oscl_Vector<MediaBuffer*, OsclMemAllocator> *_pfreeBufVec;
78         Oscl_Vector<MediaBuffer*, OsclMemAllocator> *_pusedBufVec;
79 
80         int32 _bufferSize; // Size of buffers (in bytes)
81 };
82 
83 #endif // MEDIABUFFERMANAGER_H_INCLUDED
84 
85 
86