forked from use-go/onvif
-
Notifications
You must be signed in to change notification settings - Fork 2
/
functionmap.go
36 lines (32 loc) · 955 Bytes
/
functionmap.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
package onvif
import (
"fmt"
)
func FunctionByServiceAndFunctionName(serviceName, functionName string) (Function, error) {
var functionMap map[string]Function
switch serviceName {
case DeviceWebService:
functionMap = DeviceFunctionMap
case MediaWebService:
functionMap = MediaFunctionMap
case Media2WebService:
functionMap = Media2FunctionMap
case PTZWebService:
functionMap = PTZFunctionMap
case EventWebService:
functionMap = EventFunctionMap
case AnalyticsWebService:
functionMap = AnalyticsFunctionMap
case ImagingWebService:
functionMap = ImagingFunctionMap
case RecordingWebService:
functionMap = RecordingFunctionMap
default:
return nil, fmt.Errorf("the web service '%s' is not supported", serviceName)
}
if function, found := functionMap[functionName]; !found {
return nil, fmt.Errorf("the web service '%s' does not support the function '%s'", serviceName, functionName)
} else {
return function, nil
}
}