Line data Source code
1 : /*
2 : * Copyright (C) 2010 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 A_BUFFER_H_
18 :
19 : #define A_BUFFER_H_
20 :
21 : #include <sys/types.h>
22 : #include <stdint.h>
23 :
24 : #include <media/stagefright/foundation/ABase.h>
25 : #include <utils/RefBase.h>
26 :
27 : namespace stagefright {
28 :
29 : struct AMessage;
30 :
31 : struct ABuffer : public RefBase {
32 : ABuffer(size_t capacity);
33 : ABuffer(void *data, size_t capacity);
34 :
35 : void setFarewellMessage(const sp<AMessage> msg);
36 :
37 : uint8_t *base() { return (uint8_t *)mData; }
38 0 : uint8_t *data() { return (uint8_t *)mData + mRangeOffset; }
39 : size_t capacity() const { return mCapacity; }
40 0 : size_t size() const { return mRangeLength; }
41 : size_t offset() const { return mRangeOffset; }
42 :
43 : void setRange(size_t offset, size_t size);
44 :
45 : void setInt32Data(int32_t data) { mInt32Data = data; }
46 : int32_t int32Data() const { return mInt32Data; }
47 :
48 : sp<AMessage> meta();
49 :
50 : protected:
51 : virtual ~ABuffer();
52 :
53 : private:
54 : sp<AMessage> mFarewell;
55 : sp<AMessage> mMeta;
56 :
57 : void *mData;
58 : size_t mCapacity;
59 : size_t mRangeOffset;
60 : size_t mRangeLength;
61 :
62 : int32_t mInt32Data;
63 :
64 : bool mOwnsData;
65 :
66 : DISALLOW_EVIL_CONSTRUCTORS(ABuffer);
67 : };
68 :
69 : } // namespace stagefright
70 :
71 : #endif // A_BUFFER_H_
|