Old 30th September 2019, 17:33   #1
ahmett
Junior Member
 
Join Date: Jan 2008
Posts: 21
Help with system plugin

I want to get the list of decoder GUIDs supported by the graphics hardware but I'm really bad with the system plugin.So can someone help me to get it by using the following function with the system plugin?


https://docs.microsoft.com/en-us/win...om=MSDN#syntax

code:
UINT deviceCount;
GUID* decoderDevices = nullptr;
hr = decoderService->GetDecoderDeviceGuids(&deviceCount, &decoderDevices);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("IDirectXVideoDecoderServer::GetDecoderDeviceGuids failed with error %X", hr);
return hr;
}

bool found = false;
for (UINT i = 0; i < deviceCount; i++) {
if (decoderDevices[i] == DXVA2_ModeH264_E ||
decoderDevices[i] == DXVA2_Intel_ModeH264_E) {
mDecoderGUID = decoderDevices[i];
found = true;
break;
}
}
CoTaskMemFree(decoderDevices);

if (!found) {
aFailureReason.AssignLiteral("Failed to find an appropriate decoder GUID");
return E_FAIL;
}

ahmett is offline   Reply With Quote
Old 1st October 2019, 11:39   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 882
You could write this into a plugin instead, it looks too long and messy to write this in script system plugin syntax. All it has to return is either 'error', or 'ok' then the number of guids and then just 'pop' each guid off the stack.

Anders might be able to do some magic with the system plugin though.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 1st October 2019, 12:47   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,176
If all you need is this exact code then you can do it with the System plug-in. I'll whip up some code later.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st October 2019, 13:08   #4
ahmett
Junior Member
 
Join Date: Jan 2008
Posts: 21
Thanks, I'll wait it out.
ahmett is offline   Reply With Quote
Old 1st October 2019, 17:52   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,176
Your code is actually incomplete, you failed to show how you create the device.

This should be close enough
PHP Code:

!include LogicLib.nsh
!include Win\COM.nsh

!define /IfNDef D3D_SDK_VERSION 32
!define /IfNDef D3DADAPTER_DEFAULT 0
!define /IfNDef D3DDEVTYPE_HAL 1
!define /IfNDef D3DCREATE_HARDWARE_VERTEXPROCESSING 64
!define /IfNDef D3DFMT_UNKNOWN 0
#D3DFMT_R8G8B8                20
#D3DFMT_A8R8G8B8              21
!define /IfNDef D3DMULTISAMPLE_NONE 0
!define /IfNDef D3DSWAPEFFECT_DISCARD 1
!define /IfNDef D3DPRESENT_INTERVAL_DEFAULT 0
!define /IfNDef IID_IDirectXVideoDecoderService {fc51a551-d5e7-11d9-af55-00054e43ff02}
!
define /IfNDef DXVA2_ModeH264_E       {1b81be68-a0c7-11d3-b984-00c04f2e73c5}
!
define /IfNDef DXVA2_Intel_ModeH264_E {604F8E68-4951-4c54-88FE-ABD25C15B3D6}


Section

System
::Call 'D3d9::Direct3DCreate9(i${D3D_SDK_VERSION})p.r1'
${If} $1 Z0
    Abort 
"Direct3DCreate9 failed"
${EndIf}
System::Call '*(i0,i0,i${D3DFMT_UNKNOWN},i0,i${D3DMULTISAMPLE_NONE},i0,i${D3DSWAPEFFECT_DISCARD},p$hWndParent,i1,i0,i${D3DFMT_UNKNOWN},i0,i0,i${D3DPRESENT_INTERVAL_DEFAULT})p.r3'

DetailPrint "Calling $1 ($3)"
System::Call `$1->16(i${D3DADAPTER_DEFAULT},i${D3DDEVTYPE_HAL},p0,i${D3DCREATE_HARDWARE_VERTEXPROCESSING},pr3,*p0r2)i.r0`
System::Free $3
${IUnknown::Release} $""
DetailPrint hr=$0,IDirect3DDevice9=$2
${If} $0
    Abort 
"CreateDevice failed"
${EndIf}

System::Call 'Dxva2::DXVA2CreateVideoService(pr2,&g16 "${IID_IDirectXVideoDecoderService}",*p0r1)i.r0'
${IUnknown::Release} $""
DetailPrint hr=$0,IDirectXVideoDecoderService=$1
${If} $0
    Abort 
"DXVA2CreateVideoService failed"
${EndIf}

StrCpy $"" GUID
System
::Call '$1->4(*i0r2, *p0r3)i.r0'
${If} $>= 0
    DetailPrint Count
=$2
    StrCpy 
$4 0 Offset
    StrCpy 
$5 0 Index
    loop
:
        ${
IfThen} $>= $${|} Goto end ${|}
        
System::Call '*$3(&i$4,&g16.r6)'
        
DetailPrint GUID#$5=$6
        
${If} $== ${DXVA2_ModeH264_E}
        ${
OrIf} $== ${DXVA2_Intel_ModeH264_E}
            
StrCpy $$6
            StrCpy 
$$Stop search early if we find a match
        
${EndIf}
        
IntOp $$1
        IntOp 
$$16
        
Goto loop
    end
:
    
System::Call 'OLE32::CoTaskMemFree(pr3)'
${EndIf}
${
IUnknown::Release} $""

${If} $!= ""
    
DetailPrint "Found $9 DXVA2 decoder"
${Else}
    
Abort "Failed to find an appropriate decoder GUID"
${EndIf}

SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd October 2019, 00:01   #6
ahmett
Junior Member
 
Join Date: Jan 2008
Posts: 21
Thank you, you're excellent!
ahmett is offline   Reply With Quote
Old 2nd October 2019, 11:18   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,176
Quote:
Originally Posted by ahmett View Post
Thank you, you're excellent!
You should probably modify my code a bit to suit your needs. I'm asking for hardware here but depending on what you need, you might be able to use the WARP software renderer.

Also, it might fail for silent installers because it asks for windowed mode so you should disable silent installer or create a fake window or ask for full-screen.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump