/* * Copyright 2016, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MEDIA_CODEC_BUFFER_H_ #define MEDIA_CODEC_BUFFER_H_ #include #include #include namespace android { struct ABuffer; struct AMessage; class MediaBufferBase; /** * Buffers used by MediaCodec. */ class MediaCodecBuffer : public RefBase { public: MediaCodecBuffer(const sp &format, const sp &buffer); /** * MediaCodec will release all references to the buffer when it's done using * it, so the destructor should return the buffer to the owner, such as OMX * components, buffer allocators, surfaces, etc. */ virtual ~MediaCodecBuffer() = default; // ABuffer-like interface uint8_t *base(); uint8_t *data(); size_t capacity() const; size_t size() const; size_t offset() const; // Default implementation calls ABuffer::setRange() and returns OK. virtual status_t setRange(size_t offset, size_t size); // TODO: Specify each field for meta/format. sp meta(); sp format(); void setFormat(const sp &format); private: MediaCodecBuffer() = delete; const sp mMeta; sp mFormat; const sp mBuffer; }; } // namespace android #endif // MEDIA_CODEC_BUFFER_H_