From c6a3042295d7a2154dc911b332a1c512c1b25e7b Mon Sep 17 00:00:00 2001 From: Ondrej Sery Date: Thu, 29 Sep 2022 11:37:08 +0200 Subject: [PATCH] Add media get-video-envoder-configurations command. --- cmd/gonvif/media/cmd.go | 1 + .../media/get-video-encoder-configurations.go | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cmd/gonvif/media/get-video-encoder-configurations.go diff --git a/cmd/gonvif/media/cmd.go b/cmd/gonvif/media/cmd.go index 6b57324..b1669cf 100644 --- a/cmd/gonvif/media/cmd.go +++ b/cmd/gonvif/media/cmd.go @@ -21,6 +21,7 @@ func init() { getProfiles, getSnapshotURI, getStreamURI, + getVideoEncoderConfigurations, getVideoSourceConfigurations, ) } diff --git a/cmd/gonvif/media/get-video-encoder-configurations.go b/cmd/gonvif/media/get-video-encoder-configurations.go new file mode 100644 index 0000000..6147b1a --- /dev/null +++ b/cmd/gonvif/media/get-video-encoder-configurations.go @@ -0,0 +1,40 @@ +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 getVideoEncoderConfigurations = &cobra.Command{ + Use: "get-video-encoder-configurations", + Short: "List Onvif device video encoder configurations", + 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 runGetVideoEncoderConfigurations(client, configurationToken, profileToken) + }, +} + +func init() { + getVideoEncoderConfigurations.Flags().StringVarP(&configurationToken, "configuration_token", "c", "", "Token of the requested configuration") + getVideoEncoderConfigurations.Flags().StringVarP(&profileToken, "profile_token", "t", "", "Contains the token of an existing media profile the configurations shall be compatible with") +} + +func runGetVideoEncoderConfigurations( + client wsdl.Media2, configurationToken string, profileToken string, +) error { + resp, err := client.GetVideoEncoderConfigurations(&wsdl.GetConfiguration{ + ConfigurationToken: util.NewReferenceTokenPtr(configurationToken), + ProfileToken: util.NewReferenceTokenPtr(profileToken), + }) + if err != nil { + return err + } + return root.OutputJSON(resp) +}