Second Physical Communication Laboratory

Knowledge

The simple Vide Chat on Flex3

by admin on 3 月.29, 2010, under ASP, Adobe Flex3, Showcase

I described the program of a very simple video chat out with Flex3 and Red5.

Donwload Flex3 source on FlashDevelop 3.0 here

Download Red5 source and Webapp. here

mxml : main.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
layout="absolute">

<mx:Script>
<![CDATA[
public var myCameraView:mystreaming = new mystreaming();
private var con:ChatConnection;
private var streamingURL:String = "rtmp://192.168.116.128/buruburu";
private var channetKey:String = "demo";
public function init():void {
con = new ChatConnection();
Textframe.addChild(con.logtext);
}
private function connect_chat():void {
if (connectOpen.label == "公開開始") {
cameraview.attachCamera(myCameraView.myLocalvideo.myCamera);
myCameraView.channetKey = channetKey;
myCameraView.connect_chat();
con.close();
connectOpen.label = "公開中止";
}else {
myCameraView.disconnect_chat();
con.close();
connectOpen.label = "公開開始";
}
}
private function shuffle_chat():void {
var myGuseView:gueststreaming = new gueststreaming();
myGuseView.channetKey = channetKey;
myGuseView.playVideo();
streamview.addChild(myGuseView.video);
con.connect(streamingURL);
}
private function sendMsg():void {
con.call("writeText", null, message.text);
message.text = "";
}
]]>
</mx:Script>
<mx:Panel id="VideoPanel" title="Bijo Chat" backgroundColor="0xb1bfc5" >
<mx:HBox  id="Menuframe">
<mx:Button id="connectOpen" x="0" y="0" label="公開開始"  fontSize="10" click="connect_chat()" visible="true" textRollOverColor="0xdeb700" />
<mx:Button id="connectClose" x="100" y="0" label="シャッフル" fontSize="10" click="shuffle_chat()"  visible="true" textRollOverColor="0xdeb700"/>
</mx:HBox>
<mx:HBox  id="Hframe">
<mx:VBox  id="Videoframe">
<mx:VideoDisplay x="0" y="0" width="320" height="180" id="streamview"  visible="true" backgroundImage="@Embed('iphone-camera-icon.jpg')"/>
<mx:VideoDisplay x="0" y="10" width="320" height="180" id="cameraview"  visible="true" backgroundImage="@Embed('iphone-camera-icon.jpg')"/>
</mx:VBox>
<mx:VBox  id="Textframe">
<mx:TextInput id="message" width="100%" enter="sendMsg()" />
</mx:VBox>
</mx:HBox>
</mx:Panel>
</mx:Application>

AS:mystreaming.as

package
{
import flash.media.Video;
import flash.net.NetConnection;
import flash.media.Camera;
import flash.media.Microphone;
import flash.net.NetStream;
import flash.events.*;
import mx.accessibility.AccImpl;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.events.NetStatusEvent;
import flash.events.EventDispatcher;
import mx.controls.Alert;
import mx.events.SliderEvent;
import mx.controls.sliderClasses.Slider;
import mx.rpc.events.ResultEvent;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import mx.collections.ArrayCollection;
/**
* ...
* @author yuucha
*/
public class mystreaming
{
public var counter:Number = 0;
private var pub_nc:NetConnection;
private var pub_ns:NetStream;

private var streamingURL:String = "rtmp://192.168.116.128/buruburu";
private var play_nc:NetConnection;
private var play_ns:NetStream;
private var stat:Number;
private  var clientID:Number;
private var StreamingCamera:Camera;
private var StreamingMic:Microphone;
public var myLocalvideo:myvideo;
public var video:Video = new Video(320, 180);
public var channetKey:String = "";

public function mystreaming():void
{
myLocalvideo = new myvideo();
}

public function onBWDone(... rest):Boolean {
return true;
}
public function newStream():void {
trace("newStream");
}
public function onBWCheck(... rest):Number {
return 0;
}
public function connect_chat():void {
pub_nc = new NetConnection();
var clientObj:Object = new Object();
clientObj.onBWDone = onBWDone;
clientObj.onBWCheck = onBWCheck;
pub_nc.client = clientObj;
pub_nc.connect(streamingURL);
pub_nc.addEventListener(NetStatusEvent.NET_STATUS,pub_netStatus);
pub_nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSecurityError);
}
public function disconnect_chat():void {
pub_nc.close();
Alert.show("映像の公開を中止しました。");
}
private function pub_netStatus(event:NetStatusEvent):void {
if (event.info.code == "NetConnection.Connect.Success") {
pub_ns = new NetStream(pub_nc);
pub_ns.attachAudio(myLocalvideo.myMic);
pub_ns.attachCamera(myLocalvideo.myCamera);
pub_ns.publish(channetKey, "live");
Alert.show("ストリーミングサーバへの接続に成功しました。");
}
else if (event.info.code == "NetConnection.Connect.Closed") {
pub_ns.close();
Alert.show("ストリーミングサーバへの接続に失敗しました。");
}
else {
trace("error");
}
}
private function onSecurityError(event:SecurityErrorEvent):void {
trace("netSecurityError:" + event);
}

}

}

AS:gueststreaming.as

package
{
import flash.media.Video;
import flash.net.NetConnection;
import flash.media.Camera;
import flash.media.Microphone;
import flash.net.NetStream;
import flash.events.*;
import mx.accessibility.AccImpl;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.events.NetStatusEvent;
import flash.events.EventDispatcher;
import mx.controls.Alert;
import mx.events.SliderEvent;
import mx.controls.sliderClasses.Slider;
import mx.rpc.events.ResultEvent;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import mx.collections.ArrayCollection;
/**
* ...
* @author yuucha
*/
public class gueststreaming
{
private var streamingURL:String = "rtmp://192.168.116.128/buruburu";
private var play_nc:NetConnection;
private var play_ns:NetStream;
public var video:Video = new Video(320, 180);
public var channetKey:String = "";

public function gueststreaming()
{
}

public function playVideo():void{
play_nc = new NetConnection();
var clientObjplay:Object = new Object();
play_nc.client = clientObjplay;
clientObjplay.setId = function setId( id:Number ):void { };
play_nc.addEventListener(NetStatusEvent.NET_STATUS, play_netStatus);
play_nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
play_nc.connect(streamingURL);
}

public function disconnect_chat():void {
play_nc.close();
}

private function onSecurityError(event:SecurityErrorEvent):void {
trace("netSecurityError:" + event);
}
private function play_netStatus(event:NetStatusEvent):void {
trace("netStatus: " + event.info.code);
if (event.info.code == "NetConnection.Connect.Success") {
Alert.show("ストリーミングサーバへの接続に成功しました。");
play_ns = new NetStream(play_nc);
video.attachNetStream(play_ns);
play_ns.play(channetKey);
} else{
trace("error");
Alert.show("ストリーミングサーバへの接続が中断しました。");
}
}
}

}

AS:myvideo.as

package
{
import flash.media.Video;
import flash.media.Camera;
import flash.media.Microphone;

/**
* ...
* @author yuucha
*/
public class myvideo
{
public var myCamera:Camera;
public var myMic:Microphone;

public function myvideo():void{
camera_init();
}

public function camera_init():void {
myCamera = Camera.getCamera();
myCamera.setMode(320,180, 30, true );
myCamera.setQuality(163840,0);
myMic = Microphone.getMicrophone();
myMic.rate = 44;
}
}

}

AS:ChatConnection.as

package
{
import flash.net.NetConnection;
import mx.controls.TextArea;

public class ChatConnection extends NetConnection
{
public var logtext:TextArea = new TextArea();

public function ChatConnection()
{
super();
logtext.width = 640;
logtext.height = 320;

}

public function writeText(message:String):void
{
logtext.text = message + "n" + logtext.text;
}

public function setlogtext(t:String):void
{
logtext.text = t;
}

public function getTextArea():TextArea
{
return logtext;
}
}
}

red5: buruburu.java

If you don’t want to use Text chat, you don’t need this code on your Red5 Webapp.

import java.util.Iterator;
import java.util.Set;

import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.service.IServiceCapableConnection;

public class Application extends ApplicationAdapter
{
// クライアント側から呼ばれるメソッド
public String drawLine(IConnection conn, int startX, int startY, int endX, int endY)
{
IScope scope = Red5.getConnectionLocal().getScope();
Set<IClient> clients = scope.getClients();
Iterator<IClient> it = clients.iterator();
Object[] params = new Object[]{startX, startY, endX, endY};
while(it.hasNext())
{
IClient client = it.next();
Set<IConnection> connset = client.getConnections();
Iterator<IConnection> it_con = connset.iterator();

while(it_con.hasNext())
{
IConnection connection = it_con.next();
if(connection instanceof IServiceCapableConnection)
{
IServiceCapableConnection sc = (IServiceCapableConnection)connection;
// クライアント側のメソッドを呼ぶ
sc.invoke("drawLine", params);
}
}
}
return "OK";

}

This version is the less text chat.

import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.service.IServiceCapableConnection;

public class Application extends ApplicationAdapter
{
}
Leave a Comment :, more...

The Gainer Flex3 analog out programming

by admin on 2 月.10, 2009, under USB controlle

I described the program of a very simple analog out with Flex3. I made a screen of Flash in mxml and described ActiveScript in another .as file.I make one slider controller of Flash and change output data of analog if I let a controller slide.  It is powered by two AA batteries in gainer this time and operates a DC motor.

mxml : demo.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init();" width="575" height="271" viewSourceURL="bin/index.html">
	<mx:Script source="Motor.as" />
	<mx:Text x="146" y="66" text="aout 0"/>
	<mx:HSlider x="195" y="66" id="ao0" minimum="0" maximum="255" mouseUp="aOut();"/>
</mx:Application>

AS:Motor.as

import gainer.Gainer;

public var gnr:Gainer;
public function init():void
{
gnr = new Gainer("localhost", 2000, Gainer.MODE1, true);
}
public function aOut():void
{
gnr.analogOutput(0,ao0.value);
}

1 Comment more...

Setting Gainer

by admin on 2 月.10, 2009, under USB controlle

It is to solder a pin first to have to do. Gainer can install two lines of pins. I put Gainer on the top to install it precisely after having inserted a pin in a flexible board. When I solder it, please be careful heat comes not too much, and not to break a part.

Leave a Comment more...

The clone Gainer

by admin on 1 月.27, 2009, under USB controlle

The parts list

  • A USB microcomputer board finished product (PIC18F2550) \1,000 (tax-included).
  • A RS232C cable & power supply set \800 (tax-included) for three AKI - PIC programmer Ver. kits.
  • A USB cable (A - mini B) 1.5m \150 (tax-included) (entering one case of 240).
  • A set of AKI - PIC programmer Ver.4 (a completion board) \5,700 (tax-included).

Update software
http://akizukidenshi.com/catalog/contents2/ver4support.aspx

MPLAB downloadhttp://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469

MPLAB C Compiler for PIC18 Down load
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014

#include <p18cxxx.h>
#include <delays.h>

#pragma config FOSC = HSPLL_HS
#pragma config WDT = OFF
#pragma config PLLDIV = 5
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2
#pragma config PWRT = ON
#pragma config BOR = OFF
#pragma config BORV = 2
#pragma config LVP = OFF
#pragma config VREGEN = ON
#pragma config MCLRE = OFF
#pragma config PBADEN = OFF

void main(void)
{
TRISB = 0;
LATB = 0x00;
while(1){
Delay10KTCYx(100);
LATB ^= 0xff;
}
}

The infometion source
http://blog.goo.ne.jp/sim00/e/fee5a8d229457154de4d7c10095ebd89

Leave a Comment more...

The Ecommerce ASP service

by admin on 1 月.19, 2009, under ASP

I want to use ASP for the settlement of the shop.
The settlement service which is famous in Japan is “http://estore.co.jp/”. In the site, a function of the credit card settlement and the convenience store settlement is substantial. The payment of moon is 50 dollars. I can use settlement service and a shopping cart and inventory control service.
http://estore.co.jp/index.html

Leave a Comment more...

Install the Flex3 on WindowsXP

by admin on 1 月.17, 2009, under Adobe Flex3

This page is written that how to installed the Flex3 SDK.

  1. Down load the “Flex3SDK” from Adobe site.
    http://www.adobe.com/products/flex/flexdownloads/#sdk
  2. Exstract Zip file, and movie it to C:\.
  3. If you want to set Path to flex_sdk\bin directory, You shoud set the PATH parameter in the system property setting.
    C:\flex_sdk_3\bin\
  4. Test ont the command prompt screen.
    C:\Documents and Settings\xxxxx>cd c:\flex_sdk_3\bin
    C:\flex_sdk_3\bin>mxmlc
    Adobe Flex Compiler (mxmlc)
    Version 3.2.0 build 3958
    Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved.
    mxmlc [options] [defaultVar]詳細については、’mxmlc -help’ を使用してください。
    C:\flex_sdk_3\bin>
Leave a Comment more...

Install the Red5 to Fedora

by admin on 1 月.11, 2009, under Red5

finallogo1

Install Red5 version0.7.0 into Fedora7

  1. Installation Red5 of JDK uses JAVA. Versions of installed JAVA SDK should be more than 6.
    1. Down load from Java EE site.
      http://java.sun.com/javase/ja/6/download.html
    2. Install JDK
      [root@hostname ~]# chmod a+x jdk-6u11-linux-i586-rpm.bin
      [root@hostname ~]# ./jdk-6u11-linux-i586-rpm.bin
      [root@hostname ~]# vi .bash_profile
      export JAVA_HOME=/usr/java/jdk1.6.0_11
      export PATH=$JAVA_HOME/bin:$JAVA_HOME /jre/bin:$PATH
      [root@localhost ~]# source .bash_profile
  2. Installation of Ant 1.7
    Install is usually finished. Please input command ant. If your Ant is version under 1.7

    1. Uninstall apache ant.
      [root@hostname ~]# yum remove ant
    2. Download ant version 1.7  (rpm image).
      http://ftp.riken.jp/net/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
    3. Install ant.
      [root@hostname ~]# tar vxfz apache-ant-1.7.1-bin.tar.gz
      [root@hostname ~]# mv apache-ant-1.7.1-bin /usr/local/ant
      [root@hostname ~]# export ANT_HOME=/usr/local/ant
      [root@hostname ~]# export PATH=$PATH:$ANT_HOME/bin/
      [root@hostname ~]# ant
      Buildfile: build.xml does not exist!
      Build failed
  3. Install Red5
    It is easy.

    1. Download rpm first from the site.
      http://red5.nl/installer/red5-0.7.0.tar.gz
    2. Install
      [root@hostname ~]# tar -zxf red5-0.7.0.tar.gz
      [root@hostname ~]# mv red5-0.7.0 /opt/red5
      [root@hostname ~]# chmod +x red5.sh
  4. Open ports of firewall.
    If you use Red5 from internet, You must open the ports 5080, 1488 and 443.
  5. Check the Red5.
    1. Start the Red5 server by the shell command.
      [root@hostname ~]# cd /opt/red5
      [root@hostname ~]# cd ./red5.sh &
    2. Access from the other Pc.
      http://(a servier’s address):5080
      testred5

Leave a Comment :, , more...

Gainer

by Follay Susoy on 1 月.10, 2009, under USB controlle

gainer_logo
An input/output module to control a sensor and an actuator from a PC.

This module has USB interface, and a library for driver sofrwareware and C++ and Flash for PCs is prepared. In addition, software and hardware are shown with a CC license as an open source.
http://gainer.cc/Main/HomePage?userlang=en

i-o_module_v10s

Gainer.cc 

Leave a Comment :, more...

The urethane material which realizes the softness such as the body warmth

by Follay Susoy on 1 月.10, 2009, under Material

hito-gen05
Exseal Co., Ltd. sells urethane resin reproducing human skin.

https://www.exseal.co.jp/product/gel-liquid.html
As for the resin for urethane molding, it is prepared for three kinds. The softest thing is hardness of the skin of the baby. The middle is a face and an arm. The hardest thing reproduces the feel of a foot and the back.

The price is 100 dollars at 1,200g. In addition, it is 600 dollars at 20kg.
Of course I can purchase it by a mail order.

Leave a Comment : more...