CodeShop

Code for all

About CodeShop

October 13th, 2009

CodeShop, a software company located in Amsterdam, helps companies to create and execute smart technology strategies.

We are a leading provider of cross-platform video streaming technologies. CodeShop’s products are in operation around the world with customers ranging from broadcast networks and online content distributors to small companies and webcasters.

The ease of use and reliability of our solutions allow customers to shorten their time-to-market. Our solutions fit into existing frameworks (Apache, IIS, Nginx) thus allowing for greater return on existing investment.

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, ...