1 /*
2 * Copyright 2016, 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 //#define LOG_NDEBUG 0
18 #define LOG_TAG "MediaCodecBuffer"
19 #include <utils/Log.h>
20
21 #include <media/MediaCodecBuffer.h>
22 #include <media/stagefright/foundation/ABuffer.h>
23 #include <media/stagefright/foundation/AMessage.h>
24
25 namespace android {
26
MediaCodecBuffer(const sp<AMessage> & format,const sp<ABuffer> & buffer)27 MediaCodecBuffer::MediaCodecBuffer(const sp<AMessage> &format, const sp<ABuffer> &buffer)
28 : mMeta(new AMessage),
29 mFormat(format),
30 mBuffer(buffer) {
31 }
32
33 // ABuffer-like interface
base()34 uint8_t *MediaCodecBuffer::base() {
35 return mBuffer->base();
36 }
37
data()38 uint8_t *MediaCodecBuffer::data() {
39 return mBuffer->data();
40 }
41
capacity() const42 size_t MediaCodecBuffer::capacity() const {
43 return mBuffer->capacity();
44 }
45
size() const46 size_t MediaCodecBuffer::size() const {
47 return mBuffer->size();
48 }
49
offset() const50 size_t MediaCodecBuffer::offset() const {
51 return mBuffer->offset();
52 }
53
setRange(size_t offset,size_t size)54 status_t MediaCodecBuffer::setRange(size_t offset, size_t size) {
55 mBuffer->setRange(offset, size);
56 return OK;
57 }
58
meta()59 sp<AMessage> MediaCodecBuffer::meta() {
60 return mMeta;
61 }
62
format()63 sp<AMessage> MediaCodecBuffer::format() {
64 return mFormat;
65 }
66
setFormat(const sp<AMessage> & format)67 void MediaCodecBuffer::setFormat(const sp<AMessage> &format) {
68 mMeta->clear();
69 mFormat = format;
70 }
71
72 } // namespace android
73