Code Monkey home page Code Monkey logo

kurento-client-php's Introduction

Kurento Client PHP

Kurento Client PHP library for Kurento WebRTC media server which implements client side of Kurento Protocol

Installation

The easiest way to install this library is using composer. Update your composer.json

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rukavina/kurento-client-php"
        }
    ],
    "require": {
        "rukavinamilan/kurento-client-php": "dev-master"
    }

and run

composer install

For actual Kurento WebRTC media server installation please check http://www.kurento.org/docs/current/installation_guide.html

Usage

This is the hello world example. Read more at official tutorials' page.

<?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 \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();

Generic elements

If some remove object are not directly implemented as php classes you can still create and use them via generic MediaObject class. It provides generic method:

    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);

The same hello world example could be implemented using generic class/methods as

$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();

Examples installation

Don't forget to install Kurento server first http://www.kurento.org/docs/current/installation_guide.html

then

git clone https://github.com/rukavina/kurento-client-php.git
composer install

Then check README file in each particular example folder.

Read more at official tutorials' page.

Requirements

Author

Milan Rukavina

License

Kurento Client PHP is licensed under the MIT License - see the LICENSE file for details

Acknowledgements

This library is heavily inspired by official java and javascript clients by Kurento

kurento-client-php's People

Contributors

rukavina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kurento-client-php's Issues

this library doesnt work at all

i have installed this library and also tried the server and functions with js to confirm that kurento is working, this php library does not work at all, the index.html in every example is none responsive.

class Zend\Log\Writer\Null has been deprecated

pwd

/usr/share/nginx/html/webrtc/examples/hello-world

php index.php

PHP Deprecated: The class Zend\Log\Writer\Null has been deprecated; please use Zend\Log\Writer\Noop in /usr/share/nginx/html/webrtc/vendor/zendframework/zend-log/src/Writer/Null.php on line 33

remote connection is not working

Hi Rukavina,
I m unable to connect remotely(e.g: not getting the second/remote video in one2one) in all examples specified.
Can you please guide me how can i resolve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.