content/media/omx/mediaresourcemanager/MediaResourceManagerService.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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
michael@0 7 #ifndef ANDROID_MEDIARESOURCEMANAGERSERVICE_H
michael@0 8 #define ANDROID_MEDIARESOURCEMANAGERSERVICE_H
michael@0 9
michael@0 10 #include <media/stagefright/foundation/ABase.h>
michael@0 11 #include <media/stagefright/foundation/AHandlerReflector.h>
michael@0 12 #include <media/stagefright/foundation/ALooper.h>
michael@0 13 #include <utils/List.h>
michael@0 14 #include <utils/RefBase.h>
michael@0 15
michael@0 16 #include "IMediaResourceManagerClient.h"
michael@0 17 #include "IMediaResourceManagerService.h"
michael@0 18
michael@0 19 namespace android {
michael@0 20
michael@0 21 /**
michael@0 22 * Manage permissions of using media resources(hw decoder, hw encoder, camera)
michael@0 23 * XXX Current implementaion support only one hw video decoder.
michael@0 24 * Need to extend to support multiple instance and other resources.
michael@0 25 */
michael@0 26 class MediaResourceManagerService: public BnMediaResourceManagerService,
michael@0 27 public IBinder::DeathRecipient
michael@0 28 {
michael@0 29 public:
michael@0 30 // The maximum number of hardware decoders available.
michael@0 31 enum { VIDEO_DECODER_COUNT = 1 };
michael@0 32
michael@0 33 enum {
michael@0 34 kNotifyRequest = 'noti'
michael@0 35 };
michael@0 36
michael@0 37 // Instantiate MediaResourceManagerService and register to service manager.
michael@0 38 // If service manager is not present, wait until service manager becomes present.
michael@0 39 static void instantiate();
michael@0 40
michael@0 41 // DeathRecipient
michael@0 42 virtual void binderDied(const wp<IBinder>& who);
michael@0 43
michael@0 44 // derived from IMediaResourceManagerService
michael@0 45 virtual void requestMediaResource(const sp<IMediaResourceManagerClient>& client, int resourceType);
michael@0 46 virtual status_t cancelClient(const sp<IMediaResourceManagerClient>& client);
michael@0 47
michael@0 48 // Receive a message from AHandlerReflector.
michael@0 49 // Called on ALooper thread.
michael@0 50 void onMessageReceived(const sp<AMessage> &msg);
michael@0 51
michael@0 52 protected:
michael@0 53 MediaResourceManagerService();
michael@0 54 virtual ~MediaResourceManagerService();
michael@0 55
michael@0 56 protected:
michael@0 57 // Represent a media resouce.
michael@0 58 // Hold a IMediaResourceManagerClient that got a media resource as IBinder.
michael@0 59 struct ResourceSlot {
michael@0 60 ResourceSlot ()
michael@0 61 {
michael@0 62 }
michael@0 63 sp<IBinder> mClient;
michael@0 64 };
michael@0 65
michael@0 66 void cancelClientLocked(const sp<IBinder>& binder);
michael@0 67
michael@0 68 // mVideoDecoderSlots is the array of slots that represent a media resource.
michael@0 69 ResourceSlot mVideoDecoderSlots[VIDEO_DECODER_COUNT];
michael@0 70 // The maximum number of hardware decoders available on the device.
michael@0 71 int mVideoDecoderCount;
michael@0 72
michael@0 73 // The lock protects mVideoDecoderSlots and mVideoCodecRequestQueue called
michael@0 74 // from multiple threads.
michael@0 75 Mutex mLock;
michael@0 76 typedef List<sp<IBinder> > Fifo;
michael@0 77 // Queue of media resource requests.
michael@0 78 // Hold IMediaResourceManagerClient that requesting a media resource as IBinder.
michael@0 79 Fifo mVideoCodecRequestQueue;
michael@0 80
michael@0 81 // ALooper is a message loop used in stagefright.
michael@0 82 // It creates a thread for messages and handles messages in the thread.
michael@0 83 // ALooper is a clone of Looper in android Java.
michael@0 84 // http://developer.android.com/reference/android/os/Looper.html
michael@0 85 sp<ALooper> mLooper;
michael@0 86 // deliver a message to a wrapped object(OmxDecoder).
michael@0 87 // AHandlerReflector is similar to Handler in android Java.
michael@0 88 // http://developer.android.com/reference/android/os/Handler.html
michael@0 89 sp<AHandlerReflector<MediaResourceManagerService> > mReflector;
michael@0 90
michael@0 91 };
michael@0 92
michael@0 93 }; // namespace android
michael@0 94
michael@0 95 #endif // ANDROID_MEDIARESOURCEMANAGERSERVICE_H

mercurial