content/media/omx/OMXCodecProxy.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial