RTMFPサーバのインストール

RTMFPというのはFlashやAdobe AIRでP2Pを実現するプロトコルらしい。
ノード管理用サーバがオープンソースで出ていて、今回は *Cumulus* というサーバをインストールしてみることにした。

今回はCentOS上にインストールしてみた。

opensslのインストール

yum install openssl

pocoのインストール

 
wget http://jaist.dl.sourceforge.net/project/poco/sources/poco-1.4.2/poco-1.4.2p1.tar.gz
tar zxvf poco-1.4.2p1.tar.gz
cd poco-1.4.2p1
make
make install
 

パスを通す

export LD_LIBRARY_PATH=/usr/local/lib

LuaJITのインストール

 
wget http://luajit.org/download/LuaJIT-2.0.0.tar.gz
tar zxf LuaJIT-2.0.0.tar.gz
cd LuaJIT-2.0.0
make
sudo make install
 

CumulusLibとCumulusServerをコンパイル

 
cd CumulusLib
make
cd ../CumulusServer
make
 

以上でインストールは完了。
CumulusServer内で、 ./CumulusServer を実行すると、サーバが起動する。

サーバアプリのサンプル

https://github.com/OpenRTMFP/Cumulus/wiki/Server-Application,-Samples を参考にして、簡単なサンプルを作る。

サーバ側に以下のコードのLuaスクリプトを設置。CumulusServer/www/meeting/main.luaを作成する。

 
function onStart(path)
	NOTE("Application '"..path.."' started")
end
 
function onStop(path)
	NOTE("Application '"..path.."' stopped")
end
 
function onConnection(client, userName, meeting)
 
	client.userName = userName;
	client.meeting = meeting;
 
	INFO("User connected: ", client.userName , "meeting: ", client.meeting);
 
	function client:getParticipants(meeting)
		result = {}
		i = 0;
		for key, cur_client in cumulus.clients:pairs() do
			if (cur_client.meeting == meeting) then
				i = i+1;
				participant = {};
				participant.userName = cur_client.userName;
				participant.meeting = cur_client.meeting;
				if cur_client.id then
					participant.protocol = 'rtmfp';
				end
				participant.farID = cur_client.id;
				result[i] = participant;
			end
		end
		return result;
	end
 
	function client:sendMessage(meeting, from, message)
		for key, cur_client in cumulus.clients:pairs() do
			if (cur_client.meeting == meeting) then
				cur_client.writer:writeAMFMessage("onMessage", from, message);
			end
		end
	end
 
	sendParticipantUpdate(client.meeting);
end
 
function onDisconnection(client)
	INFO("User disconnecting: "..client.userName);
	sendParticipantUpdate(client.meeting);
end
 
function sendParticipantUpdate(meeting)
	for key, cur_client in cumulus.clients:pairs() do
		if (cur_client.meeting == meeting) then
			cur_client.writer:writeAMFMessage("participantChanged");
		end
	end
end
 

クライアントは Adobeのサイト の、 rtmfp_app_assets.zip を使用する。

FlashBuilderを持っていないので、FlashDevelopを使いコンパイルする。

FlashDevelopで新規プロジェクトをAIR Flex4 Projectとして作成する。
rtmfp_app_assetsを解凍してできたソースコードを、作成したプロジェクトのsrcフォルダにコピー。
デモで使用しているosmfライブラリが古いので、 SourceForge からブランチをダウンロードし、 framework/OSMF/ 以下のorgフォルダをコピーし、プロジェクトのsrcフォルダにコピー。

プロジェクトツリー内のVideoMeeting.mxmlを右クリック、 Document Class にチェックし、実行するとデバッグが可能となる。

Service HostにCumulusを入れたサーバのIP、ポート(初期値は1935)でアクセス(100.100.100.100:1935など)し、接続を確認する。