tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

OmxPlatformLayer.h (3630B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #if !defined(OmxPlatformLayer_h_)
      8 #  define OmxPlatformLayer_h_
      9 
     10 #  include "OMX_Core.h"
     11 #  include "OMX_Types.h"
     12 #  include "OMX_Video.h"
     13 #  include "OmxPromiseLayer.h"
     14 #  include "nsStringFwd.h"
     15 
     16 namespace mozilla {
     17 
     18 class TaskQueue;
     19 class TrackInfo;
     20 
     21 /*
     22 * This class the the abstract layer of the platform OpenMax IL implementation.
     23 *
     24 * For some platform like andoird, it exposures its OpenMax IL via IOMX which
     25 * is definitions are different comparing to standard.
     26 * For other platforms like Raspberry Pi, it will be easy to implement this
     27 * layer with the standard OpenMax IL api.
     28 */
     29 class OmxPlatformLayer {
     30 public:
     31  typedef OmxPromiseLayer::BUFFERLIST BUFFERLIST;
     32  typedef OmxPromiseLayer::BufferData BufferData;
     33 
     34  virtual OMX_ERRORTYPE InitOmxToStateLoaded(const TrackInfo* aInfo) = 0;
     35 
     36  OMX_ERRORTYPE Config();
     37 
     38  virtual OMX_ERRORTYPE EmptyThisBuffer(BufferData* aData) = 0;
     39 
     40  virtual OMX_ERRORTYPE FillThisBuffer(BufferData* aData) = 0;
     41 
     42  virtual OMX_ERRORTYPE SendCommand(OMX_COMMANDTYPE aCmd, OMX_U32 aParam1,
     43                                    OMX_PTR aCmdData) = 0;
     44 
     45  // Buffer could be platform dependent. Therefore, derived class needs to
     46  // implement its owned buffer allocate/release API according to its platform
     47  // type.
     48  virtual nsresult AllocateOmxBuffer(OMX_DIRTYPE aType,
     49                                     BUFFERLIST* aBufferList) = 0;
     50 
     51  virtual nsresult ReleaseOmxBuffer(OMX_DIRTYPE aType,
     52                                    BUFFERLIST* aBufferList) = 0;
     53 
     54  virtual OMX_ERRORTYPE GetState(OMX_STATETYPE* aType) = 0;
     55 
     56  virtual OMX_ERRORTYPE GetParameter(OMX_INDEXTYPE aParamIndex,
     57                                     OMX_PTR aComponentParameterStructure,
     58                                     OMX_U32 aComponentParameterSize) = 0;
     59 
     60  virtual OMX_ERRORTYPE SetParameter(OMX_INDEXTYPE nIndex,
     61                                     OMX_PTR aComponentParameterStructure,
     62                                     OMX_U32 aComponentParameterSize) = 0;
     63 
     64  virtual nsresult Shutdown() = 0;
     65 
     66  virtual ~OmxPlatformLayer() = default;
     67 
     68  // For decoders, input port index is start port number and output port is
     69  // next. See OpenMAX IL spec v1.1.2 section 8.6.1 & 8.8.1.
     70  OMX_U32 InputPortIndex() { return mStartPortNumber; }
     71 
     72  OMX_U32 OutputPortIndex() { return mStartPortNumber + 1; }
     73 
     74  void GetPortIndices(nsTArray<uint32_t>& aPortIndex) {
     75    aPortIndex.AppendElement(InputPortIndex());
     76    aPortIndex.AppendElement(OutputPortIndex());
     77  }
     78 
     79  virtual OMX_VIDEO_CODINGTYPE CompressionFormat();
     80 
     81  // Check if the platform implementation supports given MIME type.
     82  static bool SupportsMimeType(const nsACString& aMimeType);
     83 
     84  // Hide the details of creating implementation objects for different
     85  // platforms.
     86  static OmxPlatformLayer* Create(OmxDataDecoder* aDataDecoder,
     87                                  OmxPromiseLayer* aPromiseLayer,
     88                                  TaskQueue* aTaskQueue,
     89                                  layers::ImageContainer* aImageContainer);
     90 
     91 protected:
     92  OmxPlatformLayer() : mInfo(nullptr), mStartPortNumber(0) {}
     93 
     94  // The pointee is held by |OmxDataDecoder::mTrackInfo| and will outlive this
     95  // pointer.
     96  const TrackInfo* mInfo;
     97  OMX_U32 mStartPortNumber;
     98 };
     99 
    100 }  // namespace mozilla
    101 
    102 #endif  // OmxPlatformLayer_h_