LCOV - code coverage report
Current view: top level - media/libstagefright/binding/include/mp4_demuxer - Box.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 17 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef BOX_H_
       8             : #define BOX_H_
       9             : 
      10             : #include <stdint.h>
      11             : #include "nsTArray.h"
      12             : #include "MediaResource.h"
      13             : #include "mozilla/EndianUtils.h"
      14             : #include "mp4_demuxer/AtomType.h"
      15             : #include "mp4_demuxer/ByteReader.h"
      16             : 
      17             : using namespace mozilla;
      18             : 
      19             : namespace mp4_demuxer {
      20             : 
      21             : class Stream;
      22             : 
      23           0 : class BoxContext
      24             : {
      25             : public:
      26           0 :   BoxContext(Stream* aSource, const MediaByteRangeSet& aByteRanges)
      27           0 :     : mSource(aSource), mByteRanges(aByteRanges)
      28             :   {
      29           0 :   }
      30             : 
      31             :   RefPtr<Stream> mSource;
      32             :   const MediaByteRangeSet& mByteRanges;
      33             : };
      34             : 
      35           0 : class Box
      36             : {
      37             : public:
      38             :   Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent = nullptr);
      39             :   Box();
      40             : 
      41           0 :   bool IsAvailable() const { return !mRange.IsEmpty(); }
      42           0 :   uint64_t Offset() const { return mRange.mStart; }
      43             :   uint64_t Length() const { return mRange.mEnd - mRange.mStart; }
      44           0 :   uint64_t NextOffset() const { return mRange.mEnd; }
      45           0 :   const MediaByteRange& Range() const { return mRange; }
      46           0 :   const Box* Parent() const { return mParent; }
      47           0 :   bool IsType(const char* aType) const { return mType == AtomType(aType); }
      48             : 
      49             :   Box Next() const;
      50             :   Box FirstChild() const;
      51             :   nsTArray<uint8_t> Read();
      52             :   bool Read(nsTArray<uint8_t>* aDest, const MediaByteRange& aRange);
      53             : 
      54             :   static const uint64_t kMAX_BOX_READ;
      55             : 
      56             : private:
      57             :   bool Contains(MediaByteRange aRange) const;
      58             :   BoxContext* mContext;
      59             :   mozilla::MediaByteRange mRange;
      60             :   uint64_t mBodyOffset;
      61             :   uint64_t mChildOffset;
      62             :   AtomType mType;
      63             :   const Box* mParent;
      64             : };
      65             : 
      66             : // BoxReader takes a copy of a box contents and serves through an AutoByteReader.
      67           0 : class MOZ_RAII BoxReader
      68             : {
      69             : public:
      70           0 :   explicit BoxReader(Box& aBox)
      71           0 :     : mBuffer(aBox.Read())
      72           0 :     , mReader(mBuffer.Elements(), mBuffer.Length())
      73             :   {
      74           0 :   }
      75           0 :   ByteReader* operator->() { return &mReader; }
      76             : 
      77             : private:
      78             :   nsTArray<uint8_t> mBuffer;
      79             :   ByteReader mReader;
      80             : };
      81             : }
      82             : 
      83             : #endif

Generated by: LCOV version 1.13