[Pythonmac-SIG] Newbie question about shared libraries and QuickTime

Donovan Preston dp@ulaluma.com
Mon, 4 Mar 2002 22:50:15 -0800


On Monday, March 4, 2002, at 12:29 PM, John Jackson wrote:

> Hi,
>
> I've been working with python on both OS 9 and OS X, and I was looking 
> at doing some work with QuickTime.
>
> There's a couple of things I'm not clear about:
>
> 1. With the functions in the shared libraries (such as QuickTime), 
> what's the easiest way to find the definition for the function?
>
> I can use the module browser in the IDE, and then import the function 
> in the interactive window and get its doc string, but that's a little 
> cumbersome. Is there an easier way, that would list the doc strings in 
> the module browser? (Or should I just hack the module browser?...)
>

The best reference for any of the toolbox modules is really just Apple's 
Developer Documentation. It will give you the best idea of what 
functions are available and how they are to be used. Then, you'll know 
what you are looking for.

As far as easy reference to the docstrings goes, you might want to try 
PyDoc. Does anybody know if it runs under OS 9? I have used it on X 
(using Mach-O Python). Running pydoc with the option to listen on a 
local port and then pointing your webbrowser to localhost:port is 
surprisingly easy and effective.

> 2. It looks like not all of QuickTime has been implemented in the 
> shared library. Of course, the function(s) that I'm looking for is one 
> that's not included. Is where I need to take the source for the library 
> (_Qtmodule.c) and add the missing functions, and then recompile it?

Good news: It's possible that the function you are looking for may have 
been turned into a Method of an Object by bgen, which generates the 
Python wrappers for the toolbox APIs. For example, Apple may have an API 
which looks like this:

FooRef CreateFooRef();
void DoSomethingWithAFooRef(FooRef theRef);
void DestroyFooRef(FooRef theRef);

bgen will turn "DoSomethingWithAFooRef" into a method of the FooRef 
object that is created by CreateFooRef. So in python, you might do:

myFooRef = CreateFooRef()
myFooRef.DoSomethingWithAFooRef()

(DestroyFooRef will be automatically called when the reference count 
drops to zero.)

Or, The function you are looking for may not be visible because it's not 
implemented, which you can tell by looking in the "Blacklist" section of 
the bgen module which generates the Python wrappers. In the QuickTime 
module's case,  it's in Modules/qt/qtscan.py. (In the source 
distribution of Python) Anything in the BlackListNames section will not 
be wrapped (although the function may be wrapped by hand) and any 
function which contains one of the types in BlackListTypes will not be 
wrapped automatically.

In my experience, the QuickTime module is fairly tough to use from 
Python mostly because it's such a complex API and the automatic bgen 
wrapping doesn't always get the semantics of how to use the functions 
properly. Since bgen often generates perfectly valid looking code that 
may never be tested, it's tough to know what's in a working state and 
what's not.

>
> How difficult is that? I don't have an up-to-date version of 
> Metrowerks; can this be done with downloadable compilers? I'd be happy 
> if I got it working on either one of the platforms, and then I can get 
> my application written and be on my way.
>

Depends what your level of experience and/or patience is. On OS 9, 
things are easier with Codewarrior. I've read some stuff in the past 
about using MPW, but it's going to be frustrating enough struggling with 
bgen to add struggling with MPW on top of that ;-)

Basically you're going to want to fix up the bgen module so that it 
automatically generates the correct code; sometimes that involves just 
manually writing a wrapper function yourself and putting it in the bgen 
module as one big string so it will insert that string in the output c 
files.

> (If you're familiar with the Apple sample code for Quicktime, I'm 
> trying to write a python implementation of the program 
> "MakeEffectSlideShow" which is broken and limited.)

Good luck. I'm sure Jack would love to have more people helping with the 
toolbox modules, if you have the time and the patience to help out.

>
> thanks for any help!
> ___________________
> John Jackson
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig