Ads are not an endorsement by the blog author.

aimInfo

Public Journal
 Back to Journal Archives | Subscribe to Alerts Alerts Subscribe to Alerts | Feeds
< New AIM Music Lin
Tuesday, August 28, 2007
Snag Exp(ression) >
Monday, September 10, 2007
August 2007
Thursday, August 30, 2007

Build your own AV Client

A few weeks ago I was trying to analyze some issues in our audio and video code.  I decided that while we have great test tools, it would be interesting to write a managed code AIM client that only did audio and video.  The idea was this client could be used to isolate issues like memory allocation and performance.  Writing this client is actually easy thanks to Open AIM.  I am attaching the actual c-sharp file so everyone can look at or even copy and paste the code.  But I will also go over the basic steps to create this client or for that matter any c-sharp client.  Download the full code here.

1) Start Visual Studio and create a c-sharp command line project (test tools are easier as command line projects, though you can create a full ui client too.)

2) Import the acccore.dll so you can create the main AIM session object.:
        [DllImport("acccore.dll", EntryPoint="#111", PreserveSig=false)]
        private static extern void AccCreateSession(
            [MarshalAs(UnmanagedType.LPStruct)] Guid riid,
            [MarshalAs(UnmanagedType.IDispatch)] out object session);   

3) Create the main AIM session, pass in your developer key and sign on to AIM:
                object o;
                AccCreateSession(typeof(IAccSession).GUID, out o);               
                s = (AccSession)o;
          s.ClientInfo.set_Property(AccClientInfoProp.AccClientInfoProp_Description,
                    "client name (key=KEY GOES HERE)");
                s.Identity = username;
                s.SignOn(password);   

4 ) Add a command listener to capture the commands being typed in at the command prompt.  See class InputEvent for implementation details.

5) Start an audio session:
                if (m_avManager == null)
                    m_avManager = (IAccAvManager)s.GetSecondaryManager((int)AccSecondarySessionServiceId.AccSecondarySessionServiceId_AudioVideo);
                m_avSession = m_avManager.CreateSession(userName, 0);

6) Quit an audio session:
                    if (state != AccSecondarySessionState.AccSecondarySessionState_Offline)
                        m_avSession.EndSession();
                    m_avSession = null;

Those are the basics.  Handling a multiparty audio session or peer-to-peer video is just as easy as repeating steps 5 and 6 for those types.  The sample also shows how to implement events for session state or even how to handle, monitor and select input and output devices.  We have made audio and video very powerful and yet very simple to implement.  Give the code a glance and try implementing a client like this yourself.  You might find it fun and useful.


gregsblog at 2:44:00 PM EDT Blog about this entry
This entry has 6 comments: (Add your own) Show all comments (1 more)