Macromedia Flash Server - RE: Sample code with instructions for streaming

This is Interesting: Free IT Magazines  
Home > Archive > Macromedia Flash Server > April 2005 > RE: Sample code with instructions for streaming





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author RE: Sample code with instructions for streaming
Jake Hilton

2005-04-07, 5:45 pm

Your code would look something like this based on your current code to
send it to the flash com server:

****************************************
**************

for(i=0; i<camera.names.length; i++)
{
if( camera.names[i] == "TechSmith OEM Screen Video Capture
Driver" )
{
break;
}
}
localCamera = camera.get(i);
localVidInstance.attachVideo(localCamera);
localCamera.setMode(640, 480, 5, true);
localCamera.setQuality(0, 80);
localCamera.setKeyFrameInterval(50);
localCamera.setLoopback(true);
localVidInstance.attachVideo(localCamera);

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myServer.myDomain.com/appName/appInstance");
var src_ns:NetStream = new NetStream(my_nc);
src_ns.publish("streamName", "record");
src_ns.attachVideo(localCamera);

****************************************
**************

To play it back you'd do something like so:


****************************************
**************
var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://localhost/appName/appInstance");
var my_ns:NetStream = new NetStream(my_nc);
localVidInstance.attachVideo(my_ns);
my_ns.play("streamName");
****************************************
**************

To secure it so clients can't publish streams you'd have to set the
write permissions of each client that connects. You'd have to detect
whether they were connecting as an admin or a client. By default I'd set
write access to none in your server side script like so:


****************************************
**************
application.onConnect = function( newClient, userName ) {
if (userName == "admin") {
newClient.writeAccess="/";
} else {
newClient.writeAccess="";
}
application.acceptConnection( newClient );
}
****************************************
**************

Something like that. There are more complex/surefire ways to do it but
for your testing purposes that should work just fine.

Jake
[vbcol=seagreen]
Here is the code from the sample they (TechSmith) provide

// Find the index of the TSVC OEM video capture device
for(i=0; i<camera.names.length; i++)
{
if( camera.names[i] == "TechSmith OEM Screen Video Capture
Driver" )
{
break;
}
}
// Get a reference to the camera object
localCamera = camera.get(i);
localVidInstance.attachVideo(localCamera);

// Set the camera object width, height, and frame rate.
// Set the last parameter to true to maintain the requested capture
size and
frame rate.
localCamera.setMode(640, 480, 5, true);

// Set the quality and/or bandwidth for video sent to the Flash
Communication Server
// This example ensures a minimum quality of 80, no matter how much
bandwidth it takes
localCamera.setQuality(0, 80);

// Set the keyframe interval to a keyframe every 10 seconds at 5 fps.
localCamera.setKeyFrameInterval(50);

// Set the camera to display a preview of the compressed video so that
// we do not need Flash Communication Server for this sample.
localCamera.setLoopback(true);

// Start capturing video and displaying it in the Video object on the
stage
localVidInstance.attachVideo(localCamera);


This finds the camera and inputs it locally. What do I add to make it
so it
streams to my FCS and what do I creeate so others ONLY see the stream
and
not create one of their own? This is a test for desktop sharing.

Thanks

Bill


Date: Wed, 26 Jan 2005 09:06:16 -0700
From: "Jake Hilton" <jhilton-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [FlashComm] Sample code with instructions for steaming
video
To: <flashcomm-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org>
Message-ID: <s1f75d97.001-8P+T1FnozcXjI0KkKMLNxmG1Kmeyz0DC@public.gmane.org>
Content-Type: text/plain; charset=US-ASCII

Bill,
To test whether the video driver works you could implement this code:

var my_video:Video; //my_video is a Video object on the Stage
var active_cam:Camera = Camera.get();
my_video.attachVideo(active_cam);

You have to make sure you have a video object on the stage with the
instance name of my_video. In order to do this if you don't know... In
the title bar of your library on the very right there is a menu
button.
If you click that you can create a new video object in your library.
Once created drag that to your stage. Select it and in your properties
panel in the instance name input field put the name my_video. The
above
code will find the first camera attached to your computer.. in this
case
if the TechSmith Driver is the only video input device then it will
select that and display the output of that in the video object that
you
placed on your stage. So test your movie and viola. It should work. To
hook this up to a flash com server you could do the following:

var my_video:Video; //my_video is a Video object on the Stage
var active_cam:Camera = Camera.get();
my_video.attachVideo(active_cam);

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myServer.myDomain.com/appName/appInstance");
var src_ns:NetStream = new NetStream(my_nc);
src_ns.publish("stephen", "record");
src_ns.attachVideo(active_cam);

// To stop publishing and recording
src_ns.publish(false);

// To play the recorded stream
src_ns.play("stephen");

Hope that helps.

Jake
[vbcol=seagreen]
Does anyone have some sample code with instructions for streaming
local
video through FCS? I am looking for something along the lines of
"Streaming
video through FCS for dummies" I am NO flash pogrammer and I do not
want
to pull one of my programmers off of current projeccts for a simple
test. I
have looked through the
http://www.flashcomguru.com/tutorials/camtasia.cfm
samle but it does not show me the FCS setup. Soimething with sample
code
where I can just change the FCS address wouyld be great!
I will be using the TechSmith OEM Screen Video Capture Driver v1.0.0
beta 1
for the local capture if it makes a difference.

Thank you
Bill Hoover



=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com