Skip to content

Commit c6a3042

Browse files
committed
Add media get-video-envoder-configurations command.
1 parent c27c4b4 commit c6a3042

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

cmd/gonvif/media/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func init() {
2121
getProfiles,
2222
getSnapshotURI,
2323
getStreamURI,
24+
getVideoEncoderConfigurations,
2425
getVideoSourceConfigurations,
2526
)
2627
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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

Comments
 (0)