Click here
Sunday, June 19, 2011
com.sswf.rtmp.Consumer
package com.sswf.rtmp;
import com.sswf.io.encoder.api.IEncoder;
import com.sswf.type.DataType;
public interface Consumer {
public void putData(DataType dataType, long ts, byte[] buf, int size);
public void setRecording(boolean isRecording);
public boolean isRecording();
public void setEncoder(IEncoder encoder);
public IEncoder getEncoder();
}org.jma.encoder.audio.IAudioEncoder
package org.jma.encoder.audio;
public interface IAudioEncoder {
public int encodeBuffer(byte[] input, int offset, int encodedCount, byte[] output);
public int encodeFinish(byte[] input);
public int getInputBufferSize();
public int getOutputBufferSize();
public void close();
}org.jma.encoder.video.IVideoEncoder
package org.jma.encoder.video;
public interface IVideoEncoder {
byte[] encode(final byte[] current, final byte[] previous, final int width, final int height) throws Exception;
}org.jma.encoder.IEncoder
package org.jma.encoder;
import javax.sound.sampled.AudioFormat;
import org.jma.MetaData;
import org.jma.encoder.audio.IAudioEncoder;
import org.jma.encoder.video.IVideoEncoder;
import org.jma.video.VideoFormat;
import org.red5.server.stream.codec.AudioCodec;
import org.red5.server.stream.codec.VideoCodec;
public interface IEncoder {
public void add(AudioCodec targetAudioCodec, AudioFormat sourceFormat);
public void add(VideoCodec targetVideoCodec, VideoFormat format);
public MetaData getMetaData();
public IAudioEncoder getAudioEncoder();
public IVideoEncoder getVideoEncoder();
}Java Code Examples
You can publish your desktop just for a few lines of code:
private void publish() {
first = true;
try {
if (!AudioSystem.isLineSupported(info)) {
System.err.println("Line is not supported by the Audio System");
JOptionPane.showMessageDialog(this,
"Line is not supported by the Audio System");
return;
}
line = (TargetDataLine) mixer.getLine(info);
line.open(sourceFormat);
line.start();
IEncoder encoder = new Encoder();
encoder.add(AudioCodec.MP3, sourceFormat);
encoder.add(VideoCodec.SCREEN_VIDEO, null);
clientManager.setEncoder(encoder);
clientManager.setRunning(true);
clientManager.setRecording(true);
CaptureAudio captureAudio = new CaptureAudio(clientManager, line);
CaptureVideo captureVideo = new CaptureVideo(clientManager, new Robot());
Thread publishAudio = new Thread(captureAudio);
publishAudio.start();
Thread publishVideo = new Thread(captureVideo);
publishVideo.start();
} catch (LineUnavailableException e) {
System.err.println("Line Unavailable:" + e);
e.printStackTrace();
System.exit(-2);
} catch (Exception e) {
System.out.println("Direct Upload Error");
e.printStackTrace();
}
}// End of RecordAudio methodSaturday, June 18, 2011
Release 1.1
1. Build If you have Java 1.6 installed see Demo Applet
1.1
2. Release package
-----rtmp-publisher
| -----codebase
| -----META-INF
| -----WEB-INF
| -----index.html
3. Functionality
Unzip files and copy to the webapp directory of your tomcat
5. Running
Download
1.1
2. Release package
-----rtmp-publisher
| -----codebase
| -----META-INF
| -----WEB-INF
| -----index.html
3. Functionality
- Microphone, Mixer or any sound sources publishing to RED5 server via RTMP
- Video desktop capturing. Your can put your own video source. I provide encoding interface to do it successfully.
- Screen Video codec, MP3 codec
Unzip files and copy to the webapp directory of your tomcat
5. Running
Open URL http://localhost:8080/rtmp-publisher-1.1
6. Related projects:
Download
Subscribe to:
Posts (Atom)