/// <summary> /// This method is called when a new session is about to be created. /// This method should validate the requested session parameters, and change if needed. /// If unable to handle more sessions for this channel, you can throw an Exception. /// </summary> /// <param name="session"></param> void MediaProviderSessionOpening(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new MediaProviderChannel.SessionOpeningDelegate(MediaProviderSessionOpening), session); } else { // Here we can check what the server side has configured, and adjust to what make sense for us. int maxFPS = 15; if (comboBoxFPS.SelectedItem != null) { Int32.TryParse(comboBoxFPS.SelectedItem.ToString(), out maxFPS); } if (session.FPS > maxFPS) { session.FPS = maxFPS; } // Resolution, Quality, etc can also be modified if (session.Quality > hScrollBarQuality.Value) { session.Quality = hScrollBarQuality.Value; } textBoxSessionCount.Text = "" + _videoProvider.ActiveSessions; } }
void MediaProviderSessionOpening(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new MediaProviderChannel.SessionOpeningDelegate(MediaProviderSessionOpening), session); } else { int maxFPS = 15; if (comboBoxFPS.SelectedItem != null) { Int32.TryParse(comboBoxFPS.SelectedItem.ToString(), out maxFPS); } if (session.FPS > maxFPS) { session.FPS = maxFPS; } if (session.Quality > hScrollBarQuality.Value) { session.Quality = hScrollBarQuality.Value; } textBoxSessionCount.Text = "" + _videoProvider.ActiveSessions; } }
void MetadataProviderSessionClosed(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new Action <MediaProviderSession>(MetadataProviderSessionClosed), session); } else { textBoxSessionCount.Text = "" + _metadataProviderChannel.ActiveSessions; } }
/// <summary> /// This is called when one of the sessions are closed. /// In this sample we just update the active session counter for this channel. /// </summary> /// <param name="session"></param> void MediaProviderSessionClosed(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new MediaProviderChannel.SessionClosedDelegate(MediaProviderSessionClosed), session); } else { textBoxSessionCount.Text = "" + _videoProvider.ActiveSessions; } }
/// <summary> /// This is called when one of the sessions are closed. /// In this sample we just update the active session counter for this channel. /// </summary> /// <param name="session"></param> void MetadataProviderSessionClosed(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new Action <MediaProviderSession>(MetadataProviderSessionClosed), session); } else { textBoxSessionCount.Text = (_boundingBoxProviderChannel.ActiveSessions + _gpsProviderChannel.ActiveSessions + _nonStandardProviderChannel.ActiveSessions).ToString(); } }
/// <summary> /// For this sample, we provide JPEG frames. /// </summary> /// <param name="session"></param> /// <returns></returns> MediaData MediaProviderGetMediaData(MediaProviderSession session) { if (InvokeRequired) { // Get on the UI thread before executing the below code return(Invoke(new MediaProviderChannel.GetMediaDataDelegate(MediaProviderGetMediaData), session) as MediaData); } var random = new Random(DateTime.UtcNow.Millisecond); var metadata = new MetadataStream { NavigationalData = new NavigationalData { Altitude = _altitude, Latitude = random.Next(-90, 90), Longitude = random.Next(-180, 180) } }; _altitude += 0.01; _metadataProviderChannel.QueueMetadata(metadata, DateTime.UtcNow); var bitmap = new Bitmap(panelTimeDisplay.Width, panelTimeDisplay.Height); panelTimeDisplay.DrawToBitmap(bitmap, new Rectangle(new Point(0, 0), panelTimeDisplay.Size)); var mediaData = new MediaData(); using (var ms = new MemoryStream()) { var qualityParam = new EncoderParameter(Encoder.Quality, session.Quality); bitmap.Save(ms, GetJpegEncoder(), new EncoderParameters(1) { Param = new[] { qualityParam } }); ms.Seek(0, SeekOrigin.Begin); mediaData.Bytes = new byte[ms.Length]; ms.Read(mediaData.Bytes, 0, (int)ms.Length); } mediaData.DateTime = DateTime.UtcNow; return(mediaData); }
/// <summary> /// This method is called when a new session is about to be created. /// This method should validate the requested session parameters, and change if needed. /// If unable to handle more sessions for this channel, you can throw an Exception. /// </summary> /// <param name="session"></param> void MetadataProviderSessionOpening(MediaProviderSession session) { if (InvokeRequired) { BeginInvoke(new Action <MediaProviderSession>(MetadataProviderSessionOpening), session); } else { textBoxSessionCount.Text = (_boundingBoxProviderChannel.ActiveSessions /*+ _gpsProviderChannel.ActiveSessions + _nonStandardProviderChannel.ActiveSessions*/).ToString(); if (sourceComboBox.SelectedIndex == 0) { DumpProperties(_boundingBoxProviderChannel.ServerParameterDictionary); } if (sourceComboBox.SelectedIndex == 1) { DumpProperties(_gpsProviderChannel.ServerParameterDictionary); } if (sourceComboBox.SelectedIndex == 2) { DumpProperties(_nonStandardProviderChannel.ServerParameterDictionary); } } }
void MetadataProviderParametersChanged(MediaProviderSession session, MetadataProviderChannel channel) { //TODO - we should stored the changed parameters on disk, to ensure we have them for next application execution DumpIfChannelIsShown(channel.Channel, new Dictionary <string, string>(channel.ServerParameterDictionary)); }