This documentation related to the earlier version of Flashphoner.
We recommend you upgrade to the last version and check the actual documentation

Developer guide

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

  1. 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
  2. Repository structure

    1. 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)
    2. Server
      • flashphoner_app (server-side application, deployed in WowzaMediaServer)

  3. How to checkout from public SVN repository:

    Click to expand and watch video
    We recommend to use Tortoisesvn client
  4. Releases and patches

    Please, see Downloads page for more info about releases, patches, sources, docs api

Import project

  1. Recommended software

    We recommend use this software for compiling and debugging applications based on Flashphoner:

    1. Desktop-side
      • FlexBuilder 3.0.2
      • Flex SDK 3.5
      • Intelij Idea 9.0.4
    2. Server-side
      • tcpdump
  2. How to Import flashphoner_api into FlexBuilder

    Click to expand and watch video
  3. How to Import flashphoner_client into FlexBuilder

    Click to expand and watch video
  4. How to Import flashphoner_load_tool into FlexBuilder

    Click to expand and watch video
  5. How to import flashphoner_app into IntelijIdea

    Click to expand and watch video

Building sources

  1. How to build flashphoner_app and setup IntelijIdea + JDK

    1. 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.
    2. Building
      Click to expand and watch video
  2. How to setup flex environment

    See video - how to setup FlexBuilder + FlexSDK

    Click to expand and watch video
  3. How to build flashphoner_api

    Click to expand and watch video
  4. How to build flashphoner_client

    Click to expand and watch video
  5. How to build flashphoner_load_tool

    Click to expand and watch video

Testing

  1. How to test default Flashphoner application

    You can see how to install Flashphoner release, install patch, and test flashphoner_client with Bria softphone.

    Click to expand and watch video
  2. How to deploy customized application

    See how to customize default flashphoner server-side application flashphoner_app and deploy it

    Click to expand and watch video

Server - side development

  1. FlashphonerApp

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

    2. 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.
  2. AbstractRtmpClient

    1. Description

      This is the common methods for SIP client instance
      AbstractRtmpClient has several constructor used for creating server-side SIP client.

    2. 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
  3. RtmpClient

    1. 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)
    2. Main command methods

      See FlashphonerApp main methods above.

    3. 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).
  4. Rtmp2VoipStream

    1. 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]
    2. 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)
    3. JavaDoc

      See javadoc for more details.

    4. Diagram of the modules
      Click to expand picture
  5. 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

  1. 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:

Logs
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:

  1. Download and install patch Flashphoner-1.0.3.512-xxx with SIP authentication name support.
  2. 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);
        }
    
  3. 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.java
    rtmpClient = new RtmpClient(login, password, client, sipProviderAddress, sipProviderPort, visibleName, regRequired, APPLICATION_NAME, Config.MODE_FLASHPHONER);
    
  4. 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.
  5. 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

Labels

guide guide Delete
developer developer Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.