1 /* 2 * Copyright (C) 2018 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 OMX_GRAPHIC_BUFFER_SOURCE_H_ 18 19 #define OMX_GRAPHIC_BUFFER_SOURCE_H_ 20 21 #include <media/stagefright/bqhelper/GraphicBufferSource.h> 22 #include <media/stagefright/foundation/ABase.h> 23 24 #include <android/BnOMXBufferSource.h> 25 26 #include "IOmxNodeWrapper.h" 27 28 namespace android { 29 30 using ::android::binder::Status; 31 32 /* 33 * This class is used to feed OMX codecs from a Surface via BufferQueue or 34 * HW producer. 35 * 36 * See media/stagefright/bqhelper/GraphicBufferSource.h for documentation. 37 */ 38 class OmxGraphicBufferSource : public GraphicBufferSource { 39 public: 40 OmxGraphicBufferSource() = default; 41 virtual ~OmxGraphicBufferSource() = default; 42 43 // OmxBufferSource interface 44 // ------------------------------ 45 46 // This is called when OMX transitions to OMX_StateExecuting, which means 47 // we can start handing it buffers. If we already have buffers of data 48 // sitting in the BufferQueue, this will send them to the codec. 49 Status onOmxExecuting(); 50 51 // This is called when OMX transitions to OMX_StateIdle, indicating that 52 // the codec is meant to return all buffers back to the client for them 53 // to be freed. Do NOT submit any more buffers to the component. 54 Status onOmxIdle(); 55 56 // This is called when OMX transitions to OMX_StateLoaded, indicating that 57 // we are shutting down. 58 Status onOmxLoaded(); 59 60 // Rest of the interface in GraphicBufferSource. 61 62 // IGraphicBufferSource interface 63 // ------------------------------ 64 65 // Configure the buffer source to be used with an OMX node with the default 66 // data space. 67 status_t configure( 68 const sp<IOmxNodeWrapper> &omxNode, 69 int32_t dataSpace, 70 int32_t bufferCount, 71 uint32_t frameWidth, 72 uint32_t frameHeight, 73 uint32_t consumerUsage); 74 75 // Rest of the interface in GraphicBufferSource. 76 77 private: 78 DISALLOW_EVIL_CONSTRUCTORS(OmxGraphicBufferSource); 79 }; 80 81 } // namespace android 82 83 #endif // OMX_GRAPHIC_BUFFER_SOURCE_H_ 84