Red5 2-way camera setup (videochat) - actionscript-3

I got a problem with RED5 in combination with Flash. For a personal project i am trying to make a Skype-like application. I already got a application that records the users webcam and saves it with a custom filename on the RED5 server.
But i am stuck trying to connect one more user to that window for a video chat. I made a new video container in Flash but i don't know how to connect a second client to the same stream in AS3 with Red5?
I searched on the net but i only get really old threads about RED5 in combination with Flex.
Maybe this is helping understanding my problem?
Could someone help me out? Or get me in the right direction?

Video chat? You will need 2 streams, for every client. Inbound and outbound. Outbound is a stream from the client to the media server, inbound is consumed stream of another user. So it will look like:
_streamOut = new NetStream(connection, NetStream.CONNECT_TO_FMS);
_streamIn = new NetStream(connection, NetStream.CONNECT_TO_FMS);
_streamOut.addEventListener(NetStatusEvent.NET_STATUS, onStreamOutNetStatus);
_streamIn.addEventListener(NetStatusEvent.NET_STATUS, onStreamInNetStatus);
_streamOut.attachAudio(microphone);
_streamOut.attachCamera(camera);
_streamOut.publish(hostPeerID);
_streamIn.play(companionPeerID);
Also there are some helpful examples, did you check them?

Related

Issues with RTSP video in browser using Streamedian

I have a system where I need to be able to view 4 rtsp feeds with a web browser in and amongst other web content. The feeds are coming from "Amcrest ProHD 1080P PTZ Camera Outdoor, 2MP Outdoor Vandal Dome IP PoE Camera" units. All of the connectivity is wired within the same intranet. I'm viewing the cameras on Insignia Amazon Fire TVs, and I'm not getting the results that I expected.
In order to get it working, I installed streamedian on my Windows machine and got that configured properly. I didn't change much about the default configuration of the proxy server except the port number it was using the serve the feeds on. On the browser side, I included the necessary JavaScript files (again, only changing the port numbers) and made my call to load the players. Currently, that code looks like this:
var playerOptions = {
socket: 'ws://192.168.1.253:8080/ws/',
redirectNativeMediaErrors: true,
bufferDuration: 5,
continuousFileLength: 5000,
eventFileLength: 5000,
errorHandler: function (err) {
console.log(err.message);
},
};
setTimeout(function () {
player1 = Streamedian.player("p1", playerOptions);
player2 = Streamedian.player("p2", playerOptions);
player3 = Streamedian.player("p3", playerOptions);
player4 = Streamedian.player("p4", playerOptions);
}, 100);
Each of the players look like this in the HTML:
<video id="p1" controls autoplay>
<source src="rtsp://path.to.camera" type="application/x-rtsp">
</video>
The players do load, and appear to be attempting to start the stream. However, they quickly start buffering and never come out of it to start showing anything resembling a live feed. Any ideas on what I can do to try to get this running? Am I even heading down a valid path to get where I need to be?
I'm not worried about rewind, or anything in the past. This is purely for live streaming and only needs to show "now". Saving anything more than necessary is not required in order to meet the needs.
I've tried dropping the frame rate to 4fps. It didn't seem to help.
The Windows machine has average power at best. I've opened Task Manager while the streams are running, but nothing appears to be pegged out. Am I just running an under-powered machine for what I'm asking it to do?
Are the browsers in the TV, or the TV itself, just not capable of getting it done and processing that much information? I've tried viewing the pages on my laptop as well (separate from the Windows server, and plenty powerful), but the results do not improve.
Should I be trying something else on my server side? I came across iSpyConnect this evening as I was searching for other (preferably free) options, but I can't tell for sure if it will get me what I need. I've also started looking at signboard applications for the TVs, but they all have a cost associated with them that I'd like to avoid if at all possible.
If anyone has any thoughts, ideas, comments, suggestions or questions about what I have in place, please let me know so that I can try to get something up and running within the facility.
Thanks!

SimpleWebRTC: consume video when peer machine has no webcam and microphone

I am using SimpleWebRTC to create a video chat room application.
One of the requirements is, a peer machine that has no microphone and webcam, should atleast be able to hear and see the video of other peers.
Is it possible to do?
I tried this using constraints{audio: false, video: false} in regular webRTC and it works on a machine that has no microphone and webcam.
How to accomplish this using simpleWebRTC?
Thanks!
I am not familiar with simpleWebRTC, but I use PeerJS. To answer even if you don't have a webcam or mic, all I do is I answer with 'null' instead of the stream.
So in Peerjs instead of
call.answer(window.localStream);
you can say
call.answer(null);
Try to find the code in SimpleWebRTC where the call is made or answered and try this.

Using your own AMS, how can you use BitmapData.draw() on an RTMP stream with no security exception?

I've posted a similar question about the more general case, but this question deals specifically with RTMP.
We have an Adobe AIR app written in AS3 that can view live video streams from other parties. That being said, when trying to call BitmapData.draw() on one of those remote video streams (technically we're calling ImageSnapshot.captureImage()), we're getting a 2123 error - a security sandbox exception. I've seen a lot of people refer to a real simple configuration in the AMS that will allow this to work for RTMP streams, but they keep posting broken links, links to posts that only vaguely mention this configuration, etc. The one thing I did find is something that I'm having trouble applying:
http://help.adobe.com/en_US/FlashMediaServer/3.5_SS_ASD/WS5b3ccc516d4fbf351e63e3d11a11afc95e-7ec3.html#WS5b3ccc516d4fbf351e63e3d11a11afc95e-7fcb
To make the above work, I've tried setting audioSampleAccess and videoSampleAccess both to "/", but to no avail. On the AMS, in Application.xml, I've set these configurations:
<FolderAccess>true</FolderAccess>
<AudioSampleAccess enabled="true">*</AudioSampleAccess>
<VideoSampleAccess enabled="true">*</VideoSampleAccess>
I've also seen references to setting up a wide-open cross-domain policy file, but I've seen people emphasize that it's not necessary, and I don't see any clear mention of where on the server that policy file needs to be. I have, however, started setting NetStream.checkPolicyFile to true, and I have placed a cross-domain policy file in the root directory of the website itself (as opposed to the AMS).
Please don't just give me another link, unless it's to a quick, clear explanation. How do you configure the AMS to allow people to capture screenshots from RTMP video streams? For the above article, I've tried setting videoStreamAccess and audioStreamAccess both to "/", and even it didn't work. We also need to be able to do this for P2P RTMFP streams, but that's really a different question. Thanks.
I have following FMS code to fix that error in application.onConnect method:
client.videoSampleAccess = "/";
client.audioSampleAccess = "/";

simple video chat using as3

I'm trying to make a simple video chat using Flex framework and red5 server. It's an application with 2 video displays. With connection to the server more or less figured out. However, I do not understand how to transfer user1 stream to user2.
Here is functions i use to transfer webcam image to the server and to get the stream.
public function appendStream(connection:NetConnection):void {
myNetStream = new NetStream (connection);
myNetStream.attachAudio(cameraVideo.getMic());
myNetStream.attachCamera(cameraVideo.getCam());
myNetStream.publish("videochat" , "live");
}
public function getStream(connection:NetConnection):Video {
guestNetStream = new NetStream(connection);
video2.attachNetStream (guestNetStream);
guestNetStream.play("videochat");
return video2;
}
As you can see, i am getting my own stream.
Is it possible to solve the problem by flex, or I need programming on the server side?
You dont need separate rooms, simply use unique stream names for each client. The ez way is to create your steam names ahead of time and pass them to your swf via flashvars; that way you dont have to pair them with some other complicated scheme.
For a bit more background in red5, a room is a type of scope and a scope can contain other scopes which includes broadcast scopes, shared object scopes, and rooms. There is no limit on the number of these scopes other than the amount of RAM on the server itself.
You need to have two "rooms" instead of one "videochat". User1 must publish to "videochat1" and stream from "videochat2". Vice versa for user2.
And please remove Flex mention here since there's nothing related to Flex UI framework here

Adobe AIR, URLRequest, and local ports

I'm looking at writing an app with Adobe AIR, but I wanted to figure out if this is feasible with the platform first. (Mostly new to Flash and AIR)
What I would like to do is know ahead of time what local port a URLRequest will be using. If possible, I would like to hold a connection open even and keep using the same socket.
What I'm basically trying to accomplish is doing some NAT-Traversal and port negotiation ahead of time. Once I have both the client and the server negotiated, I'd like them to connect and basically use HTTP in a peer-to-peer way to stream media, like this sample:
var s = new air.Sound();
var url = "http://www.example.com/sounds/bigSound.mp3";
var req = new air.URLRequest(url);
var context = new air.SoundLoaderContext(8000, true);
s.load(req, context);
s.play();
The problem is that I don't see this happening unless I can get some information from AIR on what ports it's planning to use. I would be OK with creating my own Socket connections to the server and using them, but I would need a way to leverage the Sound framework to stream in the same way from a socket.
Ideas? Thoughts? Thanks!
Even if you managed to guess which port AIR is going to use on your device, it is not going to be very helpful, since there is a reasonably high probability that your NAT will translate it to another value IF your AIR device has a private IP address.
This issue does not happen if your AIR server has a public IP address. Most often, you can configure the server's NAT/Router to forward traffic as is. A port scan from the WAN will quickly tell you which port is used.
If you want to 'hijack' an outbound connection created by AIR itself, then you might try to have it contact a special server peer you have implemented which will forward traffic from and to it. Not simple, but possible. Basically you would collect holes punched in the NAT by the server.