1. Go to this page and download the library: Download glavweb/kurento-client-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
glavweb / kurento-client-php example snippets
//composer autoload included
er = null;
protected $loop;
protected $logger;
protected $wsUrl;
protected $client;
function __construct($offer, $wsUrl) {
$this->offer = $offer;
$this->wsUrl = $wsUrl;
// run(){
$this->client = \MgKurentoClient\KurentoClient::create($this->wsUrl, $this->loop, $this->logger, function($client){
$this->client->createMediaPipeline(function($pipeline, $success, $data){
$webRtcEndpoint = new \MgKurentoClient\WebRtcEndpoint($pipeline);
$webRtcEndpoint->build(function($webRtcEndpoint, $success, $data){
$webRtcEndpoint->connect($webRtcEndpoint, function($success, $data) use ($webRtcEndpoint){
/* @var $webRtcEndpoint \MgKurentoClient\WebRtcEndpoint */
$webRtcEndpoint->processOffer($this->offer, function($success, $data){
echo $data['value'];
//we don't need the loop anymore , we're exiting now
$this->loop->stop();
});
});
});
});
});
$this->loop->run();
}
}
/*
* Starting here
*/
//get raw post body
$offer = file_get_contents('php://input');
//init the app
$demoApp = new DemoApp($offer, 'ws://127.0.0.1:8888/kurento');
//start the app
$demoApp->run();
public function remoteCreate($remoteType, callable $callback, array $params = array());
public function remoteInvoke($operation, $operationParams, callable $callback);
public function remoteRelease(callable $callback);
protected function remoteSubscribe($type, $onEvent, callable $callback);
public function remoteUnsubscribe($subscription, callable $callback);
$this->client = \MgKurentoClient\KurentoClient::create($this->wsUrl, $this->loop, $this->logger, function($client){
$this->client->createMediaPipeline(function($pipeline, $success, $data){
$webRtcEndpoint = new \MgKurentoClient\MediaObject($pipeline);
$webRtcEndpoint->remoteCreate('WebRtcEndpoint', function($webRtcEndpoint, $success, $data){
$webRtcEndpoint->connect($webRtcEndpoint, function($success, $data) use ($webRtcEndpoint){
$webRtcEndpoint->remoteInvoke('processOffer', array('offer' => $this->offer), function($success, $data){
echo $data['value'];
//we don't need the loop anymore , we're exiting now
$this->loop->stop();
});
});
});
});
});
$this->loop->run();