⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videotransmit.java

📁 this is the media streaming project
💻 JAVA
字号:
/****************************************************************************************/
/* 2001-Spring: Java Network-Programming Term-Project					*/
/* Title: Streaming media generation, capture and store.				*/
/* Team Member: Yumin Yuan(yuany@rpi.edu), Rui Mu(mur@rpi.edu), Yining Hu(huyn@rpi.edu) */
/* VideoTransmit.java: This class generates streams from local video and sends the         */ 
/* generated streams to remote receiver							*/
/* Complile: javac VideoTransmit.java							*/
/****************************************************************************************/

import java.awt.Dimension;
import javax.media.*;
import javax.media.protocol.*;
import javax.media.format.*;
import javax.media.control.TrackControl;
import java.io.*;

public class VideoTransmit extends Transmitter{

    public VideoTransmit(String _destURL,DataSource _dataInput){
        super(_destURL,_dataInput);
    }

    public String createProcessor() {
	try {
	    processor = Manager.createProcessor(dataInput);
	} catch (Exception ioe) {
	    return "IOException creating processor";
	}
	// Wait for it to configure
        boolean result = waitForState(processor, Processor.Configured);
	if (result == false)
	    return "Couldn't configure processor";

	// Get the tracks from the processor
        TrackControl [] tracks = processor.getTrackControls();

	if (tracks == null || tracks.length < 1)
	    return "Couldn't find tracks in processor";

	boolean programmed = false;

	for (int i = 0; i < tracks.length; i++) {
	    Format format = tracks[i].getFormat();
	    if (  tracks[i].isEnabled() &&
		  format instanceof VideoFormat &&
		  !programmed) {

		Dimension size = ((VideoFormat)format).getSize();
		float frameRate = ((VideoFormat)format).getFrameRate();
		VideoFormat jpegFormat = new VideoFormat(VideoFormat.JPEG_RTP,
							 size,
							 Format.NOT_SPECIFIED,
							 Format.byteArray,
							 frameRate);
		tracks[i].setFormat(jpegFormat);

		programmed = true;
	    } else
		tracks[i].setEnabled(false);
	}

	if (!programmed)
	    return "Couldn't find video track";


	ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW);
	processor.setContentDescriptor(cd);

	result = waitForState(processor, Controller.Realized);
	if (result == false)
	    return "Couldn't realize processor";
	dataOutput = processor.getDataOutput();
	return null;
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -