1

Some background infos:

I'm currently making a c# windows form app using visual studio 2017 and using the ONVIF .wsdl (OnvifMedia10 and OnvifPTZService).

I have admin access to the target camera.

I got a profile from the mediaClient I created:

var mediaEndPointAddress = new EndpointAddress($"http://{cameraAddress}/onvif/media");
var mediaEncoding = new TextMessageEncodingBindingElement
{
     MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};
var mediaBinding = new HttpTransportBindingElement
{
     AuthenticationScheme = AuthenticationSchemes.Digest
};
var mediaCustomBinding = new CustomBinding(mediaEncoding, mediaBinding);
var mediaPasswordDigestBehavior = new PasswordDigestBehavior(userName, password);
mediaClient = new MediaClient(mediaCustomBinding, mediaEndPointAddress);
mediaClient.Endpoint.EndpointBehaviors.Add(mediaPasswordDigestBehavior);

var profs = mediaClient.GetProfiles();

profile = mediaClient.GetProfile(profs[0].token);

The PasswordDigestBehavior is part of some code I found on this link.

I used the same methodology to get a ptzClient and it's configurations:

...
var ptzEndpointAddress = new EndpointAddress($"http://{cameraAddress}/onvif/ptz");
ptzClient = new PTZClient(commonCustomBinding, ptzEndpointAddress);
ptzClient.Endpoint.EndpointBehaviors.Add(commonPasswordDigestBehavior);
var configs = ptzClient.GetConfigurations();
options = ptzClient.GetConfigurationOptions(configs[0].token);

I then created a PTZSpeed variable to keep the way I want my camera to move:

velocity = new OnvifPTZService.PTZSpeed();
velocity.PanTilt = new OnvifPTZService.Vector2D();
velocity.Zoom = new OnvifPTZService.Vector1D();

My question:

When I want to rotate the target camera, I use some kind of PanLeft() function:

public void PanLeft()
    {
        if(Initialised && CanPanTilt)
        {
            velocity.PanTilt.x = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Min;
            velocity.PanTilt.y = 0;
            ptzClient.ContinuousMoveAsync(profile.token, velocity, "PT5S");
        }
    }

And to stop the camera, I change back the velocity.PanTilt.x and the velocity.PanTilt.y to zero, before sending another async move request.

After a couple of move/stop, I keep loosing connection to my camera...

I wonder if it's because I make too many async requests in the same time or something...

At first, I thought the problem was with my network since I was connecting to the camera through wifi, but I tried connecting it directly with an ethernet cable and it didn't change a thing...

I want to know if my way to do the movement is ok, if there's a better way to do it without having my app breaking and receiving the errors in my title (protocol violation and such)...

I also use the OnvifDeviceManager app to guide myself through the development of this project, to see what I can and cannot do, but it seems that even this app is crashing/loosing connection to the camera after a couple of ptz actions...

spender
  • 117,338
  • 33
  • 229
  • 351
LoukMouk
  • 503
  • 9
  • 29

1 Answers1

0

I think the problem is that there's too many move request sent/received at the same time...

But, I just found out that there's a ptzClient.Stop(profile.token, true, false) function that does exactly what I want...

It stops the given ptzClient from panning/tilting if the first bool is true and it stops the zooming if the second bool is true.

My application seems to last longer when I use this command.

The problem is still there, but it's less frequent!

LoukMouk
  • 503
  • 9
  • 29