Summary of the invention
The technical problem that the present invention mainly solves is to provide method of calling in a kind of voice communication and mobile terminal, effectively can reduce communication cost, also ensures the instantaneity of voice communication simultaneously.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: provide the method for calling in a kind of voice communication, described method comprises: utilize the mobile terminal number of calling party as account number and log in Internet Server by network protocol stack, if Internet Server in login, then its oneself presence variable is recorded as presence by described mobile terminal, otherwise be recorded as not presence, after described mobile terminal is connected with described Internet Server, this connection is kept, disconnect if described mobile terminal detects to connect, then described presence variable is recorded as not presence by mobile terminal, when described in being registered as not presence time, continue again to log in Internet Server, and set the threshold value of repeat logon number of times,
Judge whether when making a call to callee to connect the Internet; If described in be judged as YES, then judge whether calling party and callee log in Internet Server all; The presence recorded in Internet Server returned by network protocol stack judges whether calling party and callee log in Internet Server all, the result that what network protocol stack returned is calling party and callee is all online, be then judged as that calling party and callee log in Internet Server all; The result that what if network protocol stack returned is calling party or callee is not online, be then judged as that calling party and callee not log in Internet Server all; If described in be judged as YES, then select internet call callee, otherwise, optional m igration communication network calling callee.
Wherein, describedly judge whether that when making a call to callee connecting the step of the Internet comprises: judge whether to connect upper the Internet by network protocol stack according to the result that call function returns, if the result that call function returns is 0, be then judged as not connecting upper the Internet by network protocol stack; If the result that call function returns is 1, be then judged as connecting upper the Internet by network protocol stack.
For solving the problems of the technologies described above, another technical solution used in the present invention is: provide a kind of mobile terminal, described mobile terminal comprises: log in unit, for before judging whether calling party and callee have logged in Internet Server all, utilize the mobile terminal number of calling party as account number and log in Internet Server by network protocol stack, if Internet Server in login, then its oneself presence variable is recorded as presence by described mobile terminal, otherwise be recorded as not presence, after described mobile terminal is connected with described Internet Server, this connection is kept, disconnect if described mobile terminal detects to connect, then described presence variable is recorded as not presence by mobile terminal, when described in being registered as not presence time, described login unit continues again to log in Internet Server, and sets the threshold value of repeat logon number of times, first judging unit, connects the Internet for judging whether when making a call to callee, second judging unit, for when being judged as connecting the Internet, judges whether calling party and callee log in Internet Server all, selected cell, for when judging that calling party and callee have logged in Internet Server all, then selects internet call callee, otherwise, optional m igration communication network calling callee,
Described mobile terminal comprises network protocol stack module, communication protocol stack module and signal processing module;
Described network protocol stack module, with described first judging unit, the second judging unit, logs in unit, selected cell and signal processing module and is connected;
Described communication protocol stack module, is connected with described selected cell and signal processing module;
Described signal processing module, be connected with described network protocol stack module, communication protocol stack module and selected cell, the function of calling out callee is realized during internet call together with network protocol stack module for selecting at described selected cell, or, realize the function of calling out callee when described selected cell optional m igration communication network calling together with communication protocol stack module;
Wherein, described first judging unit, the second judging unit, selected cell and login unit are arranged in a central processing module;
Second judging unit, specifically for when judging calling party and callee whether has all logged in Internet Server, the presence recorded in remote server returned by network protocol stack module judges whether calling party and callee log in Internet Server all, if what returned by network protocol stack module is all online result of calling party and callee, be then judged as that calling party and callee log in Internet Server all; If what returned by network protocol stack module is all not online result of calling party and callee, be then judged as that calling party and callee not log in Internet Server all.
Wherein, when described first judging unit is specifically for judging whether when making a call to callee to connect the Internet, judge whether by the Internet on network protocol stack model calling according to the result that call function returns, if the result that call function returns is 0, be then judged as not by the Internet on network protocol stack model calling; If the result that call function returns is 1, be then judged as by the Internet on network protocol stack model calling.
For solving the problems of the technologies described above, another technical solution used in the present invention is: provide a kind of mobile terminal, described mobile terminal comprises: judge module, for judging that when receiving calling whether described calling is from the Internet, wherein, described mobile terminal logs in Internet Server by network protocol stack, if logined successfully, then its oneself presence variable is recorded as presence by described mobile terminal, otherwise be recorded as not presence, after described mobile terminal is connected with described Internet Server, this connection is kept, disconnect if described mobile terminal detects to connect, then described presence variable is recorded as not presence by mobile terminal, and again do not log in described Internet Server after presence being recorded as, select module, for when described being judged as YES, then select the Internet to carry out voice communication, otherwise optional m igration communication network carries out voice communication.
The invention has the beneficial effects as follows: the mobile phone being different from prior art cannot effectively be selected to be almost that free the Internet carries out voice communication, make voice communication situation costly, the present invention is when mobile phone makes a call to callee, whether automatic decision mobile phone and callee connect the Internet, if mobile phone and callee connect the Internet, the Internet is then selected to make a call, callee is after receiving calling, judge that whether calling is from the Internet, if calling is from the Internet, the Internet is then selected to carry out voice communication, due to mobile phone energy automatic decision and the Internet of prioritizing selection almost free carries out voice communication, this just greatly reduces communication cost, even if when the calling that mobile phone and callee have a side not connect the Internet or mobile phone initiation is not from the Internet, mobile phone can also carry out voice communication by automatic selecting mobile communication network, the instantaneity of voice communication can be ensured so again.
Embodiment
Below in conjunction with drawings and Examples, the present invention is described in detail.
Refer to Fig. 1, the flow chart of the method for calling in the voice communication that the embodiment of the present invention provides comprises:
Step 101: judge whether when making a call to callee to connect the Internet;
Calling party selects callee's name or input called number from telephone directory, makes a call to callee, meanwhile, judges whether to connect upper the Internet by network protocol stack according to the result that call function returns.Mobile terminal can by calling special api function, be used for detecting current network connection state, different systems soft wares has different api function names, such as some software systems call the state that IsConnected () function returns network, if the result that call function returns is 0, then be judged as not connecting upper the Internet by network protocol stack, afterwards, optional m igration communication network is also made a call to callee by communication protocol stack; If the result that call function returns is 1, be then judged as connecting upper the Internet by network protocol stack, mobile terminal can judge easily by call function whether network protocol stack can work, and namely whether mobile terminal can connecting wireless network.
Before being judged as connecting the Internet by network protocol stack, the mobile terminal number of calling party first can be utilized as account number and log in Internet Server by network protocol stack, can certainly use other numbers that mobile terminal is preset, the account number as binding mobile terminal number logs in Internet Server by network protocol stack.If Internet Server in login, be then recorded as presence, otherwise be recorded as not presence.In more design, can not continue again to log in Internet Server after presence being recorded as, the number of times again logged in can set a threshold value.
Particularly, mobile terminal is based on ICP/IP protocol, utilize network protocol stack to realize login, such as use the login mode of general Websites, first transmit mobile terminal number by procotol, then wait for Internet Server response, if response success, Successful login or success are so just described online, mobile terminal is recorded to the presence of oneself in the presence variable of the machine, and Internet Server also can be recorded in the information of Successful login in the database of oneself simultaneously.If Internet Server does not respond or respond the mobile terminal number of mistake, login failure is so just described or goes offline, and carry out record in Internet Server; Equally, mobile terminal also can be recorded to this state in the presence variable of the machine.
After mobile terminal is connected with Internet Server, this connection is kept, owing to using ICP/IP protocol, this agreement allows the communicating pair moment to keep connecting, communicating pair either party connect loss, can be perceived by an other side (Internet Server or mobile terminal), lose such as because communication failure or one party power down if connected, a so other side will make suitable response.Such as Internet Server finds to connect and disconnects, so should record this mobile terminal number in the database of oneself not online, disconnect if mobile terminal finds to connect, so first mobile terminal should revise the presence variable of oneself is not online, then attempt reconnecting Internet Server, until after successful connection, just presence variable is revised as online.
Step 102: if described in be judged as YES, then judge whether calling party and callee log in Internet Server all;
In a step 101, just this step is performed after judging to connect the Internet by network protocol stack, specifically: the presence recorded in Internet Server returned by network protocol stack judges whether calling party and callee log in Internet Server all, the result that what network protocol stack returned is calling party and callee is all online, be then judged as that calling party and callee log in Internet Server all; The result that what if network protocol stack returned is calling party or callee is not online, be then judged as that calling party and callee not log in Internet Server all.
Wherein, if callee utilizes its mobile terminal number to log in Internet Server as account number by network protocol stack and logs in upper Internet Server, then be recorded as presence, otherwise be recorded as not presence, and again do not log in Internet Server after presence being recorded as.Judge whether callee logs in the method for Internet Server or specification can freely design, called number is sent to Internet Server as by network protocol stack, Internet Server starts local data library inquiry after receiving this telephone number, check whether this number has been registered as online, if online, returned the signal of calling party " callee is online " by network protocol stack, otherwise, the signal of calling party " callee is not online " is returned by network protocol stack.
Step 103: if described in be judged as YES, then select internet call callee, otherwise, optional m igration communication network calling callee;
After being judged as that calling party and callee have logged in Internet Server all, select the Internet and open network protocol stack calling callee; After being judged as that calling party and callee have not logged in Internet Server all, optional m igration communication network also calls out callee by communication protocol stack.
In addition, callee, after the calling receiving calling party initiation, carries out following steps:
Step one: judge that whether calling is from the Internet;
Whether mobile terminal can check oneself connecting Internet by network protocol stack in the moment, if the Internet just can log in the presence of Internet Server mark oneself in connection, this state by the data-base recording of Internet Server, also can be able to be recorded in local presence variable.If oneself is online, calling party is made a call by the Internet, and so this call signal is delivered to by the Internet in the antenna of oneself, then is delivered in network protocol stack, is resolved into call signal; If oneself is not online, so communication protocol stack can receive call signal, pass to communication protocol stack through main antenna, be resolved into call signal, by judging that call signal is resolved by network protocol stack or resolved by communication protocol stack, mobile terminal judges that whether calling is from the Internet.
Wherein, network protocol stack carries out encoding and decoding process based on ICP/IP protocol standard to signal, namely primary signal is encoded into network signal form, and is delivered on Internet or the internet signal that wireless network antenna receives through wireless network antenna, be decoded into primary signal; Communication protocol stack is responsible for the signal of communication that main antenna is received, and resolves to common audio digital signals or audio digital signals is packaged into standard traffic signal to send out through main antenna.The standard that communication protocol stack must meet 3GPP could communicate with base station, it generally comprises the hardware DSP with quick computing capability, and a Software Protocol Stack, the signal received can be carried out real time parsing and transmit by the cooperation of software and hardware, existing mobile terminal generally all can use special SOC (system on a chip) (SystemonaChip, SOC) chip realizes the function of communication protocol stack, and the supplier of this kind of Soc has a lot, such as Mediatek, Qualcomm etc.
Step 2: when judging that calling is from the Internet, user is then pointed out to have new incoming call on the screen of the mobile terminal, and the internet program starting internet protocol-based voice (VoiceoverInternetProtocol, VoIP) technology responds this calling; When judging that calling is not from the Internet, then point out user to have new incoming call on the screen of the mobile terminal, and startup respond this calling based on the mobile communications network program of the network formats such as 2G/3G normally.
The present embodiment can make requirement further, the mobile terminal of communicating pair is once after being connected to the Internet, just log in Internet Server immediately, and in the database of Internet Server the connection status of record communication both sides, and communicating pair keeps and the connection of Internet Server.Like this, after the mobile terminal login Internet Server of communicating pair, Internet Server just knows that the mobile terminal of communicating pair is all ready to, and can carry out voice communication at any time by the Internet.
Utilize the voice communication of the Internet can by multiple method, such as communicating pair sets up peer-to-peer network by TCP/IP, reciprocity voice communication is carried out by voip technology between peer-to-peer network, this communication does not take server resource, save server bandwidth, also have a kind of method based on Internet Server, namely communicating pair is first sent to speech message the Internet Server mediated, Internet Server is forwarded to the opposing party again, completes communication.
The essence of the Internet is data communication network, mobile communications network also supports data communication service at a high speed, such as based on the high-speed packet access (highspeedpacketaccess of 3.5G network, HSPA) data service, in theory, use HSPA high-speed data communication also can realize similar function, but HSPA is charge, utilizes wireless Internet meeting more cheap.The present embodiment can't the bearing mode of restricting data network, as long as select optimum data communication network.
The mobile phone being different from prior art cannot effectively be selected to be almost that free the Internet carries out voice communication, makes voice communication situation costly, the present invention can automatic decision voice communication is carried out in the wireless Internet of prioritizing selection almost free, reduce communication cost, and when communicating pair has a side not connect the Internet, mobile terminal can also carry out voice communication by automatic selecting mobile communication network, ensures the instantaneity of voice communication.
Refer to Fig. 2, the schematic diagram of the voice communication system that the embodiment of the present invention provides, described system comprises: the first mobile terminal 1, second mobile terminal 2 and Internet Server 3.Wherein, the first mobile terminal 1 comprises communication module 11 and telephone directory administration module 12, second mobile terminal 2 comprises communication module 21 and telephone directory administration module 22.The communication module 11 of the first mobile terminal 1 inside and the communication module 21 of the second mobile terminal 2 inside are integrated with the Internet communication service and mobile network communication service, the Internet communication service can be the data, services obtained after Wireless Fidelity (WirelessFidelity, WIFI) is connected to the Internet; The telephone directory administration module 12 of the first mobile terminal 1 inside is responsible for the answering of the voice of the first mobile terminal 1, dial and the maintenance etc. of contact person, and the telephone directory administration module 22 of the second mobile terminal 2 inside is responsible for the answering of the voice of the second mobile terminal 2, dial and the maintenance etc. of contact person; Internet Server 3, logs in the state of the Internet for recording the first mobile terminal 1 and the second mobile terminal 2.
Before the first mobile terminal 1 calls out the second mobile terminal 2 by its telephone directory administration module 12, whether first mobile terminal 1 judges oneself connecting Internet by its communication module 11, if there is no connecting Internet, then optional m igration communication network makes a call to the second mobile terminal 2, after the telephone directory administration module 22 of the second mobile terminal 2 answers the call, carry out voice communication by the communication module 21 of the second mobile terminal 2 and the first mobile terminal 1, if connecting Internet, then the first mobile terminal 1 signs in Internet Server 3 and is recorded as presence, check that whether the second mobile terminal 2 is also online afterwards, if the second mobile terminal 2 is not online, then optional m igration communication network makes a call to the second mobile terminal 2, after the telephone directory administration module 22 of the second mobile terminal 2 answers the call, voice communication is carried out by the communication module 21 of the second mobile terminal 2 and the first mobile terminal 1, if the second mobile terminal 2 is online, the Internet is then selected to make a call to the second mobile terminal 2, after the telephone directory administration module 22 of the second mobile terminal 2 answers the call, voice communication is carried out by the communication module 21 of the second mobile terminal 2 and the first mobile terminal 1, or:
Before the second mobile terminal 2 calls out the first mobile terminal 1 by its telephone directory administration module 22, whether second mobile terminal 2 judges oneself connecting Internet by its communication module 21, if there is no connecting Internet, then optional m igration communication network makes a call to the first mobile terminal 1, after the telephone directory administration module 12 of the first mobile terminal 1 answers the call, carry out voice communication by the communication module 11 of the first mobile terminal 1 and the second mobile terminal 2, if connecting Internet, then the second mobile terminal 2 signs in Internet Server 3 and is recorded as presence, check that whether the first mobile terminal 1 is also online afterwards, if the first mobile terminal 1 is not online, then optional m igration communication network makes a call to the first mobile terminal 1, after the telephone directory administration module 12 of the first mobile terminal 1 answers the call, voice communication is carried out by the communication module 11 of the first mobile terminal 1 and the second mobile terminal 2, if the first mobile terminal 1 is online, the Internet is then selected to make a call to the first mobile terminal 1, after the telephone directory administration module 12 of the first mobile terminal 1 answers the call, voice communication is carried out by the communication module 11 of the first mobile terminal 1 and the second mobile terminal 2.
Refer to Fig. 3, the schematic diagram of a kind of mobile terminal that the embodiment of the present invention provides, comprising: central processing module 4, communication protocol stack module 5, network protocol stack module 6 and signal processing module 7.Be provided with the first judging unit 41 in central processing module 4, log in unit 42, second judging unit 43 and selected cell 44.
Network protocol stack module 6, with the first judging unit 41, logs in unit 42, second judging unit 43, selected cell 44 and signal processing module 7 and is connected; Network protocol stack module 6 is the modules of based on ICP/IP protocol standard, signal being carried out to encoding and decoding process, this module can be software module also can be hardware module, the effect of network protocol stack module 6 is that primary signal is encoded into network signal form, and is delivered on the Internet through wireless network antenna; Or the internet signal that wireless network antenna receives, be decoded into primary signal and transfer to signal processing module 7 to process.
Communication protocol stack module 5, is connected with selected cell 44 and signal processing module 7.Communication protocol stack module 5 is responsible for the signal of communication that main antenna is received, and resolves to common audio digital signals, and passes to signal processing module 7.In one embodiment, require that the standard that communication protocol stack module 5 meets 3GPP could communicate with base station, it generally comprises the hardware DSP with quick computing capability, and a Software Protocol Stack, the signal received can be carried out real time parsing and transmit by the cooperation of software and hardware, modern cell phones generally all can use special SOC (system on a chip) SOC to realize the function of this communication protocol stack, and the supplier of this kind of Soc has a lot, such as Mediatek, Qualcomm etc.
Signal processing module 7, be connected with communication protocol stack module 5, network protocol stack module 6 and selected cell 44, for communicating with network protocol stack module 6 when selected cell 44 selects internet call, or, communicate with communication protocol stack module 5 when selected cell 44 optional m igration communication network is called out.Signal processing module 7 is software modules also can be a hardware module, it is responsible for Digital Signal Processing to become the voice signal that can be accepted by loudspeaker, conversely, also voice signal is become digital signal, this module can use various signal processing algorithm, such as noise reduction process, encrypting and decrypting process etc., these process can have been calculated by computing chip by proprietary program, also can be completed by proprietary hardware computing chip computing.Signal processing module 7 not only can pass to original communication protocol stack module 5 primary speech signal and transmit, also signal transmission can be transmitted to network protocol stack module 6, central processing module 4 determines signal automatically according to algorithm, and this transmits through network protocol module 6 through communication protocol stack module 5 or this.
The whole voice communication course of central processing module 4 cooperation control, when being such as responsible for new signal arrival, signal is responded, have during incoming call and notify that user responds, opening signal passage (receiving calls), the signal of the signal of communication protocol stack module 5 or network protocol stack module 6 to be delivered in signal processing module 7 and control signal etc. in order, also be responsible for notifying that communication protocol stack module 5 or network protocol stack module 6 set up new call link (outbound calling), and after passage is connected, the signal of signal processing module 7 is imported in communication protocol stack module 5 or network protocol stack module 6.Central processing module 4 is the functions being realized its cooperation control voice communication by the unit arranged in the inner.
The concrete effect of unit is as follows:
First judging unit 41, the Internet is connected for judging whether when making a call to callee, particularly, judge whether to connect upper the Internet by network protocol stack module 6 according to the result that call function returns, if the result that call function returns is 0, be then judged as not connecting upper the Internet by network protocol stack module 6; If the result that call function returns is 1, be then judged as connecting upper the Internet by network protocol stack module 6.First judging unit can by calling special api function, be used for detecting current network connection state, different systems soft wares has different api function names, such as some software systems call the state that IsConnected () function returns network, if the result that call function returns is 0, then be judged as not connecting upper the Internet by network protocol stack module 6, afterwards, optional m igration communication network is also made a call to callee by communication protocol stack module 6; If the result that call function returns is 1, be then judged as connecting upper the Internet by network protocol stack module 6.By call function, first judging unit 41 can judge whether network protocol stack module 6 can work easily.
Before being judged as connecting the Internet by network protocol stack module 6, also can afterwards, logging in unit 42 utilizes the mobile terminal number of calling party to log in Internet Server as account number by network protocol stack module 6, other numbers that mobile terminal can certainly be used to preset log in Internet Server as account number by network protocol stack module 6, if Internet Server in login, then be recorded as presence, otherwise be recorded as not presence, and again do not log in Internet Server after presence being recorded as.
Particularly, log in unit 42 based on ICP/IP protocol, network protocol stack module 6 is utilized to realize logging in, such as use the login mode of general Websites, first transmit mobile terminal number by network protocol module 6, then wait for Internet Server response, if response success, Successful login or success are so just described online, mobile terminal is recorded to the presence of oneself in presence variable, and Internet Server also can be recorded in the information of Successful login in the database of oneself simultaneously.If Internet Server does not respond or respond the mobile terminal number of mistake, login failure is so just described or goes offline, equally, mobile terminal also can be recorded in this state in line state variable.After mobile terminal is connected with Internet Server, this connection is kept, owing to using ICP/IP protocol, this agreement allows the communicating pair moment to keep connecting, communicating pair either party connect loss, can be perceived by an other side (Internet Server or mobile terminal), lose such as because communication failure or one party power down if connected, a so other side will make suitable response.Such as Internet Server finds to connect and disconnects, so should record this mobile terminal number in the database of oneself not online, disconnect if mobile terminal finds to connect, so first mobile terminal should revise the presence variable of oneself is not online, then attempt reconnecting Internet Server, until after successful connection, just presence variable is revised as online.
Second judging unit 43, for when being judged as connecting the Internet, judge whether calling party and callee log in Internet Server all, particularly, the presence recorded in remote server returned by network protocol stack module 6 judges whether calling party and callee log in Internet Server all, if what returned by network protocol stack module 6 is all online result of calling party and callee, be then judged as that calling party and callee log in Internet Server all; If what returned by network protocol stack module 6 is all not online result of calling party and callee, be then judged as that calling party and callee not log in Internet Server all.
Wherein, callee utilizes its mobile terminal number as account number and logs in Internet Server by network protocol stack module 6, if Internet Server in login, then be recorded as presence, otherwise be recorded as not presence, and again do not log in Internet Server after presence being recorded as.Judge whether callee logs in the method for Internet Server or specification can freely design, called number is sent to Internet Server as by network protocol stack module 6, Internet Server starts local data library inquiry after receiving this telephone number, check whether this number has been registered as online, if online, returned the signal of calling party " callee is online " by network protocol stack module 6, otherwise, the signal of calling party " callee is not online " is returned by network protocol stack module 6.
Selected cell 44, for when described being judged as YES, then selects internet call callee, otherwise, optional m igration communication network calling callee.Such as, after the second judging unit 43 is judged as that calling party and callee have logged in Internet Server all, selected cell 44 selects the Internet and open network protocol stack module 6 calls out callee; After the second judging unit 43 is judged as that calling party and callee have not logged in Internet Server all, selected cell 44 optional m igration communication network also calls out callee by communication protocol stack.
Refer to Fig. 4, the another kind of mobile terminal schematic diagram that the embodiment of the present invention provides, comprising:
Judge module 81, for judging that when receiving calling whether described calling is from the Internet;
Whether mobile terminal can check oneself connecting Internet by network protocol stack in the moment, if the Internet just can log in the presence of Internet Server mark oneself in connection, this state by the data-base recording of Internet Server, also can be able to be recorded in local presence variable.If oneself is online, calling party is made a call by the Internet, and so this call signal is delivered to by the Internet in the antenna of oneself, then is delivered in network protocol stack, is resolved into call signal; If oneself is not online, so communication protocol stack can receive call signal, pass to communication protocol stack through main antenna, be resolved into call signal, by judging that call signal is resolved by network protocol stack or resolved by communication protocol stack, mobile terminal judges that whether calling is from the Internet.
Select module 82, for when described being judged as YES, then select the Internet to carry out voice communication, otherwise optional m igration communication network carries out voice communication;
When judging that calling is from the Internet, then point out user to have new incoming call on the screen of the mobile terminal, and the internet program starting internet protocol-based voice (VoiceoverInternetProtocol, VoIP) technology respond this calling; When judging that calling is not from the Internet, then point out user to have new incoming call on the screen of the mobile terminal, and startup respond this calling based on the mobile communications network program of 2G/3G normally.
The foregoing is only embodiments of the invention; not thereby the scope of the claims of the present invention is limited; every utilize specification of the present invention and accompanying drawing content to do equivalent structure or equivalent flow process conversion; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.