|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.washington.cs.sounddetector.server.api.SoundDetectorAPI
public class SoundDetectorAPI
Class for clients of the API.
SoundDetectorAPI is mutable and not threadsafe.
Constructor Summary | |
---|---|
SoundDetectorAPI(URI serverURI,
org.apache.http.client.HttpClient httpClient)
Constructs a new SoundDetectorAPI. |
Method Summary | ||
---|---|---|
String |
classify(String detectorId,
byte[] sound,
SoundFormat soundFormat,
List<PeakEvent> peakEvents)
Notify the server that a sound event was detected. |
|
org.apache.http.client.HttpClient |
getHttpClient()
|
|
List<Notification> |
getOldNotifications(String phoneId,
Date greaterThanDate,
Date lessThanDate)
Retrieves a list of notifications that have already been seen by the given phone. |
|
List<Notification> |
getPendingNotifications(String phoneId)
Retrieves the latest notifications the given phone has not yet seen from the server. |
|
URI |
getServerURI()
|
|
byte[] |
getSound(long soundId)
Retrieves the given sound from the server. |
|
Map<SoundClass,List<Long>> |
getSounds(String detectorId)
Retrieves all sounds saved to the server (from previous calls to train(java.lang.String, java.util.List ) for the
given detector. |
|
void |
registerReceiverPhone(String phoneId,
String registrationId)
Registers a new Receiver Phone with the server. |
|
void |
renameDetector(String oldDetectorId,
String newDetectorId)
Rename a detector. |
|
protected
|
sendMethod(Method method,
Class<T> methodResultClass)
Sends the given method to the server. |
|
void |
setHttpClient(org.apache.http.client.HttpClient httpClient)
|
|
void |
setSoundClassProperties(String detectorId,
List<SoundClass> soundClasses)
Set properties on sound classes. |
|
void |
setURI(URI serverURI)
|
|
List<Long> |
train(String detectorId,
List<LabeledSound> data,
SoundFormat soundFormat)
Sends training data to the server. |
|
boolean |
unregisterReceiverPhone(String phoneId)
Unregisters the given phone with the server. |
|
void |
untrain(List<Long> soundIds)
Untrains sounds from the server's classifier. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SoundDetectorAPI(URI serverURI, org.apache.http.client.HttpClient httpClient)
serverURI
- the uri of the running sound-detector serverhttpClient
- an http client that the SoundDetectorAPI will use to make requestsMethod Detail |
---|
public void registerReceiverPhone(String phoneId, String registrationId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException
phoneId
- a unique identifier for the phoneregistrationId
- registration Id obtained from the Android Cloud to Device Messaging
framework. May be null if you do not wish to receive push notifications. In
this case you can manually poll the server using getPendingNotifications(java.lang.String)
.
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic boolean unregisterReceiverPhone(String phoneId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException
phoneId
- the phoneId to unregister
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic List<Long> train(String detectorId, List<LabeledSound> data, SoundFormat soundFormat) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, CantBuildClassifierException
detectorId
- the location of the phone that detected the sounddata
- a list of sound samples labeled with sound class namessoundFormat
- the format of the sound samples
CantBuildClassifierException
- if the classifier can't be built. Known reasons this may happen:
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic void untrain(List<Long> soundIds) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, CantBuildClassifierException
soundIds
- the ids returned by a call to train(java.lang.String, java.util.List, edu.washington.cs.sounddetector.server.api.object.SoundFormat)
, identifying sounds which are to be
deleted from the server and removed from the server's classifier.
CantBuildClassifierException
- if after deleting the sounds the server could not build the classifier. In this
case the server is in the same state it was before the call to untrain.
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic String classify(String detectorId, byte[] sound, SoundFormat soundFormat, List<PeakEvent> peakEvents) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException
detectorId
- the location of the phone that detected the soundsound
- the audio event that was detectedsoundFormat
- the format of the sound samplepeakEvents
- a list of peak events for the audio event
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic List<Notification> getPendingNotifications(String phoneId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, PhoneDoesNotExistException
phoneId
- the id of the phone which has been registered with registerReceiverPhone(java.lang.String, java.lang.String)
.
PhoneDoesNotExistException
- if no phone with phoneId has been registered with a call to
registerReceiverPhone(java.lang.String, java.lang.String)
.
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic List<Notification> getOldNotifications(String phoneId, Date greaterThanDate, Date lessThanDate) throws PhoneDoesNotExistException, org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException
phoneId
- the id of the phone which has been registered with registerReceiverPhone(java.lang.String, java.lang.String)
.greaterThanDate
- retrieve notifications which were created after this datelessThanDate
- retrieve notifications which were created before this date
PhoneDoesNotExistException
- if no phone with phoneId has been registered with a call to
registerReceiverPhone(java.lang.String, java.lang.String)
.
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic Map<SoundClass,List<Long>> getSounds(String detectorId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, DetectorDoesNotExistException
train(java.lang.String, java.util.List, edu.washington.cs.sounddetector.server.api.object.SoundFormat)
) for the
given detector.
detectorId
- the id of the detector
getSound(long)
.
DetectorDoesNotExistException
- if there are no sounds with the given detectorId
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic byte[] getSound(long soundId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, SoundDoesNotExistException
soundId
- the identifier of the sound, from a previous call to train(java.lang.String, java.util.List, edu.washington.cs.sounddetector.server.api.object.SoundFormat)
or
getSounds(java.lang.String)
.
SoundDoesNotExistException
- if there is no such sound with the given soundId
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic void setSoundClassProperties(String detectorId, List<SoundClass> soundClasses) throws DetectorDoesNotExistException, org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, SoundClassDoesNotExistException
detectorId
- the detectorsoundClasses
- a list of sound classes and properties for the detector
DetectorDoesNotExistException
- if no detector with detectorId exists
SoundClassDoesNotExistException
- if one of the sound classes does not exist
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic void renameDetector(String oldDetectorId, String newDetectorId) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException, DetectorDoesNotExistException
oldDetectorId
- the old detector idnewDetectorId
- the new detector id
DetectorDoesNotExistException
- if no detector with detectorId exists
SoundDetectorInternalErrorException
- if the server encounters an error that it does not know how to deal with
IOException
- if there is a problem communicating with the server
org.apache.http.client.ClientProtocolException
- if there is an error in the HTTP protocolpublic URI getServerURI()
public void setURI(URI serverURI)
serverURI
- the server URI to setpublic org.apache.http.client.HttpClient getHttpClient()
public void setHttpClient(org.apache.http.client.HttpClient httpClient)
httpClient
- the HttpClient to use for API callsprotected <T extends MethodResult<?>> T sendMethod(Method method, Class<T> methodResultClass) throws org.apache.http.client.ClientProtocolException, IOException, SoundDetectorInternalErrorException
method
- the API method to call
org.apache.http.client.ClientProtocolException
IOException
SoundDetectorInternalErrorException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |