linphone-android-Client app-Engineering interpretation

Source: Internet
Author: User
Tags event listener switches linphone

Linphonelauncheractivity is the app's portal component, in which it will start the backend service Linphoneservice, and then constantly determine whether the backend service has been started, if it has been started, The Glimpse app enters the direct functional component linphoneactivity.

Linphoneservice is the standard Android backend service, this background service is very critical and it needs to complete the work including the following content. Load the resources that the app needs to use, launch the global manager for the Linphonemanager app, Linphonemanager this global manager manages Linphoneservice instances on the one hand, On the other hand, the core instance of Linphonecore is managed, and a linphonecorelistenerbase instance of the event notification currently needed to be processed is generated and registered to the event listener Linphonecore the core instance. The current Linphonecorelistenerbase instance listens only to the three events of Callstate,globalstate,registrationstate. If there is a phone call at this time, then the Callstate event is triggered, and the Callstate event state is the Linphonecall.state.incomingreceived,app need to switch to the phone inbound interface. Registrationstate This event feedback is the user's SIP account to the SIP server registration status, is a successful registration or registration failure, and so on.

Linphonemanager implements the Linphonecorelistener, Linphonechatmessage.linphonechatmessagelistener the two interfaces, which is responsible for the management and initialization of the resources that the system needs to use, manages the Linphonecore instance, is responsible for the initialization of Linphonecore and its entire health Life cycle, but also in response to receive a file message and file message response, feel its overall responsibility is a bit confusing, may be the author began to use it as a global unified resource manager, but then developed the development of everything into the inside put, it became this.

Linphoneactivity is the core interface component of the entire app, which uses the container's architectural pattern to organize the various fragment it contains. It maintains a list of fragment that are dedicated to storing individual fragment instances. It uses the layout file is Main.xml, for mobile phone and tablet computer made a set of layout files, hehe. This layout file is mainly divided into two parts, and then the upper part is mainly the menu and the status bar, the bottom part is divided into two parts, one part is the fragment container, the other part is the tab of the function module is the form of the toolbar. Linphoneactivity also generates an instance of Linphonecorelistenerbase and registers it with an event listener Linphonecore this core instance. The event it listens to is messagereceived (a user sends a message to himself, which may be a file or text), Registrationstate,callstate. When a call comes in, the current component of this time receives the event, and then switches the interface to the Callincomingactivity interface component.

The Callincomingactivity interface component is to provide an interface for the user to choose whether to listen or hang up, and set the relevant answer parameters. This interface component also generates an instance of Linphonecorelistenerbase and registers it with an event listener in the core instance of Linphonecore, which listens for events that are callstate, The status is state.callend, so that when the other end of the phone call to notify the current interface The other side has ended the call, no longer inbound, the app should end the current interface, back to the main interface state. In the Callincomingactivity interface component, the user chooses to answer the phone, then the app will switch to the Callactivity interface component, and also determine whether the current user accepts the video call, so that the decision is a video call or voice call.

Callactivity This interface component is a call interface, this interface component also generates an Linphonecorelistenerbase instance and registers to linphonecore the core instance of the event listener, it listens to the event is Callstate , callencryptionchanged. Callstate will notify the new incoming call incoming calls, the other side to suspend the call, the other side update the call settings and other corresponding event messages, the current interface for these messages to make corresponding feedback. This call interface is mainly to control the dynamic switching of two fragment, one is voice call callaudiofragment, in this fragment, the user can enable not to enable microphone and camera, etc. You can also make a call to a new user, but from the current interface is only allow the current user to a call to a certain user, if you invite another user to the call, it is the previous call to the user set to suspend the call status, and then the current user with multiple users to call, is to constantly switch users to the current call. The other is the video call Callvideofragment, the fragment is mainly to show two video streaming window, one is the current user's own video in the bottom right corner of the interface, the other is the video of the caller. The default is to show Callvideofragment, when the user click Callvideofragment this interface, and then switch back to Callaudiofragment, so that users can see the function bar convenient operation.

The

        Callvideofragment has two key surfaceview, each showing the current user's video and the other user's video. Private Surfaceview Mvideoview; This is the video display control of the other user. Private Surfaceview Mcaptureview; This is the video presentation control for the current user. First Callvideofragment generates an instance of Androidvideowindowimpl, which is then passed LINPHONEMANAGER.GETLC (). Setvideowindow ( Androidvideowindowimpl) into the core of Linphone, Androidvideowindowimpl instances of the relevant event listener will be able to receive the kernel of the thought of event message notification, In order to pass the video stream to the corresponding Surfaceview, the method to set the video stream of the other user to Surfaceview is LINPHONEMANAGER.GETLC (). Setvideowindow (VW), The method to set the current user video stream to Surfaceview is LINPHONEMANAGER.GETLC (). Setpreviewwindow (Mcaptureview).

The Dialerfragment interface component, which provides a dial-up keypad for entering the SIP number that needs to be called, and then making the call. The dial-up call is called linphonemanager.getinstance (). Newoutgoingcall (Maddress) This method, the parameter passed is the other's SIP number or SIP address. Newoutgoingcall This method first detects the type of network currently in use, using the Linphoneutils.ishighbandwidthconnection () method. Then finally call the Callmanager.inviteaddress () method to make the call, and this method eventually calls the Linphonecore.inviteaddresswithparams (laddress, params) method to make the call. When Linphoneactivity subscribes to the Callstate event, the state = = State.outgoinginit | | When state = = State.outgoingprogress, the App interface component switches to calloutgoingactivity, which is the interface to show the status being exhaled.

Calloutgoingactivity this interface component, which also generates an instance of Linphonecorelistenerbase and registers it with an event listener Linphonecore This core instance, the event it listens to is callstate, When the state is state=connected or streamsrunning, it indicates that the other party is successful, the interface component is switched back to the callactivity, and the voice call interface or the video call interface is displayed.

CallManager is a class of managers dedicated to making phone calls, and is specifically responsible for updating the parameters of the call or the current call.

Preferenceslistfragment and Settingsfragment interface components are responsible for the parameters of the app settings, set the parameters are very rich, have account, network, audio, video and so on. They use the Preferencescreen technology of the Android framework to establish the interface and function of the whole parameter setting, thus eliminating the function of making the corresponding parameter setting by the interface. Define Preferencescreen The most critical is to write its corresponding XML file, this XML file is written, the system will be based on its content to generate the corresponding settings interface, very convenient, the corresponding technical point can Baidu. A preferencescreen can also nest multiple preferencescreen to build a multi-layered setup interface. The system comes with many types of setup interfaces, such as Listpreference,checkboxpreference. But this preferencescreen it does not save the relevant configuration information, so the configuration parameters are saved by the external to save, and then load the Preferencescreen interface, to re-set the various components inside the corresponding state. Currently in the app is the linphonepreferences of the class to be responsible for the preservation of the configuration information, and this class is dependent on lpconfig this specific read and write configuration file class to provide the corresponding functions, Its real save configuration file is a similar INI configuration file text file, that is to say Linphone is the implementation of their own configuration save and read function, hehe, no system comes with, then we also use it. The default profile is below the res/raw of the project, and the Preferencescreen configuration file is under the Res/xml of the project.

Historylistfragment is the presentation interface component of the inbound and outbound history list, the incoming and outgoing history data Linphonecore is recorded directly on its own, so the app does not need to consider recording this information, unless it needs to be customized to save the information, Don't want to use the Linphonecore. The history of inbound and outbound calls can be obtained by LINPHONEMANAGER.GETLC (). Getcalllogs ().

The Linphonecore is a JNI-based encapsulation interface for the entire Linphone kernel, and Linphonecoreimpl is the encapsulation of the Linphone kernel for the Java development language. All of the Linphone kernel methods are exposed to the Android system through it. There are many methods in it, and there are a few key ways to focus on it.

public void iterate (); The most critical of the main loop method, the application should call it often, because it will do many things in the background, such as receiving SIP instruction, registration, authentication, time-out detection, etc., it must be run in Lihpnocore other methods run by the thread, To be frank is to make sure that the Linphonecore method runs in one thread, or else it goes wrong.

Public Linphonecall invite (linphoneaddress to) throws linphonecoreexception; initiate a phone call request to each other.

public void Terminatecall (Linphonecall acall); End the current phone call.

public void Declinecall (Linphonecall call, Reason Reason); directly hangs up the phone request that is currently being called in.

Public Linphonecall Getcurrentcall (); Gets the instance of the phone call that is currently in progress.

Public linphoneaddress getremoteaddress (); Gets the SIP address or SIP phone number of the person under the current call.

public boolean isincall (); The call is either in progress or paused, but not hung, or connected, at the moment of the call.

public void Acceptcall (Linphonecall acall) throws Linphonecoreexception; Receive calls that are being paged in to their own phones.

public void Acceptcallupdate (Linphonecall acall, linphonecallparams params) throws linphonecoreexception; The other party receiving the call changes the current call configuration so that it can ensure that the call is configured with each other.

public void Defercallupdate (Linphonecall acall) throws linphonecoreexception; the other party that rejects the call changes the current call configuration so that its own call configuration is not automatically modified.

Public linphonecalllog[] Getcalllogs (); Get a list of call logs.

Public Linphonecalllog Getlastoutgoingcalllog (); Get a list of the most recent call logs.

public boolean isnetworkreachable (); Gets whether the current network connection state can be connected.

void Mutemic (Boolean ismuted); Disable or enable the microphone.

void Enableadaptiveratecontrol (Boolean enable) enables or disables adaptive rate control, which adjusts the transfer rate automatically based on network bandwidth, with caution.

void Enableechocancellation (Boolean enable), enable or disable echo cancellation for speech, this is the use of noise reduction, echo limiter is the echo threshold.

void Enablespeaker (Boolean value), enabling or disabling the speaker.

void setvideodevice (int id); Sets a camera as the currently used camera.

int Getvideodevice (); Gets the list of cameras.

Boolean isvideosupported (); detects if the customer supports video calls

void Enablevideo (Boolean vcap_enabled, Boolean display_enabled), enable or disable video, you can set the status of your own video with the other, but if the call has been established on a call, Then calling this method has no effect, it must be called before the call.

int Updatecall (Linphonecall call, linphonecallparams params), modify the status of the established calls, but this does not change all the status of the call, for the video in the call settings change is not valid, If the resolution of the video cannot be modified during a call.

int getuploadbandwidth (); Gets the maximum upstream network bandwidth, in kbit/s.

void setuploadbandwidth (int bw); Sets the maximum upstream network bandwidth, in kbit/s.

int getdownloadbandwidth (); Gets the maximum downstream network bandwidth, in kbit/s.

void setdownloadbandwidth (int bw); Sets the maximum downstream network bandwidth, in kbit/s.

Boolean Pausecall (Linphonecall call);

Boolean Resumecall (Linphonecall call);

Boolean pauseallcalls (); pauses all current calls.

void Terminateallcalls (); end all calls.

Linphonecall[] Getcalls (); Gets all the current calls.

void Transfercall (Linphonecall call, String Referto); Transfers the current connection to the other user, and ends the call.

void Transfercalltoanother (Linphonecall calltotransfer, linphonecall destination); transfer the current call to another in-progress call.

void Setplayfile (String path), sets the music to play to the other person, and the call is still in the inbound state.

linphone-android-Client app-Engineering interpretation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.