Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef OMX_CODEC_PROXY_DECODER_H_
7 #define OMX_CODEC_PROXY_DECODER_H_
10 #include <android/native_window.h>
11 #include <IOMX.h>
12 #include <stagefright/MediaBuffer.h>
13 #include <stagefright/MediaSource.h>
14 #include <utils/threads.h>
16 #include "MediaResourceManagerClient.h"
18 namespace android {
20 struct MediaBufferGroup;
21 struct MetaData;
23 class OMXCodecProxy : public MediaSource,
24 public MediaResourceManagerClient::EventListener
25 {
26 public:
27 struct EventListener : public virtual RefBase {
28 virtual void statusChanged() = 0;
29 };
31 static sp<OMXCodecProxy> Create(
32 const sp<IOMX> &omx,
33 const sp<MetaData> &meta, bool createEncoder,
34 const sp<MediaSource> &source,
35 const char *matchComponentName = nullptr,
36 uint32_t flags = 0,
37 const sp<ANativeWindow> &nativeWindow = nullptr);
39 MediaResourceManagerClient::State getState();
41 void setEventListener(const wp<EventListener>& listener);
43 void requestResource();
44 bool IsWaitingResources();
46 // MediaResourceManagerClient::EventListener
47 virtual void statusChanged(int event);
49 // MediaSource
50 virtual status_t start(MetaData *params = nullptr);
51 virtual status_t stop();
53 virtual sp<MetaData> getFormat();
55 virtual status_t read(
56 MediaBuffer **buffer, const ReadOptions *options = nullptr);
58 virtual status_t pause();
60 protected:
61 OMXCodecProxy(
62 const sp<IOMX> &omx,
63 const sp<MetaData> &meta,
64 bool createEncoder,
65 const sp<MediaSource> &source,
66 const char *matchComponentName,
67 uint32_t flags,
68 const sp<ANativeWindow> &nativeWindow);
70 virtual ~OMXCodecProxy();
72 void notifyStatusChangedLocked();
74 private:
75 OMXCodecProxy(const OMXCodecProxy &);
76 OMXCodecProxy &operator=(const OMXCodecProxy &);
78 Mutex mLock;
80 sp<IOMX> mOMX;
81 sp<MetaData> mSrcMeta;
82 char *mComponentName;
83 bool mIsEncoder;
84 // Flags specified in the creation of the codec.
85 uint32_t mFlags;
86 sp<ANativeWindow> mNativeWindow;
88 sp<MediaSource> mSource;
90 sp<MediaSource> mOMXCodec;
91 sp<MediaResourceManagerClient> mClient;
92 MediaResourceManagerClient::State mState;
94 sp<IMediaResourceManagerService> mManagerService;
95 wp<OMXCodecProxy::EventListener> mEventListener;
96 };
98 } // namespace android
100 #endif // OMX_CODEC_PROXY_DECODER_H_