nsresult AppleVDADecoder::InitializeSession() { OSStatus rv; AutoCFRelease<CFDictionaryRef> decoderConfig = CreateDecoderSpecification(); AutoCFRelease<CFDictionaryRef> outputConfiguration = CreateOutputConfiguration(); rv = VDADecoderCreate(decoderConfig, outputConfiguration, (VDADecoderOutputCallback*)PlatformCallback, this, &mDecoder); if (rv != noErr) { NS_WARNING("AppleVDADecoder: Couldn't create hardware VDA decoder"); return NS_ERROR_FAILURE; } return NS_OK; }
nsresult AppleVTDecoder::InitializeSession() { OSStatus rv; AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions(); rv = CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_H264, mPictureWidth, mPictureHeight, extensions, &mFormat); if (rv != noErr) { NS_ERROR("Couldn't create format description!"); return NS_ERROR_FAILURE; } // Contruct video decoder selection spec. AutoCFRelease<CFDictionaryRef> spec = CreateDecoderSpecification(); // Contruct output configuration. AutoCFRelease<CFDictionaryRef> outputConfiguration = CreateOutputConfiguration(); VTDecompressionOutputCallbackRecord cb = { PlatformCallback, this }; rv = VTDecompressionSessionCreate(kCFAllocatorDefault, mFormat, spec, // Video decoder selection. outputConfiguration, // Output video format. &cb, &mSession); if (rv != noErr) { NS_ERROR("Couldn't create decompression session!"); return NS_ERROR_FAILURE; } if (AppleVTLinker::skPropUsingHWAccel) { CFBooleanRef isUsingHW = nullptr; rv = VTSessionCopyProperty(mSession, AppleVTLinker::skPropUsingHWAccel, kCFAllocatorDefault, &isUsingHW); if (rv != noErr) { LOG("AppleVTDecoder: system doesn't support hardware acceleration"); } mIsHardwareAccelerated = rv == noErr && isUsingHW == kCFBooleanTrue; LOG("AppleVTDecoder: %s hardware accelerated decoding", mIsHardwareAccelerated ? "using" : "not using"); } else { LOG("AppleVTDecoder: couldn't determine hardware acceleration status."); } return NS_OK; }
nsresult AppleVTDecoder::InitializeSession() { OSStatus rv; #ifdef LOG_MEDIA_SHA1 SHA1Sum avc_hash; avc_hash.update(mExtraData->Elements(),mExtraData->Length()); uint8_t digest_buf[SHA1Sum::kHashSize]; avc_hash.finish(digest_buf); nsAutoCString avc_digest; for (size_t i = 0; i < sizeof(digest_buf); i++) { avc_digest.AppendPrintf("%02x", digest_buf[i]); } LOG("AVCDecoderConfig %ld bytes sha1 %s", mExtraData->Length(), avc_digest.get()); #endif // LOG_MEDIA_SHA1 AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions(); rv = CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_H264, mPictureWidth, mPictureHeight, extensions, &mFormat); if (rv != noErr) { NS_ERROR("Couldn't create format description!"); return NS_ERROR_FAILURE; } // Contruct video decoder selection spec. AutoCFRelease<CFDictionaryRef> spec = CreateDecoderSpecification(); // Contruct output configuration. AutoCFRelease<CFDictionaryRef> outputConfiguration = CreateOutputConfiguration(); VTDecompressionOutputCallbackRecord cb = { PlatformCallback, this }; rv = VTDecompressionSessionCreate(kCFAllocatorDefault, mFormat, spec, // Video decoder selection. outputConfiguration, // Output video format. &cb, &mSession); if (rv != noErr) { NS_ERROR("Couldn't create decompression session!"); return NS_ERROR_FAILURE; } if (AppleVTLinker::skPropUsingHWAccel) { CFBooleanRef isUsingHW = nullptr; rv = VTSessionCopyProperty(mSession, AppleVTLinker::skPropUsingHWAccel, kCFAllocatorDefault, &isUsingHW); if (rv != noErr) { LOG("AppleVTDecoder: system doesn't support hardware acceleration"); } mIsHardwareAccelerated = rv == noErr && isUsingHW == kCFBooleanTrue; LOG("AppleVTDecoder: %s hardware accelerated decoding", mIsHardwareAccelerated ? "using" : "not using"); } else { LOG("AppleVTDecoder: couldn't determine hardware acceleration status."); } return NS_OK; }