LudovicRansau / nativelibs4java

Automatically exported from code.google.com/p/nativelibs4java
0 stars 0 forks source link

BridJ: Null virtual pointer table! #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I am trying to access webcam using BridJ.

The following code throws RuntimeException(Null virtual pointer table !):

ICreateDevEnum createDevEnum = COMRuntime.newInstance(ICreateDevEnum.class);
System.out.println("ICreateDevEnum: " + createDevEnum);
Pointer<IEnumMoniker> penum = Pointer.allocate(IEnumMoniker.class);
Pointer<Pointer<IEnumMoniker>> ppenum = Pointer.pointerToPointer(penum);
int hres = 
createDevEnum.CreateClassEnumerator(GUID.parseGUID128Bits("860BB310-5D01-11d0-BD
3B-00A0C911CE86").as(Byte.class), ppenum, 0 /*dwFlags*/);
System.out.println("hres: " + hres);

IEnumMoniker enumMoniker = penum.getNativeObject(IEnumMoniker.class);
System.out.println("enumMoniker: " + enumMoniker);

// exception is thrown on next line..        
int skip = enumMoniker.Skip(1);

Thanks, Andrei.

Original issue reported on code.google.com by andrei.s...@gmail.com on 5 Mar 2011 at 11:30

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Andrei,

Thanks for your well-documented report :-)

The major issue with your bindings is the ordering of virtual methods : the 
@Virtual(x) annotation starts at 0, not 1, and the order of the methods must be 
exactly the same as in the source code, which is unfortunately different from 
the order in which the MSDN doc lists the methods :-S (for instance, the 
IEnumMoniker methods are Next, Skip, Reset and Clone, which is not the order 
here : http://msdn.microsoft.com/en-us/library/ms692852(v=vs.85).aspx).

You can have a look at C:\Program Files\Microsoft 
SDKs\Windows\v6.0A\Include\ObjIdl.h to see the exact signatures, which should 
be present if you've installed Visual Studio C++ Express (free download).

Hopefully I'll find the time to make JNAerator deal with the COM specifics 
someday, so we won't have to deal with such annoying issues...

Attached : modified files that appear to work (notice the allocatePointer use, 
to avoid the lengthier equivalent you previously used).

Please let me know if you're facing other issues (this is gonna feed the FAQ 
and COM pages :-))

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 5 Mar 2011 at 3:25

Attachments:

GoogleCodeExporter commented 8 years ago
Also, I've just added some GUID definitions to BridJ, which you might want to 
grab from the SVN version :
http://code.google.com/p/nativelibs4java/source/detail?r=1730

(build instructions : http://code.google.com/p/bridj/wiki/Build)

Cheers

Original comment by olivier.chafik@gmail.com on 5 Mar 2011 at 4:52

GoogleCodeExporter commented 8 years ago
Great! Thank you very much!

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 5 Mar 2011 at 5:06

GoogleCodeExporter commented 8 years ago
Another questions is regarding "IPropertyBag Interface" 
(http://msdn.microsoft.com/en-us/library/aa768196%28v=vs.85%29.aspx) and 
VARIANT? Are there Java VARIANT implemented?

Thanks in advance, Andrei.

Original comment by andrei.s...@gmail.com on 5 Mar 2011 at 5:35

GoogleCodeExporter commented 8 years ago
Hi Andrei,

There is COMRuntime.VARIANT, which isn't complete yet but might be enough for 
this use.
It's hardly tested, please let me know if you face issues with it :-)

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 6 Mar 2011 at 9:44

GoogleCodeExporter commented 8 years ago
Hi Olivier,

Ups.. right. IDispatch.VARIANT actually. Thanks!
I have more questions to clarify.
Let me ask it here (to avoid more 'Invalid' issues opened :))

- Are structures that contains other structures as fields supported now?
- Is SizeT type an analogue of JNA's NativeLong, right?
- How to access 'errno' static variable in 'c' library (Linux)?
In JNA:
Pointer perrno = NativeLibrary.getInstance("c").getFunction("errno");
int errno = perrno.getInt(0);
- What is the appropriate type for Windows HANDLE?
In JNA I have "class HANDLE extends PointerType"

Thanks in advance, Andrei.

Original comment by andrei.s...@gmail.com on 6 Mar 2011 at 11:01

GoogleCodeExporter commented 8 years ago
Also I found in the provided sources..
If you change in the ICreateDevEnum#CreateClassEnumerator():
@Virtual(0) -> @Virtual(3) (3 or greater) than CPU -> 100%, looks like an 
infinite cycle.
If Virtual(1) or Virtual(2) then it executes correctly (but index is not 
correct, right) ?

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 6 Mar 2011 at 2:26

GoogleCodeExporter commented 8 years ago
Hi Andrei,

Discovered I've long lived without proper support for unions in BridJ, when 
testing / improving VARIANT...
I'm working on it right now, it's just a few lines to get right in StructIO (in 
the meanwhile, VARIANT won't work at all, even though simple workarounds are 
possible...). I'll keep you updated :-)

To answer your questions :
- structures in structures should be working, if they don't please file a bug
- SizeT represents the 'size_t' type (always the same size as a pointer, in 
practice), whereas CLong is a 'long' and same as JNA's NativeLong. The trick is 
that 'long' is always 'size_t' (it is with GCC, not with Microsoft VC++ where 
'long' is always 32 bits). See 
http://nativelibs4java.sourceforge.net/bridj/api/development/org/bridj/CLong.htm
l and 
http://nativelibs4java.sourceforge.net/bridj/api/development/org/bridj/SizeT.htm
l for reference.
- BridJ.getLibrary("c").getSymbolPointer("errno")
- HANDLE is just a Pointer<?>, but you can create a class HANDLE extends 
TypedPointer { ... } (important : reimplement the long (and Pointer) 
constructor(s) so that the HANDLE type can be used throughout BridJ
- Virtual indexes : if you have the wrong index anywhere, things indeed end up 
in infinite loops or wrong methods being called... hence the importance of 
watching out closely... (the COM classes begin by a virtual table pointer which 
contains pointers to C++ methods ; the index says which method should be used, 
with the offset of all super classes ; a wrong index may make you call the 
wrong method with a different signature or, worse, calling some code that is 
not a method at all !)

Cheers

Original comment by olivier.chafik@gmail.com on 6 Mar 2011 at 5:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Opened  issue #51  for unions bug (bad struct analysis for VARIANT).

Original comment by olivier.chafik@gmail.com on 6 Mar 2011 at 5:37

GoogleCodeExporter commented 8 years ago
(for errno, I meant BridJ.getNativeLibrary : see revision #1736)

Original comment by olivier.chafik@gmail.com on 6 Mar 2011 at 5:42

GoogleCodeExporter commented 8 years ago
Thank you very much for clarification and your efforts!
Will try to implement AviCap wrapper (for webcam access) until VARIANT issue 
will be resolved.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 6 Mar 2011 at 5:52

GoogleCodeExporter commented 8 years ago
You're welcome :-)
Btw, made a typo : "'long' is always 'size_t'" should read "'long' is NOT 
always 'size_t'"

Original comment by olivier.chafik@gmail.com on 6 Mar 2011 at 6:38

GoogleCodeExporter commented 8 years ago
Hi Olivier,

I have more questions :)

- Are there any C sizeof(struct) alternative?
Not like JNA Structure#size() method, but static method.
Something like int StructObject.sizeof(Class<T extends StructObject> class);

- How to manage User32.SendMessageA, User32.SendMessageW to use 
User32.SendMessage?
Like in JNA: Native.register(NativeLibrary.getInstance("user32", 
W32APIOptions.DEFAULT_OPTIONS));

- To be able to use AviCap I need JFrame HWND.
Like in JNA: new HWND(Native.getComponentPointer(frame)).

Is JAWT package useful for this functionality or ...?

Regards, Andrei.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 12:50

GoogleCodeExporter commented 8 years ago
I tried to use new HWND(JAWTUtils.getNativePeerHandle(frame)),
but...

Found library org.bridj.NativeLibrary@1690726
Symbols found : 1
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.Pointer 
org.bridj.jawt.JAWT.GetDrawingSurface()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.Pointer 
org.bridj.jawt.JAWT.Unlock()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.Pointer 
org.bridj.jawt.JAWT.FreeDrawingSurface()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.Pointer 
org.bridj.jawt.JAWT.GetComponent()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.Pointer 
org.bridj.jawt.JAWT.Lock()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native int 
org.bridj.jawt.JAWT.version()
07.03.2011 2:58:14 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public native org.bridj.jawt.JAWT 
org.bridj.jawt.JAWT.version(int)
java.lang.UnsatisfiedLinkError: 
org.bridj.jawt.JAWT.version(I)Lorg/bridj/jawt/JAWT;
    at org.bridj.jawt.JAWT.version(Native Method)
    at org.bridj.jawt.JAWTUtils.getNativePeerHandle(JAWTUtils.java:52)
    at bridj.win32.example.ExVideoCapturer.main(ExVideoCapturer.java:81)

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 1:01

GoogleCodeExporter commented 8 years ago
Hi Andrei,

- In the latest snapshot, there's BridJ.sizeOf(Type) (in previous versions it 
used to take a struct instance, not its type). Use with 
BridJ.sizeOf(MyStruct.class), for instance.
- For Windows Unicode / single byte alternatives there's no built-in mechanism 
yet, you can either choose the version you want and use its full name or use 
the short name and add a @Name("SendMessageW") public static native xxx 
SendMessage(yyy...);
- For the AWT peer, it's indeed 
JAWTUtils.getNativePeerHandle(java.awt.Component). The issue you're 
experiencing is unexpected and would deserve a report of its own. Could you try 
the latest snapshot with BRIDJ_JAWT_LIBRARY=c:\full\path\to\jre\bin\jawt.dll ? 
(and tell me which version of the JRE / JDK you're using, including 
32/64bits-ness)

Cheers

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 8:33

GoogleCodeExporter commented 8 years ago
Ok, the jawt issue is fixed in the latest snapshot 
(http://nativelibs4java.sourceforge.net/maven/com/nativelibs4java/bridj/0.4-SNAP
SHOT/bridj-0.4-SNAPSHOT-shaded.jar).
The problem was 1) I had no auto-test for it 2) I wrote it before the Big 
Breaking Structs Refactoring (where natively-bound structs were replaced by 
faster JNAerated methods).

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 9:30

GoogleCodeExporter commented 8 years ago
Hi Olivier,

Thanks!
Just checked it on my Windows XP (32bit), jdk1.6.0_18 environment and get:
java.lang.RuntimeException: Failed to register class org.bridj.jawt.JAWT
    at org.bridj.CRuntime.register(CRuntime.java:253)
    at org.bridj.CRuntime.register(CRuntime.java:178)
    at org.bridj.CRuntime$CTypeInfo.<init>(CRuntime.java:51)
    at org.bridj.CRuntime.getTypeInfo(CRuntime.java:174)
    at org.bridj.BridJ.getTypeInfo(BridJ.java:251)
    at org.bridj.BridJ.initialize(BridJ.java:631)
    at org.bridj.NativeObject.<init>(NativeObject.java:23)
    at org.bridj.StructObject.<init>(StructObject.java:15)
    at org.bridj.jawt.JAWT.<init>(JAWT.java:17)
    at org.bridj.jawt.JAWTUtils.getNativePeerHandle(JAWTUtils.java:42)
    at bridj.win32.example.ExVideoCapturer.main(ExVideoCapturer.java:81)
Caused by: java.io.FileNotFoundException: Library 'jawt' was not found in path 
'[C:\Program Files\Java\jdk1.6.0_18\jre\lib, null, ., C:\Program 
Files\JavaFX\javafx-sdk1.0\bin, C:\Program 
Files\JavaFX\javafx-sdk1.0\emulator\bin, C:\Program Files\PC Connectivity 
Solution\, C:\WINDOWS\system32, C:\WINDOWS, C:\WINDOWS\System32\Wbem, 
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\, 
D:\environment\apache-maven-2.0.9\bin, C:\TAL\, D:\environment\TAL\, C:\Program 
Files\Darwin Streaming Server, D:\environment\GTK2-Runtime\bin, 
D:\environment\QuickTime\QTSystem\, C:\Program Files\Java\jdk1.6.0_18\bin, ., 
C:\WINDOWS\Sun\Java\bin, C:\WINDOWS\system32, C:\WINDOWS, C:\Program 
Files\JavaFX\javafx-sdk1.0\bin, C:\Program 
Files\JavaFX\javafx-sdk1.0\emulator\bin, C:\Program Files\PC Connectivity 
Solution\, C:\WINDOWS\system32, C:\WINDOWS, C:\WINDOWS\System32\Wbem, 
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\, 
D:\environment\apache-maven-2.0.9\bin, C:\TAL\, D:\environment\TAL\, C:\Program 
Files\Darwin Streaming Server, D:\environment\GTK2-Runtime\bin, 
D:\environment\QuickTime\QTSystem\]'
    at org.bridj.BridJ.getNativeLibrary(BridJ.java:564)
    at org.bridj.BridJ.getNativeLibrary(BridJ.java:547)
    at org.bridj.BridJ.getNativeLibrary(BridJ.java:287)
    at org.bridj.CRuntime.getNativeLibrary(CRuntime.java:268)
    at org.bridj.CRuntime.register(CRuntime.java:231)
    ... 10 more

Thanks in advance, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 10:00

GoogleCodeExporter commented 8 years ago
Sorry, revision #1753 fixes that ! (messed up with Libraries directory on MacOS 
X vs. bin directory on Windows)
The snapshot is updated.

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 10:14

GoogleCodeExporter commented 8 years ago
Thanks!
Now I have:
Not enough args for null JAWT_GetAWT()
Symbol _JAWT_GetAWT@8 was a good candidate but expected demangled signature 
null JAWT_GetAWT() did not match the method public static native boolean 
org.bridj.jawt.JawtLibrary.JAWT_GetAWT(org.bridj.Pointer,org.bridj.Pointer)
07.03.2011 12:19:32 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method public static native boolean 
org.bridj.jawt.JawtLibrary.JAWT_GetAWT(org.bridj.Pointer,org.bridj.Pointer)
java.lang.UnsatisfiedLinkError: 
org.bridj.jawt.JawtLibrary.JAWT_GetAWT(Lorg/bridj/Pointer;Lorg/bridj/Pointer;)Z
    at org.bridj.jawt.JawtLibrary.JAWT_GetAWT(Native Method)
    at org.bridj.jawt.JAWTUtils.getNativePeerHandle(JAWTUtils.java:44)
    at bridj.win32.example.ExVideoCapturer.main(ExVideoCapturer.java:83)

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 10:21

GoogleCodeExporter commented 8 years ago
Sorry about that, I only tested on Windows 64 bits. 
Might not be able to fix this before friday, in the meanwhile as a workaround I 
suggest you use JNA for that specific feature (you can use BridJ and JNA 
without any problem in the same program).
Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 11:18

GoogleCodeExporter commented 8 years ago
(opened issue #52 for the JAWTUtils + win32 issue)

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 11:19

GoogleCodeExporter commented 8 years ago
Thanks :) I'll try to implement BridJ wrapper for pcap then.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 11:35

GoogleCodeExporter commented 8 years ago
Thanks for your patience !

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 1:35

GoogleCodeExporter commented 8 years ago
Hi Andrei,

Issue #52 is now fixed, you might want to try using JAWTUtils again :-)
Also, consider joining the NativeLibs4Java Google Group to share your questions 
there (http://groups.google.com/group/nativelibs4java)

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 5:38

GoogleCodeExporter commented 8 years ago
Hi Olivier,

Thanks! I don't have JAWTUtils related exception anymore...

Question: Lets say I have a library with 2 methods Method1 and Method2.
Method1 is called from Thread1 several times. After that I create Thread2 that
tries to invoke Method2... as a result Thread2 hangs in method invocation.
Is this an expected behaviour?

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 6:22

GoogleCodeExporter commented 8 years ago
Hi Andrei,

It sure isn't (I guess you mean that calling Method2 from first doesn't hang... 
if it does, triple-check the calling convention).
Calls made from different threads shouldn't interfere with each other, as 
threadlocal structures are used heavily in BridJ's native code.
If you have a reproductible bug, could you please open a new issue ?

Thanks,
Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 7 Mar 2011 at 6:27

GoogleCodeExporter commented 8 years ago
I am not sure what is the reason actually, but both implementations are hanging 
in the described situation.
I've implemented JNA wrappers for Windows AviCap and PacketCapture 
functionality (available at http://www.smaxe.com/os.jsf) and trying to 
implement the same using BridJ.

I am attaching current sources (please launch Ex*.java from the *.example 
package).
In the case of AviCap it hangs in the class VideoCaptureDevice.java, line 172..
In the case of Pcap it hangs in the class NetworkDevice.java, line 214..

Also please check NetworkDevice#getIP() method.. There are 2 lines commented 
(that reads Pointer<Byte>) that leads to JVM crash or 100% CPU.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 6:39

Attachments:

GoogleCodeExporter commented 8 years ago
pcap library requires winpcap installed on Windows 
(http://www.winpcap.org/default.htm).

The environment is the same Windows XP, 32 bit.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 7 Mar 2011 at 6:42

GoogleCodeExporter commented 8 years ago
Other issue I found is that Bridj.sizeOf(CAPDRIVERCAPS) returns 28, but
JNA's CAPDRIVERCAPS.size() returns 44 (it looks like boolean size is 4 in JNA).

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 8 Mar 2011 at 9:31

GoogleCodeExporter commented 8 years ago
Hehe... just fixed a bunch of struct/union sizing issues (including issue #51), 
which means CAPDRIVERCAPS should now have the correct size, and so should 
VARIANT :-)

Can you open a separate issue for the multi-threading issue ?

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 8 Mar 2011 at 11:53

GoogleCodeExporter commented 8 years ago
Also, beware that there's a bug in JNAerator + BridJ : BOOL should be bound to 
int, not boolean !

Original comment by olivier.chafik@gmail.com on 8 Mar 2011 at 11:55

GoogleCodeExporter commented 8 years ago
Updated com direct X example that...

Symbol PropVariantCopy was a good candidate but expected demangled signature 
null PropVariantCopy() did not match the method static native int 
org.bridj.cpp.com.COMRuntime.VariantCopy(org.bridj.Pointer,org.bridj.Pointer)
08.03.2011 19:12:03 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method static native int 
org.bridj.cpp.com.COMRuntime.VariantCopy(org.bridj.Pointer,org.bridj.Pointer)

Exception in thread "main" java.lang.RuntimeException: Failed to cast pointer 
to native object of type org.bridj.cpp.com.VARIANT
    at org.bridj.BridJ.createNativeObjectFromPointer(BridJ.java:178)
    at org.bridj.Pointer.getNativeObjectAtOffset(Pointer.java:584)
    at org.bridj.CommonPointerIOs$StructPointerIO.get(CommonPointerIOs.java:26)
    at org.bridj.CommonPointerIOs$StructPointerIO.get(CommonPointerIOs.java:11)
    at org.bridj.Pointer.get(Pointer.java:703)
    at org.bridj.Pointer.get(Pointer.java:5253)
    at org.bridj.Pointer.get(Pointer.java:679)
    at directx.TestDirectX.main(TestDirectX.java:54)
Caused by: java.lang.RuntimeException: Failed to cast pointer 
org.bridj.Pointer$2@32347c0 to instance of type org.bridj.cpp.com.VARIANT
    at org.bridj.CRuntime$CTypeInfo.cast(CRuntime.java:115)
    at org.bridj.BridJ.createNativeObjectFromPointer(BridJ.java:175)
    ... 7 more
Caused by: java.lang.NullPointerException
    at org.bridj.StructIO.getNativeObjectField(StructIO.java:552)
    at org.bridj.cpp.com.VARIANT.__VARIANT_NAME_1(VARIANT.java:33)
    at org.bridj.cpp.com.COMRuntime.getValues(COMRuntime.java:248)
    at org.bridj.cpp.com.COMRuntime.setValue(COMRuntime.java:335)
    at org.bridj.cpp.com.VARIANT.<init>(VARIANT.java:22)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.bridj.CRuntime$CTypeInfo.cast(CRuntime.java:111)
    ... 8 more

Original comment by andrei.s...@gmail.com on 8 Mar 2011 at 5:15

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Andrei,

Thanks a lot for your perseverance, it is much appreciated !
I've just fixed quite a few win32-specific problems + VARIANT bug in yet 
another snapshot, which now yields a neat "Built-in iSight" output for the 
"FriendlyName".
Please let me know of any further issue you face :-)

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 9 Mar 2011 at 1:26

GoogleCodeExporter commented 8 years ago
Hi Olivier,

Thanks a lot. It works, but i still see the log:

Symbol PropVariantCopy was a good candidate but expected demangled signature 
null PropVariantCopy() did not match the method static native int 
org.bridj.cpp.com.COMRuntime.VariantCopy(org.bridj.Pointer,org.bridj.Pointer)
09.03.2011 12:54:07 org.bridj.AbstractBridJRuntime log
SEVERE: Failed to get address of method static native int 
org.bridj.cpp.com.COMRuntime.VariantCopy(org.bridj.Pointer,org.bridj.Pointer)

Also do you think it is necessary or not VARIANT#getType() method?

I'll continue the implementation and let you know about the result.

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 9 Mar 2011 at 11:26

GoogleCodeExporter commented 8 years ago
Hi Andrei,

This error is due to a bad binding (this function is in oleaut32.dll, no 
Ole32.dll) but its only consequence is that VARIANT.clone() does not work.

Anyway, lots of work is still needed on VARIANT for it to work properly in all 
cases (using the functions like SysReAllocString that were just added to 
BridJ's SVN trunk : 
http://code.google.com/p/nativelibs4java/source/browse/trunk/libraries/Runtime/B
ridJ/src/main/java/org/bridj/cpp/com/OLEAutomationLibrary.java).

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 9 Mar 2011 at 1:21

GoogleCodeExporter commented 8 years ago
Hi Olivier,

It is necessary to write class that implements ISampleGrabberCB COM interface 
(http://msdn.microsoft.com/en-us/library/dd376985%28v=vs.85%29.aspx) to be able
to get next media sample notification.

Is it possible and how?

Regards, Andrei.

Original comment by andrei.s...@gmail.com on 9 Mar 2011 at 10:47

GoogleCodeExporter commented 8 years ago
Hi Andrei,

In a near future it will be possible with the natural Java inline anonymous 
subclass syntax.
In the meanwhile we can make use of the C-compatible bindings COM offers (see 
the "/* C style interface */" sections in 
http://www.koders.com/cpp/fid614F3E471D5D6B7854B5549ADFEC790E3B8703F6.aspx?s=qed
it.h).

If you paste the attached ISampleGrabberCB.h file into JNAerator 
(http://jnaerator.sourceforge.net/webstart/JNAerator/JNAeratorStudio.jnlp), 
you'll get the resulting attached ISampleGrabberCB.java file (I've just added 
@Convention(StdCall) to its callbacks by hand).
The input code was just complemented with standard defines / typedefs and I 
replaced 'interface' by 'class'.

To use it, you just have to create a ISampleGrabberCBVtbl virtual table (keep a 
hard reference to it), fill it with the appropriate callbacks (hopefully COM 
won't scream if you only provide SampleCB and BufferCB), set it to a 
ISampleGrabberCB instance and cross fingers... (and hard-cast your 
Pointer<ISampleGrabberCB>.as(IUnknown.class)).

Have fun !
Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 10 Mar 2011 at 12:25

Attachments: