From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- dom/media/mediasource/ContainerParser.h | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 dom/media/mediasource/ContainerParser.h (limited to 'dom/media/mediasource/ContainerParser.h') diff --git a/dom/media/mediasource/ContainerParser.h b/dom/media/mediasource/ContainerParser.h new file mode 100644 index 0000000000..baac33f545 --- /dev/null +++ b/dom/media/mediasource/ContainerParser.h @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MOZILLA_CONTAINERPARSER_H_ +#define MOZILLA_CONTAINERPARSER_H_ + +#include "mozilla/RefPtr.h" +#include "mozilla/UniquePtr.h" +#include "MediaSpan.h" +#include "MediaContainerType.h" +#include "MediaResource.h" +#include "MediaResult.h" + +namespace mozilla { + +class MediaByteBuffer; +class SourceBufferResource; + +DDLoggedTypeDeclName(ContainerParser); + +class ContainerParser : public DecoderDoctorLifeLogger { + public: + explicit ContainerParser(const MediaContainerType& aType); + virtual ~ContainerParser(); + + // Return true if aData starts with an initialization segment. + // The base implementation exists only for debug logging and is expected + // to be called first from the overriding implementation. + // Return NS_OK if segment is present, NS_ERROR_NOT_AVAILABLE if no sufficient + // data is currently available to make a determination. Any other value + // indicates an error. + virtual MediaResult IsInitSegmentPresent(const MediaSpan& aData); + + // Return true if aData starts with a media segment. + // The base implementation exists only for debug logging and is expected + // to be called first from the overriding implementation. + // Return NS_OK if segment is present, NS_ERROR_NOT_AVAILABLE if no sufficient + // data is currently available to make a determination. Any other value + // indicates an error. + virtual MediaResult IsMediaSegmentPresent(const MediaSpan& aData); + + // Parse aData to extract the start and end frame times from the media + // segment. aData may not start on a parser sync boundary. Return NS_OK + // if aStart and aEnd have been updated and NS_ERROR_NOT_AVAILABLE otherwise + // when no error were encountered. + virtual MediaResult ParseStartAndEndTimestamps(const MediaSpan& aData, + media::TimeUnit& aStart, + media::TimeUnit& aEnd); + + // Compare aLhs and rHs, considering any error that may exist in the + // timestamps from the format's base representation. Return true if aLhs + // == aRhs within the error epsilon. + bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs); + + virtual int64_t GetRoundingError(); + + MediaByteBuffer* InitData(); + + bool HasInitData() { return mHasInitData; } + + // Return true if a complete initialization segment has been passed + // to ParseStartAndEndTimestamps(). The calls below to retrieve + // MediaByteRanges will be valid from when this call first succeeds. + bool HasCompleteInitData(); + // Returns the byte range of the first complete init segment, or an empty + // range if not complete. + MediaByteRange InitSegmentRange(); + // Returns the byte range of the first complete media segment header, + // or an empty range if not complete. + MediaByteRange MediaHeaderRange(); + // Returns the byte range of the first complete media segment or an empty + // range if not complete. + MediaByteRange MediaSegmentRange(); + + static UniquePtr CreateForMIMEType( + const MediaContainerType& aType); + + const MediaContainerType& ContainerType() const { return mType; } + + protected: + RefPtr mInitData; + RefPtr mResource; + bool mHasInitData; + uint64_t mTotalParsed; + uint64_t mGlobalOffset; + MediaByteRange mCompleteInitSegmentRange; + MediaByteRange mCompleteMediaHeaderRange; + MediaByteRange mCompleteMediaSegmentRange; + const MediaContainerType mType; +}; + +} // namespace mozilla + +#endif /* MOZILLA_CONTAINERPARSER_H_ */ -- cgit v1.2.3