public void ShowVideo(Media.MediaUri uri, Media.VideoEncoderConfiguration encoder, Media.AudioEncoderConfiguration audio) { try { _videoWindow = new VideoContainer(); DeviceEnvironment environment = ContextController.GetDeviceEnvironment(); int messageTimeout = environment.Timeouts.Message; Media.TransportProtocol protocol = GetTransportProtocol(); VideoUtils.AdjustVideo( _videoWindow, environment.Credentials.UserName, environment.Credentials.Password, messageTimeout, protocol, Media.StreamType.RTPUnicast, uri, encoder); _videoWindow.KEEPALIVE = true; _videoWindow.OpenWindow(audio != null); Invoke(new Action(() => { btnGetStreams.Text = "Stop Video"; })); } catch { _videoWindow = null; throw; } }
/// <summary> /// Get stream uri for specified profile /// </summary> /// <param name="profile">Media profile</param> /// <param name="protocol"></param> public void GetMediaUri(Media.Profile profile, Media.TransportProtocol protocol) { string address = View.MediaAddress; _mediaClientWorking = true; InitializeMediaClient(address); _mediaClient.GetMediaUri(profile, protocol); }
/// <summary> /// Get stream uri with specified configurations /// </summary> /// <param name="profile"></param> /// <param name="videoSourceConfig">Video source configuration</param> /// <param name="videoEncoderConfig">Video encoder configuration</param> /// <param name="audioSourceConfig">Audio source configuration</param> /// <param name="audioEncoderConfig">Audio encoder configuration</param> /// <param name="protocol"></param> public void GetMediaUri( Media.Profile profile, Media.VideoSourceConfiguration videoSourceConfig, Media.VideoEncoderConfiguration videoEncoderConfig, Media.AudioSourceConfiguration audioSourceConfig, Media.AudioEncoderConfiguration audioEncoderConfig, Media.TransportProtocol protocol) { if ((videoEncoderConfig == null) || (videoSourceConfig == null)) { throw new ArgumentNullException(); } string address = View.MediaAddress; _mediaClientWorking = true; InitializeMediaClient(address); _mediaClient.GetMediaUri(profile, videoSourceConfig, videoEncoderConfig, audioSourceConfig, audioEncoderConfig, protocol); }
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); } }
private Media.TransportProtocol GetTransportProtocol() { Media.TransportProtocol protocol = Media.TransportProtocol.UDP; Invoke(new Action(() => { protocol = (Media.TransportProtocol)cmbTransport.SelectedItem; })); return(protocol); }