| ^ | 行の先頭 |
| [ ] | 指定内の任意の表現 |
| 例 | [ab] |
| aまたはbにマッチする | |
| メタ文字 | |
| \s | 任意の空白文字(スペース、タブ、改行、復帰)1文字にマッチします。 |
| 例 | [^\\s] |
| 先頭の空白文字位置文字にマッチする。 | |
| * | 直前にある文字が0回以上繰り返された文字列にマッチします。0回でも可なので直前の文字が存在しなくてもマッチする。 |
2012年8月12日日曜日
正規表現:基本
2012年8月2日木曜日
ライブ配信送信側のJavaプログラム:JMF
受信側プログラムはJMStudioを利用
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.format.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class TransmitterTest extends JFrame {
private MediaLocator mediaLocator = null;
private DataSink dataSink = null;
private Processor mediaProcessor = null;
private Format[] formats = new Format[] {
new VideoFormat( VideoFormat.JPEG_RTP ) };
private ContentDescriptor descriptor =
new ContentDescriptor( ContentDescriptor.RAW_RTP );
private InputPanel ipanel;
private static final int PORT=22224;
private Component ctrl;
/** Creates a new transmitter frame. */
public TransmitterTest() {
super( "Video Transmitter" );
ipanel = new InputPanel();
getContentPane().add( ipanel, "Center" );
pack();
show();
}
/** set locator from Capture Device */
public void setLocator() {
try {
MediaLocator deviceLocator = searchCaptureDevice();
DataSource source
= Manager.createDataSource( deviceLocator );
mediaLocator
= new MediaLocator( "rtp://" + ipanel.host.getText()
+ ":" + PORT + "/video" );
mediaProcessor = Manager.createRealizedProcessor(
new ProcessorModel( source, formats, descriptor ) );
dataSink = Manager.createDataSink(
mediaProcessor.getDataOutput(), mediaLocator );
setControlPanel();
startTransmitting();
} catch (Exception e) {
System.err.println( e.toString() );
}
}
/** Search Capture Device for Video */
public static MediaLocator searchCaptureDevice() {
Vector list = CaptureDeviceManager.getDeviceList(
new VideoFormat( VideoFormat.YUV ) );
if( list.size() > 0 ) {
CaptureDeviceInfo info
= (CaptureDeviceInfo)list.elementAt( 0 );
return info.getLocator();
}
System.err.println( "No Capture Device" );
return null;
}
/** set Control */
public void setControlPanel() {
ctrl = mediaProcessor.getControlPanelComponent();
getContentPane().add( ctrl, "South" );
pack();
}
/** Starts transmitting the media. */
public void startTransmitting() throws IOException {
mediaProcessor.start();
dataSink.open();
dataSink.start();
}
/** start here */
public static void main(String[] args) {
TransmitterTest transmitter = new TransmitterTest();
}
/** Input receive host name, port number */
class InputPanel extends JPanel implements ActionListener {
public JLabel label = new JLabel( "Receiver Adress:" );
public JTextField host = new JTextField( "", 16 );
public JButton transmit = new JButton( "Transmit" );
InputPanel() {
add( label );
add( host );
add( transmit );
transmit.addActionListener( this );
}
/** Event Processing */
public void actionPerformed( ActionEvent evt ) {
if( evt.getSource() instanceof JButton ) {
if( (JButton)(evt.getSource()) == transmit ) {
setLocator();
}
}
}
}
}
登録:
コメント (Atom)
