Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media structs are prefixed with onvif: #29

Open
wfotiuk opened this issue Oct 12, 2022 · 9 comments
Open

Media structs are prefixed with onvif: #29

wfotiuk opened this issue Oct 12, 2022 · 9 comments

Comments

@wfotiuk
Copy link

wfotiuk commented Oct 12, 2022

So I noticed when trying to use the media queries (sdk/media/*), that some of the structs are prefixed by onvif: for the xml parsing tags (example https://github.com/use-go/onvif/blob/master/xsd/onvif/onvif.go#L361).

image

When getting an actual response from a camera, I noticed the structs did not unmarshal properly because of this prefix. From my understanding, the prefixes should be different according to the ONVIF media spec.

image

Regardless, I have forked the repo and dropped the prefix for my uses, but was curious if you would like a PR and the tests I wrote, or if I am headed in the wrong direction

@wfotiuk
Copy link
Author

wfotiuk commented Oct 20, 2022

After investigating further, I think the issue is that the xml spec defined in Device.go uses onvif in place of tt as a prefix. This causes actual responses from cameras (which use tt according to ONVIF standards, which are followed escept for the onvif prefex). I am happy to fix this and add some tests if you would like

@guo1017138
Copy link

I have the same issue. My camera returns response with tt prefix and the response struct in Golang can't get any value which key has prefix with tt.
image

@wfotiuk
Copy link
Author

wfotiuk commented Dec 2, 2022

Hi @guo1017138, so we ended up forking the repo and I can give you some insights as to what is happening. There is two issues:

  1. The ./Device.go file contains a map of XML prefixes var Xlmns = map[string]string{.... In this map, instead of http://www.onvif.org/ver10/schema being mapped to tt it is mapped to onvif. Changing this helps things but still leaves a problem.
  2. The way go handles xml marshaling and unmarshaling is kind of strange. I found that we had to make different response and request structs, because when marshaling into xml it needed the tt prefix on struct tags (eg .xml:"tt:Type"), but when unmarshaling into a go struct it needed to NOT have the tt tags in order to work (eg xml:"Type"). This is due to a long standing bug in go xml parsing that they tried to fix many years ago but ended up breaking other things so they reverted it.

I hope that helps you!

@guo1017138
Copy link

@wfotiuk Thanks for the nice suggestion/solution. My private change solution is almost the same with you, especially for item 2. I will apply item 1 also to make it more perfect!

@wfotiuk
Copy link
Author

wfotiuk commented Dec 15, 2022

Right on! I am going to be looking into putting up some PRs getting this stuff into the main repo if possible.

@tarancss
Copy link
Contributor

I faced similar problems and also ended up forking the repo. I opened #27 some time ago with some other general fixes.

@Pawan-ky
Copy link

Right on! I am going to be looking into putting up some PRs getting this stuff into the main repo if possible.

@wfotiuk

would love to see you changes, if you have some already can you please share that

@wfotiuk
Copy link
Author

wfotiuk commented Aug 28, 2023 via email

@wfotiuk
Copy link
Author

wfotiuk commented Sep 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants