Skip to content

Commit

Permalink
Add media get-snapshot-uri command.
Browse files Browse the repository at this point in the history
  • Loading branch information
osery committed Sep 29, 2022
1 parent c404098 commit 70f9a2a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/gonvif/media/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func init() {
cmd.AddCommand(
getAnalyticsConfigurations,
getProfiles,
getSnapshotURI,
getVideoSourceConfigurations,
)
}
Expand Down
37 changes: 37 additions & 0 deletions cmd/gonvif/media/get-snapshot-uri.go
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 nil
}
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)
}

0 comments on commit 70f9a2a

Please sign in to comment.