private void cmbAudioCodec_SelectedIndexChanged(object sender, EventArgs e) { cmbAudioBitrate.Items.Clear(); Media.AudioEncoderConfigurationOption option = cmbAudioCodec.SelectedItem as Media.AudioEncoderConfigurationOption; if ((option != null) && (option.BitrateList != null)) { foreach (int bitrate in option.BitrateList) { cmbAudioBitrate.Items.Add(bitrate); } if (cmbAudioBitrate.Items.Count > 0) { cmbAudioBitrate.SelectedIndex = 0; } } }
private void SetAudioConfiguration( Media.AudioEncoderConfiguration config, Media.AudioEncoderConfigurationOption options) { config.Encoding = options.Encoding; if (cmbAudioBitrate.SelectedItem != null) { config.Bitrate = (int)cmbAudioBitrate.SelectedItem; } else if ((options.BitrateList != null) && (options.BitrateList.Length > 0)) { config.Bitrate = options.BitrateList[0]; } if ((options.SampleRateList != null) && (options.SampleRateList.Length > 0)) { config.SampleRate = options.SampleRateList[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 { MessageBox.Show(this, "Select video source and encoder configuration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(this, "Select media profile", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }