Tel.: 00 36 52 532 731

Did you know?

This SDK was used to build:

Ozeki Phone System XE - VoIP PBX Software for Developers Which is a high performance PBX system supporting Mobile and Desktop phones.

It was also used to create Ozeki 3D VoIP softphone. A cool SIP client that allows 3D Video calls.

How to record a voice call (mixing and recording incoming and outgoing audio)




This article is a detailed guide about recording incoming and outgoing voice calls in relation with Ozeki VoIP SIP SDK. After reading through this page you will be fully familiar with all the essential terms concerning voice call recording and what you will need for creating your own solution using Ozeki VoIP SIP SDK.


In Voice over IP model the communication is made through the Internet Protocol and the data that is sent between the two end points is digitized. This data can be recorded and saved in audio files if needed (Figure 1).

Figure 1 - VoIP call recording

VoIP phone calls allow voice call recording in more than one ways. You can record only one of the clients' voice, or record both into separate files or even record them into one mixed file. This last solution makes the most sense, of course.

The following program code uses the background support of Ozeki VoIP SIP SDK, therefore you will need to download and install the SDK on your computer before starting to use the program code. You will also need to have Visual Studio 2010 or compatible IDE and .NET Framework installed on your system, as the program code below is written in C# language.

The call recording is an easy task with Ozeki VoIP SIP SDK even if you need to record both the incoming and the outgoing voices. You only need to extend your softphone application with some extra tools and the recording can be done automatically when you make a call (Code 1).

You can record audio streams into .wav audio files, and for this purpose you will need a WaveStreamRecorder media handler object. If you want to record both parties' voice in one file, you will also need an AudioMixerMediaHandler that will mix the incoming and the outgoing voices.

The two extra strings are used for the .wav file name during the recording. The filename specifies the .wav file's name that will be the parameter for the recorder's constructor.

WaveStreamRecorder recorder;
AudioMixerMediaHandler mixer = new AudioMixerMediaHandler();

string filename;
string caller;

Code 1 - Tools for the voice recording

The file name for the recording will start with the caller string that will be the dialed number in the case of an outgoing call (Code 2). This instruction is needed to put into the Pick Up button's event handler that starts the outgoing call.

caller = DialedNumber.Text;

Code 2 - The caller initialization in case of an outgoing call

In the case of an incoming call, the caller will store the displayed name of the actual caller. This string is only used for specifying the recorded file's name (Code 3).

private void softPhone_IncomingCall(object sender, VoIPEventArgs<IPhoneCall> e)
    InvokeGUIThread(() =>
        RegistrationState.Text = "Incoming call";
        DialedNumber.Text = String.Format("from {0}", e.Item.DialInfo);
        caller = e.Item.DialInfo.DisplayName;

Code 3 - The caller initialization in case of an incoming call

The recording needs to be established when the call state becomes InCall (Code 4). In this case the recorder needs to be initialized with the filename that will consist of the caller string and the hour, minute and second information of the current time. This file naming convention is necessary for securing the unique file names, as you do not want to overwrite the recorded files.

As only the file name is specified, the .wav file will be stored in the same folder as the .exe of the application. If you want to save it somewhere else, you can specify the file path. The recorder needs to be subscribed for the stopped event too.

The recording will be perfect, if you make the following connections during the establishment. You need to connect the microphone and the mediaReceiver objects to the mixer. This will ensure that the two audio streams will be mixed. Then you need to connect the mixer to the recorder that will record the mixed audio stream into the file specified by the filename parameter.

When all the other connections and attachments are set, you need to start the recording by calling the recorder.StartStreaming() method.

case CallState.InCall:
    connector.Connect(microphone, mediaSender);

    filename = caller + "-" + DateTime.Now.Hour.ToString()+"-"+ DateTime.Now.Minute.ToString()+"-"+DateTime.Now.Second.ToString()+".wav";
    recorder = new WaveStreamRecorder(filename);
    recorder.Stopped += RecorderStopped;

    connector.Connect(microphone, mixer);
    connector.Connect(mediaReceiver, mixer);
    connector.Connect(mixer, recorder);

    connector.Connect(mediaReceiver, speaker);


    recorder.IsStreaming = true;


Code 4 - MediaHandler initialization and connection

When the call ends, the recording also needs to stop and the media handlers needs to be disconnected like it can be seen in Code 5.

case CallState.Completed:
    recorder.IsStreaming = false;

    connector.Disconnect(microphone, mixer);
    connector.Disconnect(mediaReceiver, mixer);
    connector.Disconnect(mixer, recorder);

Code 5 - Stop recording when the call ends

The WaveStreamRecorder object needs to be subscribed for the stopped event that is hadled in the following methods in Code 6.

void WaveStreamRecorder_Stopped(object sender, EventArgs e)
    if (RecorderStopped != null)
        RecorderStopped(this, EventArgs.Empty);

public event EventHandler<EventArgs> RecorderStopped;

Code 6 - Event handler for the record stop

As this example program records all the calls you make with it, it is suggested to show a pop-up window to inform the user about this fact. This window will appear every time you press the Pick Up button in case of accepting an incoming call and in the case of starting an outgoing one too.

private void PickUp_Click(object sender, EventArgs e)
            MessageBox.Show("Please note, that all your calls made by this softphone will be recorded.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

Code 7 - Information about the recording

This example program briefly demonstrated how you can record a voice call by mixing the incoming and outgoing voices together. You can use this code to extend your softphone applications with voice recording support or you can invent it further the way you want to use voice recording.

This article introduced you the basic knowledge about recording voice calls and showed how Ozeki VoIP SIP SDK can help you to fulfill your wishes about this topic. If you have read through this page carefully, you already have all the knowledge you need to start on your own solution.

As you are now familiar with all the terms concerning this topic, now it is time to take a step further and explore what other extraordinary solution Ozeki VoIP SIP SDK can provide to you.

If you have any questions or need assistance, please contact us at

You can select a suitable Ozeki VoIP SIP SDK license for your project on Pricing and licensing information page

Related Pages

Operating system: Windows 8, Windows 7, Vista, 200x, XP
Development environment: Visual Studio 2010 (Recommended), Visual Studio 2008, Visual Studio 2005
Programming language: C#.NET
Supported .NET framework: .NET Framework 4.5, .NET Framework 4.0, .NET Framework 3.5 SP1
Software development kit: OZEKI VoIP SIP SDK (Download)
VoIP connection: 1 SIP account
System memory: 512 MB+
Free disk space: 100 MB+