H264 Smooth Streaming
May 29th, 2009
We are adding support for Smooth Streaming to our H264 Streaming Module.. Next to supporting videos encoded by the Microsoft Expression Encoder (VC-1 multi bit rate) we are also adding support for H.264 encoded videos (H.264 multi bit rate) which can be encoded by open-source (X264) software.
Watch our demo of Smooth Streaming H.264!
object_factory
May 17th, 2009
For some reason, I needed a object factory. Well, that’s easy you might think: this subject is well understood and textbook material.
It turns out differently.
There are in fact several places where you can look: - Loki - Codeproject - Boost Sandbox
But these are all either too specialized or too generalized: nothing fitted quite what I needed: an object factory that creates objecst based on the types of the constructor parameters …
For example:
typedef ObjectFactory<base* (int, float), short> factory_t; |
where base* (int, float) is the constructor signature, and short is the key (but you could use std::string just as easily).
The best solution was to be found on Gamedev
But this too needed a bit of attention: I wanted N constructor parameters, without having to specialize them by hand – as that would be silly.
So, with the help of Boost.Preprocessor I came up with the following.
The template is here
The template is specialized once for a constructor without arguments, and with the use of Boost.Preprocessor N times; well, between LIMIT_LOWER_BOUND and LIMIT_UPPER_BOUND – which you can adjust if you need more …
The above will allow for code like this unit-test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
struct base {}; struct node1 : public base { node1(int) { std::cout << "node1(int)" << std::endl; } node1(int, float) { std::cout <<"node1(int, float)" << std::endl; } }; void test_object_factory() { std::wcout << L"object_factory_test: " << std::endl; typedef ObjectFactory<base* (int, float), char*> node1_factory_t; node1_factory_t nf; nf.Register<node1>("node1"); base* n1 = nf.Create("node1", 2, 3.0); delete n1; |
This would create an object with the (int, float) signature.
rails's daemonize
March 29th, 2009
Isn’t this a nice and clean way of forking?
1 2 3 4 5 6 7 8 9 10 |
def daemonize exit if fork # Parent exits, child continues. Process.setsid # Become session leader. exit if fork # Zap session leader. See [1]. Dir.chdir "/" # Release old working directory. File.umask 0000 # Ensure sensible umask. Adjust as needed. STDIN.reopen "/dev/null" # Free file descriptors and STDOUT.reopen "/dev/null", "a" # point them somewhere sensible. STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile. end |
That is, it’s the same as in Steven’s Advanced Programming for the Unix Environment, but a lot less verbose. Then again, above is Ruby – Stevens is C.
YouTube's Inline Ads
January 23rd, 2009
Q: What happens when Google tries to match Disney videos to their pool of advertisers?
A: 
Ah, 31 animals . Let’s see, there’s Alex, Marty, Melman, Gloria, Julien, Maurice, Moto Moto, ...
iPhone Capistrano deployment
October 28th, 2008
You can automatically deploy your own application to the iPhonedevice by using Capistrano.
Requirements: Capistrano (gem install capistrano) and ldid (install via Cydia).
Build your application for the ARM architecture:
bjam --toolset=darwin macosx-version=iphone-2.0 architecture=arm release
Deploy the application to the iPhone:
cap deploy
Your app is packaged (tar), copied (scp) to your iphone and SpringBoards is restarted. I use the following Capfile:
set :application_name, "LocateMe"
set :iphone_ip, "192.168.1.4"
set :user, "root"
# password = alpine
desc "Package your iPhone application"
task :package do
%x[cd "~/Library/Application Support/iPhone Simulator/User/Applications/00000000-0000-0000-0000-000000000000" && \
tar -czpvf #{application_name}.tar.gz #{application_name}.app && \
scp #{application_name}.tar.gz #{user}@#{iphone_ip}:/Applications]
end
desc "Install the application on your iPhone"
task :install, :hosts => "#{iphone_ip}" do
run <<-CMD
cd /Applications/;
tar -xzpvf #{application_name}.tar.gz;
rm #{application_name}.tar.gz;
ldid -S /Applications/#{application_name}.app/#{application_name};
killall SpringBoard; # OS 2.0
# /Applications/BossPrefs.app/Respring; # OS 2.1
CMD
end
desc "Package and install the application on your iPhone"
task :deploy, :hosts => "#{iphone_ip}" do
package
install
end
