1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/omx/OMXCodecProxy.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 +#ifndef OMX_CODEC_PROXY_DECODER_H_ 1.10 +#define OMX_CODEC_PROXY_DECODER_H_ 1.11 + 1.12 + 1.13 +#include <android/native_window.h> 1.14 +#include <IOMX.h> 1.15 +#include <stagefright/MediaBuffer.h> 1.16 +#include <stagefright/MediaSource.h> 1.17 +#include <utils/threads.h> 1.18 + 1.19 +#include "MediaResourceManagerClient.h" 1.20 + 1.21 +namespace android { 1.22 + 1.23 +struct MediaBufferGroup; 1.24 +struct MetaData; 1.25 + 1.26 +class OMXCodecProxy : public MediaSource, 1.27 + public MediaResourceManagerClient::EventListener 1.28 +{ 1.29 +public: 1.30 + struct EventListener : public virtual RefBase { 1.31 + virtual void statusChanged() = 0; 1.32 + }; 1.33 + 1.34 + static sp<OMXCodecProxy> Create( 1.35 + const sp<IOMX> &omx, 1.36 + const sp<MetaData> &meta, bool createEncoder, 1.37 + const sp<MediaSource> &source, 1.38 + const char *matchComponentName = nullptr, 1.39 + uint32_t flags = 0, 1.40 + const sp<ANativeWindow> &nativeWindow = nullptr); 1.41 + 1.42 + MediaResourceManagerClient::State getState(); 1.43 + 1.44 + void setEventListener(const wp<EventListener>& listener); 1.45 + 1.46 + void requestResource(); 1.47 + bool IsWaitingResources(); 1.48 + 1.49 + // MediaResourceManagerClient::EventListener 1.50 + virtual void statusChanged(int event); 1.51 + 1.52 + // MediaSource 1.53 + virtual status_t start(MetaData *params = nullptr); 1.54 + virtual status_t stop(); 1.55 + 1.56 + virtual sp<MetaData> getFormat(); 1.57 + 1.58 + virtual status_t read( 1.59 + MediaBuffer **buffer, const ReadOptions *options = nullptr); 1.60 + 1.61 + virtual status_t pause(); 1.62 + 1.63 +protected: 1.64 + OMXCodecProxy( 1.65 + const sp<IOMX> &omx, 1.66 + const sp<MetaData> &meta, 1.67 + bool createEncoder, 1.68 + const sp<MediaSource> &source, 1.69 + const char *matchComponentName, 1.70 + uint32_t flags, 1.71 + const sp<ANativeWindow> &nativeWindow); 1.72 + 1.73 + virtual ~OMXCodecProxy(); 1.74 + 1.75 + void notifyStatusChangedLocked(); 1.76 + 1.77 +private: 1.78 + OMXCodecProxy(const OMXCodecProxy &); 1.79 + OMXCodecProxy &operator=(const OMXCodecProxy &); 1.80 + 1.81 + Mutex mLock; 1.82 + 1.83 + sp<IOMX> mOMX; 1.84 + sp<MetaData> mSrcMeta; 1.85 + char *mComponentName; 1.86 + bool mIsEncoder; 1.87 + // Flags specified in the creation of the codec. 1.88 + uint32_t mFlags; 1.89 + sp<ANativeWindow> mNativeWindow; 1.90 + 1.91 + sp<MediaSource> mSource; 1.92 + 1.93 + sp<MediaSource> mOMXCodec; 1.94 + sp<MediaResourceManagerClient> mClient; 1.95 + MediaResourceManagerClient::State mState; 1.96 + 1.97 + sp<IMediaResourceManagerService> mManagerService; 1.98 + wp<OMXCodecProxy::EventListener> mEventListener; 1.99 +}; 1.100 + 1.101 +} // namespace android 1.102 + 1.103 +#endif // OMX_CODEC_PROXY_DECODER_H_