# PlayerCollector

The PlayerCollector resource is a composite resource that encapsulates all functionality of a Player and a Collector into a single resource. This resource type enables reduced development time for users and helps to streamline the logic of the client application.

## XML Definition

<playercollector identifier="<identifier>" appid="<appid>"
href=http://server/dialogicwebservice/mediacontrol/players/<identifier>
streamidentifier="<stream identifier>"
conferenceidentifier="<conference identifier>"
barge="true"
num_digits="<num_digits>" digit_mask="<digit_mask>" firstdigit_timer="<MS>"
interdigit_timer="<MS>" extradigit_timer="<MS>" return_digits="<return_digits>"
restart_digits="<restart_digits>" >
<source location="<location>" gain_level="<gain_level>" offset="<offset>" />
</playercollector>

## PlayerCollector Properties

Name | Description | Type | Input / Output | Optional / Mandatory
identifier | Unique identifier assigned to the specific instance of the resource. This identifier is used by the web service client when performing actions on the resource. | String | Output | N/A
appid | Unique application id included in the original HTTP POST creation process that is utilized by the web service such that clients only have access to resources that they created. | String | Output | N/A
href | An HTTP reference to the specific resource. | String | Output | N/A
streamidentifier | Unique identifier of the MediaStream that is to receive the media being played by the resource. | String | Input / Output | Mandatory if conference identifier is not being set
conferenceidentifier | Unique identifier of the Conference that is to receive the media being played by the resource. | String | Input / Output | Mandatory if stream identifier is not being set
<source.../> | Defines the media source to be played. Multiple <source …/> nodes can be defined and the player will play the media sources in the order in which they are defined. | Child Node | Input / Output | Mandatory (At least one source node)
location Attr of <source /> | The location of the media source to be played by the Player resource. Source can be http, file or rtsp. | String URL | Input/Output | Mandatory
offset Attr of <source /> | Determines where in the location URL to start play. | String <ms> | Input / Output | Optional
gain_level Attr of <source /> | Temporarily adds dB of gain to the current gain level. The level reverts back once this play is completed. | String <db> | Input / Output | Optional
barge | Disables or enables the ability to “barge” the active play operation when a digit is detected. Default: Enabled (True) | Boolean | Input / Output | Optional
digit_mask | Digits which can barge previously queued audio commands. Digits entered during the audio that are NOT on this list are thrown away. Default: 0123456789ABCD#* | String | Input / Output | Optional
num_digits | The number of digits to wait for. Default: 1 | Integer | Input/Output | Optional
firstdigit_timer | The number of milliseconds to wait for the first digit. 0 means wait forever. –1 means don't wait. Default: 5000 | Integer | Input/Output | Optional
interdigit_timer | The number of milliseconds to wait for the second and subsequent digits. 0 means wait forever. –1 means don't wait. Default: 2000 | Integer | Input/Output | Optional
extradigit_timer | The number of milliseconds to wait after a valid match for the return_digits. This allows the return digits to be used even when a match already occurred. 0 means wait forever. –1 means don't wait. Default: 1000 | Integer | Input/Output | Optional
return_digits | The digit sequence that is used to end digit input. Once seen, all digits in the queue up to (but not including) the return digits are returned, match or not. Default: # | String | Input/Output | Optional
restart_digits | The digit sequence that is used to abort the collect. Once seen, all digits in the queue up to (but not including) the restart_digits are discarded, and the restart_digits are returned. | String | Input/Output | Optional

## Interaction Diagram

### PlayerCollector Creation

The following diagram illustrates the PlayerCollector creation process.

### PlayerCollector Deletion

The following diagram illustrates the PlayCollector deletion process.

## Java Sample Code

public void CreatePlayerCollector(String destIdentifier, IdentifierType type, PlayCollectorStruct
playCollectorStruct) {
logger.info("PlayCollector::Create - Entered.");
//Create a HttpURLConnection with the correct server
//Send request to create conference and retrieve response
String response = "";
HttpURLConnection connection = utils.SendHTTPRequest("http://" + MainSipServlet.WMSHost +
":81/DialogicWebService/mediacontrol/playercollectors", "POST");
if (connection != null) {
DataOutputStream ostream = null;
try {
ostream = new DataOutputStream(connection.getOutputStream());
String identifierText = "streamidentifier";
if (type == IdentifierType.CONFERENCE) {
identifierText = "conferenceidentifier";
}
String strBuff = "<playercollector " +
identifierText + "=\"" +
destIdentifier + "\" " +
" barge=\"true\"" +
" num_digits=\"" + playCollectorStruct.m_strNumDigits + "\"" +
" digit_mask=\"" + playCollectorStruct.m_strDigitMask + "\""+
" firstdigit_timer=\"" + playCollectorStruct.m_strFirstDigitTimer + "\""+
" interdigit_timer=\"" + playCollectorStruct.m_strInterDigitTimer + "\""+
" extradigit_timer=\"" + playCollectorStruct.m_strExtraDigitTimer + "\""+
" return_digits=\"" + playCollectorStruct.m_strReturnDigits + "\""+
">\r\n";
for(int i=0;i<playCollectorStruct.m_sourceList.size();i++)
{
strBuff += "<source location = \"" + (String)
playCollectorStruct.m_sourceList.get(i) +"\" />/r/n";
}
strBuff += "</playercollector>";
ostream.writeBytes(strBuff);
ostream.flush();
ostream.close();
} catch (IOException ex) {
Logger.getLogger(MainSipServlet.class.getName()).log(Level.SEVERE, null, ex);
}
response = utils.GetHTTPStringResponse(connection);
}
//Retrieve response codes
int responseCode = 0;
try {
responseCode = connection.getResponseCode();
} catch (IOException ex) {
Logger.getLogger(MainSipServlet.class.getName()).log(Level.SEVERE, null, ex);
}
String responseMessage = "";
try {
responseMessage = connection.getResponseMessage();
} catch (IOException ex) {
Logger.getLogger(MainSipServlet.class.getName()).log(Level.SEVERE, null, ex);
}
String responseLocation = connection.getHeaderField("location");
//close the connection
connection.disconnect();
//log results
logger.info("PlayCollector::Create - Http response code =" + responseCode);
logger.info("PlayCollector::Create - Http response message =" + responseMessage);
logger.info("PlayCollector::Create - Http response location =" + responseLocation);
if (responseCode == 201) {
playCollectorRef = responseLocation;
int index = playCollectorRef.lastIndexOf("/playercollectors", playCollectorRef.length());
resourceId = playCollectorRef.substring(index+18);
logger.info("PlayCollector::Create - Resource Id = " + resourceId);
eventMonitor.AddPlayCollector(this);
}
logger.info("PlayCollector::Create - Exited.");
}