AUDIO_IM - Sakeesoft

chulavistajuniorΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

101 εμφανίσεις


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com


Instant Messaging

&


Live Streaming
Audio






Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Table of Contents


1.

Audio
IM
Project Introduction


1.1.

Purpose of the project

1.2.

Proposed system:

1.3.

Feasibility study:


1.3.1.

Economic Feasibility

1.3.2.

Technical feasibility

2.

Functional Requirements Specification

2.1.


Functional Requi
rements Specification

3.

How This Works?

4.

Project Class Descriptions

4.1.

MainActivity.Java

4.2.

GetFriendList.java

4.3.

ContactList.java

4.4.

IMsendData.java

4.5.

Audio_Call.java

4.6.

IpAddressDevice.java

4.7.

AutoConnection.java


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

4.8.

ServerUrl.java

4.9.

MyXmlParsing

5.

Screenshot
















Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Audio IM I
ntroduction

Audio IM Demo
is an Android based project is used to make audio calls & Instant
Messaging between two android phones through server. The scope of this project is to
develop
Audio Demo
application that runs on Android platform. This is the first

version of
its kind and is developed based on Android platform.

1.1 Purpose of the project:


The goal of this project is used to make Instant Messaging & audio calls between two
android phones through server.

1.2 Proposed system:


Using this application w
e can make audio calls, video calls and IM (Instant Messaging) with
Presence through server.

1.3 Feasibility study:


All projects are feasible if they have unlimited resources and infinite
time. But the development of software is plagued by the scarcity of

resources and difficult
delivery rates. It is necessary and

prudent to evaluate the feasibility of a project at the
earliest possible time. The three

considerations are involved in the feasibility analysis.


1.3.1 Economic Feasibility:


This procedure is
to determine the benefits and savings that are expected from a candidate
system and compare with cost. If benefits outweigh cost then the decision is made to design
and implement the system. Otherwise further justification or alterations in proposed
system

that have to be made if it is having a change of being approved .This is an ongoing
effort that improves in accuracy of each phase of the system lifecycle.


1.3.2 Technical feasibility:

Technical feasibility centers on the existing mobile system (hardware
, software etc...) and
to what extent it can support the proposed addition if the budget is a serious constraint,
then the project is judged not feasible. The Technical feasibilities are important role in our
project because here I am using android operati
ng system.



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com


2.0 Functional Requirements Specification:

The system is required to
perform the
Display
of
all the information about the application

that is being developed and

some set of instructions the user might want to rem
ember
before he sets up the
s
ystem for configuring login credentials.

2.1


Non
-
Functional Requirements:

Application framework enabling reuse and replacement of components.

Dalvik virtual machine optimized for mobile devices.

Integrated browser based on the open source Web Kit engine.

GSM

Telephony (Hardware dependent).

Bluetooth, EDGE, 3G, and Wifi (hardware dependent).

Camera, GPS, compass, and accelerometer (hardware dependent).


Rich development environment including a device emulator, tools for debugging,
memory and performance profil
ing, and a plug
-
in for the Eclipse IDE.

The system is expected to run on low memory devices also.

The system should not consume lot of bandwidth so that the other applications will
block for the internet.

The system should provide secured access to the w
eb server.








Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

3.0 How This Works?

If the Login Credentials is valid and then server provides userId to that particular
username.


Send the entered Username and Password to Server






2

5

6

7


3) If user is 4

Not Regis
tered





It will send it to the server to get the contacts list for that user.




Using this UserId, it will fetch the contacts from that use
rID and shows in the Contacts List
screen with presence as AVAILABLE and OFFLINE.

When we first open the Application, it will show the login screen with login fields to enter
username and password.


Login
Screen

Server

Get UserID

Server

Contacts List
Screen

Registration


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

After entering the username and password.
As shown in th
e block diagram, after entering
the username and password, click on Login Button to send request to the Server. If it is
valid user credentials then it will provide userId for that particular login credentials and it
successfully registers with the server.

Right now, we hardcoded the username and
password in the server side. So, even if user enters the wrong username and password also
it will register with server by taking those hardcoded values as input to server. So, still the
work is going to get the dyn
amic username and password values to register with the
server.


As shown in the block diagram 2nd, 5
th
, 6th and 7th arrow indicates the following: If the
user is valid then it will show the above screen. First it will send the valid user credentials
to
server and it authenticates with server and gets the UserId for particular login
credential. Using this UserId it will fetch the contacts list from server belonging to this login
credential and displays the above screen. Right now, everything over here is
hardcoded like
contacts and userID. So, need to work on getting the dynamic values from the server. When
we click on Logout Button then it will send request to server to end the Session and server
sends UserId as 2.

As shown in the block diagram, 3
rd

indic
ates the following: If it is not Registered User then
user has to click on Registration Button to register with the server to get the new Login
Credentials
.


4.

Project Class Descriptions

MainActivity
.java:


This is the Main Activity of an Audio App, which s
hows the login screen of an app. On login
screen you will find two buttons i.e.

1.

For getting login into the App.


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

2.

For registration.

Functions in MainActivity.java
:

setContentView

(int layoutResID) :
Set the activity content from a layout resource



onCli
ck

(
View

v)

:Called when a view or button has been clicked.

R.id.login: For checking login credentials with server
. If credential
s are true,
then login into the app.


R.id.registration:

For registering to the server.




AsyncTask
<
Void
,
Integer
,
Void
> :

AsyncTask enables prop
er and easy use of the UI thread. This class allows to
perform background operations and publish results on the UI thread without having
to manipulate threads and/or handlers.

An asynchronous task is defined by a computation that runs on a background
threa
d and whose result is published on the UI thread. An asynchronous task is
defined by 3 generic types, called
Params
,
Progress

and
Result
, and 4 steps, called
onPreExecute
,
doInBackground
,
onProgressUpdate

and
onPostExecute
.


Usage:

AsyncTask must be subcla
ssed to be used. The subclass will override
at least one method (
doInBackground(Params...)
), and most often will
override a
second one (
onPostExecute(Result)
.)


The 4 steps


When an asynchronous task is executed, the task goes thr
ough 4 steps:


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

1.

onPreExecute()
, invoked on the UI thread immediately after the task is executed.
This step is normally used to

setup the task, for instance by showing a progress bar in
the user interface.

2.

doInBackground(Params...)
, invoke
d on the background thread immediately after
onPreExecute()

finishes executing. This step is used to perform background comp
utation
that can take a long time. The parameters of the asynchronous task are passed to this
step. The result of the computation must be returned by this step and will be passed back
to the last step. This step can also use
publishProgress(Progress...)

to publish one or
more units of progress. These values are published on the UI thread, in the
onProgressUpdate(Progress...)

step.

3.

onProgressUpdate(Progress...)
, invoked on the UI thread after a call to
publishProgress(Progress...)
. The timing of the execution is undefined. This method is
used to display any form of progress in the user interface while the background
computation is still executing. For instance, it can be used to animat
e a progress bar or
show logs in a text field.

4.

onPostExecute(Result)
, invoked on the UI thread after the background
computation
finishes. The result of the background computation is passed to this step as a parameter.

Cancelling a task

A task can be cancelled at any time by invoking
cancel(boolean)
. Invoking this method will
cause subsequent calls to
isCancelled
()

to return true. After invoking this method,
onCancelled(Object)
, instead of
onPostExecute(Object)

will be invoked after
doInBackground(Object[])

returns. To ensure that a task is cancelled as quickly as possible,
you should always check the return value of
isCancelled()

periodically from
doInBackground(Object[])
, if possible
(inside a loop for instance.)


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Threading rules

There are a few threading rules that must be followed for this class to work properly:



The task instance must be created on the UI thread.



execute(Params...)

must be invoked on the UI thread.



Do not call
onPreExecute()
,
onPostExecute(Result)
,
doInBackground(Params...)
,
onProgress
Update(Progress...)

manually.



The task can be executed only once (an exception will be thrown if a second
execution is attempted.)

Memory observability

AsyncTask guarantees that all callback calls are synchronized in such a way that the
following operat
ions are safe without explicit synchronizations.



Set member fields in the constructor or
onPreExecute()
, and refer to them i
n
doInBackground(Params...)
.



Set member fields in
doInBackground(Params...)
, and refer to them in
onProgressUpdate(Progress...)

and
onPostExecute(Result)
.




PostData ()
:

Creates

Interface for a
n HTTP client. HTTP clients encapsulate a
smorgasbord of objects required to execute HTTP requests while handling
cookies, authentication, connection management, and other features using
JsonObject. Thread safety of HTTP clients depends on the implementati
on and
configuration of the specific client.


--------------------------------------------------------------------------------------------------------------------

Registration.java:


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

This is the registration screen. Where new users can
get registered by
sending small
information using app.

---------------------------------------------------------------------------------------------------------------------

GetFriendList.java:

In this class we will take login credentials from the users & according to login

credentials
we will get a friend list of particular users, forward to next screen of an app.

---------------------------------------------------------------------------------------------------------------------

ContactList.java:

This is the second screen
of an app. Here we are performing following actions:


1. Shows the user friend list.


2. On click of friend or contact list you can perform following actions:



a.
Get into the IM i.e. chatting with particular online friends.



b. Can call any of your onl
ine friends.


3. On click of menu button, you will find Advance Setting for audio call.


4. Logout from the app.

---------------------------------------------------------------------------------------------------------------------

IMSendData.Java:


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Using t
his class, on click of particular friend list can do instant messaging & import users
contact information to send for friends
.

Runs
an asynchronous task for sending & receiving
the message from both ends.

--------------------------------------------------
-------------------------------------------------------------------

Audio_Call.java:

In t
his class
, we

perform

the audio call
s

between two

app users.

We

are following function to perform the audio call between two users.

1.

AudioRecord
: This AudioRecord manag
es the audio resources for the
applications to record audio from the audio input hardware of the platform. This
can be done by reading the data from the AaudioRecord object.

a.

StartRecording
(): Starts streaming the audio using
AudioRecord


constructor.

Some
of the functions below for streaming the audio.

i.

AudioRecord
.
startrecording
();

ii.

AudioRecord
.read(
AudioData, offset in shorts
,
soze in shorts
)
:
Reads
audio data from the audio hardware for recording into a buffer.


Parameters of
AudioRecord

:



audioSource:

the recording source.

sampleRateInHz:

the sample rate expressed in Hertz. 44100Hz is
currently the only rate that is guaranteed to work on all devices, but
other rates such as 22050, 16000, and 11025 may work on some
devices.


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

channelConfig:

describes the c
onfiguration of the audio channels. See
CHANNEL_IN_MONO

and
CHANNEL_IN_STEREO
.
CHANNEL_IN_MONO

i
s guaranteed to work on all devices.

audioFormat:

the format in which the audio data is represented. See
ENCODING_PC
M_16BIT

and
ENCODING_PCM_8BIT

bufferSizeInBytes:

the total size (in bytes) of the buffer where audio
data is writte
n to during the recording. New audio data can be read
from this buffer in smaller chunks than this size. See
getMinBufferSize(int, int, int)

to determine the minimum required
buffer size for the successful creation of an AudioRecord instance.
Using values smaller than getMinBufferSize() will result in an
initialization failure.


a.

StopRecording
():
Stops the a
udio streaming. Uses following function to
stop and release the audio.

i.

AudioRecord.Stop() : Stops the audio.

ii.


AudioRecord.Release():
Releases th
e native AudioRecord resources.

The object can no longer be used and the reference should be set
to null afte
r a call to release()



2.

AudioTrack
: This AudioTrack manages & play the streaming

PCM

audio
resources for the
applications from the audio hardware playback.

Following
function shows the work of an AudioTrack.


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

i.

AudioTrack.Write(

AudioData

, offset in shorts,

si
ze in shorts):
Writes the
audio data to the audio hardware for playback. Will block until all data
has been written to the audio mixer. Note that the actual playback of this
data might occur after this function returns. This function is thread safe
with
respect to
stop()

calls, in which case all of the specified data might
not be written to the mixer.

ii.

AudioTrack.
play(): For playi
ng the Streaming audio.


AudioTrack

constructor parameters

a.

streamType:

the type of the audio stream. See
STREAM_VOIC
E_CALL
.

b.

SampleRateInHz
:

the sample rate expressed in Hertz. Examples of rates are (but
not limited to) 44100, 22050 and 11025.

c.

channelConfig:

describes the configuration of the audio channels. See
CHANNEL_OUT_MONO

and
CHANNEL_OUT_ST
EREO

d.

audioFormat:

the format in which the audio data is represented. See
ENCODING_PCM_16BIT

and
ENCODING_PCM_8BIT

e.

bufferSizeInBytes:

the total size (in bytes) of the buffer where audio data is read
from for playback. If using the
AudioTrack in streaming mode, you can write data
into this buffer in smaller chunks than this size.


---------------------------------------------------------------------------------------------------------------------

ServerUrl.java:

This class contains

the server url

information
.


Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

---------------------------------------------------------------------------------------------------------------------

MyXmlParseActivity.java:

This class is used for parsing the values into the app.

----------------------------
-----------------------------------------------------------------------------------------


IpAddressDevice.java:

This class gets the Ip address of
a

device.

---------------------------------------------------------------------------------------------------
------------------

AutoConnection.java:

This class gets the information of
a

connection i.e. W
ifi or 3G network is available or not.

---------------------------------------------------------------------------------------------------------------------









Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Screenshots

of an App

Login Screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Registration Screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Loading Screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Contact Screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Menu Screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Instant Message Screen :



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Audio Call Screen :



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Advance setting screen:



Sak
eesoft Pvt Ltd.




Confidential

J.P.Nagar 6
th

Phase, Bangalore. www.sakeesoft.com

Logout Screen: