HTTP streaming done right

Oh Microsoft, why do you make the choices you do???

Fortunately in this day and age, Microsoft dominance isn’t what it once was – meaning we the little guys now have choice.  But unless you’re vigilant, it’s still so easy to caught up in the M$ trap and not realize there’s a Better Way(tm).

I’ve been using WinAMP as an MP3 player for eons, and one of the things I appreciate about WinAMP is that you can point it at a URL and stream an MP3 directly off of an HTTP server.  Wow, no big deal there.  But the big deal is that you can seek within that MP3 because WinAMP is smart enough to use HTTP/1.1 commands to tell the server what part of the file it wants to stream.

Contrast that to Windows Media Player, which insists on streaming a file from beginning to end.

While I don’t tend to use WinAMP much these days to play MP3 files directly (that’s what the Whole Home Audio system is for, what with its streaming “zones”), I do use Windows Media Player to play recorded TV shows on my lunch break every now and then.  Particularly these days, when downtime at home is at a premium and I don’t get to keep up with my favorite TV shows.

So it’s irked me that using Windows Media Player to stream WMV files from home has meant no seeking ability, since WMP will only stream the file from beginning to end.  I think WMV files store some key or index info in the end of the file as well, but still, I have to believe that it’s possible to start streaming from the middle of a WMV file in order to start watching from the middle of the WMV file.  It’s just not that hard.

VideoLAN Client to the rescue.  My goodness, talk about refreshing!  Like WinAMP, VLC can use HTTP/1.1 commands to tell the web server exactly what part of the file it wants to stream.  So yes, seeking is possible.

No more having to queue up a show first thing in the morning to ensure it’s fully downloaded (and seekable) by the time lunch rolls around.  Nope – now I can just copy the URL over to VLC and skip commercials at my heart’s content!

Are you Home? The project takes shape…

Wow.

For a Long Time(tm) I’ve wanted some way to add “occupant awareness” to my fledgling home automation system.  There are some really cool things that you can do if you’ve got the hardware and software: announce missed calls and playback voicemails on your networked phone system; turn on the TV and list the shows that have been recorded; turn on the audio system and start some background mood music.

And so on and so forth.  Personally I’m not sure that I want that level of personalization, but one thing I’d really love to make occupant-aware is the networked surveillance system.

Currently the system has two macro states: Home and  Away.  There are various micro settings that can be configured; which cammies have audio monitoring enabled, the size of the detection field, the sensitivity of the detection field… but for the most part the system will switch between a set of Home micro settings and Away micro settings.  Those macro states also dictate how the system determines which events should trigger an alert.

The system currently changes states based on a hard-coded schedule.  It also considers sunset/sunrise, but again that only serves to change some micro settings.

The problem with a schedule is that we don’t always adhere to it, especially on weekends.  I’m pretty diligent about sending commands from my phone to change the state of the surveillance system, but I can’t expect the wifey to do so as well.

Soooo… I started looking at automated solutions, and those solutions would most certainly involve phones.  For the most part it’s a safe bet that we carry our phones with us when we leave the house so it would be great if we could use the phone locations to determine if we’re Home or Away.

I started off looking at some way to have the phones updated their location to the home system.  This can be done using some custom programming and tying into the GPS coordinates, but GPS is a power hog.  Okay, then we can use the cell towers to get an approximate fix, then turn on GPS when the phone is on the “home” cell tower.  That may work, but it’s still troublesome.

So I went back to Bluetooth.  “Back”, because I had done some reading about a year ago and thought it looked promising but had no clue how to write a solution.  The idea is simple – the phones have Bluetooth turned on 24/7 and a computer on the home network simply polls the Bluetooth radios to see who’s around and who isn’t.  Both myself and the wife leave Bluetooth turned on so that our phones can connect to our cars automatically.

So the hurdle then was to see if I could code a simple program that could detect when a Bluetooth is in range.  Any by George, I could!  It’s  a proof of concept, but it’s remarkably small and simple.  In my testing it takes 2-3 seconds to determine that a device is *not* in range.  I make an attempt to connect to the OBEX Push Service, since pretty much every phone supports this Bluetooth profile.

So the next step will be to install this program on a laptop and see what kind of detection range we can get.

Looking good!