Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
Minor stability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanrn committed Nov 21, 2019
1 parent 087f0cf commit f87f965
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
43 changes: 37 additions & 6 deletions dom/media/platforms/agnostic/VPXDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ VPXDecoder::~VPXDecoder()
rlbox_vpx->freeInSandbox(p_mVPXAlpha);
printf("Destroying Vpx Sandbox\n");
rlbox_vpx->destroySandbox();
rlbox_vpx = nullptr;
#endif
MOZ_COUNT_DTOR(VPXDecoder);
if (vpxDecodeInvocations > 5) {
Expand All @@ -206,8 +207,10 @@ VPXDecoder::Shutdown()
RefPtr<VPXDecoder> self = this;
return InvokeAsync(mTaskQueue, __func__, [self, this]() {
#if defined(NACL_SANDBOX_USE_NEW_CPP_API) || defined(WASM_SANDBOX_USE_NEW_CPP_API) || defined(PS_SANDBOX_USE_NEW_CPP_API)
sandbox_invoke(rlbox_vpx, vpx_codec_destroy, p_mVPX);
sandbox_invoke(rlbox_vpx, vpx_codec_destroy, p_mVPXAlpha);
if (rlbox_vpx) {
sandbox_invoke(rlbox_vpx, vpx_codec_destroy, p_mVPX);
sandbox_invoke(rlbox_vpx, vpx_codec_destroy, p_mVPXAlpha);
}
#else
vpx_codec_destroy(&mVPX);
vpx_codec_destroy(&mVPXAlpha);
Expand Down Expand Up @@ -653,19 +656,21 @@ VPXDecoder::IsKeyframe(RLBoxSandbox<TRLSandboxV>* rlbox_vpx, Span<const uint8_t>
//unsafe is fine memcpy
memcpy(buff_copy.UNSAFE_Unverified(), aData, aLength);

bool retBool = false;
if (aCodec == Codec::VP8) {
tainted<vpx_codec_iface_t *, TRLSandboxV> ret = sandbox_invoke(rlbox_vpx, vpx_codec_vp8_dx);
sandbox_invoke(rlbox_vpx, vpx_codec_peek_stream_info, ret, buff_copy, aLength, p_si);
return bool(p_si->is_kf.UNSAFE_Unverified(/* TODO */));
retBool = bool(p_si->is_kf.UNSAFE_Unverified(/* TODO */));
} else if (aCodec == Codec::VP9) {
tainted<vpx_codec_iface_t *, TRLSandboxV> ret = sandbox_invoke(rlbox_vpx, vpx_codec_vp9_dx);
sandbox_invoke(rlbox_vpx, vpx_codec_peek_stream_info, ret, buff_copy, aLength, p_si);
return bool(p_si->is_kf.UNSAFE_Unverified(/* TODO */));
retBool = bool(p_si->is_kf.UNSAFE_Unverified(/* TODO */));
}

rlbox_vpx->freeInSandbox(p_si);
rlbox_vpx->freeInSandbox(buff_copy);

return false;
return retBool;
}
#else
/* static */
Expand All @@ -692,6 +697,31 @@ VPXDecoder::IsKeyframe(Span<const uint8_t> aBuffer, Codec aCodec)
gfx::IntSize
VPXDecoder::GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec)
{
#if defined(NACL_SANDBOX_USE_NEW_CPP_API) || defined(WASM_SANDBOX_USE_NEW_CPP_API) || defined(PS_SANDBOX_USE_NEW_CPP_API)
auto rlbox_vpx = getKeyframeSandbox();
auto p_si = rlbox_vpx->mallocInSandbox<vpx_codec_stream_info_t>();
// Safe as this is just a memset
PodZero(p_si.UNSAFE_Unverified());
p_si->sz = sizeof(*p_si);

auto aData = aBuffer.Elements();
auto aLength = aBuffer.Length();
tainted<uint8_t*, TRLSandboxV> buff_copy = rlbox_vpx->mallocInSandbox<uint8_t>(aLength);
//unsafe is fine memcpy
memcpy(buff_copy.UNSAFE_Unverified(), aData, aLength);

if (aCodec == Codec::VP8) {
tainted<vpx_codec_iface_t *, TRLSandboxV> ret = sandbox_invoke(rlbox_vpx, vpx_codec_vp8_dx);
sandbox_invoke(rlbox_vpx, vpx_codec_peek_stream_info, ret, buff_copy, aLength, p_si);
} else if (aCodec == Codec::VP9) {
tainted<vpx_codec_iface_t *, TRLSandboxV> ret = sandbox_invoke(rlbox_vpx, vpx_codec_vp9_dx);
sandbox_invoke(rlbox_vpx, vpx_codec_peek_stream_info, ret, buff_copy, aLength, p_si);
}
auto retSize = gfx::IntSize(p_si->w.UNSAFE_Unverified(), p_si->h.UNSAFE_Unverified());
rlbox_vpx->freeInSandbox(p_si);
rlbox_vpx->freeInSandbox(buff_copy);
return retSize;
#else
vpx_codec_stream_info_t si;
PodZero(&si);
si.sz = sizeof(si);
Expand All @@ -702,9 +732,10 @@ VPXDecoder::GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec)
} else if (aCodec == Codec::VP9) {
vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), aBuffer.Elements(), aBuffer.Length(), &si);
}

return gfx::IntSize(si.w, si.h);
#endif
}

} // namespace mozilla
#undef LOG

Expand Down
6 changes: 5 additions & 1 deletion dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class FFmpegDecoderModule : public PlatformDecoderModule
// check.

// Temporarily, disable the FFMpeg decoder so we fall back to the VP9 decoder
return nullptr;
std::string mime = aParams.VideoConfig().mMimeType.get();
if (mime == "video/vp9") {
return nullptr;
}

if (aParams.VideoConfig().HasAlpha()) {
return nullptr;
}
Expand Down
2 changes: 2 additions & 0 deletions netwerk/streamconv/converters/nsHTTPCompressConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ nsHTTPCompressConv::nsHTTPCompressConv()
nsHTTPCompressConv::~nsHTTPCompressConv()
{
#if defined(NACL_SANDBOX_USE_NEW_CPP_API) || defined(WASM_SANDBOX_USE_NEW_CPP_API) || defined(PS_SANDBOX_USE_NEW_CPP_API)
// sandbox may not have been initialized, in which case, no cleanup
if (!rlbox_sbx) { return; }
auto rlbox_zlib = rlbox_sbx->rlbox_zlib;
#endif
LOG(("nsHttpCompresssConv %p dtor\n", this));
Expand Down

0 comments on commit f87f965

Please sign in to comment.