CodecBase.h revision a63141af8f036bda0b8f7800107ca8a0e0623135
1/* 2 * Copyright (C) 2014 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 CODEC_BASE_H_ 18 19#define CODEC_BASE_H_ 20 21#include <stdint.h> 22#include <media/IOMX.h> 23 24#include <media/MediaCodecInfo.h> 25#include <media/stagefright/foundation/AHandler.h> 26#include <utils/NativeHandle.h> 27 28namespace android { 29 30struct ABuffer; 31struct PersistentSurface; 32 33struct CodecBase : public AHandler { 34 enum { 35 kWhatFillThisBuffer = 'fill', 36 kWhatDrainThisBuffer = 'drai', 37 kWhatEOS = 'eos ', 38 kWhatShutdownCompleted = 'scom', 39 kWhatFlushCompleted = 'fcom', 40 kWhatOutputFormatChanged = 'outC', 41 kWhatError = 'erro', 42 kWhatComponentAllocated = 'cAll', 43 kWhatComponentConfigured = 'cCon', 44 kWhatInputSurfaceCreated = 'isfc', 45 kWhatInputSurfaceAccepted = 'isfa', 46 kWhatSignaledInputEOS = 'seos', 47 kWhatBuffersAllocated = 'allc', 48 kWhatOutputFramesRendered = 'outR', 49 }; 50 51 virtual void setNotificationMessage(const sp<AMessage> &msg) = 0; 52 53 virtual void initiateAllocateComponent(const sp<AMessage> &msg) = 0; 54 virtual void initiateConfigureComponent(const sp<AMessage> &msg) = 0; 55 virtual void initiateCreateInputSurface() = 0; 56 virtual void initiateSetInputSurface( 57 const sp<PersistentSurface> &surface) = 0; 58 virtual void initiateStart() = 0; 59 virtual void initiateShutdown(bool keepComponentAllocated = false) = 0; 60 61 // require an explicit message handler 62 virtual void onMessageReceived(const sp<AMessage> &msg) = 0; 63 64 virtual status_t queryCapabilities( 65 const AString &name, const AString &mime, bool isEncoder, 66 sp<MediaCodecInfo::Capabilities> *caps /* nonnull */) { return INVALID_OPERATION; } 67 68 virtual status_t setSurface(const sp<Surface> &surface) { return INVALID_OPERATION; } 69 70 virtual void signalFlush() = 0; 71 virtual void signalResume() = 0; 72 73 virtual void signalRequestIDRFrame() = 0; 74 virtual void signalSetParameters(const sp<AMessage> &msg) = 0; 75 virtual void signalEndOfInputStream() = 0; 76 77 struct PortDescription : public RefBase { 78 virtual size_t countBuffers() = 0; 79 virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0; 80 virtual sp<ABuffer> bufferAt(size_t index) const = 0; 81 virtual sp<NativeHandle> handleAt(size_t index) { return NULL; }; 82 virtual sp<RefBase> memRefAt(size_t index) const { return NULL; } 83 84 protected: 85 PortDescription(); 86 virtual ~PortDescription(); 87 88 private: 89 DISALLOW_EVIL_CONSTRUCTORS(PortDescription); 90 }; 91 92protected: 93 CodecBase(); 94 virtual ~CodecBase(); 95 96private: 97 DISALLOW_EVIL_CONSTRUCTORS(CodecBase); 98}; 99 100} // namespace android 101 102#endif // CODEC_BASE_H_ 103 104