Commit Graph

140 Commits

Author SHA1 Message Date
Branden Archer
0d829708c7 Only post message if connection to child was lost
If the connection to the child was intentionally severed, do not
post a "disconnected" message, as the activity is likely closing.
2015-12-28 17:11:58 -05:00
Branden Archer
6dd26b70fe improve logging for service discovery 2015-12-28 16:24:06 -05:00
Branden Archer
c25b0fdeba Allow child device to establish new connection after parent disconnects
Previously the monitor activity would only support one connection,
after which the activity would need to be restarted. With this change,
if a connection is established with a parent device but is eventually
disconnected the child device will begin advertising again.

Note that because the child device can only support one connection
at a time currently, after the connection is established it will
now stop advertising. When a connection is lost and advertising
starts again, it may end up advertising as another service. E.g.
  ProtectBabyMonitor (2)
instead of
  ProtectBabyMonitor
2015-12-28 16:12:49 -05:00
Branden Archer
375242d6fb Cleanup AudioRecord if socket throws an exception
Previously an IOException would prevent the AudioRecord
from being cleaned up.
2015-12-28 16:08:59 -05:00
Branden Archer
0c45351c5a Create wrapper function for unregistering baby monitor service
This will eventually be called in multiple places
2015-12-28 16:06:35 -05:00
brarcher
14118499fa Merge pull request #2 from brarcher/staging
Improve usability - volume control, survive screen rotation, screen stays on
2015-12-27 20:52:41 -05:00
Branden Archer
6af9dff004 Prevent screen rotation or resize from destroying activities
If the screen is rotated by default Android destroys the
activity and recreates it. This causes issues if a child and
parent are already paired, as the connection is lost.

To prevent Android from destroying the Activity, instead
invoke a configuration change on an orientation or resize.
2015-12-27 20:50:25 -05:00
Branden Archer
7f604c47ce Prevent child device from sleeping if listening
If the screen turns off, the child device will be unable to
record from the microphone. Keep the screen on in the monitor
activity to keep microphone on.
2015-12-27 20:50:25 -05:00
Branden Archer
516ba5a225 Allow volume control to adjust playback volume
The AudioTrack for playing audio from the child device
was sending audio to the voice call stream. It is more
appropriate to use the music stream. In addition, suggest
that the activity control the music stream's volume with
the hardware controls.
2015-12-27 20:50:25 -05:00
brarcher
133baf9a48 Merge pull request #1 from brarcher/staging
Improve layout and appearance of application
2015-12-27 17:40:18 -05:00
Branden Archer
9eaf90fcda Use Travis CI to build project 2015-12-27 17:36:45 -05:00
Branden Archer
2e9ca0de88 Improve listen activity layout with Linear Layout 2015-12-27 16:20:32 -05:00
Branden Archer
c455e966cd Use buttons to list available child devices
It may not have been obvious that the labels were clickable before.
2015-12-27 16:20:31 -05:00
Branden Archer
72d5c75357 Replace \\032 in reported service name with " "
When mDNS returns the service name, any spaces are replaced
with \\032. Change this back into a space
2015-12-27 16:20:31 -05:00
Branden Archer
dd737c0be5 Improve layout of dicover activity with Linear Layout 2015-12-27 16:20:31 -05:00
Branden Archer
ea29a0f4eb Improve monitor activity with LinearLayout and helper text 2015-12-27 16:20:22 -05:00
Branden Archer
eb1eac8111 Improve start activity layout with LinearLayout and helper text 2015-12-27 15:29:59 -05:00
Branden Archer
429c3005a9 Use Holo theme 2015-12-27 14:28:54 -05:00
Branden Archer
7273e4231f Change app launcher icon to a camera 2015-12-27 14:02:13 -05:00
Branden Archer
eac8bfeed6 Mention name of connected device on ListenActivity 2015-12-26 18:54:56 -05:00
Branden Archer
b1a0044fda Simplify MonitorActivity to only list relevant text in tables 2015-12-26 18:54:09 -05:00
Branden Archer
592c55c156 Simply StartActivity to two buttons 2015-12-26 18:53:29 -05:00
Branden Archer
21b59fde84 Update app name to Protect Baby Monitor 2015-12-26 18:50:16 -05:00
Branden Archer
f2a13c9160 Change terminology to child and parent devices
The "monitor" and "connect to monitor" descriptions may
have been confusing. Changing the terminology to refer to
a child and parent device.
2015-12-26 18:50:01 -05:00
brarcher
c962228e86 Update README.md 2015-12-26 17:51:22 -05:00
Branden Archer
6901745d5b Pass received audio samples to the AudioPlayer for processing
Whenever a sample is received from the socket, pass it to
the AudioPlayer thread via a blocking queue. The AudioPlayer
thread will then play the sample and wait for more input.
2015-12-26 17:51:22 -05:00
Branden Archer
8bcfe2af67 Add AudioPlayer thread for playing audio samples from a queue
This thread will be used for playing audio samples. The samples
will be provided by a blocking queue.

It is assumed that the configuration of the passed AudioTrack and
the samples from the blocking queue are compatible.
2015-12-26 17:51:22 -05:00
Branden Archer
936410e851 Receive audio from ProtectBabyMonitor, discarding it
When connected to a ProtectBabyMonitor service, accept
audio over the network. However, for now, discard the audio
instead of playing it.
2015-12-26 17:51:21 -05:00
Branden Archer
00049d4b2f Allow launch of ListenActivity from found ProtectBabyMonitor service
If any ProtectBabyMonitor services are found on the network, clicking
on one will start a ListenActivity with information on the service.
2015-12-26 17:51:21 -05:00
Branden Archer
2e164c0fb2 Add ListenActivity for playing audio from ProtectBabyMonitor services
This activity will eventually receive audio from the MonitorActivity
of another Android device and play it.
2015-12-26 17:51:21 -05:00
Branden Archer
1f7f6f04fe Populate list with ProtectBabyMonitor providers 2015-12-26 17:51:21 -05:00
Branden Archer
8d448d0ecc Discover ProtectBabyMonitor service providers on the network
Attempt to discover any providers of the ProtectBabyMonitor
service on the local network, resolving any which are found.
For now nothing is done with the information on found
providers.
2015-12-26 17:51:21 -05:00
Branden Archer
eb9cd75c3a Add DiscoverActivity - lists of baby monitors on the network
This is the stub of the DiscoverActivity, which is responsible for
discovering all available ProtectBabyMonitor services on the
local network.
2015-12-26 17:51:21 -05:00
Branden Archer
4635a78574 Set the TCP send buffer size to avoid buffering audio
If the send buffer size is large and the receiver is unable
to keep up, then audio samples will collect on the monitor
and lag will accumulate. As only the most recent sample is
important, reduce the send buffer size to the minimum
AudioRecord buffer size.
2015-12-26 17:51:16 -05:00
Branden Archer
828e6a16f6 Stream audio data to connected clients
While connected, send packets of audio data to connected clients.
2015-12-26 17:50:33 -05:00
Branden Archer
7819c31275 Stub for servicing connection to ProtectBabyMonitor service
If a client connects to the advertised ProtectBabyMonitor service,
attempt to service the connection.

For now, simply close the connection instead of sending data.
2015-12-26 15:49:17 -05:00
Branden Archer
716d82dc1c Register ProtectBabyMonitor service via mDNS
When the MonitorActivity is started it will create a ServerSocket.
The assigned port is then advertised over mDNS for a
"ProtectBabyMonitor" service.

Eventually, when something connects to the ServerSocket audio
data will be streamed out.
2015-12-26 15:49:17 -05:00
Branden Archer
11bf3822b6 Add MonitorActivity - for registering on network and sending audio
This commit adds the shell of the MonitorActivity. This activity
will register its service on the local network, wait for a connection,
then send audio data.
2015-12-26 15:49:12 -05:00
Branden Archer
7bd19f2325 Add StartActivity - landing page of baby monitor
The StartActivity is the first activity which will be launched
in the baby monitor, and in the future will list the two main
options: become a monitor or a listener.
2015-12-26 15:48:42 -05:00
brarcher
8b1b1a7414 Initial commit 2015-12-26 13:23:26 -05:00