-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dispatcher.go
51 lines (36 loc) · 1.12 KB
/
Dispatcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package kurento
import "fmt"
type IDispatcher interface {
Connect(source HubPort, sink HubPort) error
}
// A `Hub` that allows routing between arbitrary port pairs
type Dispatcher struct {
Hub
}
// Return contructor params to be called by "Create".
func (elem *Dispatcher) getConstructorParams(from IMediaObject, options map[string]interface{}) map[string]interface{} {
// Create basic constructor params
ret := map[string]interface{}{
"mediaPipeline": fmt.Sprintf("%s", from),
}
// then merge options
mergeOptions(ret, options)
return ret
}
// Connects each corresponding :rom:enum:`MediaType` of the given source port with
// the sink port.
func (elem *Dispatcher) Connect(source HubPort, sink HubPort) error {
req := elem.getInvokeRequest()
params := make(map[string]interface{})
setIfNotEmpty(params, "source", source)
setIfNotEmpty(params, "sink", sink)
req["params"] = map[string]interface{}{
"operation": "connect",
"object": elem.Id,
"operationParams": params,
}
// Call server and wait response
response := <-elem.connection.Request(req)
// Returns error or nil
return response.Error
}