forked from mirrors/gecko-dev
Bug 1848669 - Fix clang-tidy warnings in OggDemuxer.cpp. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D186357
This commit is contained in:
parent
71e467de2a
commit
fb69e39988
2 changed files with 35 additions and 35 deletions
|
|
@ -110,25 +110,33 @@ void OggDemuxer::SandboxDestroy::operator()(rlbox_sandbox_ogg* sandbox) {
|
||||||
// (https://www.whatwg.org/specs/web-apps/current-
|
// (https://www.whatwg.org/specs/web-apps/current-
|
||||||
// work/multipage/embedded-content.html#dom-audiotrack-kind) &
|
// work/multipage/embedded-content.html#dom-audiotrack-kind) &
|
||||||
// (http://wiki.xiph.org/SkeletonHeaders)
|
// (http://wiki.xiph.org/SkeletonHeaders)
|
||||||
const nsString OggDemuxer::GetKind(const nsCString& aRole) {
|
nsString OggDemuxer::GetKind(const nsCString& aRole) {
|
||||||
if (aRole.Find("audio/main") != -1 || aRole.Find("video/main") != -1) {
|
if (aRole.Find("audio/main") != -1 || aRole.Find("video/main") != -1) {
|
||||||
return u"main"_ns;
|
return u"main"_ns;
|
||||||
} else if (aRole.Find("audio/alternate") != -1 ||
|
}
|
||||||
aRole.Find("video/alternate") != -1) {
|
if (aRole.Find("audio/alternate") != -1 ||
|
||||||
|
aRole.Find("video/alternate") != -1) {
|
||||||
return u"alternative"_ns;
|
return u"alternative"_ns;
|
||||||
} else if (aRole.Find("audio/audiodesc") != -1) {
|
}
|
||||||
|
if (aRole.Find("audio/audiodesc") != -1) {
|
||||||
return u"descriptions"_ns;
|
return u"descriptions"_ns;
|
||||||
} else if (aRole.Find("audio/described") != -1) {
|
}
|
||||||
|
if (aRole.Find("audio/described") != -1) {
|
||||||
return u"main-desc"_ns;
|
return u"main-desc"_ns;
|
||||||
} else if (aRole.Find("audio/dub") != -1) {
|
}
|
||||||
|
if (aRole.Find("audio/dub") != -1) {
|
||||||
return u"translation"_ns;
|
return u"translation"_ns;
|
||||||
} else if (aRole.Find("audio/commentary") != -1) {
|
}
|
||||||
|
if (aRole.Find("audio/commentary") != -1) {
|
||||||
return u"commentary"_ns;
|
return u"commentary"_ns;
|
||||||
} else if (aRole.Find("video/sign") != -1) {
|
}
|
||||||
|
if (aRole.Find("video/sign") != -1) {
|
||||||
return u"sign"_ns;
|
return u"sign"_ns;
|
||||||
} else if (aRole.Find("video/captioned") != -1) {
|
}
|
||||||
|
if (aRole.Find("video/captioned") != -1) {
|
||||||
return u"captions"_ns;
|
return u"captions"_ns;
|
||||||
} else if (aRole.Find("video/subtitled") != -1) {
|
}
|
||||||
|
if (aRole.Find("video/subtitled") != -1) {
|
||||||
return u"subtitles"_ns;
|
return u"subtitles"_ns;
|
||||||
}
|
}
|
||||||
return u""_ns;
|
return u""_ns;
|
||||||
|
|
@ -248,7 +256,7 @@ OggCodecState* OggDemuxer::GetTrackCodecState(
|
||||||
case TrackInfo::kVideoTrack:
|
case TrackInfo::kVideoTrack:
|
||||||
return mTheoraState;
|
return mTheoraState;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,7 +478,7 @@ nsresult OggDemuxer::ReadMetadata() {
|
||||||
nsTArray<OggCodecState*> bitstreams;
|
nsTArray<OggCodecState*> bitstreams;
|
||||||
nsTArray<uint32_t> serials;
|
nsTArray<uint32_t> serials;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < ArrayLength(tracks); i++) {
|
for (auto& track : tracks) {
|
||||||
tainted_ogg<ogg_page*> page = mSandbox->malloc_in_sandbox<ogg_page>();
|
tainted_ogg<ogg_page*> page = mSandbox->malloc_in_sandbox<ogg_page>();
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
@ -479,7 +487,7 @@ nsresult OggDemuxer::ReadMetadata() {
|
||||||
|
|
||||||
bool readAllBOS = false;
|
bool readAllBOS = false;
|
||||||
while (!readAllBOS) {
|
while (!readAllBOS) {
|
||||||
if (!ReadOggPage(tracks[i], page.to_opaque())) {
|
if (!ReadOggPage(track, page.to_opaque())) {
|
||||||
// Some kind of error...
|
// Some kind of error...
|
||||||
OGG_DEBUG("OggDemuxer::ReadOggPage failed? leaving ReadMetadata...");
|
OGG_DEBUG("OggDemuxer::ReadOggPage failed? leaving ReadMetadata...");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
@ -508,7 +516,7 @@ nsresult OggDemuxer::ReadMetadata() {
|
||||||
bitstreams.AppendElement(codecState);
|
bitstreams.AppendElement(codecState);
|
||||||
serials.AppendElement(serial);
|
serials.AppendElement(serial);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(DemuxOggPage(tracks[i], page.to_opaque()))) {
|
if (NS_FAILED(DemuxOggPage(track, page.to_opaque()))) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -596,6 +604,7 @@ nsresult OggDemuxer::ReadMetadata() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mInfo.mMetadataDuration.isNothing()) {
|
if (mInfo.mMetadataDuration.isNothing()) {
|
||||||
|
OGG_DEBUG("Couldn't determine OGG file duration.");
|
||||||
mInfo.mMetadataDuration.emplace(TimeUnit::FromInfinity());
|
mInfo.mMetadataDuration.emplace(TimeUnit::FromInfinity());
|
||||||
}
|
}
|
||||||
if (HasAudio()) {
|
if (HasAudio()) {
|
||||||
|
|
@ -841,12 +850,7 @@ nsresult OggDemuxer::DemuxOggPage(TrackInfo::TrackType aType,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OggDemuxer::IsSeekable() const {
|
bool OggDemuxer::IsSeekable() const { return !mIsChained; }
|
||||||
if (mIsChained) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
UniquePtr<EncryptionInfo> OggDemuxer::GetCrypto() { return nullptr; }
|
UniquePtr<EncryptionInfo> OggDemuxer::GetCrypto() { return nullptr; }
|
||||||
|
|
||||||
|
|
@ -954,7 +958,8 @@ TimeIntervals OggDemuxer::GetBuffered(TrackInfo::TrackType aType) {
|
||||||
startOffset, endOffset, page, discard);
|
startOffset, endOffset, page, discard);
|
||||||
if (pageSyncResult == PAGE_SYNC_ERROR) {
|
if (pageSyncResult == PAGE_SYNC_ERROR) {
|
||||||
return TimeIntervals::Invalid();
|
return TimeIntervals::Invalid();
|
||||||
} else if (pageSyncResult == PAGE_SYNC_END_OF_RANGE) {
|
}
|
||||||
|
if (pageSyncResult == PAGE_SYNC_END_OF_RANGE) {
|
||||||
// Hit the end of range without reading a page, give up trying to
|
// Hit the end of range without reading a page, give up trying to
|
||||||
// find a start time for this buffered range, skip onto the next one.
|
// find a start time for this buffered range, skip onto the next one.
|
||||||
break;
|
break;
|
||||||
|
|
@ -1371,7 +1376,7 @@ OggDemuxer::PageSyncResult OggDemuxer::PageSync(
|
||||||
result > (aEndOffset - aOffset) || result < 0) {
|
result > (aEndOffset - aOffset) || result < 0) {
|
||||||
failedSkippedBytesVerify = true;
|
failedSkippedBytesVerify = true;
|
||||||
} else {
|
} else {
|
||||||
aSkippedBytes = result;
|
aSkippedBytes = AssertedCast<int>(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (failedSkippedBytesVerify) {
|
if (failedSkippedBytesVerify) {
|
||||||
|
|
@ -1414,10 +1419,8 @@ RefPtr<OggTrackDemuxer::SeekPromise> OggTrackDemuxer::Seek(
|
||||||
mQueuedSample = sample;
|
mQueuedSample = sample;
|
||||||
|
|
||||||
return SeekPromise::CreateAndResolve(seekTime, __func__);
|
return SeekPromise::CreateAndResolve(seekTime, __func__);
|
||||||
} else {
|
|
||||||
return SeekPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
|
|
||||||
__func__);
|
|
||||||
}
|
}
|
||||||
|
return SeekPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaRawData> OggTrackDemuxer::NextSample() {
|
RefPtr<MediaRawData> OggTrackDemuxer::NextSample() {
|
||||||
|
|
@ -1524,9 +1527,8 @@ RefPtr<OggTrackDemuxer::SamplesPromise> OggTrackDemuxer::GetSamples(
|
||||||
if (samples->GetSamples().IsEmpty()) {
|
if (samples->GetSamples().IsEmpty()) {
|
||||||
return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
|
return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
|
||||||
__func__);
|
__func__);
|
||||||
} else {
|
|
||||||
return SamplesPromise::CreateAndResolve(samples, __func__);
|
|
||||||
}
|
}
|
||||||
|
return SamplesPromise::CreateAndResolve(samples, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OggTrackDemuxer::Reset() {
|
void OggTrackDemuxer::Reset() {
|
||||||
|
|
@ -1552,11 +1554,9 @@ OggTrackDemuxer::SkipToNextRandomAccessPoint(const TimeUnit& aTimeThreshold) {
|
||||||
OGG_DEBUG("next sample: %f (parsed: %d)", sample->mTime.ToSeconds(),
|
OGG_DEBUG("next sample: %f (parsed: %d)", sample->mTime.ToSeconds(),
|
||||||
parsed);
|
parsed);
|
||||||
return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
|
return SkipAccessPointPromise::CreateAndResolve(parsed, __func__);
|
||||||
} else {
|
|
||||||
SkipFailureHolder failure(NS_ERROR_DOM_MEDIA_END_OF_STREAM, parsed);
|
|
||||||
return SkipAccessPointPromise::CreateAndReject(std::move(failure),
|
|
||||||
__func__);
|
|
||||||
}
|
}
|
||||||
|
SkipFailureHolder failure(NS_ERROR_DOM_MEDIA_END_OF_STREAM, parsed);
|
||||||
|
return SkipAccessPointPromise::CreateAndReject(std::move(failure), __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeIntervals OggTrackDemuxer::GetBuffered() {
|
TimeIntervals OggTrackDemuxer::GetBuffered() {
|
||||||
|
|
@ -1618,7 +1618,7 @@ struct nsDemuxerAutoOggSyncState {
|
||||||
mSandbox.free_in_sandbox(mState);
|
mSandbox.free_in_sandbox(mState);
|
||||||
}
|
}
|
||||||
rlbox_sandbox_ogg& mSandbox;
|
rlbox_sandbox_ogg& mSandbox;
|
||||||
tainted_ogg<ogg_sync_state*> mState;
|
tainted_ogg<ogg_sync_state*> mState{};
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeUnit OggDemuxer::RangeEndTime(TrackInfo::TrackType aType,
|
TimeUnit OggDemuxer::RangeEndTime(TrackInfo::TrackType aType,
|
||||||
|
|
@ -1809,7 +1809,7 @@ nsresult OggDemuxer::GetSeekRanges(TrackInfo::TrackType aType,
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
for (uint32_t index = 0; index < cached.Length(); index++) {
|
for (uint32_t index = 0; index < cached.Length(); index++) {
|
||||||
auto& range = cached[index];
|
const auto& range = cached[index];
|
||||||
TimeUnit startTime = TimeUnit::Invalid();
|
TimeUnit startTime = TimeUnit::Invalid();
|
||||||
TimeUnit endTime = TimeUnit::Invalid();
|
TimeUnit endTime = TimeUnit::Invalid();
|
||||||
if (NS_FAILED(Reset(aType))) {
|
if (NS_FAILED(Reset(aType))) {
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ class OggDemuxer : public MediaDataDemuxer,
|
||||||
|
|
||||||
nsresult Reset(TrackInfo::TrackType aType);
|
nsresult Reset(TrackInfo::TrackType aType);
|
||||||
|
|
||||||
static const nsString GetKind(const nsCString& aRole);
|
static nsString GetKind(const nsCString& aRole);
|
||||||
static void InitTrack(MessageField* aMsgInfo, TrackInfo* aInfo, bool aEnable);
|
static void InitTrack(MessageField* aMsgInfo, TrackInfo* aInfo, bool aEnable);
|
||||||
|
|
||||||
// Really private!
|
// Really private!
|
||||||
|
|
@ -307,7 +307,7 @@ class OggDemuxer : public MediaDataDemuxer,
|
||||||
bool HasVideo() const;
|
bool HasVideo() const;
|
||||||
bool HasAudio() const;
|
bool HasAudio() const;
|
||||||
bool HasSkeleton() const {
|
bool HasSkeleton() const {
|
||||||
return mSkeletonState != 0 && mSkeletonState->mActive;
|
return mSkeletonState != nullptr && mSkeletonState->mActive;
|
||||||
}
|
}
|
||||||
bool HaveStartTime() const;
|
bool HaveStartTime() const;
|
||||||
bool HaveStartTime(TrackInfo::TrackType aType);
|
bool HaveStartTime(TrackInfo::TrackType aType);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue