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// -*- c++ -*-
19
20#include "access_unit.h"
21#include "access_unit_impl.h"
22#include "oscl_mem.h"
23
24OSCL_EXPORT_REF
25AccessUnit::AccessUnit(AUImplAllocator* in_alloc, void * hint, const int num_reserved_frags)
26{
27    alloc = in_alloc;
28    impl_hint = hint;
29    if (!hint)
30    {
31        if (!(hint = OSCL_MALLOC(sizeof(AccessUnitImplementation))))
32        {
33            rep = NULL;
34            return;
35        }
36    }
37    rep = in_alloc->allocate(hint, num_reserved_frags);
38}
39
40OSCL_EXPORT_REF AccessUnit::~AccessUnit()
41{
42    alloc->deallocate(rep);
43    if (!impl_hint && rep)
44    {
45        OSCL_FREE(rep);
46    }
47}
48
49OSCL_EXPORT_REF
50BufferFragment * AccessUnit::GetCodecInfo() const
51{
52    return rep->GetCodecInfo();
53};
54
55OSCL_EXPORT_REF
56MediaStatusClass::status_t AccessUnit::AddAUFrag(const BufferFragment& frag, BufferState* buffer_state,
57        int32 location_offset)
58{
59    return rep->AddAUFrag(frag, buffer_state, location_offset);
60}
61
62MediaStatusClass::status_t AccessUnit::AddLocalAUFrag(BufferFragment& fragment,
63        int32 location_offset)
64{
65    return rep->AddLocalAUFrag(fragment, location_offset);
66}
67
68OSCL_EXPORT_REF
69MediaStatusClass::status_t AccessUnit::AddCodecInfo(BufferFragment& fragment)
70{
71    return rep->AddCodecInfo(fragment);
72}
73
74OSCL_EXPORT_REF
75MediaStatusClass::status_t AccessUnit::AddCodecInfo(void *ptr, int len)
76{
77    return rep->AddCodecInfo(ptr, len);
78}
79
80MediaStatusClass::status_t AccessUnit::GetLocalFragment(BufferFragment& fragment)
81{
82    return rep->GetLocalFragment(fragment);
83}
84
85
86uint32 AccessUnit::GetAvailableBufferSize() const
87{
88    return rep->GetAvailableBufferSize();
89}
90
91uint32 AccessUnit::GetLocalBufsize() const
92{
93    return rep->GetLocalBufsize();
94}
95
96OSCL_EXPORT_REF void AccessUnit::Clear()
97{
98    rep->Clear();
99}
100
101OSCL_EXPORT_REF MediaTimestamp AccessUnit::GetTimestamp() const
102{
103    return rep->GetTimestamp();
104}
105
106OSCL_EXPORT_REF void AccessUnit::SetTimestamp(const MediaTimestamp& media_timestamp)
107{
108    rep->SetTimestamp(media_timestamp);
109}
110
111const BufferFragment* AccessUnit::GetMediaFragments() const
112{
113    return rep->GetMediaFragments();
114}
115
116OSCL_EXPORT_REF
117int32 AccessUnit::GetNumFrags() const
118{
119    return rep->GetNumMediaFrags();
120}
121int32 AccessUnit::GetMaxFrags() const
122{
123    return rep->GetMaxMediaFrags();
124}
125
126OSCL_EXPORT_REF uint32 AccessUnit::GetLength() const
127{
128    return rep->GetMediaLength();
129}
130
131OSCL_EXPORT_REF
132BufferState * AccessUnit::GetBufferState(const uint32 idx)const
133{
134    return rep->GetBufferState(idx);
135}
136
137void AccessUnit::AppendNext(AccessUnit *next_ptr)
138{
139    rep->AppendNext(next_ptr);
140}
141OSCL_EXPORT_REF
142void AccessUnit::GetMediaFragment(uint32 index, BufferFragment& frag, BufferState*& buffer_state) const
143{
144    rep->GetMediaFragment(index, frag, buffer_state);
145}
146
147
148OSCL_EXPORT_REF
149bool AccessUnit::IsLocalData(const OsclMemoryFragment& frag) const
150{
151    return rep->IsLocalData(frag);
152}
153
154OSCL_EXPORT_REF
155AccessUnit* AccessUnit::GetNext() const
156{
157    return rep->GetNext();
158}
159
160OSCL_EXPORT_REF
161bool AccessUnit::seek(int & idx, int & offset, uint8 * & ptr, bool & boundaryReached,
162                      const int delta_in_bytes) const
163{
164    return rep->seek(idx, offset, ptr, boundaryReached, delta_in_bytes);
165}
166
167OSCL_EXPORT_REF
168bool AccessUnit::match_bit_pattern_no_state(const int idx, const int offset, const uint8 * pattern,
169        const uint8 pattern_size_in_bits) const
170{
171    return rep->match_bit_pattern_no_state(idx, offset, pattern, pattern_size_in_bits);
172}
173
174OSCL_EXPORT_REF
175int32 AccessUnit::match_bit_pattern_with_state(const int32 idx, const int32 offset, const uint8 * pattern,
176        const uint8 pattern_size_in_bits, const int32 state) const
177{
178    return rep->match_bit_pattern_with_state(idx, offset, pattern, pattern_size_in_bits, state);
179}
180/*
181int32 AccessUnit::GetNumMediaFrags() const {
182  return rep->GetNumMediaFrags();
183}
184*/
185OSCL_EXPORT_REF
186BufferFragment * AccessUnit::GetMediaFragment(const uint32 idx) const
187{
188    return rep->GetMediaFragment(idx);
189}
190
191
192/*
193void AccessUnit::reset() {
194  return rep->reset();
195}
196*/
197