MustafaCast - My Chromecast Experiments

When I first saw Chromecast, I really liked it and by a nice coincidence, my brother in law was in America during its launch and grabbed two Chromecasts. I did not find a chance to develop for Chromecast, since I live in a dormitory with no TV or monitor with HDMI.

What is Chromecast?

Chromecast is a 35$ HDMI device that is connected to internet via your WiFi. It is probably, a slimmed down version of ChromeOS. It has a Chrome inside, that displays web pages. However, these web pages are special. They are much like intents in Android. There are currently registered apps in Chromecast, and when a sender, either a web page in your PC Chrome, or Android/iOS application sends a message with specific AppID, your Chromecast opens the related app automatically and begins communicating with your sender. The best part is, integration is seamless, when you configure your Chromecast first time, you embed your WiFi creditentials in it and it is automatically discoverable by the senders. The main aim of Chromecast senders is to send a link, or an identifier, so that Chromecast can continue playing video, music without sender being active all the time. For instance, it just recieves the ID of an Youtube video and afterwards Chromecast downloads the video itself. And with your sender, you can monitor the progress, stop or pause the video/music. Currently, most of the available apps for Chromecast are audio/video apps. But the possibilities are endless, it is just a device connected to internet and can recieve messages for you. There is no reason for anyone to not implement monitoring of his security cameras, the sensors or showing some Twitter feeds. And as a bonus, you can cast a full Chrome tab to your TV, if you just want to show a web-page through your TV.

Developing for Chromecast

To develop for Chromecast, you need to apply Google for permission. The API is not stable, and it is still in development process. I applied for permission and they responded positively after 2 days. You need to supply your device's serial and a valid URL, called receiver, which Chromecast uses to download your application. Actually, it is just a web page, with Chromecast Reciever API, and you code your application in JavaScript. It is very easy to use. For more information visit Google Chromecast Developer page

My Contribution: MustafaCast

Currently, no app or web page allows you to view your local videos and photos. I wanted to solve this. Chromecast is essentially a Chrome, and it allows playing of VP8 or H.264 encoded videos. However, your local content are as their name suggests, local. They need to be served. You can send images base64 encoded to your Chromecast by its API, but this approach will not scale for videos. Additionally, your images may be large but Chromecast only supports 720p for now. Lastly, the videos might not be H.264 encoded, so they need to be transcoded.

To address those issues, I wrote a custom web server in NodeJS. (Sorry, Google does not allow publishing the code for now). With help of Imagemagick, the photos are properly resized to 1280x720 by respecting the apsect-ratio and converted to jpeg. The photos were trivial to send. Videos require fiddling with settings. I used ffmpeg to transcode videos. I first used VP8 encoding for video, but its encoding performance in ffmpeg is not good. It does not fully utilize my system. Hopefully it will increase in time. Therefore, I used the H.264 encoding. It is fast enough to stream my HD videos on my i7 quad-core laptop. The point is, the encoded videos are not stored on your disk, they are being transcoded actively on each request, so you don't have to wait. But remember to place your Chromecast close to your router, as the speed gets important when streaming a video.

It was a fun expereince to code this, and I spent approximately 4-5 hours in total, to learn and try. *Note to future developers: Don't forget to select the checkbox 'Send serial number to Google in updtaes' in setup of your Chromecast *. I have lagged almost an hour because of this.

I really hope this will be a good product, it follows the Android's intent philosophy, the result of your share click is now on a related app on your TV, instead of another app in your Android.


I cannot post code, but I can show some shots of MustafaCast :)

Welcome screen of MustafaCast


Playing DIVX encoded video on TV, transcoding Real-time to H.264 (not my favorite Star Wars movie)


Screenshot of the sender page on Chrome


Hello World, again

I am building my website, again. Good part is, I have transferred my old content from my Wordpress hosted blog.

Comparing ExpressJS Session Stores

For my next project, I was exploring the session storages for ExpressJS, and I found a question on StackOverflow, but I was frustrated with the accepted and 30 upvoted answer, which compares local in memory session store with remote session stores. The answer is very misleading, there is no chance that remote storage can beat local storage, even if the in-memory solution does O(n^9) calculations, it would be faster than going to web.

So I have decided to carry my own test on my local machine, with local installations of Express and MongoDB. The results were interesting. I have tested a simple server that does the following:

<code>app.get("/", function(req,res){
    if ( req.session &&{ = + 1;
    } else { = 1;
    res.send("No: " +;

The results for concurrency levels 1,10,100,500 are:

<code>oncurrency: 1
none       4484.86 [#/sec] 
memory     2144.15 [#/sec] 
redis      1891.96 [#/sec] 
mongo      710.85 [#/sec] 
Concurrency: 10
none       5737.21 [#/sec] 
memory     3336.45 [#/sec] 
redis      3164.84 [#/sec] 
mongo      1783.65 [#/sec] 
Concurrency: 100
none       5500.41 [#/sec] 
memory     3274.33 [#/sec] 
redis      3269.49 [#/sec] 
mongo      2416.72 [#/sec] 
Concurrency: 500
none       5008.14 [#/sec] 
memory     3137.93 [#/sec] 
redis      3122.37 [#/sec] 
mongo      2258.21 [#/sec] </code>

The source code of this is available on the GitHub:

I hope it will help you to choose a better session storage for your needs. I will go with Redis, because it is almost as fast as in-memory solution, whereas MongoDB s performance cripples down.

My First Android Game: Izuna Drop

As a part of my CS-319 Object-Oriented Software Engineering course,  I developed a computer game with Nail Akıncı and Naime Nur Çadırcı, called Izuna Drop. It is a simple space shooter clone. As the design was more imporant in that course, the implementation was not very efficient, it was written on Java, and due to our bugs, it requried approximately 1 GB of memory. If you wonder what that looked like, it is avaialable on GitHub/Izuna.

In this summer, I bought a Turkish book, Android Oyun Programlama(Android Game Programming) It focuses on AndEngine which is a Java Game engine for Android. Book is nice, but it focuses on GLES1 version of AndEngine, which is now outdated and it is hard to find support, since the GLES2 version of AndEngine has many changes over the old one. However, it is a nice book to teach you the basics, it is not rocket science to make the transition to GLES2 on your own.

Anyways, I have read the book and started to implement few simple scenes. The biggest problem in game development is that you cannot find graphical assets easily, which is the essential part. I know a little bit about designing, but it is not easy to design nice game assets. But Nail Akıncı, my team member has developed himself on modeling and animation and provided us nicely hand-made assets. (But if you Google enough, you can find very nice free 2D assets for your game). So, I have decided to re-implement our game for Android. It took almost a month, working on mostly nights during this hot summer. AndEngine simplifies many things that we had manually take care of on our PC version, so the Android version is much more faster and has small memory footprint.  It's source can be also viewed at GitHub/izuna-android. It is not perfect, for instance collisions are not pixel perfect, but overall it is a playable and enjoyable game with 5 levels and each level consisting 10 unique waves.

Here are some screenshots from the Izuna Drop:

s1 s2 s3

I would be glad if you could download it and test it:


Thank you!

My experiences with, torrenting on the cloud

I have been living in dormitory for 4 years, and sometimes I needed something. Even it is legit file, it is forbidden to use torrents in Bilkent dormitory. Or you get slow down or even a suspension for a while. Then, earlier this year, I have found out, via a referral. It's on the cloud. You upload your torrent file, or just paste the public URL and downloads it to your server. After that, you can download your file over regular HTTP, where it is not different than your regular web traffic. It is possible to limit these, however different than regular torrent, you do not have to upload the pieces in you. also uploads the files for you, it takes of seeding upto 1.00 ratio for public torrents, and 2.00 for private torrents. These are very useful, you do not consume more trafic than downloading your file. 

Besides the benefits, also has good downloading speeds. As it is in the cloud, it is probably closer to the each source than you can ever be in your home, so it downloads faster than you can do. Therefore, you do not have to keep your computer on more than you need. Also, if somebody has downloaded the torrent you have given recently, you can immedaitely access as puts them in cache. 

In terms of  downloading speed from, it differs. It can be very fast, or very slow. I recommend you to use a download manager. It can increase the download speed a lot. I have a little tool named axel on linux, which can download files upto dividing it to 256 parts. I  have seen 70 MB/sec (megabytes, meaning which is equiavlent to 0.56 gbit/sec). But, that is not alwayts the case. Usually around 10-20 parts, files can be downloaded at 5-6 MB/sec at my dormitory.

On the bad side, I have problems on resuming downloads that I have started before. They just simply do not start. This happens when filename is not detected, and you need to supply additional HTTP login parameters via your download manager. But sometimes it just gives a URL with token, these can be paused & downloaded without any problems as long as you do not change your password.

Last good feature is, if you have a torrent that consists of too many files, can zip them on the fly and deliver it to you. It is really useful. I really recommend it if you suffer from low downloading speeds, or behind a router that does not allow you to download torrents.