Pelco Developer Network (PDN)

Problems getting a live feed from an edge system

Pelco Media Control Not Showing Video

I am using the following code to build an edge system composed of a single camera, and am trying to display it on a very simple windows form application - further functionality will be built in at a later date.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Pelco.SDK;
using P = PelcoMediaControl;
 
namespace Pelco_Camera_Project
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
        }
 
 
        private void buildEdgeSystem()
        {
 
 
            var systems = pmcMediaControl.SystemCollection;
            P.System sys = null;
 
            string systemScheme = "admin:admin@pelcoedgedevices://?alias=EdgeSys";
 
            try
            {
                sys = systems.GetItemByKey(systemScheme);
            }
            catch (Pelco.SDK.Exception)
            {
                sys = systems.Add(systemScheme);
            }
            catch (System.Exception)
            {
                sys = systems.Add(systemScheme);
            }
            try
            {
                sys.CameraCollection.Add("admin:admin@pelcoedgedevices://192.168.0.20:80");
            }
 
            catch { }
            P.Camera camera = sys.CameraCollection.GetCameraByIndex(0);
 
            pmcMediaControl.CreateStream(camera);
 
            P.StreamConfiguration config = pmcMediaControl.CurrentStream.GetConfiguration();
 
            config.videoFormat = P.StreamVideoFormat.StreamFormatMPEG4h264;
            config.deliveryMode = P.StreamDeliveryMode.DeliverUnicast;
            pmcMediaControl.CurrentStream.SetConfiguration(config);
            pmcMediaControl.CurrentStream.Play(1);
            pmcMediaControl.CurrentStream.GotoLive();
        }
 
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            buildEdgeSystem();
            MessageBox.Show("Device Collection Built... Login Complete");
 
        }
    }
}

However, this code runs fine (as in there are no exceptions thrown), but the control does not display any video.

Any help would be appreciated.

Hello!

You can use Wireshark to monitor the network traffic to and from the camera to see where the failure may be. There are several possibilities.

What you should see is a series of HTTP/TCP requests to the camera and responses back. VideoOutput Query, then VideoOutput Connect, and then StreamControl Play. If those aren't reaching the camera, or you aren't receiving a response on the client PC, then that could be the problem.

If they are reaching the camera, and you are receiving a response, there could be errors in the request or the response. If you don't receive an OK 200 response from the camera, that could be the problem.

Finally if all of those requests and responses are working just fine, the next step is to check for UDP traffic incoming to the client PC from the camera itself. If you aren't seeing that, then that could be the problem.

Take a look using Wireshark and see if that helps out.

Hi,

I've checked with wireshark and everything seems to be fine from there, just the media control itself does still not appear to be displaying the stream for some reason.
I have attached a screenshot of the wireshark output for filter host 109.168.0.20 (the camera) to see if you can see anything that I can't.
Wireshark Capture
Thanks for your help so far!

Further information

Further to my previous post:

I have rewritten the above code utilising the MediaControlSample so that it now looks like so:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Pelco.SDK;
using Exception = System.Exception;
using P = PelcoMediaControl;
 
namespace Pelco_Camera_Project
{
    public partial class Form1 : Form
    {
        private const string _cameraAdress = "192.168.0.20:80";
        private const string _cameraUuid = "uuid:fdfafd58-6f1c-43e8-ca97-2460790e1404";
        private const string _user = "admin";
        private const string _password = "admin";
 
        private PelcoMediaControl.System _system;
        private PelcoMediaControl.Camera _camera;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        public void btnLogin_Click_1(object sender,EventArgs e)
        {
            InitStream();
 
            if (ctrl.CurrentStream.mode == P.StreamMode.StreamModePlayback)
            {
                ctrl.CurrentStream.GotoLive();
            }
            ctrl.CurrentStream.Play(1.0f);
        }
 
        public void InitStream()
        {
            if (ctrl.CurrentStream != null)
            {
                return;
            }
            if (_system == null)
            {
                P.SystemCollection systems = ctrl.SystemCollection;
                string systemScheme = string.Format("{0}:{1}@pelcoedgedevices://?alias=EdgeSys", _user, _password);
                try
                {
                    _system = systems.GetItemByKey(systemScheme);
                }
                catch (Exception)
                {
                    _system = systems.Add(systemScheme);
                }
                _system.Login(_user,_password);
                _camera = _system.GetCameraByUUID(_cameraUuid);
            }
            ctrl.CreateStream(_camera);
        }
 
    }
}

This code has the same effect as previously, the media control stays in the same form as prior, looking like this:
Form
As it does before the button is clicked. However, when stepping through the project in the debugger, it looks as though the code is performing its operation correctly, all variables seem to be changing correctly.
Watch 1

Watch 2
However, I have noticed that if the login button is pressed repeatedly, this error is thrown by ctrl.CurrentStream.Play(1.0f);:
Error
Which leads me to believe that it is a Firewall/AV issue, however, this did not resolve when I disabled the firewall and antivirus.

Any additional help that can be provided would be very appreciated.

Hi there -

The wireshark screenshot from the post before last did have some helpful information there; VideoOutput requests to/from the camera appear to be getting an OK 200 response at packet # 28 & 30, then again at 39 & 42). If you right click and do a Follow TCP stream on those exchanges you'll see the XML request to the camera and the response that is coming from the camera. The capture screenshot did cut off before we saw a StreamControl request from 192.168.0.100 to 192.168.0.20 -- did that also occur? If it is also in the trace and you're still not seeing video, try this: set the config.UnicastIP = "192.168.0.100";. I see that you're setting it to deliver via unicast, so specifying the IP might also help out. Again, check the Wireshark for that StreamControl request and response, and next check to see if UDP traffic is arriving from the camera to the client IP @ 192.168.0.100.

If you aren't seeing that UDP traffic, then I agree it's most likely some sort of network problem since the video packets are not arriving at the destination and specified IP address.

Oh - I just also noticed in your previous post, right at the end: that exception says "Play Stream failed: Transport URL has the wrong port: rtp://239.254.10.128:6780". That's a multicast IP address. It's probably trying to stream multicast, even though you specified unicast, because you also don't have a Unicast IP address specified.

Once you have that specified, another thing to check is that the port that is being attempted to use (which can be found in the wireshark trace), isn't blocked.

Finally there is SDK Logging available. With the Pelco SDK is an executable in the Logging folder called Pelco Logging Setup.exe. If you run that, check all of the boxes and specify the folder to place the logs (by default it's the same folder as the logging exe, which is usually fine). Of note is the MPF.log file that is created - that is helpful for troubleshooting streaming issues. If we need to delve further into things, that can help you out too.