Beispiel #1
0
 public void SetProfiles(Media.Profile[] profiles)
 {
     BeginInvoke(new Action(() =>
     {
         cmbMediaProfile.Items.Clear();
         object testProfile = null;;
         foreach (Media.Profile profile in profiles)
         {
             object item = new MediaProfileWrapper()
             {
                 Profile = profile
             };
             if (IsTestProfile(profile))
             {
                 testProfile = item;
             }
             cmbMediaProfile.Items.Add(item);
         }
         if (testProfile == null)
         {
             testProfile = new MediaProfileWrapper()
             {
                 Profile = new TestTool.Proxies.Onvif.Profile()
             };
             ((MediaProfileWrapper)testProfile).Profile.Name = MediaServiceProvider.TestMediaProfileName;
             cmbMediaProfile.Items.Add(testProfile);
         }
         cmbMediaProfile.SelectedItem = testProfile;
     }));
 }
Beispiel #2
0
        private void OnPlayVideo()
        {
            MediaProfileWrapper profile = cmbMediaProfile.SelectedItem as MediaProfileWrapper;

            if (profile != null)
            {
                VideoSourceConfigurationWrapper  videoSourceConfig  = cmbVideoSource.SelectedItem as VideoSourceConfigurationWrapper;
                VideoEncoderConfigurationWrapper videoEncoderConfig = cmbVideoEncoder.SelectedItem as VideoEncoderConfigurationWrapper;
                AudioSourceConfigurationWrapper  audioSourceConfig  = cmbAudioSource.SelectedItem as AudioSourceConfigurationWrapper;
                AudioEncoderConfigurationWrapper audioEncoderConfig = cmbAudioEncoder.SelectedItem as AudioEncoderConfigurationWrapper;

                Media.TransportProtocol transport = GetTransportProtocol();
                if ((videoSourceConfig != null) && (videoEncoderConfig != null))
                {
                    bool testProfile = IsTestProfile(profile.Profile);
                    if (testProfile)
                    {
                        VideoCodecWrapper      codecOptions = cmbVideoCodec.SelectedItem as VideoCodecWrapper;
                        VideoResolutionWrapper resolution   = cmbVideoResolution.SelectedItem as VideoResolutionWrapper;
                        int?framerate = null;
                        if (!string.IsNullOrEmpty(txtVideoFramerate.Text))
                        {
                            framerate = int.Parse(txtVideoFramerate.Text);
                        }
                        int?bitrate = null;
                        if (!string.IsNullOrEmpty(txtVideoBitrate.Text))
                        {
                            bitrate = int.Parse(txtVideoBitrate.Text);
                        }
                        if (codecOptions.Encoding == Media.VideoEncoding.H264)
                        {
                            SetH264Configuration(videoEncoderConfig.Configuration, codecOptions.H264, resolution.Resolution, framerate, bitrate);
                        }
                        else if (codecOptions.Encoding == Media.VideoEncoding.JPEG)
                        {
                            SetJPEGConfiguration(videoEncoderConfig.Configuration, codecOptions.Jpeg, resolution.Resolution, framerate, bitrate);
                        }
                        else if (codecOptions.Encoding == Media.VideoEncoding.MPEG4)
                        {
                            SetMPEG4Configuration(videoEncoderConfig.Configuration, codecOptions.Mpeg4, resolution.Resolution, framerate, bitrate);
                        }

                        if ((audioEncoderConfig != null) && (audioEncoderConfig.Configuration != null))
                        {
                            Media.AudioEncoderConfigurationOption audioCodecOptions = cmbAudioCodec.SelectedItem as Media.AudioEncoderConfigurationOption;
                            if (audioCodecOptions != null)
                            {
                                SetAudioConfiguration(audioEncoderConfig.Configuration, audioCodecOptions);
                            }
                        }

                        Controller.GetMediaUri(
                            profile.Profile.token != null ? profile.Profile : null,//if profile was not really created, pass null as parameter
                            videoSourceConfig.Configuration,
                            videoEncoderConfig.Configuration,
                            audioSourceConfig != null ? audioSourceConfig.Configuration : null,
                            audioEncoderConfig != null ? audioEncoderConfig.Configuration : null,
                            transport);
                    }
                    else
                    {
                        Controller.GetMediaUri(profile.Profile, transport);
                    }
                }
                else
                {
                    ShowPrompt("Select video source and encoder configuration", "Error");
                }
            }
            else
            {
                ShowPrompt("Select media profile", "Error");
            }
        }