forked from metal3d/kurento-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerEndpoint.go
57 lines (44 loc) · 1.23 KB
/
PlayerEndpoint.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
package kurento
import "fmt"
type IPlayerEndpoint interface {
Play() error
}
// Retrieves content from seekable sources in reliable
// mode (does not discard media information) and inject
// them into `KMS`. It
// contains one `MediaSource` for each media type detected.
type PlayerEndpoint struct {
UriEndpoint
}
// Return contructor params to be called by "Create".
func (elem *PlayerEndpoint) getConstructorParams(from IMediaObject, options map[string]interface{}) map[string]interface{} {
// Create basic constructor params
ret := map[string]interface{}{
"mediaPipeline": fmt.Sprintf("%s", from),
"uri": "",
"useEncodedMedia": false,
}
// then merge options
mergeOptions(ret, options)
return ret
}
// Starts to send data to the endpoint `MediaSource`
func (elem *PlayerEndpoint) Play() error {
req := elem.getInvokeRequest()
reqparams := map[string]interface{}{
"operation": "play",
"object": elem.Id,
}
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
}
}