My CCTV View in C# allows visualizing screens from 1 to 36. However, if all 36 cameras are connected it becomes slow. Therefore I want to create a function to adjust the resolution and bitrate for each screen.
- Is adjusting resolution and bitrate based on screen division the right choice?
- When setting width and height freely, do I need to manually adjust aspect ratio?
- Are there any issues with the function below that adjusts bitrate? Is a better bitrate control logic available?
private void timer1_Tick(object sender, EventArgs e)
{
int iBitrateValue;
for (int i = 0; i < iViewCount; i++)
{
iBitrateValue = (int)((float)StructCameraList[i].width);
if (iBitrateValue > 4096)
iBitrateValue = 4096;
if (iBitrateValue < 256) //768
iBitrateValue = 256;
if (StructCameraList[i].deviceClient != null)
{
if (StructCameraList[i].mediaClient != null && StructCameraList[i].profile != null &&StructCameraList[i].VideoConfiguration != null)
{
if (Main.util.PingTest(StructCameraList[i].strIP))
{
StructCameraList[i].VideoConfiguration = Main.controller.SetBitrate(StructCameraList[i].mediaClient, StructCameraList[i].profile, StructCameraList[i].VideoConfiguration, iBitrateValue);
}
}
}
}
timer1.Stop();
}
public OnvifMediaServiceReference.VideoEncoderConfiguration SetBitrate(MediaClient mediaclient, Profile profile, OnvifMediaServiceReference.VideoEncoderConfiguration SetConfiguration, int bitrate)
{
if (SetConfiguration != null)
{
if (SetConfiguration.RateControl.BitrateLimit != bitrate)
{
SetConfiguration.RateControl.BitrateLimit = bitrate;
mediaclient.SetVideoEncoderConfiguration(SetConfiguration, true);
}
}
else
{
SetConfiguration = GetVideoConfiguration(mediaclient, profile);
}
return SetConfiguration;
}