content/media/omx/MediaOmxReader.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     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 #if !defined(MediaOmxReader_h_)
     7 #define MediaOmxReader_h_
     9 #include "MediaResource.h"
    10 #include "MediaDecoderReader.h"
    11 #include "nsRect.h"
    12 #include "mozilla/dom/AudioChannelBinding.h"
    13 #include <ui/GraphicBuffer.h>
    14 #include <stagefright/MediaSource.h>
    16 namespace android {
    17 class OmxDecoder;
    18 class MediaExtractor;
    19 }
    21 namespace mozilla {
    23 namespace dom {
    24   class TimeRanges;
    25 }
    27 class AbstractMediaDecoder;
    29 class MediaOmxReader : public MediaDecoderReader
    30 {
    31   nsCString mType;
    32   bool mHasVideo;
    33   bool mHasAudio;
    34   nsIntRect mPicture;
    35   nsIntSize mInitialFrame;
    36   int64_t mVideoSeekTimeUs;
    37   int64_t mAudioSeekTimeUs;
    38   int32_t mSkipCount;
    39   dom::AudioChannel mAudioChannel;
    40   android::sp<android::MediaSource> mAudioOffloadTrack;
    42 protected:
    43   android::sp<android::OmxDecoder> mOmxDecoder;
    44   android::sp<android::MediaExtractor> mExtractor;
    46   // Called by ReadMetadata() during MediaDecoderStateMachine::DecodeMetadata()
    47   // on decode thread. It create and initialize the OMX decoder including
    48   // setting up custom extractor. The extractor provide the essential
    49   // information used for creating OMX decoder such as video/audio codec.
    50   virtual nsresult InitOmxDecoder();
    52 public:
    53   MediaOmxReader(AbstractMediaDecoder* aDecoder);
    54   ~MediaOmxReader();
    56   virtual nsresult Init(MediaDecoderReader* aCloneDonor);
    58   virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
    60   virtual bool DecodeAudioData();
    61   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
    62                                 int64_t aTimeThreshold);
    64   virtual bool HasAudio()
    65   {
    66     return mHasAudio;
    67   }
    69   virtual bool HasVideo()
    70   {
    71     return mHasVideo;
    72   }
    74   virtual bool IsWaitingMediaResources();
    76   virtual bool IsDormantNeeded();
    77   virtual void ReleaseMediaResources();
    79   virtual void ReleaseDecoder() MOZ_OVERRIDE;
    81   virtual nsresult ReadMetadata(MediaInfo* aInfo,
    82                                 MetadataTags** aTags);
    83   virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime);
    85   virtual void SetIdle() MOZ_OVERRIDE;
    86   virtual void SetActive() MOZ_OVERRIDE;
    88   void SetAudioChannel(dom::AudioChannel aAudioChannel) {
    89     mAudioChannel = aAudioChannel;
    90   }
    92   android::sp<android::MediaSource> GetAudioOffloadTrack() {
    93     return mAudioOffloadTrack;
    94   }
    96 #ifdef MOZ_AUDIO_OFFLOAD
    97   // Check whether it is possible to offload current audio track. This access
    98   // canOffloadStream() from libStageFright Utils.cpp, which is not there in
    99   // ANDROID_VERSION < 19
   100   void CheckAudioOffload();
   101 #endif
   103 private:
   104   // This flag is true when SetActive() has been called without a matching
   105   // SetIdle(). This is used to sanity check the SetIdle/SetActive calls, to
   106   // ensure SetActive has been called before a decode call.
   107   DebugOnly<bool> mIsActive;
   108 };
   110 } // namespace mozilla
   112 #endif

mercurial