-
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.
Add media get-video-envoder-configurations command.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 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
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) | ||
} |