This Question is Answered

2 "helpful" answers available (2 pts)
5 Replies Last post: Jan 7, 2008 4:27 PM by Tomasz Modrzejewski  
Kevin Collins   4 posts since
Sep 6, 2007
Currently Being Moderated

Sep 11, 2007 1:44 AM

Totally Lost! Using OCX for Recording Live Video and Audio

My basic task is to work with a "visual" OCX which records live video and audio. It's an OCX containing a panel showing the live video from a local video cam and has all of the plumbing to handle the recording, set file name, save it, etc. And I feel absolutely foolish but I need some assistance to just get things rolling. I've read the programmer's Guide and it's just not clear to me. I "think" I can see all the pieces but don't understand how they fit together. To get my self started I have modified the ActiveXPanel sample and have generated code from the OCX. I have my OCX starting, but:

1) The JPanel will flash and repaints when clicked but I don't see any live video playing. Leading me to believe that the OCX isn't running.

2) I don't understand how to get a handle to the OCX to call it's methods (like getRecordingStatus(), setRecordingFileName())

 

Basically I'm just not getting the whole ComfyJ / JNIWrapper class and calling structure. I don't even understand how to get a handle to the OCX in the OleContainer so I can call it's methods and therefore can't get started.

 

Any pointers are appreciated and Thanks in advance.

 

- Kevin

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Sep 11, 2007 2:17 PM in response to: Kevin Collins
Re: Totally Lost! Using OCX for Recording Live Video and Audio

Hi Kevin,

 

I don't understand how to get a handle to the OCX to call it's methods (like getRecordingStatus(), setRecordingFileName())

 

First, I suppose that you have created an OCX component in the OleContainer, like it's shown in ActiveXPanel Java example:


   oleContainer.createObject(progID); // here progID is the String ID of the OCX component; for Windows Media Player it is "WMPlayer.OCX"

 

The following code demonstrates how to get an embedded ActiveX/OCX component from the Container:


   IOleObjectImpl oleObject = oleContainer.getOleObject();

 

Then having this OleObject, which represents the emended OCX component in your case, you can cast it to the required type and call the methods of this object directly, or you can invoke the methods of this object indirectly, using Automation approach.

 

The following example demonstrates how to query the required object from the oleObject:


    // query IMediaPlayer interface from oleObject
    IMediaPlayerImpl mediaPlayer = new IMediaPlayerImpl(oleObject); 
    // invoke the method of IMediaPlayer object
    mediaPlayer.setFileName(new BStr(path));

 

This example is taken from MediaPlayerIntegrationSample file which is available in ComfyJ distribution archive in the comfyj-2.4.zip\samples\MediaPlayer\src\ folder. And IMediaPlayerImpl here is the class which is generated using Codegen for ComfyJ application.

 

And as I mentioned above, the alternative way is Automation. This approach is quite similar to reflection technique in Java. The following code snippet demonstrates how to use Automation:


        // Create Automation object for the oleObject
        Automation automation = new Automation(oleObject);
        // Invoke the property setter of the media player
        String path = ...  
        automation.setProperty("FileName", path);

 

You can find these and many other integration/automation examples in comfyj-2.4.zip\samples\ folder.

 

As to another question:

The JPanel will flash and repaints when clicked but I don't see any live video playing. Leading me to believe that the OCX isn't running.

 

I think that the embedded component was not show. Did you call oleContainer.doVerb(OleVerbs.INPLACEACTIVATE); or oleContainer.doVerb(OleVerbs.SHOW); method? Or even better, can you please attach your example?

 

-Serge

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
3. Sep 20, 2007 3:13 PM in response to: Kevin Collins
Re: Totally Lost! Using OCX for Recording Live Video and Audio

Hi Kevin,

 

Such error message "The application called an interface that was marshalled for a different thread" indicates that you are trying to work with a COM object which was created in another thread. Actually such exception occurs when a COM object does not support multithreading model.

 

Taking into account that he problem line is "UserDescription aUser = users.moveFirst();" my first though was that 'users' COM object was just created in another thread. But then I have analyzed your example and it seems to be correct.

 

It's difficult to say why such problem occurs in this case without the ability to reproduce it. Can you please send us the complete test applicaiton wich reproduces the problem? We will investigate this issue and give you the solution.

 

-Serge

Tomasz Modrzejewski   5 posts since
Jan 15, 2007
Currently Being Moderated
5. Jan 7, 2008 4:27 PM in response to: Kevin Collins
Re: Totally Lost! Using OCX for Recording Live Video and Audio

 

Hi Kevin,

 

 

Have You tried (in Your live stream ocx) to start up the activeX without registering it? (see http://support.teamdev.com/message/3393) Can You reffer to the issue of dislpaying unregistered activeX object on OleContainer? Right now I am trying to implement an applet that does not need to call regsrv32 and I am stuck because ocx loaded without registering won't show up ( although example that registers ocx does). If You have any experience with that, I would be graceful

 

 

 

 

Thanks, Tomasz

 

 

More Like This

  • Retrieving data ...