Android 13 - Media框架(21)- ACodec(三)
这一节我们将继续来学习 ACodec 的剩余部分。
enum {
kFlagIsSecure = 1,
kFlagPushBlankBuffersToNativeWindowOnShutdown = 2,
kFlagIsGrallocUsageProtected = 4,
kFlagPreregisterMetadataBuffers = 8,
};
enum {
kVideoGrallocUsage = (GRALLOC_USAGE_HW_TEXTURE
| GRALLOC_USAGE_HW_COMPOSER
| GRALLOC_USAGE_EXTERNAL_DISP)
| static_cast<uint64_t>(BufferUsage::VIDEO_DECODER),
};
struct BufferInfo {
enum Status {
OWNED_BY_US,
OWNED_BY_COMPONENT,
OWNED_BY_UPSTREAM,
OWNED_BY_DOWNSTREAM,
OWNED_BY_NATIVE_WINDOW,
UNRECOGNIZED, // not a tracked buffer
};
static inline Status getSafeStatus(BufferInfo *info) {
return info == NULL ? UNRECOGNIZED : info->mStatus;
}
IOMX::buffer_id mBufferID;
Status mStatus;
unsigned mDequeuedAt;
sp<MediaCodecBuffer> mData; // the client's buffer; if not using data conversion, this is
// the codec buffer; otherwise, it is allocated separately
sp<RefBase> mMemRef; // and a reference to the IMemory, so it does not go away
sp<MediaCodecBuffer> mCodecData; // the codec's buffer
sp<RefBase> mCodecRef; // and a reference to the IMemory
sp<GraphicBuffer> mGraphicBuffer;
bool mNewGraphicBuffer;
int mFenceFd;
FrameRenderTracker::Info *mRenderInfo;
// The following field and 4 methods are used for debugging only
bool mIsReadFence;
// Store |fenceFd| and set read/write flag. Log error, if there is already a fence stored.
void setReadFence(int fenceFd, const char *dbg);
void setWriteFence(int fenceFd, const char *dbg);
// Log error, if the current fence is not a read/write fence.
void checkReadFence(const char *dbg);
void checkWriteFence(const char *dbg);
};