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