/* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OMX_HARNESS_H_ #define OMX_HARNESS_H_ #include #include #include #include #include namespace android { class MemoryDealer; struct Harness : public BnOMXObserver { enum BufferFlags { kBufferBusy = 1 }; struct Buffer { IOMX::buffer_id mID; sp mMemory; uint32_t mFlags; }; Harness(); status_t initCheck() const; status_t dequeueMessageForNode( IOMX::node_id node, omx_message *msg, int64_t timeoutUs = -1); status_t dequeueMessageForNodeIgnoringBuffers( IOMX::node_id node, Vector *inputBuffers, Vector *outputBuffers, omx_message *msg, int64_t timeoutUs = -1); status_t getPortDefinition( IOMX::node_id node, OMX_U32 portIndex, OMX_PARAM_PORTDEFINITIONTYPE *def); status_t allocatePortBuffers( const sp &dealer, IOMX::node_id node, OMX_U32 portIndex, Vector *buffers); status_t setRole(IOMX::node_id node, const char *role); status_t testStateTransitions( const char *componentName, const char *componentRole); status_t testSeek( const char *componentName, const char *componentRole); status_t test( const char *componentName, const char *componentRole); status_t testAll(); virtual void onMessages(const std::list &messages); protected: virtual ~Harness(); private: friend struct NodeReaper; Mutex mLock; status_t mInitCheck; sp mOMX; List mMessageQueue; Condition mMessageAddedCondition; status_t initOMX(); bool handleBufferMessage( const omx_message &msg, Vector *inputBuffers, Vector *outputBuffers); Harness(const Harness &); Harness &operator=(const Harness &); }; } // namespace android #endif // OMX_HARNESS_H_