kurento client php Bibliothek für Kurento WebRTC-Medienserver, die die Clientseite des Kurento-Protokolls implementiert
Der einfachste Weg, diese Bibliothek zu installieren, ist die Verwendung von Composer . Aktualisieren Sie Ihre composer.json
"repositories" : [
{
"type" : "vcs" ,
"url" : "https://github.com/rukavina/kurento-client-php"
}
] ,
"require" : {
"rukavinamilan/kurento-client-php" : "dev-master"
}
und laufen
composer install
Informationen zur tatsächlichen Installation des Kurento WebRTC-Medienservers finden Sie unter http://www.kurento.org/docs/current/installation_guide.html
Dies ist das Hallo-Welt- Beispiel. Weitere Informationen finden Sie auf der offiziellen Tutorial-Seite.
<?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 ();
Wenn einige Entfernungsobjekte nicht direkt als PHP-Klassen implementiert sind, können Sie sie dennoch über die generische MediaObject
Klasse erstellen und verwenden. Es bietet eine generische Methode:
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 );
Das gleiche Hallo-Welt-Beispiel könnte mit generischen Klassen/Methoden wie implementiert werden
$ 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 ();
Vergessen Sie nicht, zuerst den Kurento-Server zu installieren: http://www.kurento.org/docs/current/installation_guide.html
Dann
git clone https://github.com/rukavina/kurento-client-php.git
composer install
Überprüfen Sie dann README
Datei in jedem einzelnen Beispielordner.
Weitere Informationen finden Sie auf der offiziellen Tutorial-Seite.
Milan Rukavina
kurento client php ist unter der MIT-Lizenz lizenziert – Einzelheiten finden Sie in der LICENSE
Datei
Diese Bibliothek ist stark von offiziellen Java- und Javascript-Clients von Kurento inspiriert