MultiRequest

4 replies [Last post]
Joined: 06/17/2011
Points: 9

Hi everybody,

I am using the PHP 5 Client for Kaltura. I would like to know if it's possible to use the multiplerequest functionnality with this Client ?

I don't found any documentation about.

Thanks for your help.

Kind regards

Joined: 06/17/2011
Points: 9

Hi,

Kalturian sent me this url : http://www.kaltura.org/kalorg/kaltura-api-clients-sample-code/php/Sample...
In order to have example for the multirequesting with PHP.

Thanks a lot to him :)

Joined: 06/17/2011
Points: 9

I put here private messages, all people can see them :

I want to get the media for a list of users (after i do some operation, for example calculate the average bitrate for each media of a user etc..).
My list of user is paging 5 by 5 users (with a pager) : currently my code is like this (I write with my memory, i don't have the code in front of me) :

$userList = $this->_client->user->listAction(null, $pager); // Get the list of user, with a pager 5 entries by 5 entries.
foreach ($userList as $item)
{
    $filter = new KalturaMediaEntryFilter();
    $filter->userIdEqual = $item->id;
   $media_of_one_user =  $this->_client->media->listAction($filter, null); // get the media associate to this user
foreach (media_of_one_user  as $media)
{
  ......  // Do some operation, calculate average bitrate and some other, for each media of the client.
}
}

As you can see, one call to "user->listAction", 5 call to "media->listAction", 5 call to getflavor etc ...
At the end, it make some call and performance are bad.
I would like to know if it's possible to do anything like this, in one call with the multirequest. It will look like :

$this->_client->startMultiRequest();
$this->_client->user->listAction(null, $pager);  // get my 5 paging users (and no others)      
$filter = new KalturaMediaEntryFilter();
$filter->userIdEqual = '{1:result:objects:EACH_USER(5)_IN_LAST_CALL:id}'; // here i need to say at the request, that we need to get the media of the 5 users get by the last request. But how do that ?
$this->_client->media->listAction($filter, null); // Get the media of the 5 users
..... // Do some operation on this mediaList like average bitrate and so more...
$res = $this->_client->doQueue(); // Get the result.
var_dump($res);

Is it possible ? Or i need to get all the list of the media, and sort and filter manually after get it ?
Do you understand what i want to say or not ? :(

Joined: 01/05/2009
Points: 1697

Essentially, you're looking to make multirequest do loops for you. unfortunately, multirequest can only automate, or link, results in a chain, it is not capable of loops.
I would do it completely different than you try to do below...
Call http://www.kaltura.com/api_v3/testmeDoc/index.php?service=user&action=li...
$users = $client->user->list($filter, $pager);
and then:

$this->_client->startMultiRequest();
foreach ($users as $user) {
  $filter = new KalturaMediaEntryFilter();
  $filter->userIdEqual = $user->id;
  $this->_client->media->listAction($filter, null); // Get the media of the user
}
$res = $this->_client->doQueue(); // Get the result.
var_dump($res);
  ..... // Do some operation on this mediaList like average bitrate and so more... probably in another for loop on the results

That way you can loop through the users doing the multirequest once for every user.
I understand you would like to also loop through the users in the multirequest, but this api is not designed for complex operations like loops, it merely chain actions to reduce callbacks of dependent calls.
Hopefully this helps.

Joined: 06/17/2011
Points: 9

Ok, maybe in the futur.

I did like that. Thanks.

Can we get statistiques about bandwidth, etc.. ? I see that have the kmcCollect action in statistiques (KalturaStatsKmcEventType::REPORTS_AND_ANALYTICS_BANDWIDTH_USAGE_VIEW_MONTHLY, and others), but how do this ?

Thanks a lot :)