-
Notifications
You must be signed in to change notification settings - Fork 1
/
recording.go
161 lines (144 loc) · 5.42 KB
/
recording.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package wserest
import (
"github.com/openfresh/wse-rest-library-go/entity/application/helper"
"github.com/openfresh/wse-rest-library-go/entity/base"
)
// Recording is Stream Recorder utility
type Recording struct {
wowza
}
// NewRecording creates Recording object
func NewRecording(settings *helper.Settings, appName string, appInstance string) *Recording {
if appName == "" {
appName = "live"
}
if appInstance == "" {
appInstance = "_definst_"
}
r := new(Recording)
r.init(settings)
r.props["recorderName"] = "myStream"
r.props["instanceName"] = "_definst_"
r.props["recorderState"] = "Waiting for stream"
r.props["defaultRecorder"] = true
r.props["segmentationType"] = "None"
r.props["outputPath"] = ""
r.props["baseFile"] = "myrecord.mp4"
r.props["fileFormat"] = "MP4"
r.props["fileVersionDelegateName"] = "com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate"
r.props["fileTemplate"] = "${BaseFileName}_${RecordingStartTime}_${SegmentNumber}"
r.props["segmentDuration"] = 900000
r.props["segmentSize"] = 10485760
r.props["segmentSchedule"] = "0 * * * * *"
r.props["recordData"] = true
r.props["startOnKeyFrame"] = true
r.props["splitOnTcDiscontinuity"] = false
r.props["option"] = "Version existing file"
r.props["moveFirstVideoFrameToZero"] = true
r.props["currentSize"] = 0
r.props["currentDuration"] = 0
r.props["recordingStartTime"] = ""
r.baseURI = r.host() + "/servers/" + r.serverInstance() + "/vhosts/" + r.vHostInstance() + "/applications/" + appName + "/instances/" + appInstance + "/streamrecorders"
return r
}
// Create creates a new Stream Recorder in the specified Application Instance and starts recording
func (r *Recording) Create(
recorderName string,
instanceName string,
recorderState string,
defaultRecorder bool,
segmentationType string,
outputPath string,
baseFile string,
fileFormat string,
fileVersionDelegateName string,
fileTemplate string,
segmentDuration int,
segmentSize int,
segmentSchedule string,
recordData bool,
startOnKeyFrame bool,
splitOnTcDiscontinuity bool,
option string,
moveFirstVideoFrameToZero bool,
currentSize int,
currentDuration int,
recordingStartTime string,
) (map[string]interface{}, error) {
r.props["recorderName"] = recorderName
r.props["instanceName"] = instanceName
r.props["recorderState"] = recorderState
r.props["defaultRecorder"] = defaultRecorder
r.props["segmentationType"] = segmentationType
r.props["outputPath"] = outputPath
r.props["baseFile"] = baseFile
r.props["fileFormat"] = fileFormat
r.props["fileVersionDelegateName"] = fileVersionDelegateName
r.props["fileTemplate"] = fileTemplate
r.props["segmentDuration"] = segmentDuration
r.props["segmentSize"] = segmentSize
r.props["segmentSchedule"] = segmentSchedule
r.props["recordData"] = recordData
r.props["startOnKeyFrame"] = startOnKeyFrame
r.props["splitOnTcDiscontinuity"] = splitOnTcDiscontinuity
r.props["option"] = option
r.props["moveFirstVideoFrameToZero"] = moveFirstVideoFrameToZero
r.props["currentSize"] = currentSize
r.props["currentDuration"] = currentDuration
r.props["recordingStartTime"] = recordingStartTime
r.setRestURI(r.baseURI)
response, err := r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, POST, "")
return response, err
}
// GetAll retrieves the list of Stream Recorders
func (r *Recording) GetAll() (map[string]interface{}, error) {
r.setNoParams()
r.setRestURI(r.baseURI)
return r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, GET, "")
}
// GetRecorder retrieves the specifed Stream Recorder
func (r *Recording) GetRecorder(recorderName string) (map[string]interface{}, error) {
r.setRestURI(r.baseURI + "/" + recorderName)
r.setNoParams()
return r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, GET, "")
}
// GetDefaultParams retrieves a Stream Recorder of the requested name, popluated with the default values
func (r *Recording) GetDefaultParams(recorderName string) (map[string]interface{}, error) {
r.setRestURI(r.baseURI + "/" + recorderName + "/default")
r.setNoParams()
return r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, GET, "")
}
// Stop stop recording
func (r *Recording) Stop(recorderName string) (map[string]interface{}, error) {
r.setRestURI(r.baseURI + "/" + recorderName + "/actions/stopRecording")
r.setNoParams()
return r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, PUT, "")
}
// Split splits recording
func (r *Recording) Split(recorderName string) (map[string]interface{}, error) {
r.setRestURI(r.baseURI + "/" + recorderName + "/actions/splitRecording")
r.setNoParams()
return r.sendRequest(r.preparePropertiesForRequest(), []base.Entity{}, PUT, "")
}
func (r *Recording) setNoParams() {
r.AddSkipParameter("recordName")
r.AddSkipParameter("instanceName")
r.AddSkipParameter("recorderState")
r.AddSkipParameter("defaultRecorder")
r.AddSkipParameter("segmentationType")
r.AddSkipParameter("outputPath")
r.AddSkipParameter("baseFile")
r.AddSkipParameter("fileFormat")
r.AddSkipParameter("fileVersionDelegateName")
r.AddSkipParameter("fileTemplate")
r.AddSkipParameter("segmentDuration")
r.AddSkipParameter("segmentSize")
r.AddSkipParameter("segmentSchedule")
r.AddSkipParameter("startOnKeyFrame")
r.AddSkipParameter("splitOnTcDiscontinuity")
r.AddSkipParameter("option")
r.AddSkipParameter("moveFirstVideoFrameToZero")
r.AddSkipParameter("currentSize")
r.AddSkipParameter("currentDuration")
r.AddSkipParameter("recordingStartTime")
}