コード例 #1
0
        static void Main(string[] args)
        {
            RtpParticipant part = new RtpParticipant("*****@*****.**", "SENDER");

            RtpSession session = new RtpSession(ip, part, true, true);

            session.PacketTransform = new EncryptionTransform("You are a big freak!");
            //session.PacketTransform = new XorTransform();


            RtpSender sender = session.CreateRtpSender("My sender", PayloadType.Test, null);

            Stream fs     = File.OpenRead("data.txt");
            int    length = (int)fs.Length;

            Console.Out.WriteLine("Opening file of length: " + length);

            byte[] buffer = new byte[length];

            int bytesRead = 0;

            while (bytesRead < length)
            {
                bytesRead += fs.Read(buffer, bytesRead, Math.Min(16384, (length - bytesRead)));
            }

            for (int i = 0; i < 5; i++)
            {
                Console.Out.WriteLine("Sending buffer to address: " + ip);

                sender.Send(buffer);

                Thread.Sleep(1000);
            }
        }
コード例 #2
0
        private void Send()
        {
            //    Trace.WriteLine("!!BTN: toolBarBtnGrab");

            //    if (savedArray == null)
            //    {
            //        int size = videoInfoHeader.BmiHeader.ImageSize;
            //        if ((size < 1000) || (size > 16000000))
            //            return;
            //        savedArray = new byte[size + 64000];
            //    }

            //    Image old = pictureBox1.Image;
            //    pictureBox1.Image = null;
            //    if (old != null)
            //        old.Dispose();
            //    captured = false;
            //    sampGrabber.SetCallback(this, 1);
            if (picPreview.Image != null)
            {
                MemoryStream ms = new MemoryStream();
                picPreview.Image.Save(ms, ImageFormat.Jpeg);
                rtpSender.Send(ms.GetBuffer());
            }
        }
コード例 #3
0
 // CF4 Send the data
 private void btnSend_Click(object sender, System.EventArgs e)
 {
     if (txtSend.Text.Length > 0)
     {
         // BufferChunk does an automatic conversion on text.
         rtpSender.Send((BufferChunk)txtSend.Text);
         txtSend.Clear();
     }
 }
コード例 #4
0
        void send_img()
        {
            try
            {
                if (MotionFlag.Checked)
                {
                    Image oldimage = scr.Get_Resized_Image(100, 100, scr.GetDesktopBitmapBytes());

                    while (true)
                    {
                        Image newimage   = scr.Get_Resized_Image(100, 100, scr.GetDesktopBitmapBytes());
                        float difference = scr.difference(newimage, oldimage);
                        differencelab.Text = difference.ToString() + "%";
                        if (difference >= 1)
                        {
                            sendingSt.ForeColor = Color.Green;
                            sendingSt.Text      = "Sending ...";
                            notifyIcon1.Text    = "RTP Presenter - Sending...";
                            rtpSender.Send(scr.GetDesktopBitmapBytes());
                            oldimage = scr.Get_Resized_Image(100, 100, scr.GetDesktopBitmapBytes());
                        }
                        else
                        {
                            sendingSt.ForeColor = Color.Red; sendingSt.Text = "Paused"; notifyIcon1.Text = "RTP Presenter - Paused";
                        }
                    }
                }
                else
                {
                    sendingSt.ForeColor = Color.Green;
                    sendingSt.Text      = "Sending ...";
                    notifyIcon1.Text    = "RTP Presenter - Sending...";

                    while (true)
                    {
                        rtpSender.Send(scr.GetDesktopBitmapBytes());
                    }
                }
            }
            catch (Exception) {}
        }
コード例 #5
0
        private void SendData()
        {
            frameCount++;

            rtpSender.Send(RandomData());

//            Console.WriteLine("Press any key to continue");
//            Console.ReadLine();

            if (!are.WaitOne(timeout, false))
            {
                Trace.WriteLine("Timeout waiting for frame - " + frameCount);
            }
        }
コード例 #6
0
ファイル: VsStreamer.cs プロジェクト: tmpkus/openvss
        private void process_NewFrame(object stateInfo)
        {
            try
            {
                VsImage lastImage = null;

                // get new one
                if (imgBuffer.Count > 0)
                {
                    lastImage = (VsImage)imgBuffer.Dequeue();
                }

                if (vsReadyToStream && lastImage != null)
                {
                    EncoderParameter epQuality = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality);
                    // Store the quality parameter in the list of encoder parameters
                    EncoderParameters epParameters = new EncoderParameters(1);
                    epParameters.Param[0] = epQuality;

                    using (Graphics g = Graphics.FromImage(vsImageStream))
                    {
                        g.DrawImage(lastImage.Image, 0, 0, Width, Height);
                    }

                    MemoryStream ms = new MemoryStream();
                    vsImageStream.Save(ms, GetImageCodecInfo(ImageFormat.Jpeg), epParameters);

                    int offset = search_jpegoffset(ms);
                    data = new byte[(int)ms.Length - offset];
                    Array.Copy(ms.GetBuffer(), offset, data, 0, (int)ms.Length - offset);
                    rtpSender.Send(data);
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);
            }
        }
コード例 #7
0
        // Process new frame
        private void process_NewFrame(object stateInfo)
        {
            Monitor.Enter(lockBuffer);

            try
            {
                // get windows frame

                if (vsImageStream != null)
                {
                    EncoderParameter epQuality = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality);
                    // Store the quality parameter in the list of encoder parameters
                    EncoderParameters epParameters = new EncoderParameters(1);
                    epParameters.Param[0] = epQuality;

                    using (Graphics g = Graphics.FromImage(vsImageStream))
                    {
                        g.DrawImage(VsScreenCapture.GetDesktopBitmap(), 0, 0, ImgWidth, ImgHeight);
                    }

                    MemoryStream ms = new MemoryStream();
                    vsImageStream.Save(ms, GetImageCodecInfo(ImageFormat.Jpeg), epParameters);

                    int offset = search_jpegoffset(ms);
                    data = new byte[(int)ms.Length - offset];
                    Array.Copy(ms.GetBuffer(), offset, data, 0, (int)ms.Length - offset);
                    rtpSender.Send(data);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                Monitor.Exit(lockBuffer);
            }
        }
コード例 #8
0
        /// <summary>
        /// Send all the frames that should be sent up to this point in time.
        /// </summary>
        /// <param name="bytesSent">Number of bytes sent.</param>
        /// <param name="cumulativeLateness">Sum of temporal disparities over all frames sent.</param>
        /// <param name="firstStoredTick">The 'start' time on the first index in this whole stream.</param>
        /// <param name="sender">The RtpSender to send data on.</param>
        /// <param name="startTimeTicks">The start time of sending, in ticks.</param>
        /// <param name="timeUntilFrame">The temporal distance between the current frame and the next one to be sent, in ticks.</param>
        /// <returns>Number of frames sent.</returns>
        public int SendFrames(RtpSender sender, long timeBoundary, out long timeUntilFrame, ref long totalBytesSent, ref long cumulativeLateness)
        {
            if (this.populating)
            {
                throw new InvalidOperationException(Strings.BufferplayerSendframesError);
            }

            int framesSent = 0;

            try
            {
                while (currentIndex < indexCount && indices[currentIndex].timestamp <= timeBoundary)
                {
                    long startTimer = DateTime.Now.Ticks;

                    int frameLength = 1 + indices[currentIndex].end - indices[currentIndex].start;

                    if (frameLength > 0)
                    {
                        // Calculate how late the frame will be
                        long lateness = (timeBoundary - indices[currentIndex].timestamp) / Constants.TicksPerMs;
                        if (lateness > Constants.TicksSpent)
                        {
                            Trace.WriteLine(String.Format(CultureInfo.InvariantCulture,
                                                          "--- FRAME LATENESS OF: {0} ms", lateness));
                        }
                        cumulativeLateness += lateness;

                        // Send Frame
                        buffer.Reset(indices[currentIndex].start - indices[0].start, frameLength);
                        sender.Send(buffer);
                    }
                    else
                    {
                        // (pbristow) Why would this happen???
                        Debug.Fail("Frame of length zero found.");
                    }

                    totalBytesSent += frameLength;
                    ++framesSent;
                    ++currentIndex;

                    long takenTime = DateTime.Now.Ticks - startTimer;
                    if (takenTime > Constants.TicksSpent)
                    {
                        Trace.WriteLine(String.Format(CultureInfo.InvariantCulture,
                                                      "TIME WASTED TO SEND A FRAME: {0} ms, ID: {1}, bytes: {2}",
                                                      (takenTime / Constants.TicksPerMs), streamID, frameLength));
                    }
                }

                if (currentIndex == indexCount)
                {
                    timeUntilFrame = 0;
                }
                else
                {
                    timeUntilFrame = (indices[currentIndex].timestamp - timeBoundary);
                }
            }
            catch (ObjectDisposedException)
            {
                // Sender is disposed by Stop being called
                timeUntilFrame = long.MaxValue;
            }

            return(framesSent);
        }
コード例 #9
0
ファイル: Streaming.cs プロジェクト: alfaKrzys/Peeper
 void send_Tick(object sender, EventArgs e)
 {
     rtpSender.Send(capture.Grab().GetBuffer());
 }