2014-09-17 06:33:00 +00:00
|
|
|
/* -*- 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_
|
|
|
|
|
2015-07-29 00:52:52 +00:00
|
|
|
#include "mozilla/nsRefPtr.h"
|
2015-02-12 07:52:13 +00:00
|
|
|
#include "nsString.h"
|
2015-06-11 05:49:49 +00:00
|
|
|
#include "MediaResource.h"
|
2014-09-17 06:33:00 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-06-15 04:37:13 +00:00
|
|
|
class MediaByteBuffer;
|
2015-02-04 09:20:15 +00:00
|
|
|
class SourceBufferResource;
|
2015-01-26 15:01:09 +00:00
|
|
|
|
2014-09-17 06:33:00 +00:00
|
|
|
class ContainerParser {
|
|
|
|
public:
|
2015-02-12 07:52:13 +00:00
|
|
|
explicit ContainerParser(const nsACString& aType);
|
2015-07-21 23:35:37 +00:00
|
|
|
virtual ~ContainerParser() = default;
|
2014-09-17 06:33:00 +00:00
|
|
|
|
|
|
|
// 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.
|
2015-06-15 04:37:13 +00:00
|
|
|
virtual bool IsInitSegmentPresent(MediaByteBuffer* aData);
|
2014-09-17 06:33:00 +00:00
|
|
|
|
|
|
|
// 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.
|
2015-06-15 04:37:13 +00:00
|
|
|
virtual bool IsMediaSegmentPresent(MediaByteBuffer* aData);
|
2014-09-17 06:33:00 +00:00
|
|
|
|
|
|
|
// Parse aData to extract the start and end frame times from the media
|
|
|
|
// segment. aData may not start on a parser sync boundary. Return true
|
|
|
|
// if aStart and aEnd have been updated.
|
2015-06-15 04:37:13 +00:00
|
|
|
virtual bool ParseStartAndEndTimestamps(MediaByteBuffer* aData,
|
2014-09-17 06:33:00 +00:00
|
|
|
int64_t& aStart, int64_t& 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.
|
2014-12-10 21:52:57 +00:00
|
|
|
bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs);
|
|
|
|
|
|
|
|
virtual int64_t GetRoundingError();
|
2014-09-17 06:33:00 +00:00
|
|
|
|
2015-06-15 04:37:13 +00:00
|
|
|
MediaByteBuffer* InitData();
|
2014-09-17 06:33:00 +00:00
|
|
|
|
|
|
|
bool HasInitData()
|
|
|
|
{
|
|
|
|
return mHasInitData;
|
|
|
|
}
|
|
|
|
|
2015-02-02 00:41:43 +00:00
|
|
|
bool HasCompleteInitData();
|
2015-06-11 06:27:15 +00:00
|
|
|
// Returns the byte range of the first complete init segment, or an empty
|
2015-06-11 05:49:49 +00:00
|
|
|
// range if not complete.
|
2015-06-11 05:55:20 +00:00
|
|
|
MediaByteRange InitSegmentRange();
|
2015-06-11 06:27:15 +00:00
|
|
|
// 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();
|
2015-02-02 00:41:43 +00:00
|
|
|
|
2014-09-17 06:33:00 +00:00
|
|
|
static ContainerParser* CreateForMIMEType(const nsACString& aType);
|
|
|
|
|
|
|
|
protected:
|
2015-06-15 04:37:13 +00:00
|
|
|
nsRefPtr<MediaByteBuffer> mInitData;
|
2015-02-04 09:20:15 +00:00
|
|
|
nsRefPtr<SourceBufferResource> mResource;
|
2014-09-17 06:33:00 +00:00
|
|
|
bool mHasInitData;
|
2015-06-11 05:55:20 +00:00
|
|
|
MediaByteRange mCompleteInitSegmentRange;
|
2015-06-11 06:27:15 +00:00
|
|
|
MediaByteRange mCompleteMediaHeaderRange;
|
|
|
|
MediaByteRange mCompleteMediaSegmentRange;
|
2015-02-12 07:52:13 +00:00
|
|
|
const nsCString mType;
|
2014-09-17 06:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2015-07-13 15:25:42 +00:00
|
|
|
|
2014-09-17 06:33:00 +00:00
|
|
|
#endif /* MOZILLA_CONTAINERPARSER_H_ */
|