Package javax.media.control

Examples of javax.media.control.BitRateControl


            javax.media.protocol.DataSource dataOutput = processor.getDataOutput();
            System.out.println("### processor data output " + dataOutput.getClass().getName());

            // BitRateControl
            BitRateControl bitrateControl = null;

            Object[] controls2 = dataOutput.getControls();
            for (int i=0; i<controls2.length; i++)
            {
                if ( controls2[i] instanceof BitRateControl )
                {
                    bitrateControl = (BitRateControl)controls2[i];
                    System.out.println("### found bitrate control " + bitrateControl.getClass());
                    break;
                }
            }

            // PacketSizeControl
            Object[] controls3 = processor.getControls();
            for (int i=0; i<controls3.length; i++)
            {
                if ( controls3[i] instanceof PacketSizeControl )
                {
                    PacketSizeControl psc = (PacketSizeControl)controls3[i];
                    System.out.println("### current packetsize is " + psc.getPacketSize() + " bytes");
                    psc.setPacketSize(1400);
                    System.out.println("### packetsize was set to " + psc.getPacketSize() + " bytes");
                    break;
                }
            }

            // QualityControl
            QualityControl qc = null;
            Object[] controls4 = processor.getControls();
            for (int i=0; i<controls4.length; i++)
            {
                if ( controls4[i] instanceof QualityControl )
                {
                    qc = (QualityControl)controls4[i];
                    System.out.println("### current quality is " + qc.getQuality());
                    qc.setQuality(0.5f);
                    System.out.println("### quality was set to " + qc.getQuality());
                    break;
                }
            }

            // FrameRateControl
            Object[] controls5 = processor.getControls();
            for (int i=0; i<controls5.length; i++)
            {
                if ( controls5[i] instanceof FrameRateControl )
                {
                    FrameRateControl frc = (FrameRateControl)controls5[i];
                    System.out.println("### current framerate is " + frc.getFrameRate());
                    frc.setFrameRate(5.0f);
                    System.out.println("### framerate was set to " + frc.getFrameRate());
                    break;
                }
            }

            // here you can reduce the size of video ( over RTP ) if format is not set in the processor, capture device format will be used
            // FormatControl
            /*Object[] controls6 = processor.getControls();
            for (int i=0; i<controls6.length; i++)
            {
                if ( controls6[i] instanceof FormatControl )
                {
                    FormatControl fc = (FormatControl)controls6[i];
                    System.out.println("### current format is " + fc.getFormat());
                    fc.setFormat(new javax.media.format.VideoFormat(javax.media.format.VideoFormat.JPEG_RTP, new Dimension(128, 96), -1, null, -1));
                    //fc.setFormat(new javax.media.format.VideoFormat(javax.media.format.VideoFormat.JPEG_RTP, new Dimension(640, 480), -1, null, -1));
                    System.out.println("### format was set to " + fc.getFormat());
                    break;
                }
            }*/

            Object[] pcontrols = processor.getControls();
            for (int i=0; i<pcontrols.length; i++)
            {
                System.out.println(">> processor control " + i + " " + pcontrols[i]);
            }

            javax.media.rtp.RTPManager rtpManager = javax.media.rtp.RTPManager.newInstance();

            javax.media.rtp.SessionAddress local = new javax.media.rtp.SessionAddress(InetAddress.getLocalHost(), Integer.valueOf(args[1]).intValue());
            javax.media.rtp.SessionAddress target = new javax.media.rtp.SessionAddress(InetAddress.getByName(args[0]), Integer.valueOf(args[1]).intValue());

            rtpManager.initialize(local);
            rtpManager.addTarget(target);

            javax.media.rtp.SendStream sendStream = rtpManager.createSendStream(dataOutput, 0);
            sendStream.start();
            System.out.println("### sendStream=" + sendStream.getClass());

            processor.start();
           
            float quality = 0.1f;
           
            System.out.println("\n>>>>>>  TRANSMITTING VIDEO NOW");
            while ( 2 > 1 )
            {
                Thread.sleep(1000);
               
                int fps = -1;
                if ( null != frameRateControl )
                {
                    fps = (int)frameRateControl.getFrameRate();
                }
               
                TransmissionStats stats = sendStream.getSourceTransmissionStats();
                System.out.println("rtp video send: bitrate=" + bitrateControl.getBitRate() + ", captureFPS=" + fps + " (pdu=" + stats.getPDUTransmitted() + " sent=" + stats.getBytesTransmitted() + " bytes)");
               
                /*if ( stats.getPDUTransmitted() > 100 )
                {
                    processor.close();
                    sendStream.close();
View Full Code Here

TOP

Related Classes of javax.media.control.BitRateControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.