nsresult GMPVideoDecoderParent::Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame, bool aMissingFrames, const nsTArray<uint8_t>& aCodecSpecificInfo, int64_t aRenderTimeMs) { LOGV(("GMPVideoDecoderParent[%p]::Decode() timestamp=%lld keyframe=%d%s", this, aInputFrame->TimeStamp(), aInputFrame->FrameType() == kGMPKeyFrame, CryptoInfo(aInputFrame).get())); if (!mIsOpen) { LOGE(("GMPVideoDecoderParent[%p]::Decode() ERROR; dead GMPVideoDecoder", this)); NS_WARNING("Trying to use an dead GMP video decoder"); return NS_ERROR_FAILURE; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); GMPUniquePtr<GMPVideoEncodedFrameImpl> inputFrameImpl( static_cast<GMPVideoEncodedFrameImpl*>(aInputFrame.release())); // Very rough kill-switch if the plugin stops processing. If it's merely // hung and continues, we'll come back to life eventually. // 3* is because we're using 3 buffers per frame for i420 data for now. if ((NumInUse(GMPSharedMem::kGMPFrameData) > 3*GMPSharedMem::kGMPBufLimit) || (NumInUse(GMPSharedMem::kGMPEncodedData) > GMPSharedMem::kGMPBufLimit)) { LOGE(("GMPVideoDecoderParent[%p]::Decode() ERROR; shmem buffer limit hit frame=%d encoded=%d", this, NumInUse(GMPSharedMem::kGMPFrameData), NumInUse(GMPSharedMem::kGMPEncodedData))); return NS_ERROR_FAILURE; } GMPVideoEncodedFrameData frameData; inputFrameImpl->RelinquishFrameData(frameData); if (!SendDecode(frameData, aMissingFrames, aCodecSpecificInfo, aRenderTimeMs)) { LOGE(("GMPVideoDecoderParent[%p]::Decode() ERROR; SendDecode() failure.", this)); return NS_ERROR_FAILURE; } mFrameCount++; // Async IPC, we don't have access to a return value. return NS_OK; }
nsresult GMPAudioDecoderParent::Decode(GMPAudioSamplesImpl& aEncodedSamples) { if (!mIsOpen) { NS_WARNING("Trying to use a dead GMP Audio decoder!"); return NS_ERROR_FAILURE; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); GMPAudioEncodedSampleData samples; aEncodedSamples.RelinquishData(samples); if (!SendDecode(samples)) { return NS_ERROR_FAILURE; } // Async IPC, we don't have access to a return value. return NS_OK; }
nsresult GMPVideoDecoderParent::Decode(GMPVideoEncodedFrame* aInputFrame, bool aMissingFrames, const nsTArray<uint8_t>& aCodecSpecificInfo, int64_t aRenderTimeMs) { nsAutoRef<GMPVideoEncodedFrame> autoDestroy(aInputFrame); if (!mCanSendMessages) { NS_WARNING("Trying to use an invalid GMP video decoder!"); return NS_ERROR_FAILURE; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); auto inputFrameImpl = static_cast<GMPVideoEncodedFrameImpl*>(aInputFrame); GMPVideoEncodedFrameData frameData; inputFrameImpl->RelinquishFrameData(frameData); // Very rough kill-switch if the plugin stops processing. If it's merely // hung and continues, we'll come back to life eventually. // 3* is because we're using 3 buffers per frame for i420 data for now. if (NumInUse(kGMPFrameData) > 3*GMPSharedMemManager::kGMPBufLimit || NumInUse(kGMPEncodedData) > GMPSharedMemManager::kGMPBufLimit) { return NS_ERROR_FAILURE; } if (!SendDecode(frameData, aMissingFrames, aCodecSpecificInfo, aRenderTimeMs)) { return NS_ERROR_FAILURE; } // Async IPC, we don't have access to a return value. return NS_OK; }