Kurento 프로토콜의 클라이언트 측을 구현하는 Kurento WebRTC 미디어 서버용 kurento client php 라이브러리
이 라이브러리를 설치하는 가장 쉬운 방법은 작곡가를 사용하는 것입니다. composer.json
업데이트
"repositories" : [
{
"type" : "vcs" ,
"url" : "https://github.com/rukavina/kurento-client-php"
}
] ,
"require" : {
"rukavinamilan/kurento-client-php" : "dev-master"
}
그리고 달리다
composer install
실제 Kurento WebRTC 미디어 서버 설치에 대해서는 http://www.kurento.org/docs/current/installation_guide.html을 확인하십시오.
이것은 Hello World 의 예입니다. 공식 튜토리얼 페이지에서 자세한 내용을 읽어보세요.
<?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 ();
일부 제거 객체가 PHP 클래스로 직접 구현되지 않은 경우에도 일반 MediaObject
클래스를 통해 생성하고 사용할 수 있습니다. 일반적인 방법을 제공합니다.
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 );
동일한 hello world 예제는 다음과 같은 일반 클래스/메서드를 사용하여 구현할 수 있습니다.
$ 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 ();
먼저 Kurento 서버를 설치하는 것을 잊지 마세요 http://www.kurento.org/docs/current/installation_guide.html
그 다음에
git clone https://github.com/rukavina/kurento-client-php.git
composer install
그런 다음 각 특정 예제 폴더의 README
파일을 확인하십시오.
공식 튜토리얼 페이지에서 자세한 내용을 읽어보세요.
밀란 루카비나
kurento client php MIT 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 LICENSE
파일을 참조하세요.
이 라이브러리는 Kurento의 공식 Java 및 Javascript 클라이언트에서 많은 영감을 받았습니다.