content/media/omx/OMXCodecProxy.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:054cd9f96c18
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_
8
9
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>
15
16 #include "MediaResourceManagerClient.h"
17
18 namespace android {
19
20 struct MediaBufferGroup;
21 struct MetaData;
22
23 class OMXCodecProxy : public MediaSource,
24 public MediaResourceManagerClient::EventListener
25 {
26 public:
27 struct EventListener : public virtual RefBase {
28 virtual void statusChanged() = 0;
29 };
30
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);
38
39 MediaResourceManagerClient::State getState();
40
41 void setEventListener(const wp<EventListener>& listener);
42
43 void requestResource();
44 bool IsWaitingResources();
45
46 // MediaResourceManagerClient::EventListener
47 virtual void statusChanged(int event);
48
49 // MediaSource
50 virtual status_t start(MetaData *params = nullptr);
51 virtual status_t stop();
52
53 virtual sp<MetaData> getFormat();
54
55 virtual status_t read(
56 MediaBuffer **buffer, const ReadOptions *options = nullptr);
57
58 virtual status_t pause();
59
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);
69
70 virtual ~OMXCodecProxy();
71
72 void notifyStatusChangedLocked();
73
74 private:
75 OMXCodecProxy(const OMXCodecProxy &);
76 OMXCodecProxy &operator=(const OMXCodecProxy &);
77
78 Mutex mLock;
79
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;
87
88 sp<MediaSource> mSource;
89
90 sp<MediaSource> mOMXCodec;
91 sp<MediaResourceManagerClient> mClient;
92 MediaResourceManagerClient::State mState;
93
94 sp<IMediaResourceManagerService> mManagerService;
95 wp<OMXCodecProxy::EventListener> mEventListener;
96 };
97
98 } // namespace android
99
100 #endif // OMX_CODEC_PROXY_DECODER_H_

mercurial