代码拉取完成,页面将自动刷新
package media
import (
"context"
"regexp"
"errors"
"gitee.com/waiot/onvif/sdk"
soap "gitee.com/waiot/onvif/www.w3.org/2003/05/soapEnvelope"
"gitee.com/waiot/onvif/client"
"gitee.com/waiot/onvif/entity/ver10/media"
)
// GetAudioDecoderConfigurations forwards the call to cli.CallMethod() then parses the payload of the reply as a GetAudioDecoderConfigurationsResponse.
func GetAudioDecoderConfigurations(ctx context.Context, cli *client.Client, request media.GetAudioDecoderConfigurations) (media.GetAudioDecoderConfigurationsResponse, error) {
type Envelope struct {
// Header struct{}
Header *soap.Header `xml:"Header,omitempty"`
Body struct {
GetAudioDecoderConfigurationsResponse media.GetAudioDecoderConfigurationsResponse
Fault *soap.Fault `xml:"Fault,omitempty"`
}
}
var reply Envelope
response, err := cli.CallMethod(request)
if err != nil {
if response == nil {
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
}
// 解析响应内容
if err := sdk.ReadAndParse(ctx, response, &reply, "GetAudioDecoderConfigurationsResponse"); err != nil {
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
// 检查SOAP Fault
if reply.Body.Fault != nil {
// 优先从Subcode中获取错误信息
if reply.Body.Fault.Code.Subcode != nil && len(reply.Body.Fault.Code.Subcode.Value) > 0 {
// 清理命名空间前缀,只保留错误码
err = errors.New(regexp.MustCompile(`.*:`).ReplaceAllString(string(reply.Body.Fault.Code.Subcode.Value), ""))
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
if reply.Body.Fault.Code.Subcode != nil && reply.Body.Fault.Code.Subcode.Subcode != nil && len(reply.Body.Fault.Code.Subcode.Subcode.Value) > 0 {
// 清理命名空间前缀,只保留错误码
err = errors.New(regexp.MustCompile(`.*:`).ReplaceAllString(string(reply.Body.Fault.Code.Subcode.Subcode.Value), ""))
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
// 从Reason中获取错误信息
if len(reply.Body.Fault.Reason.Text) > 0 {
// 优先使用第一个Reason Text(通常是默认语言)
for _, val := range reply.Body.Fault.Reason.Text {
err = errors.New(val.Value)
}
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
}
return reply.Body.GetAudioDecoderConfigurationsResponse, err
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。