Problems changing Stream Settings

We’re developing plug-ins to integrate cameras from our system into Milestone’s VMS. Using the background plug-in we’re fetching the camera objects from our API and programatically adding them into the recording servers. I’ve been able to do that successfully, but still need to manually change the Connection URI and Streaming Mode stream settings in the Management client for the stream to show. I’m trying to get those set when the cameras are being added in the background.

Using the code below, and the GetValue method I can read the properties, and if I GetValue again after calling SetValue, the properties have changed, but they don’t persist and I still have to manually change them in the Management client

camera.DeviceDriverSettingsFolder.DeviceDriverSettings.First().StreamChildItems.First().Properties.SetValue("StreamingMode", "RTP over RTSP (TCP)");
 
camera.Save()
 
// I also tried a couple different save levels too but that didn't make a difference
                //camera.DeviceDriverSettingsFolder.DeviceDriverSettings.First().Save();
//camera.DeviceDriverSettingsFolder.Save();

I’ve also implemented the Configuration API using code from the samples ‘AddUserWithConfigAPI’, ‘ConfigApiBatch’, ‘ConfigAPIImport’ and am running into the same issues. I’m able to access the properties, change them, but they won’t persist. The error I keep getting from the ValidateResult is:

Property definition invalid (Internal error)

I’ve pretty much done exactly what the samples show and can’t find any info on that specific error. Any help with this would be greatly appreciated. Thanks

A quick guess. You might be using display name instead of value when you update the properties.

I did have an issue between using display name vs. key previously but I got that figured out. I’ve debugged every variable throughout the entire process and everything appears to be as it should when calling the SetItem method.

Here is the code from one of the versions I’m using with the Configuration API that gives that error:

// from within the backgroundplugin.cs
_streamController.FillCameraChildItems(camera.Path, "axis-media/media.amp", "RTP over RTSP (TCP)");
 
// from within StreamController.cs inside the ConfigApi folder
var configurationApiClient = ConfigApiClient.CreateClient();
 
// inside the FillCameraChildItems method
foreach (ConfigurationItem folder in configurationApiClient.GetChildItems(cameraItem.Path))
            {
                switch (folder.ItemType)
                {
                    case ItemTypes.DeviceDriverSettingsFolder:
                        foreach (ConfigurationItem driverSettings in configurationApiClient.GetChildItems(folder.Path))
                        {
                            bool anyChanges = false;
                            FillChildren(driverSettings);
                            foreach (ConfigurationItem childItem in driverSettings.Children)
                            {
                                switch (childItem.ItemType)
                                {
                                    case ItemTypes.Stream:
                                        if (childItem.DisplayName == streamName)
                                        {
                                            Util.SetDriverPropertyValue(childItem, "ConnectionURI", connectionUri); // connectionUri == "axis-media/media.amp"
                                            Util.SetDriverPropertyValue(childItem, "StreamingMode", streamingMode); // streamingMode == "RTP over RTSP (TCP)"
                                            anyChanges = true;
                                        }
                                        break;
                                }
                            }
                            if (anyChanges)
                            {
                                ValidateResult validateResult = configurationApiClient.SetItem(driverSettings);
                                if (validateResult.ValidatedOk == false)
                                {
                                    ShowErrorResult(validateResult.ErrorResults);
                                    return false;
                                }
                                return true;
                            }
                        }
                        break;
                }
            }
 
// and the SetDriverPropertyValue method inside Util.cs file
internal static void SetDriverPropertyValue(ConfigurationItem item, String key, String value)
        {
            string matchfor = "/" + key + "/";
            foreach (Property property in item.Properties)
            {
                if (property.Key.Contains(matchfor))
                {
                    property.Value = value;
                    return;
                }
            }
            EnvironmentManager.Instance.Log(true, "PetroCloudBackgroundPlugin::Util", "Unable to set driver property value for: " + key);
        }

Some more information. I logged the driverSettings child properties after setting them and immediately before passing the driverSettings item into the SetItem method and the modified properties are there. here are the Key and Values that are logging for the properties I’m changing:

key is: stream:0.0.0/StreamingMode/44be35b5-74c2-4fe7-adaf-ec6badec8996
value is: RTP over RTSP (TCP)
key is: stream:0.0.0/ConnectionURI/a045f980-8213-4878-8cf1-6cfcaad16cb4
value is: axis-media/media.amp

I also tried passing in the child item itself into the SetItem method since that is also of type ConfigurationItem and still get the same error.

Then, just to see what would happen, I passed the items into the SetItem method without changing any properties at all, even in that case I still get the exact same ‘Property definition invalid (Internal error)’

I’ve been stuck with this issue for a lot longer than I care to admit. Please help!

Which device pack version do you have on your system? We had an issue with the Universal Driver in device pack 9.5 and older, that could cause stream properties not to be updated when changed through the configuration API, so if you have 9.5 or older please upgrade to the latest version (currently 9.7).

If you already have the latest device pack could you please try using the Configuration API Client sample found in the SDK for doing the same updates as you are doing? I just tried on my system and updating the two stream properties you mention worked without any problems (update were also reflected in Management Client and Recording Server).

Thank You! The device pack was the problem. When I downloaded all the software last month it came with Device Pack version 9.5.3.199. I downloaded 9.7 from here: https://www.milestonesys.com/community/business-partner-tools/device-packs/ and it works now.