[sip-comm-dev] Audio recording of SIP calls


#1

i think this may help u........

Writing captured audio to a file with a DataSink.

You can write captured media data to a Þle using a DataSink. To capture
and store audio data, you need to:
1. Get a CaptureDeviceInfo object for the audio capture device.
2. Create a Processor using the MediaLocator retrieved from the Capture-
DeviceInfo object.
3. Get the output DataSource from the Processor.
4. Create a MediaLocator for the file where you want to write the captured
data.
5. Create a file writer DataSink using the output DataSource.
6. Start the file writer and the Processor.

CaptureDeviceInfo di = null;
Processor p = null;
StateHelper sh = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new
AudioFormat(AudioFormat.LINEAR, 44100, 16, 2));
if (deviceList.size() > 0)
di = (CaptureDeviceInfo)deviceList.firstElement();
else
// Exit if we can't find a device that does linear,
// 44100Hz, 16 bit,
// stereo audio.
System.exit(-1);
try {
p = Manager.createProcessor(di.getLocator());
sh = new StateHelper(p);
} catch (IOException e) {
System.exit(-1);
} catch (NoProcessorException e) {
System.exit(-1);
}
// Configure the processor
if (!sh.configure(10000))
System.exit(-1);
// Set the output content type and realize the processor
p.setContentDescriptor(new
FileTypeDescriptor(FileTypeDescriptor.WAVE));
if (!sh.realize(10000))
System.exit(-1);
// get the output of the processor
DataSource source = p.getDataOutput();
// create a File protocol MediaLocator with the location of the
// file to which the data is to be written
MediaLocator dest = new MediaLocator("file://foo.wav");
// create a datasink to do the file writing & open the sink to
// make sure we can write to it.
DataSink filewriter = null;
try {
filewriter = Manager.createDataSink(source, dest);
filewriter.open();
} catch (NoDataSinkException e) {
System.exit(-1);
} catch (IOException e) {
System.exit(-1);
} catch (SecurityException e) {
System.exit(-1);
}
// if the Processor implements StreamWriterControl, we can
// call setStreamSizeLimit
// to set a limit on the size of the file that is written.
StreamWriterControl swc = (StreamWriterControl)
p.getControl("javax.media.control.StreamWriterControl");
//set limit to 5MB
if (swc != null)
swc.setStreamSizeLimit(5000000);
// now start the filewriter and processor
try {
filewriter.start();
} catch (IOException e) {
System.exit(-1);
}
// Capture for 5 seconds
sh.playToEndOfMedia(5000);
sh.close();
// Wait for an EndOfStream from the DataSink and close it...
filewriter.close();

Regards,
Rohan

···

On Wed, Oct 1, 2008 at 7:52 AM, Truls Samuelsen <truls.samuelsen@losmail.no>wrote:

Any suggestions on how to implement audiorecording of SIP Calls.

I would typically be a button in the callpanel that start recording to a
file when pressed.

Has anybody done something like this?


#2

Rohan Solanki wrote:

This is the correct code and is actually in SC already but in a the unsupported mailbox bundle.

The mailbox bundle already does this, basically you have to create a datasink object. You have to uncomment mailbox in the default config to get it to work. This is unsupported code now and I believe it had a couple of small bugs in finding image resources. If you have it right it appears as a taperecorder icon in the configuration menu.

I would like to record a call at the same time that I am talking. I think that was what the original poster wants as well. To do this in JMF you need to clone the datasource, splitting the input stream into a datasink and a player. Has anyone done this yet? Its on my todo list for the project I am working on.

Kim

···

i think this may help u........

Writing captured audio to a file with a DataSink.

You can write captured media data to a �le using a DataSink. To capture
and store audio data, you need to:
1. Get a CaptureDeviceInfo object for the audio capture device.
2. Create a Processor using the MediaLocator retrieved from the Capture-
DeviceInfo object.
3. Get the output DataSource from the Processor.
4. Create a MediaLocator for the file where you want to write the captured
data.
5. Create a file writer DataSink using the output DataSource.
6. Start the file writer and the Processor.

CaptureDeviceInfo di = null;
Processor p = null;
StateHelper sh = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new
AudioFormat(AudioFormat.LINEAR, 44100, 16, 2));
if (deviceList.size() > 0)
di = (CaptureDeviceInfo)deviceList.firstElement();
else
// Exit if we can't find a device that does linear,
// 44100Hz, 16 bit,
// stereo audio.
System.exit(-1);
try {
p = Manager.createProcessor(di.getLocator());
sh = new StateHelper(p);
} catch (IOException e) {
System.exit(-1);
} catch (NoProcessorException e) {
System.exit(-1);
}
// Configure the processor
if (!sh.configure(10000))
System.exit(-1);
// Set the output content type and realize the processor
p.setContentDescriptor(new
FileTypeDescriptor(FileTypeDescriptor.WAVE));
if (!sh.realize(10000))
System.exit(-1);
// get the output of the processor
DataSource source = p.getDataOutput();
// create a File protocol MediaLocator with the location of the
// file to which the data is to be written
MediaLocator dest = new MediaLocator("file://foo.wav");
// create a datasink to do the file writing & open the sink to
// make sure we can write to it.
DataSink filewriter = null;
try {
filewriter = Manager.createDataSink(source, dest);
filewriter.open();
} catch (NoDataSinkException e) {
System.exit(-1);
} catch (IOException e) {
System.exit(-1);
} catch (SecurityException e) {
System.exit(-1);
}
// if the Processor implements StreamWriterControl, we can
// call setStreamSizeLimit
// to set a limit on the size of the file that is written.
StreamWriterControl swc = (StreamWriterControl)
p.getControl("javax.media.control.StreamWriterControl");
//set limit to 5MB
if (swc != null)
swc.setStreamSizeLimit(5000000);
// now start the filewriter and processor
try {
filewriter.start();
} catch (IOException e) {
System.exit(-1);
}
// Capture for 5 seconds
sh.playToEndOfMedia(5000);
sh.close();
// Wait for an EndOfStream from the DataSink and close it...
filewriter.close();

Regards,
Rohan

On Wed, Oct 1, 2008 at 7:52 AM, Truls Samuelsen > <truls.samuelsen@losmail.no <mailto:truls.samuelsen@losmail.no>> wrote:

    Any suggestions on how to implement audiorecording of SIP Calls.

    I would typically be a button in the callpanel that start
    recording to a file when pressed.

    Has anybody done something like this?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Hi Roland / Kim

Roland is describing my problem. I want to record at the same time as I
speak.

I know I have to split the datasource but I cannot figure out how.

I'm kind of new in programming JMF.

Truls

-----Opprinnelig melding-----

Hr Truls Samuelsen.vcf (3.71 KB)

···

Fra: Kim Michael Fairchild [mailto:ting4@ljade.com]
Sendt: 4. oktober 2008 00:15
Til: dev@sip-communicator.dev.java.net
Emne: Re: [sip-comm-dev] Audio recording of SIP calls

Rohan Solanki wrote:

This is the correct code and is actually in SC already but in a the
unsupported mailbox bundle.

The mailbox bundle already does this, basically you have to create a
datasink object. You have to uncomment mailbox in the default config to
get it to work. This is unsupported code now and I believe it had a
couple of small bugs in finding image resources. If you have it right it
appears as a taperecorder icon in the configuration menu.

I would like to record a call at the same time that I am talking. I
think that was what the original poster wants as well. To do this in JMF
you need to clone the datasource, splitting the input stream into a
datasink and a player. Has anyone done this yet? Its on my todo list
for the project I am working on.

Kim

i think this may help u........

Writing captured audio to a file with a DataSink.

You can write captured media data to a Þle using a DataSink. To capture
and store audio data, you need to:
1. Get a CaptureDeviceInfo object for the audio capture device.
2. Create a Processor using the MediaLocator retrieved from the Capture-
DeviceInfo object.
3. Get the output DataSource from the Processor.
4. Create a MediaLocator for the file where you want to write the captured
data.
5. Create a file writer DataSink using the output DataSource.
6. Start the file writer and the Processor.

CaptureDeviceInfo di = null;
Processor p = null;
StateHelper sh = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new
AudioFormat(AudioFormat.LINEAR, 44100, 16, 2));
if (deviceList.size() > 0)
di = (CaptureDeviceInfo)deviceList.firstElement();
else
// Exit if we can't find a device that does linear,
// 44100Hz, 16 bit,
// stereo audio.
System.exit(-1);
try {
p = Manager.createProcessor(di.getLocator());
sh = new StateHelper(p);
} catch (IOException e) {
System.exit(-1);
} catch (NoProcessorException e) {
System.exit(-1);
}
// Configure the processor
if (!sh.configure(10000))
System.exit(-1);
// Set the output content type and realize the processor
p.setContentDescriptor(new
FileTypeDescriptor(FileTypeDescriptor.WAVE));
if (!sh.realize(10000))
System.exit(-1);
// get the output of the processor
DataSource source = p.getDataOutput();
// create a File protocol MediaLocator with the location of the
// file to which the data is to be written
MediaLocator dest = new MediaLocator("file://foo.wav");
// create a datasink to do the file writing & open the sink to
// make sure we can write to it.
DataSink filewriter = null;
try {
filewriter = Manager.createDataSink(source, dest);
filewriter.open();
} catch (NoDataSinkException e) {
System.exit(-1);
} catch (IOException e) {
System.exit(-1);
} catch (SecurityException e) {
System.exit(-1);
}
// if the Processor implements StreamWriterControl, we can
// call setStreamSizeLimit
// to set a limit on the size of the file that is written.
StreamWriterControl swc = (StreamWriterControl)
p.getControl("javax.media.control.StreamWriterControl");
//set limit to 5MB
if (swc != null)
swc.setStreamSizeLimit(5000000);
// now start the filewriter and processor
try {
filewriter.start();
} catch (IOException e) {
System.exit(-1);
}
// Capture for 5 seconds
sh.playToEndOfMedia(5000);
sh.close();
// Wait for an EndOfStream from the DataSink and close it...
filewriter.close();

Regards,
Rohan

On Wed, Oct 1, 2008 at 7:52 AM, Truls Samuelsen > <truls.samuelsen@losmail.no <mailto:truls.samuelsen@losmail.no>> wrote:

    Any suggestions on how to implement audiorecording of SIP Calls.

    I would typically be a button in the callpanel that start
    recording to a file when pressed.

    Has anybody done something like this?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.173 / Virus Database: 270.7.5/1704 - Release Date: 02.10.2008
21:35