forked from metal3d/kurento-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlphaBlending.go
96 lines (74 loc) · 2.54 KB
/
AlphaBlending.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package kurento
import "fmt"
type IAlphaBlending interface {
SetMaster(source HubPort, zOrder int) error
SetPortProperties(relativeX float64, relativeY float64, zOrder int, relativeWidth float64, relativeHeight float64, port HubPort) error
}
// A `Hub` that mixes the :rom:attr:`MediaType.AUDIO` stream of its connected
// sources and constructs one output with :rom:attr:`MediaType.VIDEO`
// streams of its connected sources into its sink
type AlphaBlending struct {
Hub
}
// Return contructor params to be called by "Create".
func (elem *AlphaBlending) 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 the master entry to the mixer
func (elem *AlphaBlending) SetMaster(source HubPort, zOrder int) error {
req := elem.getInvokeRequest()
params := make(map[string]interface{})
setIfNotEmpty(params, "source", source)
setIfNotEmpty(params, "zOrder", zOrder)
reqparams := map[string]interface{}{
"operation": "setMaster",
"object": elem.Id,
"operationParams": params,
}
if elem.connection.SessionId != "" {
reqparams["sessionId"] = elem.connection.SessionId
}
req["params"] = reqparams
// Call server and wait response
response := <-elem.connection.Request(req)
// Returns error or nil
if response.Error != nil {
return response.Error
} else {
return nil
}
}
// Configure the blending mode of one port.
func (elem *AlphaBlending) SetPortProperties(relativeX float64, relativeY float64, zOrder int, relativeWidth float64, relativeHeight float64, port HubPort) error {
req := elem.getInvokeRequest()
params := make(map[string]interface{})
setIfNotEmpty(params, "relativeX", relativeX)
setIfNotEmpty(params, "relativeY", relativeY)
setIfNotEmpty(params, "zOrder", zOrder)
setIfNotEmpty(params, "relativeWidth", relativeWidth)
setIfNotEmpty(params, "relativeHeight", relativeHeight)
setIfNotEmpty(params, "port", port)
reqparams := map[string]interface{}{
"operation": "setPortProperties",
"object": elem.Id,
"operationParams": params,
}
if elem.connection.SessionId != "" {
reqparams["sessionId"] = elem.connection.SessionId
}
req["params"] = reqparams
// Call server and wait response
response := <-elem.connection.Request(req)
// Returns error or nil
if response.Error != nil {
return response.Error
} else {
return nil
}
}