ChunkPlayer: Difference between revisions

From VoIPmonitor.org
(Add warning about custom C++ integration blocking VoIPmonitor threads causing packetbuffer overflow)
(Review: opravy formátování (syntaxhighlight místo pre), přidán diagram workflow, přidána kategorie Developer, vylepšen AI Summary)
 
Line 1: Line 1:
{{DISPLAYTITLE:Embedding the Live Call Player (ChunkPlayer)}}
{{DISPLAYTITLE:Embedding the Live Call Player (ChunkPlayer)}}
[[Category:Developer]]


'''This is a developer-focused guide explaining how to use and integrate the ChunkPlayer, a sample PHP application for listening to active calls in real-time ("live spying").'''
'''This is a developer-focused guide explaining how to use and integrate the ChunkPlayer, a sample PHP application for listening to active calls in real-time ("live spying").'''
Line 8: Line 9:
=== How It Works ===
=== How It Works ===
The player functions by making a connection to the VoIPmonitor sensor's '''manager API''' (default port 5029). It authenticates and requests audio chunks for a specific, active call using two key identifiers:
The player functions by making a connection to the VoIPmonitor sensor's '''manager API''' (default port 5029). It authenticates and requests audio chunks for a specific, active call using two key identifiers:
*'''`sensor_id`''': The ID of the sensor handling the call.
* '''<code>sensor_id</code>''': The ID of the sensor handling the call.
*'''`callreference`''': A unique, temporary hexadecimal ID for an active call.
* '''<code>callreference</code>''': A unique, temporary hexadecimal ID for an active call.
 
<kroki lang="mermaid">
%%{init: {'flowchart': {'nodeSpacing': 15, 'rankSpacing': 40}}}%%
flowchart LR
    A[Browser] -->|1. Request| B[ChunkPlayer]
    B -->|2. listcalls| C[Manager API<br/>port 5029]
    C -->|3. callreference| B
    B -->|4. Stream audio| A
</kroki>


== Step 1: Configure the ChunkPlayer ==
== Step 1: Configure the ChunkPlayer ==
Line 19: Line 29:


;2. Edit the file with your details:
;2. Edit the file with your details:
<pre>
<syntaxhighlight lang="php">
<?php
<?php
// /var/www/html/api/chunkplayer/configuration.php
// /var/www/html/api/chunkplayer/configuration.php
Line 40: Line 50:


?>
?>
</pre>
</syntaxhighlight>


== Step 2: Find a Live Call to Monitor ==
== Step 2: Find a Live Call to Monitor ==
To use the player, you first need to get the `callreference` for a call that is currently in progress. This is done by querying the sensor's manager API with the `listcalls` command.
To use the player, you first need to get the <code>callreference</code> for a call that is currently in progress. This is done by querying the sensor's manager API with the <code>listcalls</code> command.


;Connect to the sensor via `nc` (netcat):
;Connect to the sensor via <code>nc</code> (netcat):
<pre>
<syntaxhighlight lang="bash">
# Replace SENSOR_IP and SENSOR_MANAGE_PORT with your sensor's details
# Replace SENSOR_IP and SENSOR_MANAGE_PORT with your sensor's details
echo 'listcalls' | nc 127.0.0.1 5029
echo 'listcalls' | nc 127.0.0.1 5029
</pre>
</syntaxhighlight>
 
The command will return a list of active calls. Look for the '''<code>callreference</code>''' parameter in the output. This is the ID you will need for the player.


The command will return a list of active calls. Look for the '''`callreference`''' parameter in the output. This is the ID you will need for the player.
;Example output snippet:
;Example output snippet:
<pre>
<syntaxhighlight lang="text">
...
...
[call]
[call]
Line 61: Line 72:
callreference: 4a3f7b2c1d  <-- THIS IS THE VALUE YOU NEED
callreference: 4a3f7b2c1d  <-- THIS IS THE VALUE YOU NEED
...
...
</pre>
</syntaxhighlight>


== Step 3: Use the Player Interface ==
== Step 3: Use the Player Interface ==
Once you have a valid `callreference`, you can use the player.
Once you have a valid <code>callreference</code>, you can use the player.


;1. Access the player's web interface:
;1. Access the player's web interface:
Line 71: Line 82:


;2. Enter the call details:
;2. Enter the call details:
:* '''callref:''' Paste the hexadecimal `callreference` value you obtained in the previous step.
:* '''callref:''' Paste the hexadecimal <code>callreference</code> value you obtained in the previous step.
:* '''sensor id:''' Enter the numeric ID of the sensor that is handling the call.
:* '''sensor id:''' Enter the numeric ID of the sensor that is handling the call.


Line 79: Line 90:
== Important Security Considerations ==
== Important Security Considerations ==
The ChunkPlayer requires direct access to the sensor's manager API port (TCP 5029).
The ChunkPlayer requires direct access to the sensor's manager API port (TCP 5029).
*'''Firewall Rules:''' Ensure that your firewall allows the server hosting the GUI to connect to the sensor on this port.
 
*'''Network Exposure:''' The manager API provides powerful control over the sensor. '''Do not''' expose this port directly to the public internet. Access should be restricted to trusted internal IP addresses only.
{{Warning|1=The manager API provides powerful control over the sensor. '''Do not''' expose port 5029 directly to the public internet. Access should be restricted to trusted internal IP addresses only.}}
 
* '''Firewall Rules:''' Ensure that your firewall allows the server hosting the GUI to connect to the sensor on this port.
* '''Network Exposure:''' Restrict access to trusted internal IP addresses only.


== Critical Warning: Using Internal Classes vs. Manager API ==
== Critical Warning: Using Internal Classes vs. Manager API ==
Line 110: Line 124:


== AI Summary for RAG ==
== AI Summary for RAG ==
'''Summary:''' This guide explains how to use the ChunkPlayer, a sample PHP application included with VoIPmonitor for embedding a live audio player for active calls ("live spying"). It details the three-step process for developers: 1) Configuring the player's `configuration.php` file with database and sensor manager API credentials. 2) Finding an active call to monitor by querying the sensor's manager API with the `listcalls` command to obtain a hexadecimal `callreference`. 3) Using the player's web interface (`index.html`) by entering the `callreference` and `sensor_id` to begin streaming the live audio. The guide concludes with a critical security warning (protect manager port 5029/TCP) and a warning against linking directly against VoIPmonitor's internal C++ classes, which can block packet processing threads and cause `packetbuffer: MEMORY IS FULL` errors. Developers are strongly advised to use the Manager API instead of internal classes to avoid blocking issues.
'''Summary:''' Developer guide for ChunkPlayer, a sample PHP application for embedding live audio streaming of active calls ("live spying"). Three-step process: 1) Configure <code>configuration.php</code> with manager API (port 5029) and DB credentials. 2) Get <code>callreference</code> using <code>listcalls</code> command via netcat. 3) Use web interface (<code>index.html</code>) with <code>callreference</code> and <code>sensor_id</code>. Critical security: protect port 5029/TCP, internal network only. Warning against linking internal C++ classes (causes blocking, <code>packetbuffer: MEMORY IS FULL</code>). Use Manager API for custom integrations.
'''Keywords:''' chunkplayer, live call, live spying, listen, active call, embed, api, manager api, `listcalls`, `callreference`, real-time, audio stream, developer, internal classes, C++, packetbuffer overflow, blocking threads, destructor
 
'''Keywords:''' chunkplayer, live call, live spying, listen, active call, embed, api, manager api, listcalls, callreference, real-time, audio stream, developer, internal classes, C++, packetbuffer overflow, blocking threads, port 5029
 
'''Key Questions:'''
'''Key Questions:'''
* What is the ChunkPlayer and how do I use it?
* What is the ChunkPlayer and how do I use it?
* How can I embed a live VoIPmonitor audio player into my own application?
* How can I embed a live VoIPmonitor audio player into my own application?
* What firewall ports are needed for the ChunkPlayer?
* What firewall ports are needed for the ChunkPlayer?
* How to use the `listcalls` manager API command?
* How to use the listcalls manager API command?
* How do I get the callreference for an active call?
* Why should I use Manager API instead of linking against internal C++ classes?
* Why should I use Manager API instead of linking against internal C++ classes?
* Can custom C++ code cause packetbuffer overflow by blocking VoIPmonitor threads?
* Can custom C++ code cause packetbuffer overflow by blocking VoIPmonitor threads?
* What are symptoms of custom code blocking the VoIPmonitor sniffer?

Latest revision as of 18:00, 6 January 2026


This is a developer-focused guide explaining how to use and integrate the ChunkPlayer, a sample PHP application for listening to active calls in real-time ("live spying").

Overview

The ChunkPlayer is a sample application included with the VoIPmonitor GUI that demonstrates how to stream and play audio from a call that is currently in progress. It is intended to be used as a starting point for developers who wish to embed live monitoring functionality into their own custom dashboards or applications.

How It Works

The player functions by making a connection to the VoIPmonitor sensor's manager API (default port 5029). It authenticates and requests audio chunks for a specific, active call using two key identifiers:

  • sensor_id: The ID of the sensor handling the call.
  • callreference: A unique, temporary hexadecimal ID for an active call.

Step 1: Configure the ChunkPlayer

The player has its own configuration file that must be set up with your database and manager API credentials.

1. Locate the configuration file
The file is located in the GUI's web directory, typically at:
/var/www/html/api/chunkplayer/configuration.php
2. Edit the file with your details
<?php
// /var/www/html/api/chunkplayer/configuration.php

/**
 * The IP address and port of the sensor's manager API.
 * This is used if a sensor_id is not provided in the request.
 */
define('VPMANAGERHOST', '127.0.0.1');
define('VPMANAGERPORT', 5029);

/**
 * Database credentials.
 * Although not directly used for streaming, they may be required by underlying libraries.
 */
define("MYSQL_HOST", "127.0.0.1");
define("MYSQL_DB", "voipmonitor");
define("MYSQL_USER", "root");
define("MYSQL_PASS", "your_db_password");

?>

Step 2: Find a Live Call to Monitor

To use the player, you first need to get the callreference for a call that is currently in progress. This is done by querying the sensor's manager API with the listcalls command.

Connect to the sensor via nc (netcat)
# Replace SENSOR_IP and SENSOR_MANAGE_PORT with your sensor's details
echo 'listcalls' | nc 127.0.0.1 5029

The command will return a list of active calls. Look for the callreference parameter in the output. This is the ID you will need for the player.

Example output snippet
...
[call]
id: 1
caller: 1001
called: 1002
callreference: 4a3f7b2c1d  <-- THIS IS THE VALUE YOU NEED
...

Step 3: Use the Player Interface

Once you have a valid callreference, you can use the player.

1. Access the player's web interface
Navigate your browser to:
http://Your-GUI-IP/api/chunkplayer/index.html
2. Enter the call details
  • callref: Paste the hexadecimal callreference value you obtained in the previous step.
  • sensor id: Enter the numeric ID of the sensor that is handling the call.
3. Click "play"
The player will connect to the manager API and begin streaming the live audio from the call.

Important Security Considerations

The ChunkPlayer requires direct access to the sensor's manager API port (TCP 5029).

⚠️ Warning: The manager API provides powerful control over the sensor. Do not expose port 5029 directly to the public internet. Access should be restricted to trusted internal IP addresses only.

  • Firewall Rules: Ensure that your firewall allows the server hosting the GUI to connect to the sensor on this port.
  • Network Exposure: Restrict access to trusted internal IP addresses only.

Critical Warning: Using Internal Classes vs. Manager API

The ChunkPlayer demonstrates the recommended approach for custom integration: using the Manager API (port 5029) to communicate with the sensor.

Why Not Link Against Internal Classes?

Some developers may be tempted to link their custom C++ applications directly against VoIPmonitor's internal C++ classes (the sniffer library). This approach is strongly discouraged for the following reasons:

  • Blocking VoIPmonitor Threads: If your custom code performs blocking operations (such as waiting indefinitely for threads to join) that interact with VoIPmonitor's internal data structures, you can block the sniffer's critical packet processing threads. This can cause packetbuffer: MEMORY IS FULL errors even if the system has adequate resources.
  • Destructor Blocking: A common source of problems is improper thread management in destructors. For example, if your code uses internal Call class objects and the destructor waits indefinitely for a listening thread to join, this will block VoIPmonitor's main processing loop.
  • API Stability: The internal C++ classes are not part of the public API. They may change without notice, breaking your custom application on future VoIPmonitor updates.

Symptoms of Custom Code Blocking VoIPmonitor

If you have integrated custom code that links against VoIPmonitor's internal classes, watch for these indicators of blocking issues:

  • packetbuffer: MEMORY IS FULL appears under high call load, even with adequate max_buffer_mem
  • High CPU usage but packets are being dropped
  • The issue occurs only when your custom application is running

Recommended Debugging Approach

If you suspect your custom code is blocking VoIPmonitor: 1. Review destructors for thread join operations that may wait indefinitely 2. Ensure all thread operations use timeouts instead of blocking waits 3. Consider profiling your application to identify critical paths where it may block VoIPmonitor's threads 4. If possible, migrate to using the Manager API instead of internal classes

For information on troubleshooting packetbuffer overflow generally, see Sniffer_configuration#Packet_Buffer_Settings.

AI Summary for RAG

Summary: Developer guide for ChunkPlayer, a sample PHP application for embedding live audio streaming of active calls ("live spying"). Three-step process: 1) Configure configuration.php with manager API (port 5029) and DB credentials. 2) Get callreference using listcalls command via netcat. 3) Use web interface (index.html) with callreference and sensor_id. Critical security: protect port 5029/TCP, internal network only. Warning against linking internal C++ classes (causes blocking, packetbuffer: MEMORY IS FULL). Use Manager API for custom integrations.

Keywords: chunkplayer, live call, live spying, listen, active call, embed, api, manager api, listcalls, callreference, real-time, audio stream, developer, internal classes, C++, packetbuffer overflow, blocking threads, port 5029

Key Questions:

  • What is the ChunkPlayer and how do I use it?
  • How can I embed a live VoIPmonitor audio player into my own application?
  • What firewall ports are needed for the ChunkPlayer?
  • How to use the listcalls manager API command?
  • How do I get the callreference for an active call?
  • Why should I use Manager API instead of linking against internal C++ classes?
  • Can custom C++ code cause packetbuffer overflow by blocking VoIPmonitor threads?