• 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 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
19 #define PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
20 
21 #ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
22 #include "pvmf_media_data_impl.h"
23 #endif
24 
25 #ifndef OSCL_SHARED_PTR_H_INCLUDED
26 #include "oscl_shared_ptr.h"
27 #endif
28 
29 #ifndef OSCL_MEM_H_INCLUDED
30 #include "oscl_mem.h"
31 #endif
32 /**
33  * The PVMFSimpleMediaBuffer class is a basic MediaDataImpl
34  * implementation that allows for a single buffer memory
35  * fragment.  The buffer itself can be allocated from the
36  * general memory pool or any method since the contructor
37  * accepts a ptr to the data and the corresponding refcnt object
38  * to handle freeing the memory.
39  */
40 
41 class PVMFSimpleMediaBuffer : public PVMFMediaDataImpl
42 {
43 
44     public:
45         OSCL_IMPORT_REF virtual uint32 getMarkerInfo();
46         OSCL_IMPORT_REF virtual bool isRandomAccessPoint();
47         OSCL_IMPORT_REF virtual uint32 getErrorsFlag();
48         OSCL_IMPORT_REF virtual uint32 getNumFragments();
49         OSCL_IMPORT_REF virtual bool getMediaFragment(uint32 index, OsclRefCounterMemFrag& memfrag);
50         OSCL_IMPORT_REF virtual bool getMediaFragmentSize(uint32 index, uint32& size);
51         OSCL_IMPORT_REF virtual uint32 getFilledSize();
52         OSCL_IMPORT_REF virtual uint32 getCapacity();
53 
54         OSCL_IMPORT_REF virtual void setCapacity(uint32 aCapacity);
55         OSCL_IMPORT_REF virtual bool setMediaFragFilledLen(uint32 index, uint32 len);
56         OSCL_IMPORT_REF virtual bool setMarkerInfo(uint32 marker);
57         OSCL_IMPORT_REF virtual bool setRandomAccessPoint(bool flag);
58         OSCL_IMPORT_REF virtual bool setErrorsFlag(uint32 flag);
59         OSCL_IMPORT_REF virtual bool appendMediaFragment(OsclRefCounterMemFrag& memfrag);
60         OSCL_IMPORT_REF virtual bool clearMediaFragments();
61 
62         /* NOTE!!:  The constructor assumes the refcnt has already been incremented
63          * to reflect this class holding a reference to the buffer. Increment it
64          * externally if you aren't simply passing ownership of a reference
65          */
66         OSCL_IMPORT_REF PVMFSimpleMediaBuffer(void *ptr,
67                                               uint32 capacity,
68                                               OsclRefCounter *my_refcnt);
69 
70         OSCL_IMPORT_REF virtual ~PVMFSimpleMediaBuffer();
71 
72     private:
73         uint32 marker_info;
74         bool random_access_point;
75         uint32 errors_flag;
76         OsclMemoryFragment buffer;
77         uint32 capacity;
78         OsclRefCounter* refcnt;
79 
80 };
81 
82 
83 /**
84  * The PVMFSimpleMediaBufferCombinedAlloc allocator class
85  * takes care of allocating the refcounter, PVMFSimpleMediaBuffer container,
86  * and the actual buffer space in a single block of memory.
87  */
88 
89 class PVMFSimpleMediaBufferCombinedAlloc : public HeapBase
90 {
91 
92     public:
PVMFSimpleMediaBufferCombinedAlloc(Oscl_DefAlloc * opt_gen_alloc)93         PVMFSimpleMediaBufferCombinedAlloc(Oscl_DefAlloc* opt_gen_alloc):
94                 gen_alloc(opt_gen_alloc)
95         {
96             if (opt_gen_alloc == NULL)
97             {
98                 OSCL_ASSERT(false);
99             }
100         };
101         OSCL_IMPORT_REF OsclSharedPtr<PVMFMediaDataImpl> allocate(uint32 requested_buffer_capacity = 0);
102 
103     private:
104         Oscl_DefAlloc* gen_alloc;
105 
106 };
107 
108 
109 #endif
110 
111