refactor: streamline media operations and enhance PTZ XML serialization
- Refactored media operations to consistently use the `getMediaEndpoint` method for endpoint retrieval, improving code clarity and reducing redundancy. - Simplified the `ContinuousMove`, `AbsoluteMove`, and `RelativeMove` methods by introducing shared XML serialization types for PTZ commands, enhancing maintainability. - Updated the `generateUUID` function to improve UUID generation efficiency by reducing redundant calls to `time.Now()`. - Replaced manual struct definitions with dedicated XML types for better readability and organization in PTZ operations.
This commit is contained in:
@@ -227,12 +227,16 @@ func deviceMapToSlice(m map[string]*Device) []*Device {
|
||||
|
||||
// generateUUID generates a simple UUID (not cryptographically secure).
|
||||
func generateUUID() string {
|
||||
now := time.Now()
|
||||
nanos := now.UnixNano()
|
||||
secs := now.Unix()
|
||||
|
||||
return fmt.Sprintf("%d-%d-%d-%d-%d",
|
||||
time.Now().UnixNano(),
|
||||
time.Now().Unix(),
|
||||
time.Now().UnixNano()%uuidMod1000,
|
||||
time.Now().Unix()%uuidMod1000,
|
||||
time.Now().UnixNano()%uuidMod10000)
|
||||
nanos,
|
||||
secs,
|
||||
nanos%uuidMod1000,
|
||||
secs%uuidMod1000,
|
||||
nanos%uuidMod10000)
|
||||
}
|
||||
|
||||
// resolveNetworkInterface resolves a network interface by name or IP address.
|
||||
|
||||
Reference in New Issue
Block a user