GMPErr GMPVideoEncoderParent::Encode(UniquePtr<GMPVideoi420Frame> aInputFrame, const nsTArray<uint8_t>& aCodecSpecificInfo, const nsTArray<GMPVideoFrameType>& aFrameTypes) { if (!mIsOpen) { NS_WARNING("Trying to use an dead GMP video encoder"); return GMPGenericErr; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); UniquePtr<GMPVideoi420FrameImpl> inputFrameImpl( static_cast<GMPVideoi420FrameImpl*>(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)) { return GMPGenericErr; } GMPVideoi420FrameData frameData; inputFrameImpl->InitFrameData(frameData); if (!SendEncode(frameData, aCodecSpecificInfo, aFrameTypes)) { return GMPGenericErr; } // Async IPC, we don't have access to a return value. return GMPNoErr; }
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 GMPVideoDecoderParent::Decode(UniquePtr<GMPVideoEncodedFrame> aInputFrame, bool aMissingFrames, const nsTArray<uint8_t>& aCodecSpecificInfo, int64_t aRenderTimeMs) { if (!mIsOpen) { NS_WARNING("Trying to use an dead GMP video decoder"); return NS_ERROR_FAILURE; } MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread()); UniquePtr<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)) { return NS_ERROR_FAILURE; } GMPVideoEncodedFrameData frameData; inputFrameImpl->RelinquishFrameData(frameData); if (!SendDecode(frameData, aMissingFrames, aCodecSpecificInfo, aRenderTimeMs)) { return NS_ERROR_FAILURE; } // Async IPC, we don't have access to a return value. return NS_OK; }