RealThumb v0.21 Copyright (c) 2003 by Michael Barrientos. All rights reserved. mbarrien@geocities.com http://mb.n3.net/projects/ -------- Overview -------- RealThumb is a RealPlayer thumbnail handler for Windows Explorer. When Explorer is in thumbnail view (whether it be in an Explorer window or in a File Open dialog box), Windows will use this handler to read thumbnail pictures from QuickTime movies. ------------------------------- Build Requirements/Instructions ------------------------------- Building RealThumb requires Visual Studio and RealNetwork's RealSystem SDK. I have only tested builds on Visual Studio .NET and RealOne Player, although there is nothing in the project that prevents it from being running using RealPlayer G2 onwards. The project may or may not compile using Visual Studio 6; it is untested. (It might not work in VS6, since I think the CInterfaceList class was not added until ATL 3.0) The RealSystem SDK can be downloaded from http://forms.real.com/rnforms/resources/server/realsystemsdk/index.html If you are building RealThumb on visual Studio .NET, you must replace the pncom.h file that comes with the RealSystem SDK with the one included in the source. (The pncom.h included in the SDK is based on a file that came in VS6 and was heavily modified for VS7). Building in Visual Studio is as simple as pressing Shift-Ctrl-B. (^_^) --------------------------- Installation/Uninstallation --------------------------- Install: 1. Copy RealThumb.dll to your System32 directory (e.g. C:\WINDOWS\SYSTEM32) 2. As an Administrator, from the System32 directory, run "regsvr32 RealThumb.dll". You should get a message saying registration was successful. Uninstall: 1. As an Administrator, from the System32 directory, run "regsvr32 /u RealThumb.dll" ------- Running ------- Since this is a Windows Shell Extension, there is no application to run. A test application which I used to test the program is included, call RealThumbTest. Running it is as simple as double clicking, the using the standard menus to navigate around and open QuickTime files. Currently, it is dependent on the directory structure of the build environment (it expects the DLL in ..\..\RealThumb\Debug\RealThumb.dll) to run. --------------- Troubleshooting --------------- When installing the program, you may get the message "LoadLibrary("RealThumb.dll") failed - The specified module could not be found." This message means that the computer is missing a DLL, most likely MSVCR70.DLL (Microsoft Visual C++ 7.0 Runtime Library). This file should be in C:\WINDOWS\SYSTEM32. If you do not already have it, you can download a copy from . Copy it to the directory, then try installing again as above. --------- Internals --------- The internals of RealThumb are much more complicated than what we had in QuickThumb. RealThumb basically loads up RealPlayer, actually plays the video, and upon getting the first frame, tells the player to stop. Unfortunately Real's SDK provides no direct way of capturing video or frames. So what we do is provide a fake video device. Fortunately, Real's SDK draws onto this video surface by providing it a device-independent bitmap (DIB), which is easy to convert into a Windows HBITMAP. We cannot provide RealPlayer a video surface directly. Instead, we need to provide a SiteSupplier, which in turn provides Sites which provide VideoSurfaces, which is provided by supplying a Context to the RealPlayer core. The site itself actually makes the VideoSurface part of it internally. Most methods within each interface we implement just provide a token implementation that just returns PNR_OK, PNR_NOTIMPL, or a dummy return value without doing any actual processing. Only those methods we actually need are implemented. Since RealThumb actually plays the video, we need to keep it from having audio. This is done by making a fake audio device that takes in all the sound and just throws it away. After getting the DIB, we signal the program to stop looping, and to start processing the picture. From there, it's a simple resize procedure that is identical to the one used in QuickThumb. Since RM files might not have video (there are audio-only RM files), we have to detect that case to prevent from playing the RM file all the way through. This information is not available just by loading the file; we have to start playback before we can find out what streams are available. We register a ClientAdviseSink that waits for an OnBegin message. Once we have the OnBegin, we iterate through all the sources and streams. Each stream fortunately has a MIME type associated with it, so we check for any stream whose MIME type starts with "video/". If we find none, we signal RealThumb to stop waiting for the frame and to return a failure. In theory, everything could be done using one object, or at the bare minimum, CoRealThumb, CoRTNullAudioDevice, and CoRTContext could be combined into one COM object. I might consider that for future versions. ----------------- Interesting facts ----------------- After making QuickThumb, I turned my attention to RealPlayer thumbnails. After the QuickThumb release in March 2003, it took me about a week to get familiar with the RealPlayer SDK and to find the necessary places to hook into the RealPlayer engine, then 3 days of programming and debugging once I started making the DLL file. This gave me a much more extensive workout in Windows APIs and COM. If you could only see the other test programs I made along the way to get to this relatively simple end program... Why'd I pick this? Well, I have collected various movies and have always liked the thumbnails that Windows Media Player files have to be able to see at a glance what's in the file. I also happen to have a lot of RealPlayer movies, so I decided to write my own handler. ------------ Known issues ------------ * The program currently associates itself only with .rm and .ram files. There are many other possible extensions of RealPlayer media, but the program will need an installer to identify all of them. For now, we make thumbnails for the most common extensions * Although untested, the thumbnail image will probably be of poor quality in Windows ME. StretchBlt didn't support halftoning until Windows 2000. * The color depth of the output bitmap will match the current screen resolution, not the bit depth requested by the Load() call. Fortunately, this won't be an issue for Explorer thumbnails (the bit depth will match the screen), but if you plan on using this to make thumbnails outside of Explorer and require a bit depth other than the screen resolution, you'll need to do your own down-sampling for now. ----- To do ----- * Test on RM files with multiple video streams. * Test on RM files with multiple sources. * Test on RM files where video stream starts after the beginning of the presentation * Test on RM files where the first frame only draws part of the screen (need to check the bounding rectangles in the Blt/OptimizedBlt function) * Test on RM files where we don't have the codec yet * Check thread safety * Honor the color depth requested * Figure out if we can start/stop individual streams (so we can get rid off null audio device) * Add property sheet handlers to allow users to specify options about the picture extraction. * Add an icon handler? * Simplify/User friendlify installation. * Associate with all RM files * Implement a caching system * Merge with QuickThumb into one product (since lots of the resizing code was cut and paste) * Capture live RealPlayer streams from the web into Windows media files? (I have all the hooks in place to capture video and audio.... why not?) ------- Credits ------- codeguru.com - For pointing out why using StretchBlt without halftoning Andrew Troelsen - For writing the excellent book "Developer's Workshop to ATL and COM 3.0". After reading the book, suddenly everything made sense (and I realized how many dumb things I was doing in v0.01). Borders - For letting me sit in the store and read the above book since I can't afford the $50 right now. (Give me a job!) ------- History ------- v0.20 (3/26/03): Initial release. Version number made to match QuickThumb. v0.21 (3/29/03): Removed dependency on MSVCP70.dll. Uses CRegKey class instead of direct registry manipulation. Fixed bug when deleting movie files (fixed null pointer on priority), changed to use Windows shell string manipulation methods. Added my pncom.h file to distribution. Removed ErrorSink code. Make debug build use CComDebugObject instead of CComObject. -------------------------- Other products of interest -------------------------- QuickThumb v0.21 If you liked RealThumb, try QuickThumb. QuickThumb does for QuickTime movies what RealThumb does for RealPlayer: makes thumbnails! Go to http://mb.n3.net/projects to get it.