// caller publishes media stream
outgoingStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, outgoingStreamHandler);
outgoingStream.publish("media-caller");
// caller subscribes to callee's media stream
incomingStream = new NetStream(netConnection, identity);
incomingStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
incomingStream.play("media-caller");
//音频和视频的启动
private function startAudio():void
{
if (sendAudioCheckbox.selected)
{
var mic:Microphone = getMicrophone();
if (mic && outgoingStream)
{
outgoingStream.attachAudio(mic);
}
}
else
{
if (outgoingStream)
{
outgoingStream.attachAudio(null);
}
}
}
private function startVideo():void
{
if (sendVideoCheckbox.selected)
{
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
localVideoDisplay.attachCamera(camera);
if (outgoingStream)
{
outgoingStream.attachCamera(camera);
}
}
}
else
{
localVideoDisplay.attachCamera(null);
if (outgoingStream)
{
outgoingStream.attachCamera(null);
}
}
}
// user clicked accept button
private function acceptCall():void
{
stopRing();
incomingStream.receiveAudio(true);
incomingStream.receiveVideo(true);
remoteVideo = new Video();
remoteVideo.width = 320;
remoteVideo.height = 240;
remoteVideo.attachNetStream(incomingStream);
remoteVideoDisplay.addChild(remoteVideo);
// callee publishes media
outgoingStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, outgoingStreamHandler);
outgoingStream.publish("media-callee");
var o:Object = new Object
o.onPeerConnect = function(caller:NetStream):Boolean
{
status("Caller connecting to media stream: " + caller.farID + "\n");
return true;
}
outgoingStream.client = o;
netConnection.call(Relay, null, remoteId, Accept, userNameInput.text);
startVideo();
startAudio();
currentState = CallEstablished;
}

1040

被折叠的 条评论
为什么被折叠?



