示例#1
0
        protected void AdjustMpeg4VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.MPEG4 == null)
            {
                profile.VideoEncoderConfiguration.MPEG4 = new Mpeg4Configuration();
            }

            if (options.MPEG4.Mpeg4ProfilesSupported.Contains(Mpeg4Profile.SP))
            {
                profile.VideoEncoderConfiguration.MPEG4.Mpeg4Profile = Mpeg4Profile.SP;
            }
            else
            {
                profile.VideoEncoderConfiguration.MPEG4.Mpeg4Profile = Mpeg4Profile.ASP;
            }

            if (options.MPEG4.ResolutionsAvailable.Length > 0)
            {
                profile.VideoEncoderConfiguration.Resolution = options.MPEG4.ResolutionsAvailable[0];
            }
            if (options.MPEG4.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.MPEG4.GovLength =
                    options.MPEG4.GovLengthRange.Min > 30 ? options.MPEG4.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.MPEG4.GovLength = 30;
            }
        }
        public void ProfilesVideoEncoderConfigurationAndConfigurationOptionsConsistencyTest()
        {
            RunTest(() =>
            {
                Profile[] profiles = GetProfiles();

                Assert(profiles != null,
                       "DUT did not return any profile",
                       "Check if the DUT returned media profiles");


                foreach (Profile profile in profiles)
                {
                    if (profile.VideoEncoderConfiguration != null)
                    {
                        VideoEncoderConfigurationOptions options =
                            GetVideoEncoderConfigurationOptions(profile.VideoEncoderConfiguration.token, profile.token);

                        Assert(options != null,
                               "Video encoder configuration options not returned",
                               "Check if the DUT returned video encoder configuration options");

                        CheckOptions(options, profile.VideoEncoderConfiguration);
                    }
                }
            });
        }
        public void VideoEncoderConfigurationAndOptionsConsistencyTest()
        {
            RunTest(() =>
            {
                // VideoEncoder configurations

                VideoEncoderConfiguration[] configurations = GetVideoEncoderConfigurations();

                Assert(configurations != null,
                       "DUT did not return any configuration",
                       "Check if the DUT returned configurations");

                foreach (VideoEncoderConfiguration configuration in configurations)
                {
                    ValidateConfiguration(configuration);

                    VideoEncoderConfigurationOptions options = GetVideoEncoderConfigurationOptions(configuration.token, null);

                    Assert(options != null,
                           "Video encoder configuration options not returned",
                           "Check if the DUT returned video encoder configuration options");

                    CheckOptions(options, configuration);
                }
            });
        }
示例#4
0
 protected void AdjustJPEGVideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
 {
     if (options.JPEG.ResolutionsAvailable.Length > 0)
     {
         profile.VideoEncoderConfiguration.Resolution = options.JPEG.ResolutionsAvailable[0];
     }
 }
示例#5
0
        protected VideoEncoderConfigurationOptions GetVideoEncoderConfigurationOptions()
        {
            MediaClient mediaClient = MediaClient;
            VideoEncoderConfigurationOptions options = null;

            RunStep(() => { options = mediaClient.GetVideoEncoderConfigurationOptions(null, null); }, "Get Video Encoder Configuration Options");
            DoRequestDelay();
            return(options);
        }
示例#6
0
        public static VideoEncoderConfigurationOptions GetVideoEncoderConfigurationOptions(
            BaseOnvifTest test, MediaClient client, string configuration, string profile)
        {
            VideoEncoderConfigurationOptions options = null;

            RunStep(test, () => { options = client.GetVideoEncoderConfigurationOptions(configuration, profile); },
                    Resources.StepGetVideoEncoderConfigOptions_Title);
            DoRequestDelay(test);
            return(options);
        }
示例#7
0
 public void GetVideoEncoderConfigOptions(string config)
 {
     RunInBackground(new Action(() =>
     {
         VideoEncoderConfigurationOptions options = Client.GetVideoEncoderConfigurationOptions(config, null);
         if (OnVideoEncoderConfigOptionsReceived != null)
         {
             OnVideoEncoderConfigOptionsReceived(options);
         }
     }));
 }
示例#8
0
        protected void AdjustH264VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.H264 == null)
            {
                profile.VideoEncoderConfiguration.H264 = new H264Configuration();
            }

            H264Profile[] profiles = options.H264.H264ProfilesSupported;
            // The parameter of H264Profile is set the highest value that DUT supports as the order is High/Extended/Main/Baseline.
            H264Profile encoderProfile = H264Profile.High;

            // if high not supported...
            if (!profiles.Contains(H264Profile.High))
            {
                if (profiles.Contains(H264Profile.Extended))
                {
                    encoderProfile = H264Profile.Extended;
                }
                else
                {
                    // if Main supported
                    if (profiles.Contains(H264Profile.Main))
                    {
                        encoderProfile = H264Profile.Main;
                    }
                    else
                    {
                        // if Extended not supported.
                        encoderProfile = H264Profile.Baseline;
                    }
                }
            }

            profile.VideoEncoderConfiguration.H264.H264Profile = encoderProfile;

            if (options.H264.ResolutionsAvailable.Length > 0)
            {
                profile.VideoEncoderConfiguration.Resolution = options.H264.ResolutionsAvailable[0];
            }
            if (options.H264.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.H264.GovLength =
                    options.H264.GovLengthRange.Min > 30 ? options.H264.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.H264.GovLength = 30;
            }
        }
            public static Model Create(
                string profToken,
                VideoResolution resolution,
                int maxFrameRate,
                int minFrameRate,
                double frameRate,
                int maxEncodingInterval,
                int minEncodingInterval,
                int encodingInterval,
                int maxQuality,
                int minQuality,
                float quality,
                int maxBitrate,
                int minBitrate,
                double bitrate,
                int maxGovLength,
                int minGovLength,
                int govLength,
                VideoEncoding encoder,
                VideoEncoderConfigurationOptions encoderOptions
                )
            {
                var _this = new Model();

                _this.profToken               = profToken;
                _this.maxFrameRate            = maxFrameRate;
                _this.minFrameRate            = minFrameRate;
                _this.maxEncodingInterval     = maxEncodingInterval;
                _this.minEncodingInterval     = minEncodingInterval;
                _this.maxQuality              = maxQuality;
                _this.minQuality              = minQuality;
                _this.maxBitrate              = maxBitrate;
                _this.minBitrate              = minBitrate;
                _this.maxGovLength            = maxGovLength;
                _this.minGovLength            = minGovLength;
                _this.encoderOptions          = encoderOptions;
                _this.origin.resolution       = resolution;
                _this.origin.frameRate        = frameRate;
                _this.origin.encodingInterval = encodingInterval;
                _this.origin.quality          = quality;
                _this.origin.bitrate          = bitrate;
                _this.origin.govLength        = govLength;
                _this.origin.encoder          = encoder;
                _this.RevertChanges();

                return(_this);
            }
示例#10
0
        protected void AdjustH264VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.H264 == null)
            {
                profile.VideoEncoderConfiguration.H264 = new H264Configuration();
            }

            profile.VideoEncoderConfiguration.H264.H264Profile = H264Profile.Baseline;
            if (options.H264.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.H264.GovLength =
                    options.H264.GovLengthRange.Min > 30 ? options.H264.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.H264.GovLength = 30;
            }
        }
示例#11
0
        protected void AdjustMpeg4VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.MPEG4 == null)
            {
                profile.VideoEncoderConfiguration.MPEG4 = new Mpeg4Configuration();
            }

            profile.VideoEncoderConfiguration.MPEG4.Mpeg4Profile = Mpeg4Profile.SP;
            if (options.MPEG4.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.MPEG4.GovLength =
                    options.MPEG4.GovLengthRange.Min > 30 ? options.MPEG4.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.MPEG4.GovLength = 30;
            }
        }
示例#12
0
        // Annex A.14
        protected Profile SelectVideoProfile(
            VideoEncoding videoEncoding,
            string profileRequirementsDescription,
            TestVideoEncoderConfigurationOptions testVideo,
            ref VideoEncoderConfigurationOptions videoOptions)
        {
            Profile[] profiles = GetProfiles();
            Profile   profile  = null;
            VideoEncoderConfigurationOptions videoOptionsTmp = null;

            RunStep(() =>
            {
                foreach (Profile p in profiles)
                {
                    LogStepEvent(string.Format("Check if {0} profile supports {1} Video encoder configuration",
                                               p.Name, profileRequirementsDescription));
                    if (p.VideoEncoderConfiguration != null)
                    {
                        videoOptionsTmp =
                            Client.GetVideoEncoderConfigurationOptions(p.VideoEncoderConfiguration.token, p.token);

                        DoRequestDelay();

                        if (testVideo(videoOptionsTmp))
                        {
                            profile = p;
                            break;
                        }
                    }
                }
            },
                    string.Format("Select profile with {0} Video encoder configuration", profileRequirementsDescription));

            Assert(profile != null,
                   string.Format("Profile with {0} Video encoder configuration not found", profileRequirementsDescription),
                   "Check if required profile found");

            profile.VideoEncoderConfiguration.Encoding = videoEncoding;
            videoOptions = videoOptionsTmp;

            AdjustVideoEncoderConfiguration(videoEncoding, profile.VideoEncoderConfiguration, videoOptions);

            return(profile);
        }
示例#13
0
        protected void AdjustH264VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.H264 == null)
            {
                profile.VideoEncoderConfiguration.H264 = new H264Configuration();
            }

            H264Profile[] profiles       = options.H264.H264ProfilesSupported;
            H264Profile   encoderProfile = H264Profile.Baseline;

            // if baseline not supported...
            if (!profiles.Contains(H264Profile.Baseline))
            {
                if (profiles.Contains(H264Profile.Main))
                {
                    encoderProfile = H264Profile.Main;
                }
                else
                {
                    // if Main not supported
                    if (profiles.Contains(H264Profile.Extended))
                    {
                        encoderProfile = H264Profile.Extended;
                    }
                    else
                    {
                        // if Extended not supported.
                        encoderProfile = H264Profile.High;
                    }
                }
            }

            profile.VideoEncoderConfiguration.H264.H264Profile = encoderProfile;

            if (options.H264.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.H264.GovLength =
                    options.H264.GovLengthRange.Min > 30 ? options.H264.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.H264.GovLength = 30;
            }
        }
示例#14
0
        void AdjustH264VideoEncoderConfiguration(Profile profile, VideoEncoderConfigurationOptions options)
        {
            if (profile.VideoEncoderConfiguration.H264 == null)
            {
                profile.VideoEncoderConfiguration.H264 = new H264Configuration();
            }

            profile.VideoEncoderConfiguration.H264.H264Profile = H264Profile.Baseline;
            if (options.H264.ResolutionsAvailable.Length > 0)
            {
                profile.VideoEncoderConfiguration.Resolution = options.H264.ResolutionsAvailable[0];
            }

            if (options.H264.GovLengthRange != null)
            {
                profile.VideoEncoderConfiguration.H264.GovLength =
                    options.H264.GovLengthRange.Min > 30 ? options.H264.GovLengthRange.Min : 30;
            }
            else
            {
                profile.VideoEncoderConfiguration.H264.GovLength = 30;
            }
        }
        public void JpegVideoEncoderConfiguration()
        {
            RunTest(() =>
            {
                VideoEncoderConfiguration[] configs = GetVideoEncoderConfigurations();
                string reason;
                Assert(ValidateVideoEncoderConfigs(configs, out reason), reason, Resources.StepValidatingVideoEncoderConfigs_Title);

                VideoEncoderConfigurationOptions options = null;
                VideoEncoderConfiguration config         = GetVideoEncoderConfiguration(configs, VideoEncoding.JPEG, out options);

                config.Encoding   = VideoEncoding.JPEG;
                config.Resolution = options.JPEG.ResolutionsAvailable[0];
                config.Resolution.Height++;//invalid param
                config.Quality = options.QualityRange.Max;
                config.MPEG4   = null;
                config.H264    = null;
                //config.SessionTimeout = "PT600S";//send the same as received
                if (config.RateControl != null)
                {
                    config.RateControl.FrameRateLimit   = options.JPEG.FrameRateRange.Min;
                    config.RateControl.EncodingInterval = options.JPEG.EncodingIntervalRange.Min;
                }

                string details = string.Format("Setting invalid configuration (VideoEncoderConfiguration/Resolution/Height = '{0}')", config.Resolution.Height);
                SetInvalidVideoEncoderConfiguration(config, false, details);

                config.Resolution.Height--;
                SetVideoEncoderConfiguration(config, false);

                VideoEncoderConfiguration newConfig = GetVideoEncoderConfiguration(config.token);
                Assert(
                    EqualConfigurations(config, newConfig, out reason),
                    string.Format(Resources.ErrorVideoEncoderConfigNotEqual_Format, reason),
                    Resources.StepCompareVideoEncoderConfigs_Title);
            });
        }
        public void H264VideoEncoderConfiguration()
        {
            RunTest(() =>
            {
                VideoEncoderConfiguration[] configs = GetVideoEncoderConfigurations();
                string reason;
                Assert(ValidateVideoEncoderConfigs(configs, out reason), reason, Resources.StepValidatingVideoEncoderConfigs_Title);

                VideoEncoderConfigurationOptions options = null;
                VideoEncoderConfiguration config         = GetVideoEncoderConfiguration(configs, VideoEncoding.H264, out options);

                config.Encoding         = VideoEncoding.H264;
                config.Resolution       = options.H264.ResolutionsAvailable[0];
                config.Quality          = options.QualityRange.Max;
                config.H264             = new H264Configuration();
                config.H264.GovLength   = options.H264.GovLengthRange.Max + 1;//invalid param
                config.H264.H264Profile = H264Profile.Baseline;
                config.MPEG4            = null;
                //config.SessionTimeout = "PT600S";////send the same as received
                if (config.RateControl != null)
                {
                    config.RateControl.FrameRateLimit   = options.H264.FrameRateRange.Min;
                    config.RateControl.EncodingInterval = options.H264.EncodingIntervalRange.Min;
                }
                string details = string.Format("Setting invalid configuration (/VideoEncoderConfiguration/H264/GovLength = {0})", config.H264.GovLength);
                SetInvalidVideoEncoderConfiguration(config, false, details);

                config.H264.GovLength = options.H264.GovLengthRange.Max;
                SetVideoEncoderConfiguration(config, false);

                VideoEncoderConfiguration newConfig = GetVideoEncoderConfiguration(config.token);
                Assert(EqualConfigurations(config, newConfig, out reason),
                       string.Format(Resources.ErrorVideoEncoderConfigNotEqual_Format, reason),
                       Resources.StepCompareVideoEncoderConfigs_Title);
            });
        }
        protected void ResolutionTest(
            MediaConfigurationChangeLog changeLog,
            VideoEncoding encodingUnderTest,
            GetResolutionsAvailable getResolutionsAvailable)
        {
            //3.	ONVIF Client invokes GetVideoEncoderConfigurationsRequest message to retrieve
            // video configuration list.
            //4.	Verify the GetVideoEncoderConfigurationsResponse message.

            VideoEncoderConfiguration[] encoderConfigurations = GetVideoEncoderConfigurations();
            CheckVideoEncoderConfigurationsList(encoderConfigurations);
            bool NoProfilesForEncoding = true;

            List <VideoEncoderConfiguration> selectedConfigs = null;
            var WhereRes = encoderConfigurations.Where(C => C.Encoding == encodingUnderTest);

            if (WhereRes != null)
            {
                selectedConfigs = WhereRes.ToList();
            }
            if (selectedConfigs == null || selectedConfigs.Count == 0)
            {
                LogTestEvent("There are no VideoEncoderConfiguration ready for selected encoder type - will try to reconfigure (if this may fail - please pre-configure before making tests)." + Environment.NewLine);
                selectedConfigs = encoderConfigurations.ToList();
            }
            selectedConfigs = MediaTestUtils.SelectConfigurations(selectedConfigs);

            var configGroups = encoderConfigurations.Where(e => !selectedConfigs.Contains(e)).Select(e => new List <VideoEncoderConfiguration>()
            {
                e
            }).ToList();

            configGroups.Insert(0, selectedConfigs);

            //Try to perform steps for selected profiles.
            //In case of fail for all selected profiles try to perform steps for each another profile until first success.
            foreach (var configGroup in configGroups)
            {
                foreach (VideoEncoderConfiguration encoderConfig in configGroup)
                {
                    //5.	Find or create media profile with Video Source Configuration and Video Encoder
                    // Configuration with token VECToken1 and supporting of JPEG encoding, where VECToken1
                    // is first video encoder configuration token from GetVideoEncoderConfigurationsResponse
                    // message (see Annex A.8). If it is not possible skip steps 6-61 and go to the step 62.

                    Profile profile = GetProfileForSpecificConfigurationAndCodec(encoderConfig.token, encodingUnderTest, changeLog);

                    if (profile == null)
                    {
                        continue;
                    }
                    NoProfilesForEncoding = false;

                    //6.	ONVIF Client invokes GetVideoEncoderConfigurationOptionsRequest message
                    // (ProfileToken = “Profile1”, where “Profile1” is profile token from the step 5)
                    // to get video encoder configuration options.
                    //7.	Verify the GetVideoEncoderConfigurationOptionsResponse message from the DUT.

                    VideoEncoderConfigurationOptions options = GetVideoEncoderConfigurationOptions(null, profile.token);

                    Assert(CheckVideoSupport(options, encodingUnderTest),
                           string.Format("{0} encoding is not compatible with current configurations",
                                         GetVideoCodecName(encodingUnderTest)),
                           string.Format("Validate {0} options",
                                         GetVideoCodecName(encodingUnderTest)));

                    VideoResolution highest = null;
                    VideoResolution lowest  = null;
                    VideoResolution median  = null;

                    FindResolutions(getResolutionsAvailable(options), out highest, out lowest, out median);

                    //8.	ONVIF Client invokes SetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1, Resolution = [Width1, Height1], Encoding = JPEG,
                    // where [Width1, Height1] is maximum resolution from the Options.JPEG.ResolutionsAvailable)
                    // to change video encoder configuration.

                    VideoEncoderConfiguration unchanged = Utils.CopyMaker.CreateCopy(encoderConfig);

                    encoderConfig.Encoding   = encodingUnderTest;
                    encoderConfig.Resolution = highest;

                    AdjustVideoEncoderConfiguration(encodingUnderTest, encoderConfig, options);
                    switch (encodingUnderTest)
                    {
                    case VideoEncoding.MPEG4:
                        AdjustMpeg4VideoEncoderConfiguration(encoderConfig, options, false);
                        break;

                    case VideoEncoding.H264:
                        AdjustH264VideoEncoderConfiguration(encoderConfig, options, false);
                        break;
                    }

                    SetVideoEncoderConfiguration(encoderConfig, false);

                    //9.	Verify the SetVideoEncoderConfigurationResponse message from the DUT.

                    changeLog.ModifiedVideoEncoderConfigurations.Add(unchanged);

                    //10.	ONVIF Client invokes GetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1) to get video encoder configuration.
                    //11.	Verify the GetVideoEncoderConfigurationResponse message (ConfigurationToken =
                    // VECToken1, Resolution = [Width1, Height1], Encoding = JPEG) from the DUT. Check
                    // that new setting for Resolution and Encoding was applied.

                    VideoEncoderConfiguration actual = GetVideoEncoderConfiguration(unchanged.token);

                    string reason = string.Empty;
                    // check encoding and resolutions
                    bool ok = ConfigurationValid(actual, encodingUnderTest, highest, out reason);
                    Assert(ok, reason, "Check that the DUT accepted values passed");

                    //12.	ONVIF Client invokes GetStreamUriRequest message (Profile Token, RTP-Unicast,
                    // UDP transport) to retrieve media stream URI for the selected media profile.
                    //13.	DUT sends RTSP URI and parameters defining the lifetime of the URI like
                    // ValidUntilConnect, ValidUntilReboot and Timeout in the GetStreamUriResponse message.
                    StreamSetup streamSetup = new StreamSetup();
                    streamSetup.Transport          = new Transport();
                    streamSetup.Transport.Protocol = TransportProtocol.UDP;
                    streamSetup.Stream             = StreamType.RTPUnicast;

                    MediaUri streamUri = GetStreamUri(streamSetup, profile.token);

                    //14.	ONVIF Client verifies the RTSP media stream URI provided by the DUT.
                    //15.	ONVIF Client invokes RTSP DESCRIBE request.
                    //16.	DUT sends 200 OK message and SDP information.
                    //17.	 ONVIF Client invokes RTSP SETUP request with transport parameter as RTP/UDP.
                    //18.	DUT sends 200 OK message and the media stream information.
                    //19.	ONVIF Client invokes RTSP PLAY request.
                    //20.	DUT sends 200 OK message and starts media streaming.
                    //21.	DUT sends JPEG RTP media stream to ONVIF Client over UDP. Verify that stream
                    // has JPEG encoding and [Width1, Height1] resolution.
                    //22.	DUT sends RTCP sender report to ONVIF Client.
                    //23.	DUT validates the received RTP and RTCP packets, decodes and renders them.
                    //24.	ONVIF Client invokes RTSP TEARDOWN control request at the end of media
                    // streaming to terminate the RTSP session.
                    //25.	DUT sends 200 OK Response and terminates the RTSP Session.
                    //TestTool.Tests.Common.Media.VideoUtils.AdjustVideo(_videoForm, _username, _password, _messageTimeout,
                    //                                                   streamSetup.Transport.Protocol,
                    //                                                   streamSetup.Stream, streamUri, encoderConfig);
                    //ValidateStreamSequence(false, true);
                    DoSequence(encoderConfig, streamUri);

                    //26.	ONVIF Client invokes SetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1, Resolution = [Width1, Height1], Encoding = JPEG,
                    // where [Width2, Height2] is minimum resolution from the Options.JPEG.ResolutionsAvailable) to change video encoder configuration.
                    //27.	Verify the SetVideoEncoderConfigurationResponse message from the DUT.
                    encoderConfig.Encoding   = encodingUnderTest;
                    encoderConfig.Resolution = lowest;

                    AdjustVideoEncoderConfiguration(encodingUnderTest, encoderConfig, options);

                    SetVideoEncoderConfiguration(encoderConfig, false);

                    //28.	ONVIF Client invokes GetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1) to get video encoder configuration.
                    //29.	Verify the GetVideoEncoderConfigurationResponse message (ConfigurationToken =
                    // VECToken1, Resolution = [Width2, Height2], Encoding = JPEG, where [Width2, Height2]) from the DUT. Check that new setting for Resolution and Encoding was applied.
                    actual = GetVideoEncoderConfiguration(unchanged.token);
                    ok     = ConfigurationValid(actual, encodingUnderTest, lowest, out reason);
                    Assert(ok, reason, "Check that the DUT accepted values passed");

                    //30.	ONVIF Client invokes GetStreamUriRequest message (Profile Token, RTP-Unicast,
                    // UDP transport) to retrieve media stream URI for the selected media profile.
                    //31.	DUT sends RTSP URI and parameters defining the lifetime of the URI like ValidUntilConnect, ValidUntilReboot and Timeout in the GetStreamUriResponse message.

                    streamUri = GetStreamUri(streamSetup, profile.token);

                    //32.	ONVIF Client verifies the RTSP media stream URI provided by the DUT.
                    //33.	ONVIF Client invokes RTSP DESCRIBE request.
                    //34.	DUT sends 200 OK message and SDP information.
                    //35.	 ONVIF Client invokes RTSP SETUP request with transport parameter as RTP/UDP.
                    //36.	DUT sends 200 OK message and the media stream information.
                    //37.	ONVIF Client invokes RTSP PLAY request.
                    //38.	DUT sends 200 OK message and starts media streaming.
                    //39.	DUT sends JPEG RTP media stream to ONVIF Client over UDP. Verify that stream has JPEG encoding and [Width2, Height2] resolution.
                    //40.	DUT sends RTCP sender report to ONVIF Client.
                    //41.	DUT validates the received RTP and RTCP packets, decodes and renders them.
                    //42.	ONVIF Client invokes RTSP TEARDOWN control request at the end of media streaming to terminate the RTSP session.
                    //43.	DUT sends 200 OK Response and terminates the RTSP Session.
                    //TestTool.Tests.Common.Media.VideoUtils.AdjustVideo(_videoForm, _username, _password, _messageTimeout,
                    //                                                   streamSetup.Transport.Protocol,
                    //                                                   streamSetup.Stream, streamUri, encoderConfig);
                    //ValidateStreamSequence(false, true);
                    DoSequence(encoderConfig, streamUri);

                    //44.	ONVIF Client invokes SetVideoEncoderConfigurationRequest message (ConfigurationToken = VECToken1, Resolution = [Width1, Height1], Encoding = JPEG, where [Width3, Height3] is middle resolution from the Options.JPEG.ResolutionsAvailable) to change video encoder configuration.
                    //45.	Verify the SetVideoEncoderConfigurationResponse message from the DUT.
                    encoderConfig.Encoding   = encodingUnderTest;
                    encoderConfig.Resolution = median;

                    AdjustVideoEncoderConfiguration(encodingUnderTest, encoderConfig, options);

                    SetVideoEncoderConfiguration(encoderConfig, false);

                    //46.	ONVIF Client invokes GetVideoEncoderConfigurationRequest message (ConfigurationToken = VECToken1) to get video encoder configuration.
                    //47.	Verify the GetVideoEncoderConfigurationResponse message (ConfigurationToken = VECToken1, Resolution = [Width3, Height3], Encoding = JPEG) from the DUT. Check that new setting for Resolution and Encoding was applied.

                    actual = GetVideoEncoderConfiguration(unchanged.token);
                    ok     = ConfigurationValid(actual, encodingUnderTest, median, out reason);
                    Assert(ok, reason, "Check that the DUT accepted values passed");

                    //48.	ONVIF Client invokes GetStreamUriRequest message (Profile Token, RTP-Unicast, UDP transport) to retrieve media stream URI for the selected media profile.
                    //49.	DUT sends RTSP URI and parameters defining the lifetime of the URI like ValidUntilConnect, ValidUntilReboot and Timeout in the GetStreamUriResponse message.
                    streamUri = GetStreamUri(streamSetup, profile.token);

                    //50.	ONVIF Client verifies the RTSP media stream URI provided by the DUT.
                    //51.	ONVIF Client invokes RTSP DESCRIBE request.
                    //52.	DUT sends 200 OK message and SDP information.
                    //53.	 ONVIF Client invokes RTSP SETUP request with transport parameter as RTP/UDP.
                    //54.	DUT sends 200 OK message and the media stream information.
                    //55.	ONVIF Client invokes RTSP PLAY request.
                    //56.	DUT sends 200 OK message and starts media streaming.
                    //57.	DUT sends JPEG RTP media stream to ONVIF Client over UDP. Verify that stream has JPEG encoding and [Width3, Height3] resolution.
                    //58.	DUT sends RTCP sender report to ONVIF Client.
                    //59.	DUT validates the received RTP and RTCP packets, decodes and renders them.
                    //60.	ONVIF Client invokes RTSP TEARDOWN control request at the end of media streaming to terminate the RTSP session.
                    //61.	DUT sends 200 OK Response and terminates the RTSP Session.
                    //TestTool.Tests.Common.Media.VideoUtils.AdjustVideo(_videoForm, _username, _password, _messageTimeout,
                    //                                                   streamSetup.Transport.Protocol,
                    //                                                   streamSetup.Stream, streamUri, encoderConfig);
                    //ValidateStreamSequence(false, true);
                    DoSequence(encoderConfig, streamUri);

                    //62.	Repeat steps 5-62 for the rest Video Encoder configurations supported by the DUT with using different multicast ports and the same multicast addresses for Video Encoder Configurations.
                }

                if (!NoProfilesForEncoding)
                {
                    break;
                }
            }

            if (NoProfilesForEncoding)
            {
                RunStep(() =>
                {
                    throw new Exception(string.Format("No profiles for {0}", GetVideoCodecName(encodingUnderTest)));
                }, string.Format("Check if at least one profile were found ({0} not supported?)", GetVideoCodecName(encodingUnderTest)));
            }
        }
        protected void AllResolutionsTest(MediaConfigurationChangeLog changeLog,
                                          VideoEncoding encodingUnderTest,
                                          GetResolutionsAvailable getResolutionsAvailable)
        {
            //3.	ONVIF Client invokes GetVideoEncoderConfigurationsRequest message to retrieve
            // video configuration list.
            //4.	Verify the GetVideoEncoderConfigurationsResponse message.

            VideoEncoderConfiguration[] encoderConfigurations = GetVideoEncoderConfigurations();
            CheckVideoEncoderConfigurationsList(encoderConfigurations);
            bool NoProfilesForEncoding = true;

            foreach (VideoEncoderConfiguration encoderConfig in encoderConfigurations)
            {
                //5.	Find or create media profile with Video Source Configuration and
                // Video Encoder Configuration with token VECToken1 and supporting of JPEG encoding,
                // where VECToken1 is first video encoder configuration token from
                // GetVideoEncoderConfigurationsResponse message (see Annex A.14). If it is not possible
                // skip steps 6-26 and go to the step 27.
                Profile profile = GetProfileForSpecificConfigurationAndCodec(
                    encoderConfig.token, encodingUnderTest, changeLog);

                if (profile == null)
                {
                    continue;
                }
                if (NoProfilesForEncoding)
                {
                    NoProfilesForEncoding = false;
                }

                //6.	ONVIF Client invokes GetVideoEncoderConfigurationOptionsRequest message
                // (ProfileToken = “Profile1”, where “Profile1” is profile token from the step 5)
                // to get video encoder configuration options.
                //7.	Verify the GetVideoEncoderConfigurationOptionsResponse message from the DUT.
                VideoEncoderConfigurationOptions options = GetVideoEncoderConfigurationOptions(
                    null, profile.token);

                Assert(CheckVideoSupport(options, encodingUnderTest),
                       string.Format("{0} encoding is not compatible with current configuration",
                                     GetVideoCodecName(encodingUnderTest)),
                       string.Format("Validate {0} options", GetVideoCodecName(encodingUnderTest)));

                VideoResolution[] ResolutionsAvailable = getResolutionsAvailable(options);

                VideoEncoderConfiguration unchanged = Utils.CopyMaker.CreateCopy(encoderConfig);
                bool addToChangeLog = true;

                foreach (VideoResolution resolution in ResolutionsAvailable)
                {
                    //8.	ONVIF Client invokes SetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1, Resolution = [Width1, Height1], Encoding = JPEG,
                    // where [Width1, Height1] is the first resolution
                    // from the Options.JPEG.ResolutionsAvailable) to change video encoder configuration.
                    //9.	Verify the SetVideoEncoderConfigurationResponse message from the DUT.

                    encoderConfig.Encoding   = encodingUnderTest;
                    encoderConfig.Resolution = resolution;

                    AdjustVideoEncoderConfiguration(encodingUnderTest, encoderConfig, options);
                    switch (encodingUnderTest)
                    {
                    case VideoEncoding.MPEG4:
                        AdjustMpeg4VideoEncoderConfiguration(encoderConfig, options, false);
                        break;

                    case VideoEncoding.H264:
                        AdjustH264VideoEncoderConfiguration(encoderConfig, options, false);
                        break;
                    }

                    SetVideoEncoderConfiguration(encoderConfig, false);

                    if (addToChangeLog)
                    {
                        changeLog.ModifiedVideoEncoderConfigurations.Add(unchanged);
                        addToChangeLog = false;
                    }


                    //10.	ONVIF Client invokes GetVideoEncoderConfigurationRequest message
                    // (ConfigurationToken = VECToken1) to get video encoder configuration.
                    //11.	Verify the GetVideoEncoderConfigurationResponse message
                    //(ConfigurationToken = VECToken1, Resolution = [Width1, Height1], Encoding = JPEG)
                    // from the DUT. Check that new setting for Resolution and Encoding was applied.

                    VideoEncoderConfiguration actual = GetVideoEncoderConfiguration(unchanged.token);

                    string reason = string.Empty;
                    // check encoding and resolutions
                    bool ok = ConfigurationValid(actual, encodingUnderTest, resolution, out reason);
                    Assert(ok, reason, "Check that the DUT accepted values passed");

                    //12.	ONVIF Client invokes GetStreamUriRequest message (Profile Token, RTP-Unicast,
                    // UDP transport) to retrieve media stream URI for the selected media profile.
                    //13.	DUT sends RTSP URI and parameters defining the lifetime of the URI like
                    // ValidUntilConnect, ValidUntilReboot and Timeout in the GetStreamUriResponse message.

                    StreamSetup streamSetup = new StreamSetup();
                    streamSetup.Transport          = new Transport();
                    streamSetup.Transport.Protocol = TransportProtocol.UDP;
                    streamSetup.Stream             = StreamType.RTPUnicast;

                    MediaUri streamUri = GetStreamUri(streamSetup, profile.token);

                    //14.	ONVIF Client verifies the RTSP media stream URI provided by the DUT.
                    //15.	ONVIF Client invokes RTSP DESCRIBE request.
                    //16.	DUT sends 200 OK message and SDP information.
                    //17.	 ONVIF Client invokes RTSP SETUP request with transport parameter as RTP/UDP.
                    //18.	DUT sends 200 OK message and the media stream information.
                    //19.	ONVIF Client invokes RTSP PLAY request.
                    //20.	DUT sends 200 OK message and starts media streaming.
                    //21.	DUT sends JPEG RTP media stream to ONVIF Client over UDP. Verify that stream has JPEG encoding and [Width1, Height1] resolution.
                    //22.	DUT sends RTCP sender report to ONVIF Client.
                    //23.	DUT validates the received RTP and RTCP packets, decodes and renders them.
                    //24.	ONVIF Client invokes RTSP TEARDOWN control request at the end of media streaming to terminate the RTSP session.
                    //25.	DUT sends 200 OK Response and terminates the RTSP Session.
                    //TestTool.Tests.Common.Media.VideoUtils.AdjustVideo(_videoForm, _username,
                    //    _password, _messageTimeout, streamSetup.Transport.Protocol, streamSetup.Stream,
                    //    streamUri, encoderConfig);
                    //ValidateStreamSequence(false, true);
                    DoSequence(encoderConfig, streamUri);
                }
            }

            if (NoProfilesForEncoding)
            {
                RunStep(() =>
                {
                    throw new Exception(string.Format("No profiles for {0}", GetVideoCodecName(encodingUnderTest)));
                }, string.Format("Check if at least one profile were found ({0} not supported?)", GetVideoCodecName(encodingUnderTest)));
            }
        }
示例#19
0
        void SetResourcesUsageToMimimal(MediaConfigurationChangeLog changeLog, IEnumerable <Profile> profiles)
        {
            List <VideoEncoderConfiguration> modifiedConfigurations = new List <VideoEncoderConfiguration>();

            // set resolutions and FPS to minimal values
            foreach (Profile profile in profiles)
            {
                // actually we change configurations
                // so we must track modified configurations and don't apply changes more than once
                VideoEncoderConfiguration AlreadyModifiedVec = null;
                AlreadyModifiedVec = modifiedConfigurations.Find(vec => null != profile.VideoEncoderConfiguration && vec.token == profile.VideoEncoderConfiguration.token);
                if (AlreadyModifiedVec != null)
                {
                    profile.VideoEncoderConfiguration = AlreadyModifiedVec;
                    continue;
                }

                if (null != profile.VideoEncoderConfiguration)
                {
                    VideoEncoderConfigurationOptions options = GetVideoEncoderConfigurationOptions(profile.VideoEncoderConfiguration.token, null);
    #if true
                    if (OptimizeVEC(changeLog, profile.VideoEncoderConfiguration, options))
                    {
                        //SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false);
                        SetVideoEncoderConfiguration(Utils.CopyMaker.CreateCopy(profile.VideoEncoderConfiguration), false);
                        modifiedConfigurations.Add(profile.VideoEncoderConfiguration);
                    }
    #else
                    VideoResolution[] resolutionsAvailable = null;
                    IntRange          fpsRange             = null;
                    switch (profile.VideoEncoderConfiguration.Encoding)
                    {
                    case VideoEncoding.JPEG:
                        if (options.JPEG != null)
                        {
                            resolutionsAvailable = options.JPEG.ResolutionsAvailable;
                            fpsRange             = options.JPEG.FrameRateRange;
                        }
                        break;

                    case VideoEncoding.H264:
                        if (options.H264 != null)
                        {
                            resolutionsAvailable = options.H264.ResolutionsAvailable;
                            fpsRange             = options.H264.FrameRateRange;
                        }
                        break;

                    case VideoEncoding.MPEG4:
                        if (options.MPEG4 != null)
                        {
                            resolutionsAvailable = options.MPEG4.ResolutionsAvailable;
                            fpsRange             = options.MPEG4.FrameRateRange;
                        }
                        break;
                    }

                    VideoResolution minimalResolution = null;
                    bool            updateResolution  = false;
                    if (resolutionsAvailable != null)
                    {
                        VideoResolution currentResolution = profile.VideoEncoderConfiguration.Resolution;
                        foreach (VideoResolution resolution in resolutionsAvailable)
                        {
                            if (minimalResolution == null)
                            {
                                minimalResolution = resolution;
                            }
                            else
                            {
                                if (minimalResolution.Height * minimalResolution.Width > resolution.Height * resolution.Width)
                                {
                                    minimalResolution = resolution;
                                }
                            }
                        }
                        updateResolution = (minimalResolution.Width * minimalResolution.Height < currentResolution.Width * currentResolution.Height);
                    }

                    bool updateFps = false;
                    if (fpsRange != null)
                    {
                        if (profile.VideoEncoderConfiguration.RateControl != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.FrameRateLimit > fpsRange.Min)
                            {
                                updateFps = true;
                            }
                        }
                        else
                        {
                            updateFps = true;
                        }
                    }

                    if (updateResolution || updateFps)
                    {
                        VideoEncoderConfiguration backup = Utils.CopyMaker.CreateCopy(profile.VideoEncoderConfiguration);
                        changeLog.TrackModifiedConfiguration(backup);
                        if (updateResolution)
                        {
                            profile.VideoEncoderConfiguration.Resolution = minimalResolution;
                        }
                        if (updateFps)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl == null)
                            {
                                profile.VideoEncoderConfiguration.RateControl = new VideoRateControl();
                            }
                            profile.VideoEncoderConfiguration.RateControl.FrameRateLimit = fpsRange.Min;
                        }
                        SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false);
                        modifiedConfigurations.Add(profile.VideoEncoderConfiguration);
                    }
    #endif
                }
            }
        }
示例#20
0
        public void NvtStartAndStopMulticastStreamingJpegIPv4()
        {
            Profile profile = null;

            RunTest(() =>
            {
                VideoEncoderConfigurationOptions videoOptions = null;
                profile = SelectVideoProfile(
                    VideoEncoding.JPEG, "JPEG",
                    (options) => { return(options.JPEG != null); },
                    ref videoOptions);

                SetMulticastSettings(profile, true, false, IPType.IPv4);

                SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false, true);

                bool needResetAudio = false;
                RunStep(
                    () =>
                {
                    needResetAudio = (profile.AudioEncoderConfiguration != null);
                    if (needResetAudio)
                    {
                        LogStepEvent("AudioEncoderConfiguration exists");
                    }
                    else
                    {
                        LogStepEvent("No AudioEncoderConfiguration");
                    }
                },
                    "Check AudioEncoderConfiguration");

                if (needResetAudio)
                {
                    profile.AudioEncoderConfiguration.Multicast.Address.Type        = IPType.IPv4;
                    profile.AudioEncoderConfiguration.Multicast.Address.IPv4Address = "0.0.0.0";
                    SetAudioEncoderConfiguration(profile.AudioEncoderConfiguration, false, true);
                }

                bool needResetMeta = false;
                RunStep(
                    () =>
                {
                    needResetMeta = (profile.MetadataConfiguration != null);
                    if (needResetMeta)
                    {
                        LogStepEvent("MetadataConfiguration exists");
                    }
                    else
                    {
                        LogStepEvent("No MetadataConfiguration");
                    }
                },
                    "Check MetadataConfiguration");

                if (needResetMeta)
                {
                    profile.MetadataConfiguration.Multicast.Address.Type        = IPType.IPv4;
                    profile.MetadataConfiguration.Multicast.Address.IPv4Address = "0.0.0.0";
                    SetMetadataConfiguration(profile.MetadataConfiguration, false);
                }

                VideoUtils.AdjustVideo(
                    _videoForm, null, null, _messageTimeout, TransportProtocol.UDP,
                    StreamType.RTPMulticast, null, profile.VideoEncoderConfiguration);

                RunStep(
                    () => { Client.StartMulticastStreaming(profile.token); },
                    "StartMulticastStreaming");

                DoRequestDelay();

                _videoForm.VideoFPS              = profile.VideoEncoderConfiguration.RateControl.FrameRateLimit;
                _videoForm.MulticastAddress      = profile.VideoEncoderConfiguration.Multicast.Address.IPv4Address;
                _videoForm.MulticastRtpPortVideo = profile.VideoEncoderConfiguration.Multicast.Port;
                _videoForm.MulticastTTL          = profile.VideoEncoderConfiguration.Multicast.TTL;
                _videoForm.VideoCodecName        = "JPEG";
                _videoForm.EventSink             = this;
                _videoForm.OpenWindow(false);
                VideoIsOpened = true;

                Assert(_operator.GetYesNoAnswer("Do you observe video?"),
                       "Operator does not observe video",
                       "Video quality check (manual)");

                VideoIsOpened = false;
                _videoForm.CloseWindow();
                _videoForm.EventSink = null;
            },
                    () =>
            {
                if (profile != null)
                {
                    RunStep(
                        () => { Client.StopMulticastStreaming(profile.token); },
                        "StopMulticastStreaming");

                    DoRequestDelay();
                }
                if (VideoIsOpened)
                {
                    VideoIsOpened = false;
                    _videoForm.CloseWindow();
                    _videoForm.EventSink = null;
                }
            }
                    );
        }
示例#21
0
        MediaUri GetAudioVideoMediaUri(TestVideoEncoderConfigurationOptions videoTest,
                                       string videoCodec,
                                       VideoEncoding encoding,
                                       TestAudioEncoderConfigurationOptions audioTest,
                                       string audioCodec,
                                       AudioEncoding audioEncoding,
                                       StreamType streamType,
                                       TransportProtocol protocol,
                                       IPType?multicastAddressType)
        {
            Profile[] profiles = GetProfiles();

            Profile profile = null;
            VideoEncoderConfigurationOptions options = null;
            int bitrate    = 0;
            int sampleRate = 0;

            RunStep(() =>
            {
                foreach (Profile p in profiles)
                {
                    LogStepEvent(string.Format("Check if {0} profile satisfies current needs", p.Name));

                    if (p.VideoEncoderConfiguration != null)
                    {
                        LogStepEvent("GetVideoEncoderConfigurationOptions");
                        VideoEncoderConfigurationOptions videoOptions =
                            Client.GetVideoEncoderConfigurationOptions(p.VideoEncoderConfiguration.token, p.token);
                        DoRequestDelay();

                        if (videoTest(videoOptions))
                        {
                            // Video configuration OK  - configure Audio, if needed.
                            options = videoOptions;

                            if (p.AudioEncoderConfiguration != null && p.AudioSourceConfiguration != null)
                            {
                                LogStepEvent("GetAudioEncoderConfigurationOptions");
                                AudioEncoderConfigurationOptions audioOptions =
                                    Client.GetAudioEncoderConfigurationOptions(p.AudioEncoderConfiguration.token,
                                                                               p.token);

                                DoRequestDelay();

                                if (audioTest(audioOptions))
                                {
                                    profile = p;
                                    LogStepEvent("OK - profile found");

                                    // find nearest bitrate and samplerate
                                    bitrate = FindNearestAudioBitrate(p.AudioEncoderConfiguration.Bitrate, audioEncoding,
                                                                      audioOptions);
                                    sampleRate = FindNearestAudioSamplerate(p.AudioEncoderConfiguration.SampleRate,
                                                                            audioEncoding, audioOptions);
                                    break;
                                }
                            }
                            else
                            {
                                LogStepEvent("GetAudioEncoderConfigurations");
                                AudioEncoderConfiguration[] audioEncoderConfigurations =
                                    Client.GetAudioEncoderConfigurations();

                                DoRequestDelay();

                                bool audioEncoderConfigurationFound = false;

                                foreach (AudioEncoderConfiguration configuration in audioEncoderConfigurations)
                                {
                                    LogStepEvent("GetAudioEncoderConfigurationOptions");
                                    AudioEncoderConfigurationOptions audioOptions =
                                        Client.GetAudioEncoderConfigurationOptions(configuration.token, p.token);

                                    DoRequestDelay();

                                    if (audioTest(audioOptions))
                                    {
                                        if (p.AudioSourceConfiguration == null)
                                        {
                                            AudioSourceConfiguration[] audioSourceConfigurations = Client.GetAudioSourceConfigurations();

                                            DoRequestDelay();

                                            if (audioSourceConfigurations.Length > 0)
                                            {
                                                LogStepEvent("AddAudioSourceConfiguration");
                                                Client.AddAudioSourceConfiguration(p.token, audioSourceConfigurations[0].token);
                                                DoRequestDelay();
                                            }
                                            else
                                            {
                                                throw new DutPropertiesException("Audio Source Configurations not found");
                                            }
                                        }

                                        bitrate = FindNearestAudioBitrate(configuration.Bitrate, audioEncoding,
                                                                          audioOptions);
                                        sampleRate = FindNearestAudioSamplerate(configuration.SampleRate, audioEncoding,
                                                                                audioOptions);

                                        LogStepEvent("AddAudioEncoderConfiguration");
                                        Client.AddAudioEncoderConfiguration(p.token, configuration.token);
                                        DoRequestDelay();

                                        p.AudioEncoderConfiguration = configuration;

                                        profile = p;

                                        LogStepEvent(string.Format("Add Audio configuration to the {0} profile - OK", profile.Name));

                                        audioEncoderConfigurationFound = true;
                                        break;
                                    }
                                }

                                if (!audioEncoderConfigurationFound)
                                {
                                    throw new DutPropertiesException("Audio Encoder Configuration with required properties not found");
                                }
                            }
                        }
                    }
                }

                if (profile == null)
                {
                    throw new DutPropertiesException("Respective profile cannot be found or created");
                }
            },
                    string.Format("Select or create profile with {0} Video encoder configuration and {1} Audio encoder configuration",
                                  videoCodec,
                                  audioCodec));

            // profile found

            profile.VideoEncoderConfiguration.Encoding = encoding;

            // support for extensions (bitrate limits)

            // fix for Panasonic
            if (encoding == VideoEncoding.JPEG)
            {
                profile.VideoEncoderConfiguration.MPEG4 = null;
                profile.VideoEncoderConfiguration.H264  = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.JPEG != null)
                    {
                        if (options.Extension.JPEG.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.JPEG.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.JPEG.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.JPEG.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.JPEG.BitrateRange.Max;
                            }
                        }
                    }
                }
            }
            if (encoding == VideoEncoding.MPEG4)
            {
                profile.VideoEncoderConfiguration.H264 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.MPEG4 != null)
                    {
                        if (options.Extension.MPEG4.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.MPEG4.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.MPEG4.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.MPEG4.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.MPEG4.BitrateRange.Max;
                            }
                        }
                    }
                }
            }
            if (encoding == VideoEncoding.H264)
            {
                profile.VideoEncoderConfiguration.MPEG4 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.H264 != null)
                    {
                        if (options.Extension.H264.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.H264.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.H264.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.H264.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.H264.BitrateRange.Max;
                            }
                        }
                    }
                }
            }

            if (multicastAddressType.HasValue)
            {
                SetMulticastSettings(profile, true, true, multicastAddressType.Value);
            }

            SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false, multicastAddressType.HasValue);

            profile.AudioEncoderConfiguration.Encoding   = audioEncoding;
            profile.AudioEncoderConfiguration.Bitrate    = bitrate;
            profile.AudioEncoderConfiguration.SampleRate = sampleRate;

            SetAudioEncoderConfiguration(profile.AudioEncoderConfiguration, false, multicastAddressType.HasValue);

            StreamSetup streamSetup = new StreamSetup();

            streamSetup.Transport          = new Transport();
            streamSetup.Transport.Protocol = protocol;
            streamSetup.Stream             = streamType;

            UsedProfileToken = profile.token;
            MediaUri streamUri = GetStreamUri(streamSetup, profile.token);

            AdjustVideo(protocol, streamType, streamUri, profile.VideoEncoderConfiguration);

            return(streamUri);
        }
示例#22
0
        // Annex A.15
        protected Profile SelectVideoAudioProfile(
            VideoEncoding videoEncoding,
            string videoCodec,
            TestVideoEncoderConfigurationOptions testVideo,
            AudioEncoding audioEncoding,
            string audioCodec,
            TestAudioEncoderConfigurationOptions testAudio,
            ref VideoEncoderConfigurationOptions videoOptions,
            ref AudioEncoderConfigurationOptions audioOptions)
        {
            Profile[] profiles = GetProfiles();
            Profile   profile  = null;
            VideoEncoderConfigurationOptions videoOptionsTmp = null;
            AudioEncoderConfigurationOptions audioOptionsTmp = null;


            RunStep(() =>
            {
                foreach (Profile p in profiles)
                {
                    LogStepEvent(string.Format("Check if {0} profile satisfies current needs", p.Name));

                    if (p.VideoEncoderConfiguration != null)
                    {
                        LogStepEvent("GetVideoEncoderConfigurationOptions");
                        videoOptionsTmp =
                            Client.GetVideoEncoderConfigurationOptions(p.VideoEncoderConfiguration.token, p.token);

                        DoRequestDelay();

                        if (testVideo(videoOptionsTmp))
                        {
                            // Video configuration OK  - configure Audio, if needed.

                            if (p.AudioEncoderConfiguration != null && p.AudioSourceConfiguration != null)
                            {
                                LogStepEvent("GetAudioEncoderConfigurationOptions");
                                audioOptionsTmp =
                                    Client.GetAudioEncoderConfigurationOptions(p.AudioEncoderConfiguration.token, p.token);

                                DoRequestDelay();

                                if (testAudio(audioOptionsTmp))
                                {
                                    profile = p;
                                    LogStepEvent("OK - profile found");
                                    break;
                                }
                            }
                            else
                            {
                                LogStepEvent("GetAudioEncoderConfigurations");
                                AudioEncoderConfiguration[] audioEncoderConfigurations =
                                    Client.GetAudioEncoderConfigurations();

                                DoRequestDelay();

                                bool audioEncoderConfigurationFound = false;

                                foreach (AudioEncoderConfiguration configuration in audioEncoderConfigurations)
                                {
                                    LogStepEvent("GetAudioEncoderConfigurationOptions");
                                    audioOptionsTmp =
                                        Client.GetAudioEncoderConfigurationOptions(configuration.token, p.token);

                                    DoRequestDelay();

                                    if (testAudio(audioOptionsTmp))
                                    {
                                        if (p.AudioSourceConfiguration == null)
                                        {
                                            AudioSourceConfiguration[] audioSourceConfigurations = Client.GetAudioSourceConfigurations();

                                            DoRequestDelay();

                                            if (audioSourceConfigurations.Length > 0)
                                            {
                                                LogStepEvent("AddAudioSourceConfiguration");
                                                Client.AddAudioSourceConfiguration(p.token, audioSourceConfigurations[0].token);
                                                DoRequestDelay();
                                            }
                                            else
                                            {
                                                throw new DutPropertiesException("Audio Source Configurations not found");
                                            }
                                        }

                                        LogStepEvent("AddAudioEncoderConfiguration");
                                        Client.AddAudioEncoderConfiguration(p.token, configuration.token);
                                        DoRequestDelay();

                                        p.AudioEncoderConfiguration = configuration;

                                        profile = p;

                                        LogStepEvent(string.Format("Add Audio configuration to the {0} profile - OK", profile.Name));

                                        audioEncoderConfigurationFound = true;
                                        break;
                                    }
                                }

                                if (!audioEncoderConfigurationFound)
                                {
                                    throw new DutPropertiesException("Audio Encoder Configuration with required properties not found");
                                }
                            }
                        }
                    }
                }

                if (profile == null)
                {
                    throw new DutPropertiesException("Respective profile cannot be found or created");
                }
            },
                    string.Format("Select or create profile with {0} Video encoder configuration and {1} Audio encoder configuration",
                                  videoCodec, audioCodec));

            profile.VideoEncoderConfiguration.Encoding = videoEncoding;

            // find nearest bitrate and samplerate
            profile.AudioEncoderConfiguration.Bitrate =
                FindNearestAudioBitrate(profile.AudioEncoderConfiguration.Bitrate,
                                        audioEncoding, audioOptions);
            profile.AudioEncoderConfiguration.SampleRate =
                FindNearestAudioSamplerate(profile.AudioEncoderConfiguration.SampleRate,
                                           audioEncoding, audioOptions);

            videoOptions = videoOptionsTmp;
            audioOptions = audioOptionsTmp;

            AdjustVideoEncoderConfiguration(videoEncoding, profile.VideoEncoderConfiguration, videoOptions);

            return(profile);
        }
示例#23
0
        protected void AdjustVideoEncoderConfiguration(
            VideoEncoding encoding,
            VideoEncoderConfiguration config,
            VideoEncoderConfigurationOptions options)
        {
            Action <IntRange, VideoRateControl> adjustBitrateLimit = (IntRange bitrateRange, VideoRateControl rateControl) =>
            {
                if (bitrateRange != null)
                {
                    if (rateControl.BitrateLimit < bitrateRange.Min)
                    {
                        rateControl.BitrateLimit = bitrateRange.Min;
                    }
                    if (rateControl.BitrateLimit > bitrateRange.Max)
                    {
                        rateControl.BitrateLimit = bitrateRange.Max;
                    }
                }
            };

            // fix for Panasonic
            if (encoding == VideoEncoding.JPEG)
            {
                config.MPEG4 = null;
                config.H264  = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.JPEG != null)
                    {
                        adjustBitrateLimit(options.Extension.JPEG.BitrateRange, config.RateControl);
                    }
                }
            }
            if (encoding == VideoEncoding.MPEG4)
            {
                config.H264 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.MPEG4 != null)
                    {
                        adjustBitrateLimit(options.Extension.MPEG4.BitrateRange, config.RateControl);
                    }
                }
            }
            if (encoding == VideoEncoding.H264)
            {
                config.MPEG4 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.H264 != null)
                    {
                        adjustBitrateLimit(options.Extension.H264.BitrateRange, config.RateControl);
                    }
                }
            }
        }
示例#24
0
        public void NvtStartAndStopMulticastStreamingJpegIPv4()
        {
            Profile profile = null;

            RunTest(() =>
            {
                VideoEncoderConfigurationOptions videoOptions = null;
                profile = SelectVideoProfile(
                    VideoEncoding.JPEG, "JPEG",
                    (options) => { return(options.JPEG != null); },
                    ref videoOptions);

                SetMulticastSettings(profile, true, false, IPType.IPv4);

                SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false, true);

                VideoUtils.AdjustVideo(
                    _videoForm, null, null, _messageTimeout, TransportProtocol.UDP,
                    StreamType.RTPMulticast, null, profile.VideoEncoderConfiguration);

                RunStep(
                    () => { Client.StartMulticastStreaming(profile.token); },
                    "StartMulticastStreaming");

                DoRequestDelay();

                int fps = 1;
                if (profile.VideoEncoderConfiguration.RateControl != null)
                {
                    fps = profile.VideoEncoderConfiguration.RateControl.FrameRateLimit;
                }
                else
                {
                    if (videoOptions.JPEG.FrameRateRange != null)
                    {
                        fps = videoOptions.JPEG.FrameRateRange.Min;
                    }
                }
                _videoForm.VideoFPS              = fps;
                _videoForm.MulticastAddress      = profile.VideoEncoderConfiguration.Multicast.Address.IPv4Address;
                _videoForm.MulticastRtpPortVideo = profile.VideoEncoderConfiguration.Multicast.Port;
                _videoForm.MulticastTTL          = profile.VideoEncoderConfiguration.Multicast.TTL;
                _videoForm.VideoCodecName        = "JPEG";
                _videoForm.EventSink             = this;
                _videoForm.OpenWindow(false);
                VideoIsOpened = true;

                Sleep(_operationDelay);

                VideoIsOpened = false;
                _videoForm.CloseWindow();
                _videoForm.EventSink = null;
            },
                    () =>
            {
                if (profile != null)
                {
                    RunStep(
                        () => { Client.StopMulticastStreaming(profile.token); },
                        "StopMulticastStreaming");

                    DoRequestDelay();
                }
                if (VideoIsOpened)
                {
                    VideoIsOpened = false;
                    _videoForm.CloseWindow();
                    _videoForm.EventSink = null;
                }
            }
                    );
        }
示例#25
0
 /// <summary>
 /// Handles video encoder configuration options received event
 /// </summary>
 /// <param name="options">Received profiles</param>
 protected void OnVideoEncoderConfigOptionsReceived(VideoEncoderConfigurationOptions options)
 {
     View.SetVideoEncoderConfigOptions(options);
 }
示例#26
0
        public void H264VideoEncoderConfiguration()
        {
            RunTest(() =>
            {
                VideoEncoderConfiguration[] configs = GetVideoEncoderConfigurations();
                string reason;
                Assert(ValidateVideoEncoderConfigs(configs, out reason), reason, Resources.StepValidatingVideoEncoderConfigs_Title);

                VideoEncoderConfigurationOptions options = null;
                VideoEncoderConfiguration config         = GetVideoEncoderConfiguration(configs, VideoEncoding.H264, out options);

                config.Encoding         = VideoEncoding.H264;
                config.Resolution       = options.H264.ResolutionsAvailable[0];
                config.Quality          = options.QualityRange.Max;
                config.H264             = new H264Configuration();
                config.H264.GovLength   = options.H264.GovLengthRange.Max + 1;//invalid param
                config.H264.H264Profile = H264Profile.Baseline;
                config.MPEG4            = null;
                if (config.RateControl != null)
                {
                    config.RateControl.FrameRateLimit   = options.H264.FrameRateRange.Min;
                    config.RateControl.EncodingInterval = options.H264.EncodingIntervalRange.Min;
                }
                string details = string.Format("Setting invalid configuration (/VideoEncoderConfiguration/H264/GovLength = {0})", config.H264.GovLength);
                SetInvalidVideoEncoderConfiguration(config, false, details);

                VideoResolution highest = null;
                VideoResolution lowest  = null;
                VideoResolution median  = null;

                FindResolutions(options.H264.ResolutionsAvailable, out highest, out lowest, out median);

                Func <List <H264Profile>, H264Profile> firstSupported =
                    new Func <List <H264Profile>, H264Profile>(
                        (list) =>
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (options.H264.H264ProfilesSupported.Contains(list[i]))
                        {
                            return(list[i]);
                        }
                    }
                    return(options.H264.H264ProfilesSupported[0]);
                });

                List <H264Profile> profiles = new List <H264Profile>();
                profiles.Add(H264Profile.Baseline);
                profiles.Add(H264Profile.Main);
                profiles.Add(H264Profile.Extended);
                profiles.Add(H264Profile.High);

                H264Profile profile = firstSupported(profiles);


                config.H264.H264Profile         = profile;
                config.RateControl              = new VideoRateControl();
                config.RateControl.BitrateLimit = 64000;

                // max

                config.Resolution = highest;
                config.Quality    = options.QualityRange.Max;
                config.RateControl.FrameRateLimit   = options.H264.FrameRateRange.Max;
                config.RateControl.EncodingInterval = options.H264.EncodingIntervalRange.Min;
                config.H264.GovLength = options.H264.GovLengthRange.Min;

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use max values)");
                VideoEncoderConfiguration newConfig = GetVideoEncoderConfiguration(config.token);

                bool ok = ConfigurationValid(newConfig, VideoEncoding.H264, highest, out reason);

                Action checkProfile =
                    new Action(
                        () =>
                {
                    if (newConfig.H264.H264Profile != config.H264.H264Profile)
                    {
                        ok           = false;
                        string error = string.Format("H264Profile is incorrect. Expected: {0}, actual: {1} ",
                                                     config.H264.H264Profile, newConfig.H264.H264Profile);
                        if (string.IsNullOrEmpty(reason))
                        {
                            reason = error;
                        }
                        else
                        {
                            reason += System.Environment.NewLine;
                            reason += error;
                        }
                    }
                });

                checkProfile();
                Assert(ok, reason, "Check that the DUT accepted values passed");

                // Min

                profiles.Clear();
                profiles.Add(H264Profile.Main);
                profiles.Add(H264Profile.Extended);
                profiles.Add(H264Profile.High);
                profiles.Add(H264Profile.Baseline);

                profile = firstSupported(profiles);


                config.Resolution = lowest;
                config.Quality    = options.QualityRange.Min;
                config.RateControl.FrameRateLimit   = options.H264.FrameRateRange.Min;
                config.RateControl.EncodingInterval = options.H264.EncodingIntervalRange.Max;
                config.H264.GovLength   = options.H264.GovLengthRange.Max;
                config.H264.H264Profile = profile;

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use min values)");
                newConfig = GetVideoEncoderConfiguration(config.token);

                ok = ConfigurationValid(newConfig, VideoEncoding.H264, lowest, out reason);
                checkProfile();
                Assert(ok, reason, "Check that the DUT accepted values passed");

                // Average


                profiles.Clear();
                profiles.Add(H264Profile.Extended);
                profiles.Add(H264Profile.High);
                profiles.Add(H264Profile.Baseline);
                profiles.Add(H264Profile.Main);

                profile = firstSupported(profiles);

                config.Resolution = median;
                config.Quality    = options.QualityRange.Average();
                config.RateControl.FrameRateLimit   = options.H264.FrameRateRange.Average();
                config.RateControl.EncodingInterval = options.H264.EncodingIntervalRange.Average();
                config.H264.GovLength   = options.H264.GovLengthRange.Average();
                config.H264.H264Profile = profile;

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use average values)");
                newConfig = GetVideoEncoderConfiguration(config.token);

                ok = ConfigurationValid(newConfig, VideoEncoding.H264, median, out reason);
                checkProfile();
                Assert(ok, reason, "Check that the DUT accepted values passed");
            });
        }
 public Model(
     string profToken, int maxFrameRate, int minFrameRate, int maxEncodingInterval, int minEncodingInterval, int maxQuality, int minQuality, int maxBitrate, int minBitrate, int maxGovLength, int minGovLength, VideoEncoderConfigurationOptions encoderOptions
     )
 {
     this.profToken           = profToken;
     this.maxFrameRate        = maxFrameRate;
     this.minFrameRate        = minFrameRate;
     this.maxEncodingInterval = maxEncodingInterval;
     this.minEncodingInterval = minEncodingInterval;
     this.maxQuality          = maxQuality;
     this.minQuality          = minQuality;
     this.maxBitrate          = maxBitrate;
     this.minBitrate          = minBitrate;
     this.maxGovLength        = maxGovLength;
     this.minGovLength        = minGovLength;
     this.encoderOptions      = encoderOptions;
 }
示例#28
0
        MediaUri GetVideoMediaUri(TestVideoEncoderConfigurationOptions test,
                                  CopyVideoEncoderConfiguration copyMethod,
                                  string profileRequirementsDescription,
                                  VideoEncoding encoding,
                                  TransportProtocol protocol,
                                  StreamType streamType,
                                  IPType?multicastAddressType)
        {
            Profile profile = null;
            VideoEncoderConfigurationOptions options = null;

            Profile[] profiles = GetProfiles();

            RunStep(() =>
            {
                foreach (Profile p in profiles)
                {
                    LogStepEvent(string.Format("Check if {0} profile supports {1} Video encoder configuration",
                                               p.Name, profileRequirementsDescription));
                    if (p.VideoEncoderConfiguration != null)
                    {
                        options =
                            Client.GetVideoEncoderConfigurationOptions(p.VideoEncoderConfiguration.token, p.token);

                        DoRequestDelay();

                        if (test(options))
                        {
                            profile = p;
                            break;
                        }
                    }
                }
            },
                    string.Format("Select profile with {0} Video encoder configuration", profileRequirementsDescription));

            Assert(profile != null,
                   string.Format("Profile with {0} Video encoder configuration not found", profileRequirementsDescription),
                   "Check if required profile found");

            profile.VideoEncoderConfiguration.Encoding = encoding;
            copyMethod(profile, options);
            // fix for Panasonic
            if (encoding == VideoEncoding.JPEG)
            {
                profile.VideoEncoderConfiguration.MPEG4 = null;
                profile.VideoEncoderConfiguration.H264  = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.JPEG != null)
                    {
                        if (options.Extension.JPEG.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.JPEG.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.JPEG.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.JPEG.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.JPEG.BitrateRange.Max;
                            }
                        }
                    }
                }
            }
            if (encoding == VideoEncoding.MPEG4)
            {
                profile.VideoEncoderConfiguration.H264 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.MPEG4 != null)
                    {
                        if (options.Extension.MPEG4.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.MPEG4.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.MPEG4.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.MPEG4.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.MPEG4.BitrateRange.Max;
                            }
                        }
                    }
                }
            }
            if (encoding == VideoEncoding.H264)
            {
                profile.VideoEncoderConfiguration.MPEG4 = null;

                // support for extensions (bitrate limits)
                if (options.Extension != null)
                {
                    if (options.Extension.H264 != null)
                    {
                        if (options.Extension.H264.BitrateRange != null)
                        {
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit < options.Extension.H264.BitrateRange.Min)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.H264.BitrateRange.Min;
                            }
                            if (profile.VideoEncoderConfiguration.RateControl.BitrateLimit > options.Extension.H264.BitrateRange.Max)
                            {
                                profile.VideoEncoderConfiguration.RateControl.BitrateLimit = options.Extension.H264.BitrateRange.Max;
                            }
                        }
                    }
                }
            }

            if (multicastAddressType.HasValue)
            {
                SetMulticastSettings(profile, true, false, multicastAddressType.Value);
            }

            SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false, multicastAddressType.HasValue);

            StreamSetup streamSetup = new StreamSetup();

            streamSetup.Transport          = new Transport();
            streamSetup.Transport.Protocol = protocol;
            streamSetup.Stream             = streamType;

            UsedProfileToken = profile.token;
            MediaUri streamUri = GetStreamUri(streamSetup, profile.token);

            AdjustVideo(protocol, streamType, streamUri, profile.VideoEncoderConfiguration);

            return(streamUri);
        }
示例#29
0
        public void MpegVideoEncoderConfiguration()
        {
            RunTest(() =>
            {
                VideoEncoderConfiguration[] configs = GetVideoEncoderConfigurations();
                string reason;
                Assert(ValidateVideoEncoderConfigs(configs, out reason), reason, Resources.StepValidatingVideoEncoderConfigs_Title);

                VideoEncoderConfigurationOptions options = null;
                VideoEncoderConfiguration config         = GetVideoEncoderConfiguration(configs, VideoEncoding.MPEG4, out options);

                config.Encoding           = VideoEncoding.MPEG4;
                config.Resolution         = options.MPEG4.ResolutionsAvailable[0];
                config.Quality            = options.QualityRange.Max;
                config.MPEG4              = new Mpeg4Configuration();
                config.MPEG4.GovLength    = options.MPEG4.GovLengthRange.Max + 1;//invalid param
                config.MPEG4.Mpeg4Profile = Mpeg4Profile.SP;
                config.H264 = null;
                if (config.RateControl != null)
                {
                    config.RateControl.FrameRateLimit   = options.MPEG4.FrameRateRange.Min;
                    config.RateControl.EncodingInterval = options.MPEG4.EncodingIntervalRange.Min;
                }
                string details = string.Format("Setting invalid configuration (/VideoEncoderConfiguration/MPEG4/GovLength = {0})", config.MPEG4.GovLength);
                SetInvalidVideoEncoderConfiguration(config, false, details);


                VideoResolution highest = null;
                VideoResolution lowest  = null;
                VideoResolution median  = null;

                VideoResolution[] resolutions = options.MPEG4.ResolutionsAvailable;
                FindResolutions(resolutions, out highest, out lowest, out median);

                /*
                 * Encoding = “MPEG4”,
                 * Mpeg4Profile = “SP”, if “SP” is not supported “ASP”,
                 * Resolution = Highest resolution based on number of pixels ,
                 * Quality = QualityRange.Max,
                 * FramerateLimit = FrameRateRange.Max,
                 * BitrateLimit = “64000”,
                 * EncodingInterval = EncodingIntervalRange.Min,
                 * GovLength = GovLengthRange.Min, and force persistence = false)
                 */

                // schema requires at least one element in Mpeg4ProfilesSupported
                // as well as for other elements
                config.MPEG4.Mpeg4Profile = options.MPEG4.Mpeg4ProfilesSupported.Contains(Mpeg4Profile.SP)
                                                ? Mpeg4Profile.SP
                                                : Mpeg4Profile.ASP;
                config.Resolution  = highest;
                config.Quality     = options.QualityRange.Max;
                config.RateControl = new VideoRateControl();
                config.RateControl.FrameRateLimit   = options.MPEG4.FrameRateRange.Max;
                config.RateControl.BitrateLimit     = 64000;
                config.RateControl.EncodingInterval = options.MPEG4.EncodingIntervalRange.Min;
                config.MPEG4.GovLength = options.MPEG4.GovLengthRange.Min;

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use max values)");
                VideoEncoderConfiguration newConfig = GetVideoEncoderConfiguration(config.token);

                bool ok = ConfigurationValid(newConfig, VideoEncoding.MPEG4, highest, out reason);

                Action checkProfile =
                    new Action(
                        () =>
                {
                    string error = string.Empty;
                    if (newConfig.MPEG4 == null)
                    {
                        ok    = false;
                        error = "MPEG4 configuration not found";
                    }
                    else
                    {
                        if (newConfig.MPEG4.Mpeg4Profile != config.MPEG4.Mpeg4Profile)
                        {
                            ok    = false;
                            error = string.Format("Mpeg4Profile is incorrect. Expected: {0}, actual: {1} ",
                                                  config.MPEG4.Mpeg4Profile, newConfig.MPEG4.Mpeg4Profile);
                        }
                    }

                    if (!string.IsNullOrEmpty(error))
                    {
                        if (string.IsNullOrEmpty(reason))
                        {
                            reason = error;
                        }
                        else
                        {
                            reason += System.Environment.NewLine;
                            reason += error;
                        }
                    }
                });

                checkProfile();

                Assert(ok, reason, "Check that the DUT accepted values passed");

                config.Resolution  = lowest;
                config.Quality     = options.QualityRange.Min;
                config.RateControl = new VideoRateControl();
                config.RateControl.FrameRateLimit   = options.MPEG4.FrameRateRange.Min;
                config.RateControl.BitrateLimit     = 64000;
                config.RateControl.EncodingInterval = options.MPEG4.EncodingIntervalRange.Max;
                config.MPEG4.GovLength = options.MPEG4.GovLengthRange.Max;

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use min values)");
                newConfig = GetVideoEncoderConfiguration(config.token);

                ok = ConfigurationValid(newConfig, VideoEncoding.MPEG4, lowest, out reason);
                checkProfile();
                Assert(ok, reason, "Check that the DUT accepted values passed");

                // Average

                config.Resolution  = median;
                config.Quality     = options.QualityRange.Average();
                config.RateControl = new VideoRateControl();
                config.RateControl.FrameRateLimit   = options.MPEG4.FrameRateRange.Average();
                config.RateControl.BitrateLimit     = 64000;
                config.RateControl.EncodingInterval = options.MPEG4.EncodingIntervalRange.Average();
                config.MPEG4.GovLength = options.MPEG4.GovLengthRange.Average();

                SetVideoEncoderConfiguration(config, false, false, "SetVideoEncoderConfiguration (use average values)");
                newConfig = GetVideoEncoderConfiguration(config.token);

                ok = ConfigurationValid(newConfig, VideoEncoding.MPEG4, median, out reason);
                checkProfile();
                Assert(ok, reason, "Check that the DUT accepted values passed");
            });
        }
示例#30
0
        MediaUri GetVideoMediaUri(TestVideoEncoderConfigurationOptions test,
                                  CopyVideoEncoderConfiguration copyMethod,
                                  string profileRequirementsDescription,
                                  VideoEncoding encoding,
                                  TransportProtocol protocol,
                                  StreamType streamType,
                                  IPType?multicastAddressType,
                                  MediaConfigurationChangeLog changeLog)
        {
            Profile profile = null;
            VideoEncoderConfigurationOptions options = null;

            Profile[] profiles = GetProfiles();

            RunStep(() =>
            {
                foreach (Profile p in profiles)
                {
                    LogStepEvent(string.Format("Check if {0} profile supports {1} Video encoder configuration",
                                               p.Name, profileRequirementsDescription));
                    if (p.VideoEncoderConfiguration != null)
                    {
                        options =
                            Client.GetVideoEncoderConfigurationOptions(p.VideoEncoderConfiguration.token, p.token);

                        DoRequestDelay();

                        if (test(options))
                        {
                            profile = p;
                            break;
                        }
                    }
                }
            },
                    string.Format("Select profile with {0} Video encoder configuration", profileRequirementsDescription));

            Assert(profile != null,
                   string.Format("Profile with {0} Video encoder configuration not found", profileRequirementsDescription),
                   "Check if required profile found");

            VideoEncoderConfiguration vecCopy = Utils.CopyMaker.CreateCopy(profile.VideoEncoderConfiguration);

            changeLog.TrackModifiedConfiguration(vecCopy);

            profile.VideoEncoderConfiguration.Encoding = encoding;
            copyMethod(profile, options);

            AdjustVideoEncoderConfiguration(encoding, profile.VideoEncoderConfiguration, options);

            if (multicastAddressType.HasValue)
            {
                SetMulticastSettings(profile, true, false, multicastAddressType.Value);
            }

            SetVideoEncoderConfiguration(profile.VideoEncoderConfiguration, false, multicastAddressType.HasValue);

            StreamSetup streamSetup = new StreamSetup();

            streamSetup.Transport          = new Transport();
            streamSetup.Transport.Protocol = protocol;
            streamSetup.Stream             = streamType;

            UsedProfileToken = profile.token;
            MediaUri streamUri = GetStreamUri(streamSetup, profile.token);

            AdjustVideo(protocol, streamType, streamUri, profile.VideoEncoderConfiguration);

            return(streamUri);
        }