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.

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

mercurial