3

I'm trying to get stream URL using ONVIF, and I'm stucked. Method GetStreamURL always returns Null, but when I'm sniffing traffic in wireshark I get correct responses from camera. Maybe someone had similar problem and can help me? My code looks like this:

HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
EndpointAddress serviceAddress = new EndpointAddress(__url);
TextMessageEncodingBindingElement messegeElement = new TextMessageEncodingBindingElement();

httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
messegeElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10);

CustomBinding bind = new CustomBinding(messegeElement, httpBinding);
ONVIF.onvifMedia.mediaClient mclient = new ONVIF.onvifMedia.mediaClient(bind, serviceAddress);

ONVIF.onvifMedia.StreamSetup streamSetup = new ONVIF.onvifMedia.StreamSetup();
streamSetup.Stream = ONVIF.onvifMedia.StreamType.RTPUnicast;

streamSetup.Transport = new ONVIF.onvifMedia.Transport();
streamSetup.Transport.Protocol = ONVIF.onvifMedia.TransportProtocol.RTSP;

mediaUri uri = new mediaUri();
Profile[] profiles;

log.Debug("Trying to fetch profiles");
profiles = mclient.GetProfiles();

foreach (Profile item in profiles)
{
   uri = mclient.GetStreamUri(streamSetup, item.token);
}
Paweł Wojtal
  • 330
  • 5
  • 11
  • Can you paste the corresponding traffic you found with Wireshark please. – ChrisWard1000 Jun 24 '15 at 08:01
  • How did you get to work directly with the ONVIF Class? I tried to access the api to retrieve an image snapshot from the camera, but didn't get it to work: http://stackoverflow.com/questions/32779467/onvif-api-capture-image-in-c-sharp – Pinte Dani Sep 26 '15 at 14:05

1 Answers1

0

It looks like I helped myself and resolve this issue: code works great, but I need to delete all service references to wsdl files and add them again. I didn't find if there was any update of wsdls last time at ONVIF website, however - it helped me and now above code is working, and I get proper streaming URI.

There is one issue in this code, but in my opinion in depends how standard was implemented on device: some cameras returns streaming URI with HTTP prefix, but they transmit it only via RTSP.

If you want to use similar code don't forget to add login and password field to address.

Paweł Wojtal
  • 330
  • 5
  • 11