stephen's Journal stephen's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:48:16+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 stephen's Journal New Video::Xine release <p>Just released Video-Xine-0.14.</p><p>Finally bit the bullet and split all of the Xine modules into separate files. Based on the XS examples, I had been concerned that only one file could bootstrap a shared object at a time (which would do some damage to the term "shared object").</p><p>The tipping point was implementing Xine's on-screen display, which really needed a full doc page all to itself.</p><p>There's a minor compatibility break here-- instead of exporting huge numbers of constants into your namespace by default, I've put the constants into their related submodules. Since as far as I know the only user of Video::Xine so far is PlaybackMachine (which I'm releasing an update on tomorrow), this is OK.</p> stephen 2008-01-22T15:14:24+00:00 journal Xines To Come <p>In the "because we can" department, I'm working on some new things things for Video::Xine.</p><p>1. Overlays.</p><p>I've got text overlays working. (Journals can be very helpful-- I was just writing "but I need a way of specifying the font without giving a full path to a TrueType document", then realized I should try using just "serif".) That would seem enough for a release.</p><p>Implementing bitmap overlays will be a bit more interesting, because I'd need to specify an in-memory bitmap. I'll almost certainly need to implement it alongside a module to load and save bitmap images, such as Image::Magick, Imager, or Prima.</p><p>2. Callbacks</p><p>Xine frequently uses a callback architecture for things like delivering events and log messages. I currently work around this by using event queues, but it's worth a try to implement them properly.</p><p>Back when I tried this before (2002-2003), most perls were not compiled for multithreading, and I was desperately trying to get things done in time for BayCon.</p><p>How to call a specific named subroutine seems clear enough, but unless I start getting clever I don't see a way to call a method on a specific object without static storage-- and I don't want to use static storage, since I want to be able to run multiple Xines and streams at the same time.</p><p>Hmm...</p> stephen 2008-01-20T23:13:24+00:00 journal Revivifying Video::PlaybackMachine <p>After some interest from <a href="">RockBochs</a>, I've done some more work in making Video::PlaybackMachine easy to install.</p><p>A quick refresher: Video::PlaybackMachine is a video playback scheduler which can be used to create the video feed for a television station. It's available on CPAN.</p><p>This new release doesn't offer anything new in terms of features, but irons out a number of wrinkles in the install process.</p> stephen 2007-12-27T01:23:40+00:00 journal Entracte <p>Now the PM will display text-based slides, like "Up Next" fillframes.</p><p>The rest of this entry is in fact drivel, since I'm jabbering about unreleased code. (Not officially released; please e-mail if me </p><p>The primary to-do items at this point are either ease-of-use or are architectural refactorings.</p><p>Structural to-dos: </p><ul> <li>Create a central state machine whose job is to reflect overall system state. So, this machine concentrates on knowing: are we currently playing a movie? Are we playing a fill video? The Filler then becomes a sub-state-machine underneath it. </li><li>Split out the "DB" module into submodules to form a better rear tier. </li><li>Make the Filler module into a state machine as described above.</li> </ul> stephen 2005-04-24T21:04:57+00:00 journal In XS <p>Got tired of working around a thrown-together Xine/Xwindows interface, and am writing a proper interface to Xine which will (I hope) let me do the actual window management in Tk and/or Gtk.</p><p>I've already gotten it to the point of being able to play music files. The next trick is hooking in an X11 driver, which is causing me to pore over perlguts to find out how to do things like C structures.</p> stephen 2005-03-25T05:11:09+00:00 journal Status Update, and Question for the Community Minds So Playback Machine, the TV station in a box, is essentially ready to rock and roll. Basic functionality includes: <ul> <li>It plays things back at the right times.</li> <li>Whenever it isn't doing anything else, it plays some kind of filler-- either a short film or music with slides.</li> <li>It provides a usable (if plain) web interface, so that we can change the schedule on the fly.</li> <li>It restarts itself every four hours, between playing things, so that any memory leak in the player gets cleaned up.</li> </ul><p>(The last one really shouldn't be necessary, but I've found memory leaks in Xine which only become apparent after you play for about eight hours straight. I'd imagine that other players may have similar problems, and I don't want to be at the mercy of others' memory leaks.) </p><p>In theory I should be able to walk into the BCTV room, hook up the computer, start playback, head for the bar, and come back at the end of the weekend when the Con is over. (Yeah, right.) </p><p>Except... one thing I'd really like to do is have onscreen schedules. I'd like to be able to generate a PNG which shows the next five shows and their start times, then display it onscreen as a slide. </p><p>My options are: </p><ol> <li>SVGs. Nearly custom-designed for the purpose. I can define nice bounding boxes. I tried this last year and got incredibly ugly results. Try again?</li> <li>Image::Magick. Common, easy to install, available as an RPM. However, its interface assumes that you're writing a simple annotation, and so I can't really do the kind of cell-based word wrapping I need.</li> <li>Image::Imlib2. I'm already using Imlib2's C interface to load and display slides, so there's some dependency efficiency. There's no RPM, though (I'd like to distribute this eventually as an RPM, so I'm watching my dependencies closely) and I'd need to implement my own word-wrapping code. Possible, though.</li> <li>GD. Looks like there's already a CPAN class out there for the kind of aligned text I'd like to produce. It'd add yet another C library dependency, but I should be able to live with that.</li> </ol><p>So it looks like I'll try SVGs again, then try GD to see if I can get it running quickly. </p><p>So my questions: Are there any easy ways of creating the kind of formatted-text-in-graphics that I'm looking for? I'm happy to have the system call a non-Perl command line utility, or even do a little XS work. The requirements: I need to be able to format tabular text against a background. </p><p>Second question: anyone have any suggestions for a better name? "The Playback Machine" sounds like a Xine-type movie player. "TV Station In A Box" lacks coolness. "The Twonky" is cool, appropriate, and taken by the Twonky Media Server.</p> stephen 2005-03-19T22:43:04+00:00 journal Prius Madness Ahh, glorious... <p>Today my Prius arrived at the local dealership. I'd been waiting for it since about last May. </p><p>I've got to say that the biggest pleasure is in using something extremely well-designed. The keyless entry and ignition system, so that you don't need to fumble for keys in the rain. The built-in Bluetooth. This is a car built by engineers who worked hard to understand how people actually use their cars. </p><p>And, of course, the hybrid drive system. When this car stops at a stoplight, it <strong>stops</strong>. No idle motor. Nothing is consumed. I could probably wedge the brake pedal, leave it there for a week, and then get back in and drive away without any problems. Most people measure efficiency in terms of miles per gallon, but consider how much time, in the course of our driving careers, we spend stopped at stoplights, stop signs, in traffic, or in drive-throughs. </p><p>So after six hours I still love it. Of course, it's been raining steadily all evening, so I've only gotten to drive it around a bit and sit around in the driveway making "vroom vroom" noises. </p><p>Ok, I didn't make "vroom vroom" noises. But only because I was imagining it in electric mode.</p> stephen 2005-02-28T06:30:13+00:00 journal The Playback Machine In a previous entry, I talked about the Playback Machine, a "television station in a box" system I've put together to animate the convention TV feed for BayCon. Well, after about two years of on-and-off work, it's finally ready-- or at least working reliably. <p>Of course, it has only a subset of the features I originally envisioned for it-- but that's mostly because those features proved a poor match. It's enough of a challenge getting the basic features working. </p><p>And the basic features are: </p><ol> <li>Being able to schedule a movie for a particular time and have the system play it back at that time.</li> <li>Playing short movies and slides whenever nothing else is playing.</li> <li>Stability-- we need to play content nonstop for three days.</li> </ol><p>Simple enough stuff, it seems, but to do this I've needed to write a Perl interface to Xine, a simple X fullscreen interface, and integrate Imlib2 and POE with both of those. I've needed to write an object system that automatically calculates the appropriate amounts of time to play different types of fill content. Not a lot of ground-breaking CS research here, but some exacting busy-work if nothing else. </p><p>My current roadblock: playing music alongside slides. I display the slides using X and Imlib2 and control all scheduling with POE. My original plan was to use SDL to play background music, but something about my POE functions do not sit well with SDL. I'm suspecting that POE's and SDL's select() or alarm() calls are interfering somehow, but can't confirm this. </p><p>My current solution is to fork off a subprocess that plays the music using SDL. Irritating, though, since in having a subprocess I'm at an increased risk of the music keeping playing when a movie is going on. </p><p>Wish me luck... </p><p> <b>Update:</b> Eventually, I wound up using Xine itself as a music player. I essentially restart Xine with a null video driver and play only audio. It has the advantage of not requiring any additional packages. Playing Xine also seems slightly more reliable.</p> stephen 2005-02-28T05:43:34+00:00 journal Language Advocacy Considered Harmful <p>A little while ago, I was at a meeting where someone asked for help working on a web application. After the meeting, I approached him to find out if I could help. I briefly ran over my credentials, and said that I primarily worked in Perl right now. He said that the application was currently in PHP, but he would perhaps be interested in rewriting it in Perl. Some other folks jumped into the conversation, and some interesting ideas were surfacing, when someone I didn't know walked into the conversation and started lecturing me. The conversation went something like this, condensed down:</p><p> <b>She:</b> Perl is terrible. You should leave it in PHP. <br> <b>Me:</b> Um... <br> <b>She:</b> PHP has feature X. <br> <b>Me:</b> I'm sorry, but I don't know PHP-- <br> <b>She:</b> You should learn it. Its syntax is simple, very similar to C. Perl is unreadable. <br> <b>Me:</b> I don't want to argue about languages. <br> <b>She:</b> No, it's true! I have lots of experience. <br> <b>Me:</b> (tiredly) I was just offering to help, I don't care what-- <br> <b>She:</b> Perl is unmaintainable. <br> <b>Me:</b> I don't c-- <br> <b>She:</b> I've had to work on too many crappy Perl scripts. <br> <b>Me:</b> So have I. </p><p>At that point I decided that I had enough to do already, and quietly made my departure.</p><p>My point is not that she was wrong. She wasn't. It's possible to write hideous scripts in Perl. In fact, it's possible to write hideous, unmaintainable scripts in any language worth knowing. I've written some scripts so difficult to deal with that I had to stop development for months just to go back and refactor my own code until I understood it again.</p><p>Instead, I've got two points. First, language advocacy is really, really irritating. To me, it's like jingoism-- "the way I do things is better than anyone else's, and I want to squelch anyone who does things otherwise!" Perl language advocacy is as irritating as any other kind. This person was trying to convert me to the One True Way of PHP, which no doubt has its advantages and disadvantages. I was just trying to help accomplish a task. If, instead, she had offered to help me learn PHP, I would have been more receptive. I can be as guilty of overevangelism as anyone else. "Use strict or die!"</p><p>Secondly, Perl does have a reputation for being as unintelligible as a cartoon swear. The more often we have people that don't pay attention to code readability, the more anti-Perl zealots we create. Irritating as it is, we need to listen to our critics.</p> stephen 2003-02-13T21:35:09+00:00 journal BCTV: The Project <p>Imagine that you're a science fiction fan staying at a hotel for the BayCon convention. It's late at night, so there are no exhibits to attend. You don't want to go to sleep, because you want to attend a party in an hour or so. So you flip on the TV and tune into the convention's in-house (well, in-hotel) station, BCTV. It's playing an old (or fan-produced) science fiction movie. Perfect.</p><p>Now imagine that you're on the delivery end for BCTV. You don't have a fancy control room; instead you have a regular hotel room with a cable dropped in allowing you to broadcast. You've put together a long tape of movies, but since half your content didn't arrive until the last minute, you're stuck in your room frantically trying to edit tapes together. You can't sleep at night. You can't enjoy the convention in the daytime. You're trapped in the control room.</p><p>This looks like a job for Perl.</p><p>Using <a href="">POE</a>, a video digitizer card, and an IR controller, I'm developing a system that will allow us to let BCTV run itself. I've created a program that allows us to create program schedules and play digital and analog content automatically. It's designed to handle everything from preplanned, pre-digitized content to VCR tapes pressed frantically into my hands at midnight.</p><p>Will it be everything I hope for it? Probably not. The first version will probably flicker between programs, since I'm using external processes for most of this. I'm having troubles getting the IR port running to control the external VCR. And I made the mistake of buying a video digitizer card that's only sorta-kinda supported under Linux.</p><p>However, the work progresses. I'm at the edge of creating a module that will automatically create text titles, such as "Up Next" screens and Con schedules. I'll be documenting what I run into here, so that people doing similar projects can learn from my mistakes.</p> stephen 2003-01-28T19:59:04+00:00 journal Beginning <p>Hello all...</p><p>Since what the world needs now is, beyond a doubt, ANOTHER web journal, I'm moving swiftly to answer that demand. Perhaps the delusion that other people are reading my words might help me stick to the useful task of keeping a journal.</p><p>Perl and programming-related content here will include: </p><ul> <li>My experiences working on a Perl-based broadcast system for BCTV, the in-house television station for <a href="">BayCon</a>, the Bay Area Science Fiction Convention</li><li>I've just started CMU's new West Coast Master's program for software engineering, so I'll probably gripe aimlessly about the entire process, and hopefully share some things I learn.</li><li>Notes as I continue my fitful process of gathering Perl refactorings, particularly from PerlMonks.</li></ul><p>All of that might get kind of dry, so I'll occasionally throw in bizarre, offtopic essays and tales about whatever pops into my head: skepticism, music, tea, etc. Excitement! Excitement! Excitement!</p> stephen 2003-01-28T18:30:37+00:00 journal