Total members 11890 |It is currently Tue Apr 23, 2024 11:32 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





i m making a code i m begginer in java so plz help me wit the vdeo chat i m done wit normal chat i need vide code i tried few code bt nt working




Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

Please can you post the codes your tried so we can help u in ?

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

this is the code


Attachments:
clientside.rar [21.38 KiB]
Downloaded 1379 times
serverside.rar [6.49 KiB]
Downloaded 1337 times
Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

Well , it worked with me , i created a netbeans project for both and i downloaded the missing jars.
Attachment:
File comment: Include client and server
ClientSide.rar [91.53 KiB]
Downloaded 1298 times

Attachment:
File comment: Video chat window
VedioChat.png
VedioChat.png [ 32 KiB | Viewed 10703 times ]


i changed the IP to localhost at:
Code:

public interface ClientConstant
{
    public static final String SERVER_ADDRESS="127.0.0.1";
    public static final int SERVER_PORT=4567;
    public static final int CLIENT_NUMBER=100;
    public static final String DISCONNECT_STRING="DISCONNECT";
    public static final String MESSAGE_SEPARATOR=" >> ";
}

 


Remember that u have to start the server first then start two clients... then use them together.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

For this message the author DrRakha has received gratitude : rajeshnepal

get the missing jars from here :
Code:
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#7372-jmf-2.1.1e-oth-JPR


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

Thnx for soln


Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

proble for running video how ?

it says below problem in netbeans 7

Track 0 is set to transmit as:
dvi/rtp, 8000.0 Hz, 4-bit, Mono
Created RTP session: 127.0.0.1 20004
java.io.IOException: Could not connect to capture device
Error : Couldn't create DataSource
BUILD SUCCESSFUL (total time: 41 seconds)

help


Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

I will try to understand the problem .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

even i m nt able to connect plz help


Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

I have printed out the exception
Code:
try {
     ds = javax.media.Manager.createDataSource(locator);
} catch (Exception e) {
     e.printStackTrace();
     return "Couldn't create DataSource";
}

The the exception is as follows :
Code:
Error : Couldn't create DataSource
javax.media.NoDataSourceException: Cannot find a DataSource for: vfw://0
   at javax.media.Manager.createDataSource(Manager.java:1037)
   at clientside.AVTransmit2.createProcessor(AVTransmit2.java:95)
   at clientside.AVTransmit2.start(AVTransmit2.java:51)
   at clientside.MessageRecever.run(MessageRecever.java:187)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)



The problem now is not about the chat or even transferring the video frames, it is about that if JMF sees your camera or not , with my case even using other snippets like this ;
Code:


import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.util.Calendar;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.control.FrameGrabbingControl;
import javax.media.format.VideoFormat;
import javax.media.util.BufferToImage;
import javax.swing.JButton;
import javax.swing.JComponent;



public class Main extends Panel implements ActionListener{

    public static Player player=null;
    public CaptureDeviceInfo di=null;
    public MediaLocator ml=null;
    public JButton capture=null;
    public Buffer buf=null;
    public Image img=null;
    public VideoFormat vf=null;
    public BufferToImage btoi=null;
    public ImagePanel imgpanel=null;
    public int capturenumber=0;

    public Main(){
        setLayout(new BorderLayout());
        setSize(320,550);
        imgpanel=new ImagePanel();
        capture= new JButton("Capture");
        capture.addActionListener(this);
       
        String str = "vfw:Microsoft WDM Image Capture (Win32):0";
        di=CaptureDeviceManager.getDevice(null);
        ml = new MediaLocator(str);
        try{
            player=Manager.createRealizedPlayer(ml);
            player.start();
            Component comp;
            if((comp = player.getVisualComponent())!=null){
                add(comp,BorderLayout.NORTH);
            }
            add(capture,BorderLayout.CENTER);
            add(imgpanel,BorderLayout.SOUTH);
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
    }
    public static void main(String[] args){
        Frame f=new Frame("Take picture");
        Main cf = new Main();
        f.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e){
                playerclose();
                System.exit(0);
            }
        });
        f.add(cf);
        f.pack();
        f.setSize(320, 550);
        f.setVisible(true);
    }

    public static void playerclose(){
        player.close();
        player.deallocate();
    }

    public void actionPerformed(ActionEvent e) {
        JComponent c = (JComponent) e.getSource();
        if(c==capture){
            FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
            buf = fgc.grabFrame();
            btoi= new BufferToImage((VideoFormat)buf.getFormat());
            img = btoi.createImage(buf);
            imgpanel.setImage(img);
            Calendar cal= Calendar.getInstance();
            @SuppressWarnings("static-access")
            int data = (cal.getTime().getYear()+1900)*10000+ (cal.getTime().getMonth()+1)*100+cal.getTime().getDate();
            saveJPG(img,"D:\\"+ data +capturenumber+".jpg");
            capturenumber++;
        }
    }

    private void saveJPG(Image img, String s) {
        BufferedImage bi= new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_INT_RGB);
        Graphics2D g2=bi.createGraphics();
        g2.drawImage(img, null, null);
        FileOutputStream out=null;
        try{
            out = new FileOutputStream(s);
        }
        catch(java.io.FileNotFoundException ex){
            ex.printStackTrace();
        }
        JPEGImageEncoder encoder= JPEGCodec.createJPEGEncoder(out);
        JPEGEncodeParam param= encoder.getDefaultJPEGEncodeParam(bi);
        param.setQuality(0.5f, false);
        encoder.setJPEGEncodeParam(param);
        try{
            encoder.encode(bi);
            out.close();
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
    }

    public class ImagePanel extends Panel{
        public Image myimg=null;
        public ImagePanel(){
            setLayout(null);
            setSize(320,240);
        }
        public void setImage(Image img){
            this.myimg=img;
            repaint();
        }
        @Override
        public void paint(Graphics g){
            if(myimg != null){
                g.drawImage(myimg,0,0,this);
            }
        }
    }

}


or
Code:

import java.awt.BorderLayout;
import java.util.Vector;

import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.control.FormatControl;
import javax.swing.JFrame;

public class main {

    CaptureDeviceInfo cam; 
    MediaLocator locator;
    Player player;
    FormatControl formatControl;
    /**
     * @param args
     */

    public main(){
        try{
            // List out available Devices to Capture Video.
            Vector<CaptureDeviceInfo> list = CaptureDeviceManager.getDeviceList ( null );

            // Iterating list
            for(CaptureDeviceInfo temp : list){
                // Checking whether the current device supports VfW
                // VfW = Video for Windows
                if(temp.getName().startsWith("vfw:")){

                    System.out.println("Found : "+temp.getName().substring(4));
                    // Selecting the very first device that supports VfW
                    cam = temp;
                    System.out.println("Selected : "+cam.getName().substring(4));
                    break;
                } else {
                    System.out.println(temp.getName().substring(4));
                    cam = temp;
                }

            }
            if (cam != null){
                System.out.println("Camera found.");
                locator = cam.getLocator();
            } else System.out.println("Camera not found.");

            if(locator != null){

                // Create a Player for Media Located by MediaLocator
                player = Manager.createRealizedPlayer(locator);

                if(player != null){

                    // Starting the player
                    player.start();

                    // Creating a Frame to display Video
                    JFrame f = new JFrame();
                    f.setTitle("Test Webcam");
                    f.setLayout(new BorderLayout());
                    // Adding the Visual Component to display Video captured by Player
                    // from URL provided by MediaLocator
                    f.add(player.getVisualComponent(), BorderLayout.CENTER);
                    f.pack();
                    f.setVisible(true);

                }

            }

        }catch(Exception e){
            e.printStackTrace();
        }

    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new main();
    }



}


This line return null
Code:
Vector<CaptureDeviceInfo> list = CaptureDeviceManager.getDeviceList ( null );


The only case it worked with me when i downloaded :http://sourceforge.net/projects/fmj/files/fmj/
and run fmjstudio.bat .

I can run the camera using this APP ! , so i think next step it to investigate this project code and use its library , i also suggest to trying other type of Webcams like usb webcam because some sources says that may be your webcam is not supported by JMF (Am using version : jmf-2_1_1e) .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 10 posts ] 

  Related Posts  to : video chat
 Chat with Video Transmission in Java     -  
 video chat application in java     -  
 Chat Help     -  
 Java Chat     -  
 Chat Room in JSP     -  
 I need chat application using php     -  
 java chat program.     -  
 Chat Room application     -  
 MultiClient Bluetooth Chat     -  
 Java Chat With Customizable GUI     -  



Topic Tags

Java JMF






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com