Biblioteca kurento client php para el servidor de medios Kurento WebRTC que implementa el lado cliente del protocolo Kurento
La forma más sencilla de instalar esta biblioteca es utilizando Composer . Actualiza tu composer.json
"repositories" : [
{
"type" : "vcs" ,
"url" : "https://github.com/rukavina/kurento-client-php"
}
] ,
"require" : {
"rukavinamilan/kurento-client-php" : "dev-master"
}
y correr
composer install
Para la instalación real del servidor de medios Kurento WebRTC, consulte http://www.kurento.org/docs/current/installation_guide.html
Este es el ejemplo de hola mundo . Lea más en la página de tutoriales oficiales.
<?php
//composer autoload included
require_once ( " vendor/autoload.php " );
class DemoApp{
protected $ offer = null ;
protected $ loop ;
protected $ logger ;
protected $ wsUrl ;
protected $ client ;
function __construct ( $ offer , $ wsUrl ) {
$ this -> offer = $ offer ;
$ this -> wsUrl = $ wsUrl ;
//required react even loop
$ this -> loop = React EventLoop Factory:: create ();
$ this -> logger = new Zend Log Logger ();
$ writer = new Zend Log Writer Null ();
$ this -> logger -> addWriter ( $ writer );
}
public function 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 MgKurentoClientWebRtcEndpoint */
$ 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 ();
Si algunos objetos eliminados no se implementan directamente como clases php, aún puedes crearlos y usarlos a través de la clase MediaObject
genérica. Proporciona un método genérico:
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 );
El mismo ejemplo de Hola mundo podría implementarse utilizando clases/métodos genéricos como
$ 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 ();
No olvide instalar primero el servidor Kurento http://www.kurento.org/docs/current/installation_guide.html
entonces
git clone https://github.com/rukavina/kurento-client-php.git
composer install
Luego verifique el archivo README
en cada carpeta de ejemplo en particular.
Lea más en la página de tutoriales oficiales.
Milan Rukaviná
kurento client php tiene la licencia MIT; consulte el archivo LICENSE
para obtener más detalles
Esta biblioteca está fuertemente inspirada en los clientes oficiales de Java y JavaScript de Kurento.