Showing Video on an Optimus Mini Three
However, while their software configurator is pretty as heck, their Plugin Model is stuck in the world of VTables and is largely unusable for the general hacker out there. If you want to write a plugin, you do it in C++ and implement a Create() method and export it. There are three pure virtual methods that a plugin writer needs to implement, GetInfo, Paint, and OnKeyDown. My preferred software environment is managed. Full stop. I'm not going to apologize for preferring it. I was a bad-ass in C++ back in the day, but I fully recognize that those days are over, and I'm not going to write another lpcszcbFoo* again.
I'm pretty disappointed that I'd need to do all that unmanaged dancing. That said, if you, dear reader, would like to dance, I'd like an unmanaged shim in C++ that forwards these three calls to a parallel C# managed interface. Any takers? Give me a call. I'm sure we could work on it together and give it back to the company so their plugin model wouldn't suck so much. It'd really make the device take off, I think. I'd love to do a Continuous Integration widget.
Anyway, while they are a USB device, as with all good (read: usable/hackable) USB devices they are really a "Prolific USB-Serial" Device so they are addressable via a virtual COM port and they have a well defined spec. So instead of a plugin, this is currently a command line app. I suspect it'd be pretty easy to make it a Tray App and basically rewrite their config app in .NET.
They also include a C# sample that pushes bitmaps to the buttons as byte[] arrays. I used the existing IVideoSource libraries from the brilliant Andrew Kirillov (he worked on the motion detection baby article for Coding4Fun with me) and captured each frame from the AVI and resized it to 96x96 before pushing it to the Mini Three.
The SendToButton method takes a .NET Bitmap and a button number apart and sends it as an array that's 96x96x3 (3 for R,G,B). It calls the Optimus C-style library via PInvoke calls.
public unsafe static void SendToButton(int button, Bitmap i)
{
byte[] bmpBytes = null;
BitmapData bData = i.LockBits(new Rectangle(new Point(), i.Size),
ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
try
{
// number of bytes in the bitmap
int byteCount = bData.Stride * i.Height;
bmpBytes = new byte[byteCount];
// Copy the locked bytes from memory
Marshal.Copy(bData.Scan0, bmpBytes, 0, byteCount);
}
// don't forget to unlock the bitmap!!
finally
{
i.UnlockBits(bData);
}
IOptimusMini.ShowPictureBlocking(button, bmpBytes);
}
Here's a fantastically poor video taken with a cell phone camera that shows an AVI of a plane landing on the second mini-three button. The frame rate is crap, but it'll do. I've also got the Mini Three showing my infant son's internet "cradle cam" via a secure MJPEG stream as well. I think I'll do a Vista Side Show driver at some point as well.
Video: Video on an Optimus Mini Three. I'll do a more complete Coding4Fun Article soon.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Pretty sweet, though.
Great example at dnrTV: http://www.dnrtv.com/default.aspx?showID=34
Once you have that figured out, there's more information about Providers in .NET at: http://www.dnrtv.com/default.aspx?showID=52
http://digg.com/mods/Enterprising_hacker_gets_video_playing_on_Optimus_Mini_Three
Link for the history - http://lenta.ru/news/2007/02/08/optimus/
One idea for a useful app for me would be to make the 2 buttons on the left and right scroll through a list of possible A/V sources, and when the middle button is pressed it sends a signal to my home automation controller to set that source on the tv.
I also use switchers and scalers in these home automation systems. If I could somehow take a downscaled composite feed from my switcher and send that image into one of the buttons, it would be extremely slick.
Any links to source code I can tinker around with would be greatly appreciated.
-Vince
Comments are closed.