Esempio n. 1
0
        private void cmbVideoCodec_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbVideoResolution.Items.Clear();
            txtVideoBitrate.Text   = null;
            txtVideoFramerate.Text = null;
            VideoCodecWrapper encoder = cmbVideoCodec.SelectedItem as VideoCodecWrapper;

            if (encoder != null)
            {
                Media.VideoResolution[] resolutions = encoder.GetResolutions();
                if (resolutions != null)
                {
                    foreach (Media.VideoResolution resolution in resolutions)
                    {
                        cmbVideoResolution.Items.Add(new VideoResolutionWrapper {
                            Resolution = resolution
                        });
                    }
                }
                Media.IntRange framerate = encoder.GetFrameLimit();
                if (framerate != null)
                {
                    txtVideoFramerate.Text = framerate.Min.ToString();
                }
            }
            if (cmbVideoResolution.Items.Count > 0)
            {
                cmbVideoResolution.SelectedIndex = 0;
            }
        }
Esempio n. 2
0
 private void txtVideoFramerate_Validating(object sender, CancelEventArgs e)
 {
     if (!string.IsNullOrEmpty(txtVideoFramerate.Text))
     {
         int               value;
         Media.IntRange    range = null;
         bool              valid = int.TryParse(txtVideoFramerate.Text, out value);
         VideoCodecWrapper codec = cmbVideoCodec.SelectedItem as VideoCodecWrapper;
         if (codec != null)
         {
             range = codec.GetFrameLimit();
             if ((range != null) && (valid))
             {
                 valid = (value >= range.Min) && (value <= range.Max);
             }
         }
         if (!valid)
         {
             string message = "Please enter integer value";
             if (range != null)
             {
                 message += string.Format(" between {0} and {1}", range.Min, range.Max);
             }
             ShowPrompt(message, "Error");
             e.Cancel = true;
         }
     }
 }
Esempio n. 3
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");
            }
        }