Implementation in Golang - lack of documentation

550 views
Skip to first unread message

Patrice FERLET

unread,
Mar 8, 2015, 11:05:00 AM3/8/15
to kur...@googlegroups.com
hi,

I'm trying to make implement "basic" communication between golang and kurento. The main goal (at this time) is to be able to stream webcam to kurento server and get back the video stream.

Since 3 days, I'm reading kurento documentation to understand how and what to send to kurento server. Without any success.

This is where I am now:

Webpage uses kurento-utils. I'm able to start video with "startSendOnly" and my webcam appears in a video bloc.
I've got sdpOffer that I send to my Go server with websocket

I can connect to Kurento server with a Go websocket client, and that's all...

I understood that I have to send WebRtcEndpoint creation request from Go server to Kurento server with a JSONRPC call, but I really don't understand what to send in the request. 

I don't find what creationParams to send, if I should create my own sessionId, my own client "Id", and so on...


Thanks a lot for that media server, it seems you're the only one to have understood that we need to communicate "not only from browser to brower", and your examples gave me entire satisfaction. Congratulation.

Patrice FERLET

unread,
Mar 8, 2015, 1:40:08 PM3/8/15
to kur...@googlegroups.com
OK... I found one of my problem, I should create a MediaPipe to get IDs then I had to request a WebRtcEndpoint creation. And now, I don't find the constructorParams to send.

I get this error:
{"error":{"code":40001,"data":{"type":"MARSHALL_ERROR"},"message":"'constructorParams' is required"},"id":456456,"jsonrpc":"2.0"}

Jose Antonio Santos Cadenas

unread,
Mar 8, 2015, 3:14:29 PM3/8/15
to kur...@googlegroups.com
Great you got the solution to one of your problems.

constructorParams is an object that contains all the constructor parameters serialized as JSON.

In general, if you pass a constructorParams as an empty json object, mediaserver will tell you what required parameters you may need.


--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Micael Gallego

unread,
Mar 8, 2015, 3:15:51 PM3/8/15
to kur...@googlegroups.com
Hi Patrice, 

Glad to hear that kurento is useful for you.

In order to implemente a kurento client in another language than Java or JavaScript you have to know that there are two planes: 1) Protocol (based on json-rpc) and 2) Kurento API (that you have to use remotely from your client).

The protocol is specified in [1]. There are several types of messages: creation, invocation, releasing, subscribing and unsubscribing. 

The Kurento API is only outlined in [2]. This page contains only an overview of the Kurento API. In order to implemente a kurento client you need the reference documentation. The best way to know all details is take a look to IDL file that defines the interface of the kurento elements. We have defined a custom IDL format based on JSON. From it, we generate the client code for Java and JavaScript. Kurento API is defined in the following IDL files: [3] and all .kmd.json files in [4] and [5]. I think these files are auto-explained, but if you need more info, please let us know.

If you want to generate your Go code from these IDL files ( kmd.json ), you can use FreeMarker template system and the Java tool Kurento-module-creator in [6].

Regards.



Un saludo.

Micael Gallego
http://about.me/micael.gallego

--

Patrice FERLET

unread,
Mar 8, 2015, 4:42:48 PM3/8/15
to kur...@googlegroups.com
Thanks a lot for this answer. Very complete.

At this time, I have successfully implemented a WebRTCEndpoint creation with some basic calls (create mediapipe, create WebRTCEndpoint, then invoke connection and processOffer) 
I'm unable to understand how (at this time) I can now read the stream from KMS, and I'm not sure that my webcam streams something to KMS. I only have good answer with JSONRPC.

But I'm pretty sure I'm not doing things as I must to. I don't see how it works but I will probably understand... If really I cannot use it, I will check other methods.

At this time, I guess that I don't understand exactly the stream creation (from webcam to kms, and from kms to other browser). I'm making calls step by step with Golang... without to be sure I making calls I should.

I will take a look on your [6] link to check if I can process Golang code. Not sure on "how to build" the tool, and how to use it...

Thanks again

Patrice FERLET

unread,
Mar 8, 2015, 5:08:28 PM3/8/15
to kur...@googlegroups.com
Right, 

In fact, now, I have successfully created a process that does:

client -> send sdp to GoServer
Go -> connect to KMS (websocket)
Go -> KMS : create mediapipe
KMS -> Go : response (with sessionId and so on)
GO -> create WebRTCConnection
KMS -> Go: ok, sesion id, and so on
Go -> KMS: processSDPOffer 
KMS -> Go: return sdp answer

I just don't understand how to use this in another web view to stream this... I'm not sure that I reaaly send data to KMS from my webcam... I only have good json answers...

I'm testing what Micael said me, but I have no java or maven installation (I'm using docker to start KMS, I will use docker to run maven)

Patrice FERLET

unread,
Mar 9, 2015, 10:32:58 AM3/9/15
to kur...@googlegroups.com
OK...
I'm able to generate Golang package from the json you gave. But I will need some help to understand some subtilities.

First, to clarify the subject (in case of you're not a Golang developper) you need to know that:

- Go has no class, we've got "struct" that can handle properties and functions (that's not very different)
- Go has no abstract class
- Go has interfaces, so I've got possibilities to create right interfaces.


Each element I parse from json description is generated as "type".

The problem arrives when I see a the "abstract" property. Because I cannot create such class (struct) I let them instanciable.

First questions

Let me show you what will be possible:

// create a MediaPipeline
pipeline := &MediaPipeline{}

// prepare a webrtc endpoint
webrtc := &WebRtcEndpoint{}
pipeline.create(webrtc) 

// -> with reflection, I know that I will call "create" on API with type "WebRtcEndoint"

So, now, it's ok. "webrtc" object is a WebRtcEnpoint (go type, struct)

What makes me disapointed is that I know that to create a WebRtcEndpoint, I need to "connect" the sink. If I'm not wrong, javascript-client knows that and do the job. But where is it described ?

Or maybe, each "create" method should connect parent to created sink ?

If someone can help me to be sure I'm not making something wrong...


Second questions:

Each API call need to have an "id" (client id). If I don't change this id each time, API doesn't respond with correct values. Is it mandatory to change this id for each call ? or one more time I did something wrong ?...

PS: Sorry for my bad english

Le dimanche 8 mars 2015 20:15:51 UTC+1, Micael Gallego Carrillo a écrit :
Message has been deleted

Patrice FERLET

unread,
Mar 11, 2015, 8:17:34 AM3/11/15
to kur...@googlegroups.com

If someone is interessed, I'm currently near to have a correct Go pacakge.
I made a generator:


I'm currently working on correct params generation, then I will finish the websocket process. I think I will have something working next sunday.


Le dimanche 8 mars 2015 20:15:51 UTC+1, Micael Gallego Carrillo a écrit :

Ivan Gracia

unread,
Mar 11, 2015, 8:40:54 AM3/11/15
to kur...@googlegroups.com
Hi Patrice,

Thank you very much for your great contribution and your efforts! We're eager to see a Golang client working ;-)


To unsubscribe from this group and stop receiving emails from it, send an email to kurento+unsubscribe@googlegroups.com.

Patrice FERLET

unread,
Mar 11, 2015, 5:57:19 PM3/11/15
to kur...@googlegroups.com
Trust me, that's a pleasure :) 
At this time, my lasts problems are:

- Where should I store sessionID
- For what is used ServerManager
- Make a solid Websocket response manager (with client id that should change each time if I'm not wrong)
- When I pass a MediaObject child to a method (eg. Connect()) I should use object.id in request, I will try to implement String() method that should work

I'm pretty sure I will be able to make it working

Patrice FERLET

unread,
Mar 15, 2015, 4:12:57 AM3/15/15
to kur...@googlegroups.com
Hi
I'm near to have something that can work (without event manager at this time)
At this time, I only have to manage sessionId and return types (for example, the form of []ElementConnectionData)

Also, I really don't understand how are managed sessions - when will be the sessionID different that another ? And how to use SeverManager :)

I just remarked that the page http://www.kurento.com/docs/current/mastering/kurento_protocol.html has got several errors.

First: it's explained that a "create" request need "createParams" but later in the page, at example section, you use "constructorParams" (that is right)

In example section at point "5" you explain that we call "create" primitive, but the JSON show a "connect" call (connect is right if I'm not wrong). 



Le dimanche 8 mars 2015 20:15:51 UTC+1, Micael Gallego Carrillo a écrit :

Micael Gallego

unread,
Mar 15, 2015, 8:05:49 AM3/15/15
to kur...@googlegroups.com
I'll respond between lines...

On Sun, Mar 15, 2015 at 9:12 AM, Patrice FERLET <met...@gmail.com> wrote:
Hi
I'm near to have something that can work (without event manager at this time)

Nice to hear it... 
 
At this time, I only have to manage sessionId and return types (for example, the form of []ElementConnectionData)

Also, I really don't understand how are managed sessions - when will be the sessionID different that another ?

Your first request in a websocket connection don't have to include any sessionId. The first response from server will include the sessionId you have to use in the following requests. The sessionId value is working like session cookie in web requests.
 
And how to use SeverManager :)

ServerManager is an automatically created object that you can use using the id "manager_ServerManager".  You can't create any object of type "ServerManager". This object is created automatically in the server on startup.

I just remarked that the page http://www.kurento.com/docs/current/mastering/kurento_protocol.html has got several errors.

First: it's explained that a "create" request need "createParams" but later in the page, at example section, you use "constructorParams" (that is right)

In example section at point "5" you explain that we call "create" primitive, but the JSON show a "connect" call (connect is right if I'm not wrong). 

Thank you, we'll fix them ASAP. 

Regards...

Patrice FERLET

unread,
Mar 15, 2015, 9:23:36 AM3/15/15
to kur...@googlegroups.com


Le dimanche 15 mars 2015 13:05:49 UTC+1, Micael Gallego Carrillo a écrit :
I'll respond between lines...

On Sun, Mar 15, 2015 at 9:12 AM, Patrice FERLET <met...@gmail.com> wrote:
Hi
I'm near to have something that can work (without event manager at this time)

Nice to hear it... 
 
 
At this time, I only have to manage sessionId and return types (for example, the form of []ElementConnectionData)

Also, I really don't understand how are managed sessions - when will be the sessionID different that another ?

Your first request in a websocket connection don't have to include any sessionId. The first response from server will include the sessionId you have to use in the following requests. The sessionId value is working like session cookie in web requests.

Yes, I understand what is sessionId, how to get it and what it means :)

I just don't know if there is a possibility to have several sessionId with the same websocket connection. If I'm not wrong, I should have only one session ID per connection. 
 
 
And how to use SeverManager :)

ServerManager is an automatically created object that you can use using the id "manager_ServerManager".  You can't create any object of type "ServerManager". This object is created automatically in the server on startup.

Ok... At this time that's not very problematic for me, I will check this part later.
 

I just remarked that the page http://www.kurento.com/docs/current/mastering/kurento_protocol.html has got several errors.

First: it's explained that a "create" request need "createParams" but later in the page, at example section, you use "constructorParams" (that is right)

In example section at point "5" you explain that we call "create" primitive, but the JSON show a "connect" call (connect is right if I'm not wrong). 

Thank you, we'll fix them ASAP. 

I also remark something... MediaObject has "Childs" parameter... that should be named "Children".

Thanks a lot for your help and answers :)

Patrice FERLET

unread,
Mar 17, 2015, 5:39:25 PM3/17/15
to kur...@googlegroups.com
With pleasure, I can now tell you that It works !

I spent a lot of time to understand some Kurento specificity as "master webrtcendpoint has to connect itself", and that one2many stream should be created with the same Pipeline (yes, that logical now I know it :) )

I've got only one problem to resolve, but that's a problem with Go implementation (error code is always set, even if the error is null from Kurento response...)

I'm pretty sure I will be able to have an alpha version tonight. There is no Event manager at this time (from Kurento to Go) and I didn't implemented Filters (I will begin this work tomorow)

Big thanks to you for your help. 

Micael Gallego

unread,
Mar 17, 2015, 6:08:37 PM3/17/15
to kur...@googlegroups.com
Congratulations!!!

One excuse more to learn Go ;)

Un saludo.

Micael Gallego
http://about.me/micael.gallego

Ivan Gracia

unread,
Mar 17, 2015, 6:17:14 PM3/17/15
to kur...@googlegroups.com
Kudos Patrice!

Cheers,
Ivan.

Patrice FERLET

unread,
Mar 17, 2015, 7:28:51 PM3/17/15
to kur...@googlegroups.com
The first alpha: https://github.com/metal3d/kurento-go

I need to fix Error handling and try more, but it works :)
Reply all
Reply to author
Forward
0 new messages