Sunday, February 1, 2009

All is good.

I think I've settled on what is to be the default look:

















The way I solved the transparency problem was to make every control derived from MarSara.MediaCenter.Controls.Baseline.TransparentControl, and to disable any control that is suppose to be underneath of another transparent control. As with my experiments with Transparency, if a control has the WS_EX_TRANSPARENT property it is drawn in reverse of the parent's Z-ordering. So controls that are at the end of the Z-order (farthest away from the screen) are drawn last, instead of first like normal. Making it appear as if controls are on top of the overlayed control but infact are behind it and thus cannot be used. In other words the control that appears to be bottom control is infact the top-most control and will take input focus before all those "above it."

Friday, January 30, 2009

The Invisible

A few new features added: Custom message boxes, and TRANSPARENCY! All of the forms now support transparency as a color, so details of the window behind them can be seen. With this feature the custom desktop images have been enabled.

I've also got nearly everything running though the MarSara.MediaCenter.Playback.MediaPlayer class. So all that is needed to start a DVD, AVI, MP3, or JPG in the MediaPlayer is to call: MediaPreviewForm.PlayMedia(string dataSource, MediaType mediaType);

I still need to wait for some hardware before I can add TV and Recording features to the MediaPlayer.

The only real issue I'm having to deal with at the moment is the refresh rate of the scrollbars. Refreshing the positions of sometimes 100+ items in a folder is causing clipping issues as the File Browser control attempts to redraw itself. Most of this is due though to the Transparency effect, with controls layered ontop of each other, everything down to the MainForm is having to have at least part of its region refreshed.

Wednesday, January 28, 2009

A feature here a feature there

As I've said, I've just been trying to clean some stuff up at the moment. I've created a new custom control: a progress bar, and I've added it to the control bar so now you can both jump to any point in the current video/audio stream and adjust the volume to any level.





The next task is I'd like to complete, after finishing up all of the custom controls is:

1) Implementing the use of website for address. So if one was to specify a URL for either the Play, Listen, or Browse buttons then it would load that webpage instead. But if a user specifies a URL to a FTP site or a HTTP site that just has a directory listing then it will appear to load like normal, but if that address supplied has a custom index page then it will open an embedded web browser to display it. This way, the Media Center can work with webpages like Pandora and also work with remote servers one may have.

2) I'm getting to the point where I'd like to start comming up with a logo and a name for the project. So far the namespace MarSara.MediaCenter doesn't seem to attractive.

Sunday, January 25, 2009

Been a little busy...

Ok, so I've got a lot done here recently.

The current solution to video playback is DirectShow. It will currently do everything that I need it to do for this project and here is what I have working so far:

  • Video Playback, AVI, WMV, etc

  • DVD Playback

  • Audio Playback

  • Picture Browsing

I've even got most of the options configurable, although the options dialog doesn't look too pretty yet. You can currently set the root directories of all of the buttons, except for "Play DVD" "Watch", and "Record" also don't do anything at the moment, but "Play", "Listen", and "Browse" all can have their root directories modified.

Themes are working 99% now. The way I've decided to handle Themes is to provide several basic pre-set themes that are selectable from the options dialog. After a theme is selected it is loaded and all of the color settings are stored then in the ThemeSettings.config file, in the programs root directory. Users are free to play around with the values in this XML file to customize their theme's settings. The XML file just contains a list of ARGB values for each configurable color setting. Right now there are only three themes available: 'Royal Blue', 'Maroon', and 'Monochrome'. Royal blue and Maroon are pictured below.





















I've also managed to create working scroll bars for the file section dialogs:


























At the moment the current priority is just going to be to cleanup the UI. At least until I can get the hardware required to start implimenting and testing the "Watch" and "Record" buttons.

Tuesday, January 20, 2009

DirectX

So... I started playing around with Direct3D and to see if I couldn't get everything to render that way.

My first task here was just to see if I couldn't get a basic button to render on the screen. 20 line segments and 26 triangles later I had a rounded rectangle drawn on the screen. Task number 2, try and get a sub-window to display and to render solely inside of it... BRICK WALL.

As you can see here to the left, I successfully drew on top of the preview screen but all hopes were lost when I started to play actual video, as the control disappeared and the video obscured it. Back to square one... how to draw over the top of the video.

Monday, January 19, 2009

AC3 Audio Codec

So I've done a lot of research on the AC3 audio format.

Any stream of AC3 data can be broken down into frames. Then each frame contains a SyncInfo (si) header, a BitStreamInfo (bsi) header, Audio Information header, aux data, and 6 audio channels. I would simply need to open the file, read in the si, bsi, ai, and aux data headers and then use that information to convert the audio channels from AC3 into wave format, and then play each of the 6 wave files in synchronization for each of their respective speakers. (Left, Right, Back Left, Back Right, Back Center and Subwoofer)

It has been a few days since I've done the research on this, so excuse any misconceptions.

Problem #2

Now that I'm comfortable with the layout its time to start working on the nuts and bolts. The picture browser wasn't too hard at all to code, a couple hours and it's working like a champ. The problem comes to the Video Player. Trying to find wrappers for codecs/filters is proving impossible. It looks like I have a couple options:

1) Microsoft.DirectX.AudtioVideoPlayback. This is a managed wrapper for the payback of AVI and MP3 files. But it has it's problems. Mainly Microsoft is no longer supporting the namespace. But the largest problem with using it is I'm still trying to figure out how to draw over the top of the video, as to add controls. This may be just because of my lack of knowledge in DirextX but I've also heard complaints about this namespace altogether.

2) Using the C++ windows library AVI functions. These are great and they provide a nice easy way to decode AVI video, but as for the audio they are lacking. I can extract the AC3 audio stream from the AVI file but I can't play it, yet. The bonus to using the C++ library is that I can draw the video using the System.Drawing namespace and thus very easly draw over the top of any video output to create video controls. But as I've said there is no audio decoder that I'm aware of that I can use here to convert the AC3 data. The current working version of this is able to produce frame rates upto 60 in the mini-player and as low as 5-10 frames per second in full-screen view. Frame skipping was impliments so that when the frame rate wasn't at ideal levels (24-30 for all of the AVI files I've been testing with) it either repeats the old frame in the cases when above ideal rates, or skips missed frames when the renderer slows down.

3) This would be the most promising and ideal for the long term, but the most time consuming and research intensive... Writing my own DivX and AC3 codecs. The same would have to be done for any compression format available to all of the media types. First though would be that the en/decoders would be written into a C++ library and then a C# wrapper class would be created over the top of that.

I've already done a fair bit of research for the AC3 decoder and I believe it won't be too difficult to write it's just going to be very very time consuming. I'll explain the details in the next post.