Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Raydash video chat service allows you to easily use video chat in Ruby on Rails

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
ChangeLog
Gemfile
Rakefile
Readme
raydash.gemspec

Readme

== Introduction

Raydash allows you to easily integrate live video and/or audio into your
Rails applications. You will need a userid and secret to access Raydash's servers. This can be obtained by signing up for the beta at http://www.raydash.com. Next, you will follow the instructions below. You will be using helpers to embed videostream and videorecord flash objects into your application for playing and recording real-time audio and/or video.

== Quickstart

1) Add the following to your Gemfile:

   gem "raydash", :git => 'git://github.com/gersh/Raydash-Ruby-on-Rails.git'

2) Configure your project your userid and secret with the following command:

   rails g raydash:install [user] [token]

This will generate the required configuration files to use Raydash

3) You now need to generate a model, which will call the Raydash API
to generate tokens for your video streams. Optionally, you can create
your own model, and call the API directly, but a generator is provided
to make this easier. You can invoke the generator by calling

   rails g raydash:model [modelname]

This model will represent a token. Each token can be used for both a
record and playback stream control. 

4) Create a controller for your app. For example, if you name the
named the model 'video' you can create a new video with:

      def index()
          @video = Video.new()
          @video.save() 
      end           

5) Add the proper header information to your layout. Often, this is
app/views/layouts/application.html.erb. You will need add the
following into the header:

          <%= raydash_header %>
6) Create a view to display the video. You will utilize two helpers
provided by raydash: 'videostream' and 'videorecord'. These will embed
a streaming ability, and a recording ability respectively. 

A sample view might look like:
  
        <%= videostream(@video.token,"video_in") %>
        <%= videorecord(@video.token,"video_out") %>

In this sample, @video.token specifies the token we are connecting to,
and "video_in" and "video_out" are div ids. 


7) Assuming you have configured the necessary routes (E.X adding:
            match '/YOUR_CONTROLLER' => 'YOUR_CONTROLLER#index'
to routes 'routes.rb', you should be
able to load the page, and enable your camera. The streaming
capabilities will also be enabled but the stream isn't connect to
anything.

8) You can connect arbitrary tokens. This all handled on the
server-end, and it can be done in real-time. So, create a new
controller function such as:

          def connect_to()
              video=Model.find(params[:id1])
	      otherVideo=Video.find(params[:id2])
              video.point_to(otherVideo.token)
          end

          with route
          '/videos/route/:id1/:id2' => 'YOUR_CONTROLLER#connect_to'

When connect_to is called, it will point on stream at another stream

== Helpers
These can be used within any view you use the Raydash gem.
=== raydash_header()
Generates the html for the header to include necessary javascript files to use raydash
=== videostream(token,id,height="640",width="480",videoOff="0")
Adds an flash element that plays video and sound

- token The token for the stream. You can generate a new token with Raydash.getToken(), or it is done automatically in models generated with "rails g raydash:model". 
- id The div id for use within the HTML. This can be useful for interacting with the javascript API
- height The height of the videostream
- width The width of the videostream
- videoOff if "1", it will hide the video, and only stream audio.
=== videorecord(token,id,height="640",width="480",hideCamera="0")
Adds a flash element to record and send to the server video and sound

- token The token for the stream. You can generate a new with Raydash.getToken(), or it is done automatically in models generated with "rails g raydash:model".
- id The div id for use within the HTML. This can be useful for interacting with the javascript API
- height The height of videorecord
- width The width of videorecord
- hideCamera if "1", it will hide the camera. This is useful is you don't want to show the camera
- videoOff if "1", it will only stream audio.

== Javascript API
Generally, most functionality should be performed via the backend API. However, there is a Javascript API for working with the flash elements for certain purposes. You can call these elements by using document.getElementById("id"), where id is the id you specify when you add the element to your page 
=== Videostream
==== play()
If you aren't currently playing the stream, start playing. Generally, the stream auto-starts when you load the page in your web browser, so it is unneccessary to use this
==== stop()
Stop playing any stream. Note: It is often preferrable to use changeStream in the backend API to switch to a black stream. There is a special token, "dummyblack" on the server for this purpose 
=== Videorecord
==== play()
If you aren't currently recording the stream, it starts recording. Generally, the recording auto-starts when you load the page in your web browser, so it is unneccessary to use this
==== stop()
Totally stops all recording.
==== changeResolution(width,height)
Changes the resolution and size of the video recording
-width The new width
-height The new height

== Backend-API library

=== Raydash.getToken(streamName="")
This function gets a token. A token is needed for every recording or
viewing video box in the application. 

streamName is an optional parameter that is another token created with
this function. If specified, the display stream will show the stream
from the call of that function


=== Raydash.changeStream(output_token, input_token)
The function re-points where a token is streaming from. We can
dynamically change where any stream is pointing, dynamically. You can point to the input_token "dummyblack" to make the window totally black.

output_token is the name of the token we are streaming to. If we have
a video stream initialized with this token, if will immediately start
displaying content from the input_token.

input_token refers to a videorecord that has been initialized with its stream
 
=== Raydash.getStreamInfo(token)
Returns a hash-array with information about the token. 
	 
Something went wrong with that request. Please try again.