|
| 1 | +package media |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/spf13/cobra" |
| 5 | + |
| 6 | + "github.com/eyetowers/gonvif/cmd/gonvif/root" |
| 7 | + "github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver20/media/wsdl" |
| 8 | + "github.com/eyetowers/gonvif/pkg/util" |
| 9 | +) |
| 10 | + |
| 11 | +var getVideoEncoderConfigurations = &cobra.Command{ |
| 12 | + Use: "get-video-encoder-configurations", |
| 13 | + Short: "List Onvif device video encoder configurations", |
| 14 | + Args: cobra.NoArgs, |
| 15 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 16 | + client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose) |
| 17 | + if err != nil { |
| 18 | + return nil |
| 19 | + } |
| 20 | + return runGetVideoEncoderConfigurations(client, configurationToken, profileToken) |
| 21 | + }, |
| 22 | +} |
| 23 | + |
| 24 | +func init() { |
| 25 | + getVideoEncoderConfigurations.Flags().StringVarP(&configurationToken, "configuration_token", "c", "", "Token of the requested configuration") |
| 26 | + getVideoEncoderConfigurations.Flags().StringVarP(&profileToken, "profile_token", "t", "", "Contains the token of an existing media profile the configurations shall be compatible with") |
| 27 | +} |
| 28 | + |
| 29 | +func runGetVideoEncoderConfigurations( |
| 30 | + client wsdl.Media2, configurationToken string, profileToken string, |
| 31 | +) error { |
| 32 | + resp, err := client.GetVideoEncoderConfigurations(&wsdl.GetConfiguration{ |
| 33 | + ConfigurationToken: util.NewReferenceTokenPtr(configurationToken), |
| 34 | + ProfileToken: util.NewReferenceTokenPtr(profileToken), |
| 35 | + }) |
| 36 | + if err != nil { |
| 37 | + return err |
| 38 | + } |
| 39 | + return root.OutputJSON(resp) |
| 40 | +} |
0 commit comments