Click here to Skip to main content
11,645,893 members (72,066 online)
Click here to Skip to main content

Your First Step to the Silverlight Voice/Video Chatting Client/Server

, 15 Dec 2013 CPOL 215K 22.6K 187
Rate this:
Please Sign up or sign in to vote.
What you should to do to create your own Silverlight Voice/Video chatting system
SocketCoderDesktopPresenter

Introduction

Comparing with the Adobe Flash Player, Microsoft has provided the first step to support the live voice/video chatting through the web By Supports dealing with the Microphone and the Camera in Silverlight 4. Yes it was a great step but still not enough, there is more of a problem that is still unresolved, and as a programmer you have to rely on yourself to make your own programming solutions if you decided to go ahead with working on Silverlight techniques to create your own live voice/video chatting software. It can be summarized as follows:

  1. There isn't any Managed Library for coding/decoding the Video/Audio data for compression to be suitable to send it via the Internet, comparing with Adobe technologies it supports dealing with the H.263 and H.264 to compress the audio and Video on high resolution, unfortunately it's still not available in Silverlight4.
  2. There isn't any support for the real time transport protocols, such as RTP. Therefore you just have two options, either through using the transport protocol TCP or UDP, or to program your own real time transport protocol. Comparing with Adobe, it supports transport through a custom protocol for this purpose in the RTMP.
  3. There isn't any real streaming server For Live Video/Audio streaming directly from Silverlight to the Media Server and from the media server to Silverlight clients, so you only have two solutions. You have to either use Microsoft Windows Media Server or use the Smooth Streaming through IIS, and will thus be obliged to renounce Silverlight, because Silverlight does not support dealing with these servers for sending and the only solution is also to create your own server. Compared to Adobe, they have a great product which is The Flash Media Server that deals perfectly with the Flash player.

Background

In general, all Voice/Video Chatting Systems must go through these phases:

  1. Connecting with a camera and/or microphone and then returning the output as Binary Data, then converting it to Bytes to make it easier to deal for the next step.
  2. The data will be returned as a Raw Format, therefore its size would be too large so we need first to code it into a compressed format. For example, coding the captured image into a JPEG format as well as the voice data can turn into a Wave Format or compress it into any well-known audio compression format such as G.711 ,GSM, speex or any other format standard. Also we can integrate the video/voice together using a special standard such as H.263 or H.264. This step is the most important thing we would be doing, it simply will determine the bandwidth requirements of your chatting system.
  3. Sending the compressed data using one of both transport protocols TCP, UDP or RTP/UDP transport protocol and this step is also important as it depends on the importance of data quality that is transferred on the one hand and the importance of the transfer in Real Time on the other hand. The goal of any system is to transfer the data in real time and in the best quality as possible.
  4. Receiving the sent data through the Server has specific functions depending on what you want from the application, as an example in the chatting software. The received data on the server side should send it back to the connected clients in the chat room. Usually if the software is working on the internet and if the clients are behind a NAT, the Server should be on a Public IP. Fortunately the Socket in Silverlight supports this process without any problem as you will see in this article.
  5. The Client would receive the data as a compressed format, so we need to decode it first and then display it on an output device.

Using the Code

The above phases can be achieved in the following steps:

On the client side:

  1. To know how to access into the Microphone and the Camera, check this video.
  2. To Know how to decode the captured image into JPEG format, check this article and this one.
  3. To know how to record the voice from the microphone and then play it back into the speakers using the AudioSink and The MediaElement Classes in Silverlight. Check these articles:
    1. Record The Audio Into A Wave File
    2. Playback The Wave File in Silverlight
    3. Using the G.711 Codec
  4. To Know how to use the Socket in Silverlight, check this video and also a good video for Network Authentication and Trusted Network Access here.

On the server side:

In our case, the server should do the following processes:

  1. Allowing the clients to communicate with the server - to do this in Silverlight, you should create a policy service on the server side on port 943 to grant the clients access on the server domain. To achieve this, create an XML file that contains below to allow using the TCP port 4530 and the all domains URI on the server as an example:
    <?xml version="1.0" encoding ="utf-8"?> 
    <access-policy> 
    <cross-domain-access> 
    <policy> 
    <allow-from> 
    <domain uri="*" /> 
    </allow-from> 
    <grant-to> 
    <socket-resource port="4530" protocol="tcp" /> 
    </grant-to> 
    </policy> 
    </cross-domain-access> 
    </access-policy> 

    Then create a socket to grant access on port 943 as a default port for the policy service in Silverlight: (Please check the PolicyService.cs class that is attached with the article samples.)

  2. Receiving the Client request and adding the client socket to an Array List - after that, the server should receive the client data (Audio or Video data), then send it to all the connected clients using the Socket Array List that we created as an example. (Please Check the SocketCoderBinaryServer.cs class that is attached with the article samples.)

Finally

The client and the server should do more than this but as a starting point, this will be very useful to get you through the beginning of network programming in Silverlight to create your own client/server voice/video chatting system.

References

  1. SocketCoder.Com, to download the last update of the Silverlight 4 Web Conferencing Project:
    1. Module 1: Silverlight 4 Voice Chat Sample: http://socketcoder.com/ArticleFile.aspx?index=2&ArticleID=70
    2. Module 2: Silverlight 4 WebCam Conferencing Sample: http://socketcoder.com/ArticleFile.aspx?index=2&ArticleID=68
    3. Module 3: Silverlight 4 Desktop Presenter Sample: http://socketcoder.com/ArticleFile.aspx?index=2&ArticleID=69
  2. Silverlight.NET http://www.silverlight.net/
  3. Microsoft MSDN

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Fadi Abdelqader
Systems Engineer SocketCoder.Com
Jordan Jordan
Fadi Abdelqader
WebSite: http://www.SocketCoder.com
Facebook Group: http://www.facebook.com/groups/socketcoder/
Facebook Page: http://www.facebook.com/socketcoders/

Last Published Book:
-Professional Network, Distributed Systems & TCP/IP Programming In .NET Framework 1.1 & 2.0 (2006 Release)

Last Published eBook:
- The SocketCoder e-Reference For Network, Distributed Systems And TCP/IP Programming In .NET, Arabic (SocketCoder.Com 2010)

Last Projects:
- Silverlight Based Projects For Web Video Conferencing (WCS,WMS,WCS Plus..) www.Socketlab.com
-(SocketCoder) RTP Multicasting VOIP Library
-(SocketCoder) Remote Controlling Systems

Last SocketCoder RSS: http://www.socketcoder.com/feed/

You may also be interested in...

Comments and Discussions

 
Bugvoice chat hangs on exit, anyone else noticed it? Pin
card116-Jun-15 15:23
membercard116-Jun-15 15:23 
Questionimpliment peer to peer conference system in c# Pin
roddam harini23-Mar-15 21:57
memberroddam harini23-Mar-15 21:57 
QuestionHow to test the Application in pc.. tel me please it's urgent ... Pin
Member 99971163-Jun-14 2:34
memberMember 99971163-Jun-14 2:34 
QuestionGetting error in video chat Module downloded from code plex Pin
Member 1048833026-Dec-13 19:43
memberMember 1048833026-Dec-13 19:43 
QuestionThis is NOT FREE and NOT OPEN SOURCE! Pin
BillChi14-Dec-13 20:01
memberBillChi14-Dec-13 20:01 
AnswerRe: This is NOT FREE and NOT OPEN SOURCE! Pin
Fadi Abdelqader15-Dec-13 21:04
memberFadi Abdelqader15-Dec-13 21:04 
GeneralMy vote of 5 Pin
Renju Vinod18-Apr-13 2:26
memberRenju Vinod18-Apr-13 2:26 
QuestionHow To Run?Please help.!! Pin
Member 998633113-Apr-13 19:29
memberMember 998633113-Apr-13 19:29 
GeneralVideo compression algorithm Pin
uthayanathan3-Apr-13 21:48
memberuthayanathan3-Apr-13 21:48 
QuestionHow to run video and voice module at the same time Pin
uthayanathan12-Mar-13 5:25
memberuthayanathan12-Mar-13 5:25 
QuestionNeed help regarding desktop sharing Pin
Tridip Bhattacharjee1-Dec-12 7:59
memberTridip Bhattacharjee1-Dec-12 7:59 
Questionhow to use it in web application or how to run Pin
Member 957667130-Nov-12 6:36
memberMember 957667130-Nov-12 6:36 
Questionwork on internet???? Pin
aggarwal.saurabh20-Aug-12 6:01
memberaggarwal.saurabh20-Aug-12 6:01 
QuestionRe: work on internet???? Pin
bubifengyun17-Dec-12 2:57
memberbubifengyun17-Dec-12 2:57 
QuestionHow can I record video stream into wmv format with silverlight Pin
shlomigadold3-Jul-12 3:28
membershlomigadold3-Jul-12 3:28 
QuestionDo you have the speex project for winform? Pin
LancerEx29-Mar-12 22:34
memberLancerEx29-Mar-12 22:34 
QuestionHow this is going to work Pin
satish.madugunud29-Mar-12 1:12
membersatish.madugunud29-Mar-12 1:12 
Hi
I downloaded this silverlight voice/video chatting source and I executed in my local machine.
when it comes to the browser then it is showing one small popup with title as "conect to the video chat service" and current connection status is offline and asking to enter nickname.
I entered some nick name but is saying connection failed and not able to do any action on the page.
could you please explain it how it works and functionality.
Questionthree modules of voice, video ,desktop presenter... Pin
Member 817549328-Mar-12 23:23
memberMember 817549328-Mar-12 23:23 
QuestionSilverlight SDK Pin
WilsonLast19-Mar-12 4:08
memberWilsonLast19-Mar-12 4:08 
QuestionWhich ip required to connect on server when we going to live this application ..? Pin
kiran_pal5-Jan-12 22:36
memberkiran_pal5-Jan-12 22:36 
AnswerRe: Which ip required to connect on server when we going to live this application ..? Pin
YakudzaBY12-Mar-12 4:07
memberYakudzaBY12-Mar-12 4:07 
QuestionWhat are requirements for upload on internet(server host) ???for make it working fine ... Pin
kiran_pal2-Jan-12 1:42
memberkiran_pal2-Jan-12 1:42 
Questionthanks Pin
muhamd yusuf4-Dec-11 21:15
membermuhamd yusuf4-Dec-11 21:15 
QuestionClient with RTP and H264 encoding Pin
securigy224-Nov-11 21:52
membersecurigy224-Nov-11 21:52 
QuestionMultiple Client sending vidio and every client receve all vidioes Pin
Marwa-200816-Nov-11 20:47
memberMarwa-200816-Nov-11 20:47 
GeneralMy vote of 4 Pin
hardiksoni889-Nov-11 1:51
memberhardiksoni889-Nov-11 1:51 
QuestionHow to test it on the one PC? Pin
coder13pp5-Jul-11 3:05
membercoder13pp5-Jul-11 3:05 
AnswerRe: How to test it on the one PC? Pin
YakudzaBY12-Mar-12 4:09
memberYakudzaBY12-Mar-12 4:09 
QuestionProblems with voice and video Pin
coder13pp4-Jul-11 10:05
membercoder13pp4-Jul-11 10:05 
AnswerRe: Problems with voice and video Pin
Fadi Abdelqader4-Jul-11 20:01
memberFadi Abdelqader4-Jul-11 20:01 
GeneralRe: Problems with voice and video Pin
coder13pp5-Jul-11 2:54
membercoder13pp5-Jul-11 2:54 
GeneralHow to make it work on internet? [modified] Pin
Yash Ganthe7-May-11 23:07
memberYash Ganthe7-May-11 23:07 
GeneralRe: How to make it work on internet? Pin
Fadi Abdelqader4-Jul-11 20:06
memberFadi Abdelqader4-Jul-11 20:06 
GeneralWHO HAD THE PROJECT GO???? Pin
costinbogdan20-Apr-11 4:28
membercostinbogdan20-Apr-11 4:28 
GeneralRe: WHO HAD THE PROJECT GO???? Pin
Fadi Abdelqader4-Jul-11 20:08
memberFadi Abdelqader4-Jul-11 20:08 
Generalserver module Pin
Member 769831612-Apr-11 22:42
memberMember 769831612-Apr-11 22:42 
GeneralRe: server module Pin
Fadi Abdelqader4-Jul-11 20:13
memberFadi Abdelqader4-Jul-11 20:13 
GeneralPLS help me Pin
costinbogdan12-Apr-11 1:31
membercostinbogdan12-Apr-11 1:31 
GeneralRe: PLS help me Pin
Fadi Abdelqader4-Jul-11 20:17
memberFadi Abdelqader4-Jul-11 20:17 
Generaltraffic Pin
hamada el3ashe213-Mar-11 5:30
memberhamada el3ashe213-Mar-11 5:30 
AnswerRe: traffic Pin
Fadi Abdelqader13-Mar-11 10:33
memberFadi Abdelqader13-Mar-11 10:33 
Generalrecord Pin
samathu7-Mar-11 19:35
membersamathu7-Mar-11 19:35 
QuestionUPD Pin
kemaltolga22-Feb-11 13:25
memberkemaltolga22-Feb-11 13:25 
AnswerRe: UPD Pin
Fadi Abdelqader13-Mar-11 10:23
memberFadi Abdelqader13-Mar-11 10:23 
GeneralSpeex Problem Pin
lordlondon13-Feb-11 10:10
memberlordlondon13-Feb-11 10:10 
GeneralRe: Speex Problem Pin
Fadi Abdelqader13-Feb-11 23:54
memberFadi Abdelqader13-Feb-11 23:54 
GeneralMy vote of 5 Pin
Espen Harlinn6-Feb-11 5:50
memberEspen Harlinn6-Feb-11 5:50 
QuestionHow to Pin
bgeerdes11-Jan-11 8:20
memberbgeerdes11-Jan-11 8:20 
NewsNew Versions For Both The Free Modules and the Professional WCS Pin
Fadi Abdelqader15-Dec-10 11:47
memberFadi Abdelqader15-Dec-10 11:47 
Generalvideo / audio compression Pin
engghada20-Nov-10 23:55
memberengghada20-Nov-10 23:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150731.1 | Last Updated 16 Dec 2013
Article Copyright 2010 by Fadi Abdelqader
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid