2014-09-17 10:33:00 +04: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-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
Bug 1331289 - Use MediaContainerType in MediaResource, SourceBuffer, TrackBuffersManager, and dependencies - r=jya
Continuing the work of replacing MIME strings with MediaContainerType, starting
from MediaResource and following the dependencies.
Most changes are mechanical: Just change ns*String into MediaContainerType, and
MIME string literals into MEDIAMIMETYPE("a/b").
Some checks for empty/invalid strings and lowercase comparisons can go, thanks
to the always-valid always-lowercase-MIME invariants of MediaContainerType.
One special case in is MediaSourceResource, which used to have an empty string
as its type (because its own type is not relevant, but its SourceBuffers carry
types). Because the inherited GetContentType *must* be overridden, and must
return a MediaContainerType, we needed a valid type even though it should not
be seen in the real world. I've chosen "application/x.mediasource" for that.
MozReview-Commit-ID: 1aCH75Kh2e6
--HG--
extra : rebase_source : 0d9cd9b69c264e5dcfc3845f80ee107f4bcbcd9a
2016-12-28 10:59:02 +03:00
|
|
|
#include "MediaContainerType.h"
|
2015-06-11 08:49:49 +03:00
|
|
|
#include "MediaResource.h"
|
2016-11-02 13:29:13 +03:00
|
|
|
#include "MediaResult.h"
|
2014-09-17 10:33:00 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-06-15 07:37:13 +03:00
|
|
|
class MediaByteBuffer;
|
2015-02-04 12:20:15 +03:00
|
|
|
class SourceBufferResource;
|
2015-01-26 18:01:09 +03:00
|
|
|
|
2014-09-17 10:33:00 +04:00
|
|
|
class ContainerParser {
|
|
|
|
public:
|
Bug 1331289 - Use MediaContainerType in MediaResource, SourceBuffer, TrackBuffersManager, and dependencies - r=jya
Continuing the work of replacing MIME strings with MediaContainerType, starting
from MediaResource and following the dependencies.
Most changes are mechanical: Just change ns*String into MediaContainerType, and
MIME string literals into MEDIAMIMETYPE("a/b").
Some checks for empty/invalid strings and lowercase comparisons can go, thanks
to the always-valid always-lowercase-MIME invariants of MediaContainerType.
One special case in is MediaSourceResource, which used to have an empty string
as its type (because its own type is not relevant, but its SourceBuffers carry
types). Because the inherited GetContentType *must* be overridden, and must
return a MediaContainerType, we needed a valid type even though it should not
be seen in the real world. I've chosen "application/x.mediasource" for that.
MozReview-Commit-ID: 1aCH75Kh2e6
--HG--
extra : rebase_source : 0d9cd9b69c264e5dcfc3845f80ee107f4bcbcd9a
2016-12-28 10:59:02 +03:00
|
|
|
explicit ContainerParser(const MediaContainerType& aType);
|
2015-07-23 00:58:19 +03:00
|
|
|
virtual ~ContainerParser();
|
2014-09-17 10:33:00 +04: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.
|
2016-11-02 13:29:13 +03:00
|
|
|
// 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(MediaByteBuffer* aData);
|
2014-09-17 10:33:00 +04: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.
|
2016-11-02 13:29:13 +03:00
|
|
|
// 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(MediaByteBuffer* aData);
|
2014-09-17 10:33:00 +04:00
|
|
|
|
|
|
|
// Parse aData to extract the start and end frame times from the media
|
2016-11-04 15:09:47 +03:00
|
|
|
// 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(MediaByteBuffer* aData,
|
|
|
|
int64_t& aStart, int64_t& aEnd);
|
2014-09-17 10:33:00 +04:00
|
|
|
|
|
|
|
// 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-11 00:52:57 +03:00
|
|
|
bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs);
|
|
|
|
|
|
|
|
virtual int64_t GetRoundingError();
|
2014-09-17 10:33:00 +04:00
|
|
|
|
2015-06-15 07:37:13 +03:00
|
|
|
MediaByteBuffer* InitData();
|
2014-09-17 10:33:00 +04:00
|
|
|
|
|
|
|
bool HasInitData()
|
|
|
|
{
|
|
|
|
return mHasInitData;
|
|
|
|
}
|
|
|
|
|
2015-07-22 00:38:09 +03:00
|
|
|
// 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.
|
2015-02-02 03:41:43 +03:00
|
|
|
bool HasCompleteInitData();
|
2015-06-11 09:27:15 +03:00
|
|
|
// Returns the byte range of the first complete init segment, or an empty
|
2015-06-11 08:49:49 +03:00
|
|
|
// range if not complete.
|
2015-06-11 08:55:20 +03:00
|
|
|
MediaByteRange InitSegmentRange();
|
2015-06-11 09:27:15 +03: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 03:41:43 +03:00
|
|
|
|
Bug 1331289 - Use MediaContainerType in MediaResource, SourceBuffer, TrackBuffersManager, and dependencies - r=jya
Continuing the work of replacing MIME strings with MediaContainerType, starting
from MediaResource and following the dependencies.
Most changes are mechanical: Just change ns*String into MediaContainerType, and
MIME string literals into MEDIAMIMETYPE("a/b").
Some checks for empty/invalid strings and lowercase comparisons can go, thanks
to the always-valid always-lowercase-MIME invariants of MediaContainerType.
One special case in is MediaSourceResource, which used to have an empty string
as its type (because its own type is not relevant, but its SourceBuffers carry
types). Because the inherited GetContentType *must* be overridden, and must
return a MediaContainerType, we needed a valid type even though it should not
be seen in the real world. I've chosen "application/x.mediasource" for that.
MozReview-Commit-ID: 1aCH75Kh2e6
--HG--
extra : rebase_source : 0d9cd9b69c264e5dcfc3845f80ee107f4bcbcd9a
2016-12-28 10:59:02 +03:00
|
|
|
static ContainerParser* CreateForMIMEType(const MediaContainerType& aType);
|
2014-09-17 10:33:00 +04:00
|
|
|
|
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaByteBuffer> mInitData;
|
|
|
|
RefPtr<SourceBufferResource> mResource;
|
2014-09-17 10:33:00 +04:00
|
|
|
bool mHasInitData;
|
2015-06-11 08:55:20 +03:00
|
|
|
MediaByteRange mCompleteInitSegmentRange;
|
2015-06-11 09:27:15 +03:00
|
|
|
MediaByteRange mCompleteMediaHeaderRange;
|
|
|
|
MediaByteRange mCompleteMediaSegmentRange;
|
Bug 1331289 - Use MediaContainerType in MediaResource, SourceBuffer, TrackBuffersManager, and dependencies - r=jya
Continuing the work of replacing MIME strings with MediaContainerType, starting
from MediaResource and following the dependencies.
Most changes are mechanical: Just change ns*String into MediaContainerType, and
MIME string literals into MEDIAMIMETYPE("a/b").
Some checks for empty/invalid strings and lowercase comparisons can go, thanks
to the always-valid always-lowercase-MIME invariants of MediaContainerType.
One special case in is MediaSourceResource, which used to have an empty string
as its type (because its own type is not relevant, but its SourceBuffers carry
types). Because the inherited GetContentType *must* be overridden, and must
return a MediaContainerType, we needed a valid type even though it should not
be seen in the real world. I've chosen "application/x.mediasource" for that.
MozReview-Commit-ID: 1aCH75Kh2e6
--HG--
extra : rebase_source : 0d9cd9b69c264e5dcfc3845f80ee107f4bcbcd9a
2016-12-28 10:59:02 +03:00
|
|
|
const MediaContainerType mType;
|
2014-09-17 10:33:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2015-07-13 18:25:42 +03:00
|
|
|
|
2014-09-17 10:33:00 +04:00
|
|
|
#endif /* MOZILLA_CONTAINERPARSER_H_ */
|