Skip to content

Commit

Permalink
Add media get-video-envoder-configurations command.
Browse files Browse the repository at this point in the history
  • Loading branch information
osery committed Sep 29, 2022
1 parent c27c4b4 commit c6a3042
Show file tree
Hide file tree
Showing 2 changed files with 41 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 @@ -21,6 +21,7 @@ func init() {
getProfiles,
getSnapshotURI,
getStreamURI,
getVideoEncoderConfigurations,
getVideoSourceConfigurations,
)
}
Expand Down
40 changes: 40 additions & 0 deletions cmd/gonvif/media/get-video-encoder-configurations.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit c6a3042

Please sign in to comment.