Developer guide contain info about how to closely work with Flashphoner.
Here you can finв all detailed information about changing Flashphoner for your needs.
- Getting source
- Flashphoner SVN repository
- Repository structure
-
How to checkout from public SVN repository: - Releases and patches
- Import project
- Recommended software
-
How to Import flashphoner_api into FlexBuilder -
How to Import flashphoner_client into FlexBuilder -
How to Import flashphoner_load_tool into FlexBuilder -
How to import flashphoner_app into IntelijIdea - Building sources
- How to build flashphoner_app and setup IntelijIdea + JDK
-
How to setup flex environment -
How to build flashphoner_api -
How to build flashphoner_client -
How to build flashphoner_load_tool - Testing
- Server - side development
- Client-side development
- Using different SIP username and authentication name
Getting source
Flashphoner SVN repository
Flashphoner has public SVN repository. You can get sources from here:
- svn://flashphoner.com/tags/release_512 - current release
- svn://flashphoner.com/tags/release_420 - previous supported release
Repository structure
Client
- flashphoner_api - internal part of project (communications with server-side, signaling and media)
- flashphoner_client - visual part of project (views, html, mxml files, front-end)
- flashphoner_load_tool (load tool, which simulate user behaviour with many simultanious calls)
Server
- flashphoner_app (server-side application, deployed in WowzaMediaServer)
- flashphoner_app (server-side application, deployed in WowzaMediaServer)
How to checkout from public SVN repository:
Click to expand and watch video
Releases and patches
Please, see Downloads page for more info about releases, patches, sources, docs api
Import project
Recommended software
We recommend use this software for compiling and debugging applications based on Flashphoner:
How to Import flashphoner_api into FlexBuilder
Click to expand and watch video
How to Import flashphoner_client into FlexBuilder
Click to expand and watch video
How to Import flashphoner_load_tool into FlexBuilder
Click to expand and watch video
How to import flashphoner_app into IntelijIdea
Click to expand and watch video
Building sources
How to build flashphoner_app and setup IntelijIdea + JDK
Libraries
You will need these libraries to build server-side application (you can get it in the WowzaMediaServer/lib folder):

You should install latest Flashphoner release and patch before - log4j-1.2.14.jar
- wms-server.jar
- wms-stream-live.jar
- wms-stream-publish.jar
- tbs-flashphoner.jar
- jain-sip.jar
- jspeex.jar
Then put these libs into classpath as it shown in the video.
Building
Click to expand and watch video
How to setup flex environmentSee video - how to setup FlexBuilder + FlexSDK
Click to expand and watch video
How to build flashphoner_api
Click to expand and watch video
How to build flashphoner_client
Click to expand and watch video
How to build flashphoner_load_tool
Click to expand and watch video
Testing
How to test default Flashphoner applicationYou can see how to install Flashphoner release, install patch, and test flashphoner_client with Bria softphone.
Click to expand and watch video
How to deploy customized applicationSee how to customize default flashphoner server-side application flashphoner_app and deploy it
Click to expand and watch video
Server - side development
FlashphonerApp
Description
This is the main server-side application.
It handles client connects and client actions: CALL, HANGUP, ANSWER, HOLD etc.
It Implements IRtmpClientsCollectionSupport interface, this interface provides IRtmpClientsCollection.
RtmpClients is simple implementation of the IRtmpClientsCollection interface and provides add(), findBy() and remove() methods for collection of RtmpClient instances.Main methods
Here are the main methods of the FlashphonerApp application.
onConnect() Invoked when flash-client invokes NetConnection.connect(). FlashphonerApp creates new RtmpClient instance for this connect. onDisconnect() Invoked when flash-client disconnects from server. FlashphonerApp removes the RtmpClient instance from collection and does finalize actions. call() Invoked when flash-client invokes NetConnection.call("call"...). FlashphonerApp delegates creating of new outgoing SIP call to the RtmpClient, which related this RTMP connect. answer() Invoked when flash-client invokes NetConnection.call("answer"...). FlashphonerApp delegates answer the SIP call to the RtmpClient, which related this RTMP connect. hangup() ... flash-client invokes NetConnection.call("hangup"...). FlashphonerApp delegates answer the SIP call to the RtmpClient, which related this RTMP connect.
AbstractRtmpClient
Description
This is the common methods for SIP client instance
AbstractRtmpClient has several constructor used for creating server-side SIP client.Main methods
Here are the main methods of the AbstractRtmpClient.
playAudio() Send audio data to the flash-client for playing playVideo() Send video data to the flash-clienr for playing streamStart() Start server-side sharing of incoming (SIP to Flashphoner) audio or video stream . streamAudioStop() Stop audio stream streamVideoStop Stop video stream writeAudio() Send audio data to SIP endpoint writeVideo() Send video data to SIP endpoint
RtmpClient
Description
This is the implementation of the server-side SIP client instance.
It extends from AbstractRtmpClient, and has:- Commands - actions of flash-client (see ISoftphoneCommands)
- Callbacks - notifications from internal server-side SIP engine (see ISoftphoneCallback)
Main command methods
See FlashphonerApp main methods above.
Main callback methods
Here are the main callback methods of the RtmpClient.
ring() invoked by Flashphoner SIP engine on SIP responses 100 Trying, 180 Ringing, 183 Session progress talk() invoked by Flashphoner SIP engine on SIP response 200 OK finish() invoked by Flashphoner SIP engine on finish of the call (by hangup, error, or other reason).
Rtmp2VoipStream
Description
This class streams mediadata from the flash-client to the SIP endpoint through RtmpClient
You can see MyRtmp2VoipStream class extends Rtmp2VoipStream.
Rtmp2VoipStream accepts flash-client netstream(audio+video) as NetStream.publish("streamName") and transfer this stream through RtmpClient instance, which related this RTMP connect.
Stream name must have this format: [sip_account]_[call_id] Example
[email protected]
where- 2001 - sip account
- [email protected] - call id
Flashphoner parses stream name and use call_id for redirecting media stream exactly this call line. (Since Flashphoner-1.0.3.512 release)
JavaDoc
See javadoc for more details.
Diagram of the modules
Click to expand picture
How to get call duration
The best way to get billing info is to use external API of your SIP provider.
But there are some cases when you need info about call duration.
We suggest you follow a way described below.
There are two points: begining of call and end of call.
So, you may use methods talk() and finish() of class RtmpClient (See Javadoc API and Flashphoner sources):class RtmpClient { ... private long begining; ... public void talk(...){ ... begining=System.currentTimeMills(); ... } ... public void finish(...){ ... end = System.currentTimeMills() - begining; ... } ... }
Client-side development
Using additional parameters from the webpage
Assume, we are going to use additional parameters from the URL of PHP, ASP or simple HTML page.
Example: Your page URL looks like http://mydomain.com/mypage.php?sipuser=mysipuser&sipserver=mysipserver or you use POST HTTP request for sipuser, sipserver params.
Your server-side page should generate such HTML code:var flashvars={sipuser=foo&sipserver=mysipserver.com}See flashphoner_client/html-template/Phone.html file (you can find this file in the latest relase or get it from our public SVN).
Then you need to get these values in flash application.
Download sources, import and build flashphoner_api and flashphoner_client projects as described above. Make sure that all works and no errors appeared.
Now you should change this class in the flashphoner_api project:com.flashphoner.api.PhoneModel
Pay attention to the method
PhoneModel.init()
This method invoked immediately after SWF object initialized on page.
You can add resolving of your custom parameters into the PhoneModel implementation:PhoneModel{ ... //Keeps sipuser parameter public static var sipuser:String; //Keeps sipserver parameter public static var sipserver:String; ... }init(...){ ... //Resolve sipuser parameter this.sipuser = Application.application.parameters.sipuser; //Resolve sipserver parameter this.sipserver = Application.application.parameters.sipserver; ... }That's all. You can use these params in this method:
com.flashphoner.api.PhoneServerProxy.login()
Login method uses customized parameters as described below:
//Using sipuser parameter obj.login =PhoneModel.sipuser ; obj.password = password; obj.mode = "flashphoner"; //Using sipserver parameter obj.sipProviderAddress = PhoneModel.sipserver; obj.sipProviderPort = username.substring(username.indexOf(":")+1);
Using different SIP username and authentication name
In some cases, we need have different SIP username and SIP authentication name.
Lets consider authentication challenge from Flashphoner:
REGISTER sip:flashphoner.com;lr SIP/2.0 Call-ID: [email protected] CSeq: 3 REGISTER From: <sip:[email protected]>;tag=59a238b9 To: <sip:[email protected]> Via: SIP/2.0/UDP rtmp.flashphoner.com:30000;branch=z9hG4bK502df9fb592f0635ba3f68dfb1595a6c Max-Forwards: 70 Contact: <sip:[email protected]:30000>;expires=3600 Expires: 3600 Authorization: Digest username="authenticationName",realm="asterisk",nonce="1a141d84",uri="sip:flashphoner.com;lr",response="e8538314ccfac1c383d7e842a932cf5b",algorithm=MD5 Content-Length: 0 Call-ID: [email protected] CSeq: 3 REGISTER From: <sip:[email protected]>;tag=59a238b9 To: <sip:[email protected]> Via: SIP/2.0/UDP 87.226.225.62:30000;branch=z9hG4bK502df9fb592f0635ba3f68dfb1595a6c Max-Forwards: 70 Contact: <sip:[email protected]:30000>;expires=3600 Expires: 3600 Authorization: Digest username="authenticationName",realm="asterisk",nonce="1a141d84",uri="sip:87.226.225.61;lr",response="e8538314ccfac1c383d7e842a932cf5b",algorithm=MD5 Content-Length: 0
In this example:
This parts uses SIP username 2001
From: <sip:[email protected]>;tag=59a238b9
To: <sip:[email protected]>
But this part uses SIP authentication name: "authenticationName".
username="authenticationName"
Default Flashphoner behavior is:
SIP username == SIP authentication name
So to use different SIP username and SIP authentication name you need follow this steps:
- Download and install patch Flashphoner-1.0.3.512-xxx with SIP authentication name support.
- Add constructor to RtmpClient.java:
RtmpClient.java
public RtmpClient(String login, String authenticationName, String pwd, IClient client, String sipProviderAddress, int sipProviderPort, String visibleName, boolean regRequired, String appName, String mode) { super(login, authenticationName, pwd, client, sipProviderAddress, sipProviderPort, visibleName, regRequired, appName, mode); }
- Use this constructor in the FlashphonerApp.java (line #173):
FlashphonerApp.java
rtmpClient = new RtmpClient(login, "authenticationName", password, client, sipProviderAddress, sipProviderPort, visibleName, regRequired, APPLICATION_NAME, Config.MODE_FLASHPHONER);
instead of
FlashphonerApp.javartmpClient = new RtmpClient(login, password, client, sipProviderAddress, sipProviderPort, visibleName, regRequired, APPLICATION_NAME, Config.MODE_FLASHPHONER); - Now you can build and deploy server side tbs-flashphoner-app.jar as described above in this developer guide.
And you will see in logs, that Flashphoner uses "authenticationName" string as SIP authentication name. - Then you should customize flashphoner_client, flashphoner_api and flashphoner_app code to send
SIP username and SIP authentication name both and use custom authentication name instead of "authenticationName" stub string.
| If RtmpClient.authenticationName is null, Flashphoner will use RtmpClient.login as authenticationName. |
See also: How to send custom param during login
