Loading include/media/stagefright/ACodec.h +1 −7 Original line number Diff line number Diff line Loading @@ -76,21 +76,15 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { size_t countBuffers(); IOMX::buffer_id bufferIDAt(size_t index) const; sp<MediaCodecBuffer> bufferAt(size_t index) const; sp<NativeHandle> handleAt(size_t index) const; sp<RefBase> memRefAt(size_t index) const; private: friend struct ACodec; Vector<IOMX::buffer_id> mBufferIDs; Vector<sp<MediaCodecBuffer>> mBuffers; Vector<sp<NativeHandle> > mHandles; Vector<sp<RefBase> > mMemRefs; PortDescription(); void addBuffer( IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer, const sp<NativeHandle> &handle, const sp<RefBase> &memRef); void addBuffer(IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer); DISALLOW_EVIL_CONSTRUCTORS(PortDescription); }; Loading include/media/stagefright/CodecBase.h +0 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,6 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { virtual size_t countBuffers() = 0; virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0; virtual sp<MediaCodecBuffer> bufferAt(size_t index) const = 0; virtual sp<NativeHandle> handleAt(size_t index) const { return NULL; }; virtual sp<RefBase> memRefAt(size_t index) const { return NULL; } protected: PortDescription(); Loading include/media/stagefright/MediaCodec.h +1 −3 Original line number Diff line number Diff line Loading @@ -255,9 +255,7 @@ private: struct BufferInfo { uint32_t mBufferID; sp<MediaCodecBuffer> mData; sp<NativeHandle> mNativeHandle; sp<RefBase> mMemRef; sp<MediaCodecBuffer> mEncryptedData; sp<MediaCodecBuffer> mSecureData; sp<IMemory> mSharedEncryptedBuffer; sp<AMessage> mNotify; sp<AMessage> mFormat; Loading media/libstagefright/ACodec.cpp +6 −27 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ #include "include/avc_utils.h" #include "include/DataConverter.h" #include "include/SecureBuffer.h" #include "include/SharedMemoryBuffer.h" #include "omx/OMXUtils.h" Loading Loading @@ -876,7 +877,6 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { info.mStatus = BufferInfo::OWNED_BY_US; info.mFenceFd = -1; info.mRenderInfo = NULL; info.mNativeHandle = NULL; if (portIndex == kPortIndexInput && (mFlags & kFlagIsSecure)) { mem.clear(); Loading @@ -887,19 +887,9 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { portIndex, bufSize, &info.mBufferID, &ptr, &native_handle); // TRICKY: this representation is unorthodox, but ACodec requires // an ABuffer with a proper size to validate range offsets and lengths. // Since mData is never referenced for secure input, it is used to store // either the pointer to the secure buffer, or the opaque handle as on // some devices ptr is actually an opaque handle, not a pointer. // TRICKY2: use native handle as the base of the ABuffer if received one, // because Widevine source only receives these base addresses. const native_handle_t *native_handle_ptr = native_handle == NULL ? NULL : native_handle->handle(); info.mData = new MediaCodecBuffer(format, new ABuffer(ptr != NULL ? ptr : (void *)native_handle_ptr, bufSize)); info.mNativeHandle = native_handle; info.mData = (native_handle == NULL) ? new SecureBuffer(format, ptr, bufSize) : new SecureBuffer(format, native_handle, bufSize); info.mCodecData = info.mData; } else { err = mOMXNode->useBuffer( Loading Loading @@ -948,7 +938,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) { const BufferInfo &info = mBuffers[portIndex][i]; desc->addBuffer(info.mBufferID, info.mData, info.mNativeHandle, info.mMemRef); desc->addBuffer(info.mBufferID, info.mData); } notify->setObject("portDesc", desc); Loading Loading @@ -5247,12 +5237,9 @@ ACodec::PortDescription::PortDescription() { } void ACodec::PortDescription::addBuffer( IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer, const sp<NativeHandle> &handle, const sp<RefBase> &memRef) { IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer) { mBufferIDs.push_back(id); mBuffers.push_back(buffer); mHandles.push_back(handle); mMemRefs.push_back(memRef); } size_t ACodec::PortDescription::countBuffers() { Loading @@ -5267,14 +5254,6 @@ sp<MediaCodecBuffer> ACodec::PortDescription::bufferAt(size_t index) const { return mBuffers.itemAt(index); } sp<NativeHandle> ACodec::PortDescription::handleAt(size_t index) const { return mHandles.itemAt(index); } sp<RefBase> ACodec::PortDescription::memRefAt(size_t index) const { return mMemRefs.itemAt(index); } //////////////////////////////////////////////////////////////////////////////// ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) Loading media/libstagefright/BufferImpl.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -21,7 +21,10 @@ #include <binder/IMemory.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/AMessage.h> #include <media/ICrypto.h> #include <utils/NativeHandle.h> #include "include/SecureBuffer.h" #include "include/SharedMemoryBuffer.h" namespace android { Loading @@ -31,4 +34,25 @@ SharedMemoryBuffer::SharedMemoryBuffer(const sp<AMessage> &format, const sp<IMem mMemory(mem) { } SecureBuffer::SecureBuffer(const sp<AMessage> &format, void *ptr, size_t size) : MediaCodecBuffer(format, new ABuffer(nullptr, size)), mPointer(ptr) { } SecureBuffer::SecureBuffer( const sp<AMessage> &format, const sp<NativeHandle> &handle, size_t size) : MediaCodecBuffer(format, new ABuffer(nullptr, size)), mPointer(nullptr), mHandle(handle) { } void *SecureBuffer::getDestinationPointer() { return (void *)(mHandle == nullptr ? mPointer : mHandle->handle()); } ICrypto::DestinationType SecureBuffer::getDestinationType() { return mHandle == nullptr ? ICrypto::kDestinationTypeOpaqueHandle : ICrypto::kDestinationTypeNativeHandle; } } // namespace android Loading
include/media/stagefright/ACodec.h +1 −7 Original line number Diff line number Diff line Loading @@ -76,21 +76,15 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { size_t countBuffers(); IOMX::buffer_id bufferIDAt(size_t index) const; sp<MediaCodecBuffer> bufferAt(size_t index) const; sp<NativeHandle> handleAt(size_t index) const; sp<RefBase> memRefAt(size_t index) const; private: friend struct ACodec; Vector<IOMX::buffer_id> mBufferIDs; Vector<sp<MediaCodecBuffer>> mBuffers; Vector<sp<NativeHandle> > mHandles; Vector<sp<RefBase> > mMemRefs; PortDescription(); void addBuffer( IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer, const sp<NativeHandle> &handle, const sp<RefBase> &memRef); void addBuffer(IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer); DISALLOW_EVIL_CONSTRUCTORS(PortDescription); }; Loading
include/media/stagefright/CodecBase.h +0 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,6 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { virtual size_t countBuffers() = 0; virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0; virtual sp<MediaCodecBuffer> bufferAt(size_t index) const = 0; virtual sp<NativeHandle> handleAt(size_t index) const { return NULL; }; virtual sp<RefBase> memRefAt(size_t index) const { return NULL; } protected: PortDescription(); Loading
include/media/stagefright/MediaCodec.h +1 −3 Original line number Diff line number Diff line Loading @@ -255,9 +255,7 @@ private: struct BufferInfo { uint32_t mBufferID; sp<MediaCodecBuffer> mData; sp<NativeHandle> mNativeHandle; sp<RefBase> mMemRef; sp<MediaCodecBuffer> mEncryptedData; sp<MediaCodecBuffer> mSecureData; sp<IMemory> mSharedEncryptedBuffer; sp<AMessage> mNotify; sp<AMessage> mFormat; Loading
media/libstagefright/ACodec.cpp +6 −27 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ #include "include/avc_utils.h" #include "include/DataConverter.h" #include "include/SecureBuffer.h" #include "include/SharedMemoryBuffer.h" #include "omx/OMXUtils.h" Loading Loading @@ -876,7 +877,6 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { info.mStatus = BufferInfo::OWNED_BY_US; info.mFenceFd = -1; info.mRenderInfo = NULL; info.mNativeHandle = NULL; if (portIndex == kPortIndexInput && (mFlags & kFlagIsSecure)) { mem.clear(); Loading @@ -887,19 +887,9 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { portIndex, bufSize, &info.mBufferID, &ptr, &native_handle); // TRICKY: this representation is unorthodox, but ACodec requires // an ABuffer with a proper size to validate range offsets and lengths. // Since mData is never referenced for secure input, it is used to store // either the pointer to the secure buffer, or the opaque handle as on // some devices ptr is actually an opaque handle, not a pointer. // TRICKY2: use native handle as the base of the ABuffer if received one, // because Widevine source only receives these base addresses. const native_handle_t *native_handle_ptr = native_handle == NULL ? NULL : native_handle->handle(); info.mData = new MediaCodecBuffer(format, new ABuffer(ptr != NULL ? ptr : (void *)native_handle_ptr, bufSize)); info.mNativeHandle = native_handle; info.mData = (native_handle == NULL) ? new SecureBuffer(format, ptr, bufSize) : new SecureBuffer(format, native_handle, bufSize); info.mCodecData = info.mData; } else { err = mOMXNode->useBuffer( Loading Loading @@ -948,7 +938,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) { const BufferInfo &info = mBuffers[portIndex][i]; desc->addBuffer(info.mBufferID, info.mData, info.mNativeHandle, info.mMemRef); desc->addBuffer(info.mBufferID, info.mData); } notify->setObject("portDesc", desc); Loading Loading @@ -5247,12 +5237,9 @@ ACodec::PortDescription::PortDescription() { } void ACodec::PortDescription::addBuffer( IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer, const sp<NativeHandle> &handle, const sp<RefBase> &memRef) { IOMX::buffer_id id, const sp<MediaCodecBuffer> &buffer) { mBufferIDs.push_back(id); mBuffers.push_back(buffer); mHandles.push_back(handle); mMemRefs.push_back(memRef); } size_t ACodec::PortDescription::countBuffers() { Loading @@ -5267,14 +5254,6 @@ sp<MediaCodecBuffer> ACodec::PortDescription::bufferAt(size_t index) const { return mBuffers.itemAt(index); } sp<NativeHandle> ACodec::PortDescription::handleAt(size_t index) const { return mHandles.itemAt(index); } sp<RefBase> ACodec::PortDescription::memRefAt(size_t index) const { return mMemRefs.itemAt(index); } //////////////////////////////////////////////////////////////////////////////// ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) Loading
media/libstagefright/BufferImpl.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -21,7 +21,10 @@ #include <binder/IMemory.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/AMessage.h> #include <media/ICrypto.h> #include <utils/NativeHandle.h> #include "include/SecureBuffer.h" #include "include/SharedMemoryBuffer.h" namespace android { Loading @@ -31,4 +34,25 @@ SharedMemoryBuffer::SharedMemoryBuffer(const sp<AMessage> &format, const sp<IMem mMemory(mem) { } SecureBuffer::SecureBuffer(const sp<AMessage> &format, void *ptr, size_t size) : MediaCodecBuffer(format, new ABuffer(nullptr, size)), mPointer(ptr) { } SecureBuffer::SecureBuffer( const sp<AMessage> &format, const sp<NativeHandle> &handle, size_t size) : MediaCodecBuffer(format, new ABuffer(nullptr, size)), mPointer(nullptr), mHandle(handle) { } void *SecureBuffer::getDestinationPointer() { return (void *)(mHandle == nullptr ? mPointer : mHandle->handle()); } ICrypto::DestinationType SecureBuffer::getDestinationType() { return mHandle == nullptr ? ICrypto::kDestinationTypeOpaqueHandle : ICrypto::kDestinationTypeNativeHandle; } } // namespace android