-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
3,298 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/eyetowers/gonvif/cmd/gonvif/root" | ||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" | ||
"github.com/eyetowers/gonvif/pkg/gonvif" | ||
) | ||
|
||
var cmd = &cobra.Command{ | ||
Use: "media2", | ||
Short: "Manipulate Onvif device media features.", | ||
} | ||
|
||
func init() { | ||
root.RequireAuthFlags(cmd) | ||
root.Command.AddCommand(cmd) | ||
cmd.AddCommand( | ||
getAnalyticsConfigurations, | ||
getProfiles, | ||
getSnapshotURI, | ||
getStreamURI, | ||
getVideoEncoderConfigurations, | ||
getVideoSourceConfigurations, | ||
setSynchronizationPoint, | ||
) | ||
} | ||
|
||
func ServiceClient(url, username, password string, verbose bool) (wsdl.Media2, error) { | ||
onvif, err := gonvif.New(url, username, password, verbose) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return onvif.Media2() | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/eyetowers/gonvif/cmd/gonvif/root" | ||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" | ||
) | ||
|
||
var ( | ||
types []string | ||
) | ||
|
||
var getProfiles = &cobra.Command{ | ||
Use: "get-profiles", | ||
Short: "List Onvif device media profiles", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
return runGetProfiles(client, types) | ||
}, | ||
} | ||
|
||
func init() { | ||
getProfiles.Flags().StringArrayVarP(&types, "types", "t", []string{"All"}, "Types of profile configurations to include") | ||
} | ||
|
||
func runGetProfiles(client wsdl.Media2, types []string) error { | ||
resp, err := client.GetProfiles(&wsdl.GetProfiles{ | ||
Type: types, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return root.OutputJSON(resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/eyetowers/gonvif/cmd/gonvif/root" | ||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" | ||
"github.com/eyetowers/gonvif/pkg/util" | ||
) | ||
|
||
var getSnapshotURI = &cobra.Command{ | ||
Use: "get-snapshot-uri", | ||
Short: "Get Onvif device media snapshot URI", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
return runGetSnapshotURI(client, profileToken) | ||
}, | ||
} | ||
|
||
func init() { | ||
getSnapshotURI.Flags().StringVarP(&profileToken, "profile_token", "t", "", "The ProfileToken element indicates the media profile to use and will define the source and dimensions of the snapshot.") | ||
root.MustMarkFlagRequired(getSnapshotURI, "profile_token") | ||
} | ||
|
||
func runGetSnapshotURI(client wsdl.Media2, profileToken string) error { | ||
resp, err := client.GetSnapshotUri(&wsdl.GetSnapshotUri{ | ||
ProfileToken: util.NewReferenceTokenPtr(profileToken), | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return root.OutputJSON(resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/eyetowers/gonvif/cmd/gonvif/root" | ||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" | ||
"github.com/eyetowers/gonvif/pkg/util" | ||
) | ||
|
||
var ( | ||
protocol string | ||
) | ||
|
||
var getStreamURI = &cobra.Command{ | ||
Use: "get-stream-uri", | ||
Short: "Get Onvif device media stream URI", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
return runGetStreamURI(client, profileToken, protocol) | ||
}, | ||
} | ||
|
||
func init() { | ||
getStreamURI.Flags().StringVarP(&profileToken, "profile_token", "t", "", "The ProfileToken element indicates the media profile to use and will define the configuration of the content of the stream.") | ||
getStreamURI.Flags().StringVarP(&protocol, "protocol", "r", "RTSP", "Defines the network protocol for streaming (RtspUnicast, RtspMulticast, RTSP, RtspOverHttp).") | ||
root.MustMarkFlagRequired(getStreamURI, "profile_token") | ||
} | ||
|
||
func runGetStreamURI(client wsdl.Media2, profileToken string, protocol string) error { | ||
resp, err := client.GetStreamUri(&wsdl.GetStreamUri{ | ||
ProfileToken: util.NewReferenceTokenPtr(profileToken), | ||
Protocol: protocol, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return root.OutputJSON(resp) | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/eyetowers/gonvif/cmd/gonvif/root" | ||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" | ||
"github.com/eyetowers/gonvif/pkg/util" | ||
) | ||
|
||
var setSynchronizationPoint = &cobra.Command{ | ||
Use: "set-synchronization-point", | ||
Short: "Request Onvif device to insert a key frame into all streams for the given profile", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
return runSetSynchronizationPoint(client, profileToken) | ||
}, | ||
} | ||
|
||
func init() { | ||
setSynchronizationPoint.Flags().StringVarP(&profileToken, "profile_token", "t", "", "The ProfileToken element indicates the media profile to use and will define the source and dimensions of the snapshot.") | ||
root.MustMarkFlagRequired(setSynchronizationPoint, "profile_token") | ||
} | ||
|
||
func runSetSynchronizationPoint(client wsdl.Media2, profileToken string) error { | ||
resp, err := client.SetSynchronizationPoint(&wsdl.SetSynchronizationPoint{ | ||
ProfileToken: util.NewReferenceTokenPtr(profileToken), | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return root.OutputJSON(resp) | ||
} |
Oops, something went wrong.