-
Notifications
You must be signed in to change notification settings - Fork 17
/
DispatcherOneToMany.go
68 lines (48 loc) · 1.49 KB
/
DispatcherOneToMany.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package kurento
import "fmt"
type IDispatcherOneToMany interface {
SetSource(source HubPort) error
RemoveSource() error
}
// A `Hub` that sends a given source to all the connected sinks
type DispatcherOneToMany struct {
Hub
}
// Return contructor params to be called by "Create".
func (elem *DispatcherOneToMany) 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
}
// Sets the source port that will be connected to the sinks of every `HubPort` of
// the dispatcher
func (elem *DispatcherOneToMany) SetSource(source HubPort) error {
req := elem.getInvokeRequest()
params := make(map[string]interface{})
setIfNotEmpty(params, "source", source)
req["params"] = map[string]interface{}{
"operation": "setSource",
"object": elem.Id,
"operationParams": params,
}
// Call server and wait response
response := <-elem.connection.Request(req)
// Returns error or nil
return response.Error
}
// Remove the source port and stop the media pipeline.
func (elem *DispatcherOneToMany) RemoveSource() error {
req := elem.getInvokeRequest()
req["params"] = map[string]interface{}{
"operation": "removeSource",
"object": elem.Id,
}
// Call server and wait response
response := <-elem.connection.Request(req)
// Returns error or nil
return response.Error
}