Tiliman’s Weblog

June 13, 2014

Playing local videos on ChromeCast

Filed under: Tech Tips — Tags: , , — tiliman @ 8:57 pm

 

It seems a bit strange initially that only way to play videos is via Chrome Browser. This is well and good if video format is playable by Quicktime plugin in Chrome Browser. This is not enough for other formats like DivX. This leaves 2 options for you to play videos.

  1. You can re-encode videos using ffmpeg to a format suitable for quicktime.
  2. you can download DivX or other video plugins (if available) for quicktime and then play those.

The second option is far easier and is one time effort. It is simple logic but hardly anyone mentions it as a solution on internet, hence the blog post.

DivX plugin can be downloaded from here.

http://www.divx.com/en/software/divx

There is also discussion on creating plugin for ChromeCast in VLC and in a few months we should see support for ChromeCast in VLC.

 

Advertisements

July 29, 2013

Viewing Erlang Crashdump Remotely

Filed under: Backend, Erlang — Tags: , , — tiliman @ 8:53 pm

Erlang allows you to load crashdump by using Crash Dump Viewer. The information provided has backtrace to figure out what went wrong and where. The catch is that default viewer only listens on 127.0.0.1 (localhost) ip address. There is no start method that takes IP address as a parameter to listen on. The way to make crash dump viewer to listen on other port is to start webtool before crash dump viewer and give it ip port.
Here is an example


1> webtool:start(standard_path,[{port,8888},{bind_address,{0,0,0,0}},{server_name,"mytest"}]).
WebTool is available at http://mytest:8888/
Or  http://0.0.0.0:8888/
{ok,}
2> crashdump_viewer:start().

or simply start webtool and browse to it and start crashdump viewer from the web GUI itself.

January 2, 2013

Google Cloud Messaging with Erlang

I have been working on Facebook matchmaking code for Android/Unity to mimic iOS Game Center like flow of match making where other player receives notification on phone. Server side is coded with Mochiweb in Erlang. Here is simple code to send GCM Notification.

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
send_gcm_msg(ApiKey, Pnstoken, Message, Game) ->
        Baseurl = "http://android.googleapis.com/gcm/send",
        ApiKey1 = string:concat("key=",ApiKey),
        %% Create Json struct
        Body = lists:flatten(mochijson:encode({struct, [{registration_ids,{array, [Pnstoken]}},
                        {data,{struct, [{message,Message},{game,Game}]}},
                        {time_to_live,3600},
                        {collapse_key,game_invite}]})),
        try httpc:request(post, {Baseurl,[{"Authorization",ApiKey1}],"application/json",Body},[],[]) of
                {ok, {{_,200,_},_,RespBody}} ->
                        {ok, mochijson:decode(RespBody)};
                {error, Reason } ->
                        {error, Reason};
                {ok, {{StatusLine,_,_},_,RespBody}} ->
                        {error, {StatusLine, RespBody}};
                BigError -> {error, BigError}
        catch
                Throw -> {error, caught, Throw}
        end.

October 21, 2011

Sending Unicode SMS via Kannel

Filed under: GSM — Tags: , , , — tiliman @ 3:36 pm

Kannel is always a delight to work with. It is solid piece of software that would win over any commercial SMS GW.

Standard GSM characters are usually enough for English and most European languages but when it comes to sending SMS in other languages you have to rely on UNICODE. Here is character sheet of GSM characterset http://www.csoft.co.uk/sms/character_sets/gsm.htm
It might seem tricky at first to send Unicode SMS via Kannel and usually requires trial and error.

Sending unicode SMS involves following
1– Converting your SMS body string from whatever character set to into UNICODE (UTF-16).
2– URL Encoding (Percent Encoding) the SMS body.

HTTP GET example for sending Unicode SMS

<?php
$in_msg = "你好朋友Michael";
print urlencode(iconv('utf-8', 'ucs-2', $in_msg));
?>

My text here is stored in UTF-8 so I have to first convert it to UNICODE and then convert to URLencoded format.
The result comes out to be something like this
%60O%7DY%0Bg%CBSM%00i%00c%00h%00a%00e%00l%00
Now in Kannel send URL I have to specify that I am sending it UNICODE and for that I used charset=UCS-2
and to tell Kannel to send SMS as UNICODE as well (not as GSM characters)&nbsp;coding=2
I use HTTP GET URL for testing and this is how my final URL looks like
lynx –dump “http://KANNEL_SERVER:13003/cgi-bin/sendsms?username=USERNAME&password=PASSWORD&from=YOURFROMID&to=MOBILE_NUMBER&text=%60O%7DY%0Bg%CBSM%00i%00c%00h%00a%00e%00l%00&coding=2&charset=UCS-2&#8221;

HTTP XML POST example for sending Unicode SMS

XML POST is a little different indeed. The charcterset is actually identified in encoding param of xml namespace tag. You need to provide it the body in UNICODE (UTF-16/UTF-16BE) in URLEncoded form.


<?php
$SERVER = 'KANNEL_SERVER';
$PORT = '13003';

$out_msg = "你好朋友Michael怎么了";

# convert from UTF-8 to UTF-16.
$out_msg = mb_convert_encoding($out_msg,"UTF-16","UTF-8");

# Don't forget to URLEncode or else you might get unwanted string termination
$out_msg =  urlencode($out_msg);

print $out_msg."\n";
print "len ". strlen($out_msg)."\n";

$fp = fsockopen ($SERVER, $PORT, $errno, $errstr, 30);
    $res = "";
    $header = "POST /cgi-bin/sendsms HTTP/1.1\r\nHost: $SERVER\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: __LENGTH__\r\n\r\n";
    $re1 = "";
    $req = "
<message>
    <submit>
        <da>
            <number>YOUR_NUMBER</number>
        </da>
        <oa>
            <number>FROM_ID</number>
        </oa>
        <ud>$out_msg</ud>
        <udh/>
        <dcs>
            <coding>2</coding>
        </dcs>
        <from>
            <username>USERNAME</username>
            <password>PASSWORD</password>
        </from>
    </submit>
</message>"; 

    $header = str_replace("__LENGTH__",strlen($req),$header);
    if (!$fp) {
            // HTTP ERROR
            print("Error in service.\nPlease try again later..");
            exit;
    } else {
            print "Sending\n$req\n";
            fputs ($fp, $header . $req);
            // read the body data
            $res = '';
            $headerdone = false;
            if (!feof($fp)) {
                $line = fread ($fp, 4096);
                print "Read:\n$line\n";
                fclose($fp);
            }

    }
?>

This is how your XML should look like

<?xml version="1.0" encoding="utf-16"?>
<message>
    <submit>
        <da>
            <number>MOBILE_NUMBER</number>
        </da>
        <oa>
            <number>YOURFROMID</number>
        </oa>
        <ud>O%60Y%7Dg%0BS%CB%00M%00i%00c%00h%00a%00e%00l%60%0ENHN%86</ud>
        <udh/>
        <dcs>
            <coding>2</coding>
        </dcs>
        <from>
            <username>USERNAME</username>
            <password>PASSWORD</password>
        </from>
    </submit>
</message>

This is all. Sending Unicode SMS is not that hard with Kannel after all.

Bringing back Adler32 to SCTP for Kernel 2.6

Filed under: GSM — Tags: , , , , , , , — tiliman @ 9:55 am

I had a situation a few days ago where I wanted to connect to our STP to test MAP applications built on Mobicents. Our STP was configured to only support Adler32 checksum. Adler32 is deprecated and CRC32 is considered a standard checksum to be used for SCTP. Keeping up with standards the Linux 2.6 kernel stopped supporting Adler32 and implemented CRC32 using libcrc32c.

I couldn’t reconfigure STP to use CRC32 and it was not possible to use different checksums for different SCTP peers as it is a Transport Layer Protocol. There was no solution I could find on internet, so I decided to patch my kernel and replace CRC32 with Adler32. I could see that a lot of other have had this problem and they couldn’t find any solution. I hope my solution would work for them as well.

  • Download kernel-headers for your kernel. Command like this would work on Debian apt-get install linux-headers-$(uname -r). Note: you don’t need sources for kernel. Just header files.
  • Take a backup of your original sctp.ko file. It would be somewhere /lib/modules/$(uname -r)/kernel/net/sctp/sctp.ko
  • Download the sctp module code from here to a clean directory somewhere away from usual linux sources. You don’t need it to be in linux sources directory.
  • Do make and make install in the new SCTP code at src/sctp/.
  • Check if new module is installed using modinfo sctp. It should say in description:    Support for the SCTP protocol (RFC2960) – with Adler32.
  • Do rmmod sctp and then modprobe sctp to load this new module. If you can’t do rmmod as module is busy and you can’t free it then you might have to reboot the system.
  • On load the module prints a message in /var/log/messages Initialising Adler32 patched SCTP module for 2.6 kernel

Now you have SCTP using Adler32 instead of CRC32. If you need to ever go back to CRC32, you can replace sctp.ko with your backedup module or you could download kernel sources and remake module.
May be in future I would add a load param to module to tell it to use CRC32 or Adler32 checksum.


Update October 24, 2011
The initial code was able to use checksum for outbound packets but was still using CRC32 for inbound packets. Updated the link to fix that.

September 3, 2011

CIMA UK Professional Experience Requirement for Entrepreneurs

CIMA UK is a great institute (accountancy body) in Management Accountancy fields. I happily opted for it because of its strength even though I had always wanted to be an Entrepreneur and I started my first company in 2006 at age 22.

I passed all my CIMA exams a few months ago. CIMA requires fulfilling of professional experience of about 3 years to be awarded membership as an ACMA. The discussion of this Professional Experience always revolves around about getting a job in industry and going through different roles. We all know that running a company specially starting a company requires you to take on multiple roles which require working on accountancy, legal matters and taxation matters. I have been able to handle most of these roles because of my education.

I was disheartened that I couldn’t fulfill professional experience requirements because I was not an employee of some other big company that could authenticate/verify my experience. So, I emailed CIMA regarding this matter and to my amusement I got a clear response that made my day. It looked like from the tone of email that CIMA has given thought about Entrepreneurs for Professional Experience requirements.

Here is the quoted part from email

—————–

To start I would like to clarify our practical experience requirements to you. Please note you do not need to be working with various jobs or even with reputable corporations. You could work for any size company in any industry,  well known or not, as long as you meet the requirements.

The purpose of the practical experience requirements is to maintain our prestige, and ensure we only qualify the best of the best. To ensure this, we require our members to have experience with common management accounting practices. The types of experience we require can be found via the following link:

http://www.cimaglobal.com/Students/2010-professional-qualification/Test-of-professional-competence-in-management-accounting/Part-A-initial-professional-development–work-based-practical-experience/

If you own your own business you may still gain the experience listed in the above link. However, keep in mind this experience must be verified by parties other than yourself. Generally this would be a line manager/boss, but in the case of an entrepreneur could be a bank manager, external auditor, or company accountant.

So please do not think we limit the opportunity for those employed by smaller firms/self employed, because we recognize all experience in the same light.

I hope this answers your query.

—————–

This should be good information for anyone who is doing CIMA and is worried about Professional Experience part of qualification.

P.S. The accountancy qualification gives a lot of advantage in starting business. The amount of money saved in accountant and lawyer fees and the ability to take advantages of tax exemptions can be used to strengthen business.

June 11, 2010

ImAware – Application for Nokia’s Calling All Innovators

This software was my only entry for Nokia Calling All Innovators competition ended on June 10th, 2010.

Concept

The key idea of this software is to allow users to submit reports about events that occurred around them and let others who visit the area know about it in realtime.

ImAware - Submit Tab

This way users can avoid high crime areas as well as visit close by attractions.

It would not be wrong to say that this is sort of wikipedia for real life events using mobile technology.

How it works

This software allows users to report an event that they have just witnessed via their phone. Each such report gets tagged with location information of the phone. This doesn’t only mean GPS but also includes using Network(CellID).

The software also pulls realtime events surrounding the user, again by taking the users’ location. Events can be of types Crime, News or Attractions like Sports/Concerts.

Threat Level Analysis/Calculation

Most interesting feature of this software  is the Crime threat analysis based on user submitted reports. This is somewhat important for big cities like where crime rate is high. The system uses a simple algorithm by taking crimes that occurred within 5 km of user’s location to calculate an approximate threat level of that area.

The age, severity of crime, time of day, all participate in calculating the threat level.

Threat Levels go between Low, Medium, High and Critical.

What is Event type “Attractions”?

The rest of software is about attractions like Sports, Concerts, Book Sales etc which is shown on users’ map.

Roadmap

ImAware - Status Display

  • A full set of Web API will be provided to allow other websites/softwares to integrate.
  • Integration with facebook to add it as an app.
  • Better analysis of crimes and possible prediction
  • Create a service out of it and a possible business around it.

Technologies/API used

The software makes use of following APIs

  • Nokia Location Services API
  • Qt GUI and Core library
  • Qt Network services for HTTP communication
  • Google Maps
  • Database on remote server using MySQL
  • Python+django based webservice
  • WebKit using QtWebKit wrapper to display map and other html retrieved from server

February 11, 2010

British TV Series Hustle predicted Oil Prices to be 150 dollars in 2006

Filed under: Uncategorized — Tags: , , , , , — tiliman @ 6:22 pm

Hustle is a british TV series where a group of grifters steal money from greedy people by creating brilliant schemes. The 3rd episode of season 3 aired on 24th March 2006 predicted oil prices to reach 150 dollars a barrel in 2 years which would be around 2008 according to airing date of show. Ash and Stacey while presenting their predictions about Oil prices to a banker, convince him that in 2 years time the Oil will hit 150 dollars and all known reserves will be exhausted by 2020. We can’t say about 2020 but the oil prices prediction which were supposedly fake in episode came to be true.

OIL Historical Prices

OIL Historical Prices

February 10, 2010

Android Development with Scala

Filed under: Android, Mobile Software Development — Tags: , , , , , — tiliman @ 4:33 pm

I learned a few weeks back about Scala programming language. I never liked Java and thought to try Scala as I would learn functional language and be able to still use JVMs.
I also wanted to learn Android development as I have done previously Windows Mobile, Symbian and iPhone development. Using Scala with Android was my idea to hit 2 birds with one stone.

Android Decelopment using Eclipse and Scala language

Android Decelopment using Eclipse and Scala language

All the information that I could find about using Scala with Android was for Android 1.6/1.7 but not with Android 2.0.1. Today finally I got Scala-Android development working for me. I am using Eclipse for development on OSX.

The steps involved are documented in detail here which can be followed till Step 4 as after that I will explain the trick to use Scala . If you are an advanced programmer then you should be able to follow my brief guide below.

Increasing memory of Eclipse

Edit eclipse.ini file which can be found in OSX at /Applications/Eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
If you have not made changes to an app contents before in OSX then for your information right-click Show Package Contents displays all the internal directories in .app bundle.
Make sure that these parameters are there in config file as below


256m
-vmargs
-Xms256m
-Xmx1024m
-XX:PermSize=64m

Goto android sdk tools directory at <ANDORID_SDK>/platforms/android-2.0.1/tools/dx.sh and edit it and make sure this param is there


defaultMx="-Xmx512M"

It can be different on windows as windows uses batch file. You can find it as -Xmx<NNN>M where NNN is the memory size.

Note: mine was setup as 1024M so I kept it like that. 512M should work fine as well.

Install Android 2.x.x SDK

Download and install Android SDK and Tools from this link http://developer.android.com/sdk/eclipse-adt.html
I had to use HTTP instead of HTTPS for installing ADT plugin on Eclipse.

Install Scala

Download and install Scala plugin for Eclipse
You can put this URL directly in Install New Software feature of Eclipse
Scala – http://www.scala-lang.org/scala-eclipse-plugin
More details can be found at http://www.scala-lang.org/node/94

Download and install full Scala installer as well to get more control on Scala as well as get sbaz support.
http://www.scala-lang.org/downloads/distrib/files/scala-2.7.6.final-installer.jar or find whatever is the latest version at the time of reading.

Install scala-android library for development

Download and install scala-android.jar (library)


sbaz install scala-android

You can compile it yourself by visiting this link http://robey.lag.net/2009/01/19/scala-on-android.html

Create an Android project

Add Scala Nature by right clicking on project and then Scala->Add Scala Nature

Fix Project settings to use Scala

Scala Eclipse Settings

Scala Eclipse Settings

Goto Properties->Builders tab and make Scala Builder as 2nd last item in list.

Goto Java Build Path->Libraries and Remove Scala Library Version 2.x
In same Java Build Path->Libraries, Add External Jar and locate scala-android.jar in lib directory of Scala SDK.

Extending Scala class from Java

I always had issue compiling Android app written in Scala with class not being found as per manifest file. The issue was somewhere between Java expecting .java file as starting point and not being able to find it. So, I found a solution to leave original .java file as entry point and make a new file for Scala. Now the Java startup/main class extends Scala class which allows me to write rest of application in Scala.
My project was called ScalaTest and the ScalaTest.java was boilerplate code generated by android new project wizard.
The file looks like this after changes made for Scala


package android.ScalaTest;

import android.app.Activity;
import android.os.Bundle;

public class ScalaTest extends MainScala {}

The MainScala.scala looks like this


class MainScala extends Activity {
    override def onCreate(savedInstanceState: Bundle) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main)
    }
}




First Scala Application

First Scala Application

Thats it. Scala can be used to do rest of Android Development as well as Debugging. Now I am off to learn Scala with Android.

January 7, 2010

Dawn of new 3-D TV Era

Filed under: Gadgets — Tags: , , , , , , , , , — tiliman @ 3:21 am

It seems that suddenly there is increased interest from big electronic appliances manufacturers in 3D TV as well as TV channels.

  • Samsung is releasing a new pencil thin 3D TV that can convert 2D videos into 3D. More interestingly they are integrating their new AppStore withthe system as well.I wonder where is the SDK for building apps for TV? We know Bada for Phone is being launched in April.
  • Toshiba with a set top box has also promised to upconvert 2D videos to 3D as well as upconverting of not-so-high-def videos to highdef.

    Sony Bravia XBR-60LX900 3-D TV

    Sony Bravia XBR-60LX900 3-D TV

  • Sony’s Bravia XBR-60LX900 due this summer will support 3D as well.
  • Discovery partnering with Sony and Imax promises for 24hour 3D TV channel as well as  ESPN promises for 3D TV channel this summer.

The 3D tech is finally arriving in our homes but it is yet to be seen how well the technology delivers. I hope Hollywood is planning on more 3D movies as well to support the initiative of manufacturers.

Update 10 January, 2010

I just saw a test 3D TV channel on Eurobird 9 is available at Freq 11747 tp 51.It seems to be Italian channel called 3DSG. Here is lyngsat link http://www.lyngsat.com/eb9a.html with complete info.

Older Posts »

Create a free website or blog at WordPress.com.