1 Replies Last post: Apr 18, 2008 4:50 AM by Guest  
Guest

Apr 17, 2008 2:33 PM

[OpenSIPStack] How can I add a mediaformat to a soundchannel ?

Hi,

I was working with sound channels and had a problem: How can I add a media
format to it ?
And How can I recognise the sound devices that are present in the computer ?

I have tried the following solutions. But it did not work. Any guess ?

Thanks in advance.

Claudio Miceli de Farias

PSoundChannel * MMedia::CreateSoundChannel(const OpalMediaFormat &
mediaFormat,
BOOL isSource)
{
PString deviceName;
PSoundChannel * soundChannel = new PSoundChannel();

if (isSource)
deviceName = soundChannel->GetDefaultDevice(
PSoundChannel::Recorder );
else
deviceName = soundChannel->GetDefaultDevice(
PSoundChannel::Player );

if (isSource) cout << "\n record device: " << deviceName << "\n";

if (soundChannel->Open(deviceName,
isSource ? PSoundChannel::Recorder
: PSoundChannel::Player,
1, mediaFormat.GetClockRate(), 16)) {
PTRACE(1, "PCSS\tOpened sound channel \"" << deviceName
<< "\" for " << (isSource ? "record" : "play") <<
"ing."); //nao estah entrando aqui
return soundChannel;
}
return soundChannel;
}


OpalMediaStream * MMedia::CreateMediaStream(const OpalMediaFormat &
mediaFormat,
unsigned
sessionID,BOOL isSource)
{
PSoundChannel * soundChannel = CreateSoundChannel(mediaFormat,
isSource);
if (soundChannel == NULL)
return NULL;

return new OpalAudioMediaStream(mediaFormat, sessionID, isSource,
soundChannelBuffers, soundChannel);
}

OpalAudioFormat::OpalAudioFormat (OPAL_G711_ULAW_64K,
RTP_DataFrame::PCMU, "PCMU", 8, 8, 240, 30, 256);
mediaFormats+= OpalMediaFormat::OpalMediaFormat(OPAL_G711_ULAW_64K);


This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
opensipstack-devel mailing list
opensipstack-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensipstack-devel
Guest
1. Apr 18, 2008 4:50 AM in response to: Guest
Re: [OpenSIPStack] How can I add a mediaformat to a soundchannel ?
Claudio Miceli wrote:
Hi,

I was working with sound channels and had a problem: How can I add a media
format to it ?

I am not sure I understand your question but here is my best effort
guess. Right now OPAL assumes that the sound card can only handle PCM16.

OpalMediaFormatList pcm;
pcm += OpalPCM16;
CreateSoundChannel( format );

And How can I recognise the sound devices that are present in the computer ?

Depends on what you mean by "recognise". But if you mean how to get the
sound devices present, then take a look at PSoundChannel::GetDeviceNames()

I have tried the following solutions. But it did not work. Any guess ?

Thanks in advance.

Claudio Miceli de Farias

PSoundChannel * MMedia::CreateSoundChannel(const OpalMediaFormat &
mediaFormat,
BOOL isSource)
{
PString deviceName;
PSoundChannel * soundChannel = new PSoundChannel();

if (isSource)
deviceName = soundChannel->GetDefaultDevice(
PSoundChannel::Recorder );
else
deviceName = soundChannel->GetDefaultDevice(
PSoundChannel::Player );

if (isSource) cout << "\n record device: " << deviceName << "\n";

if (soundChannel->Open(deviceName,
isSource ? PSoundChannel::Recorder
: PSoundChannel::Player,
1, mediaFormat.GetClockRate(), 16)) {
PTRACE(1, "PCSS\tOpened sound channel \"" << "\" for " << (isSource ? "record" : "play") "ing."); //nao estah entrando aqui
return soundChannel;
}
return soundChannel;
}


OpalMediaStream * MMedia::CreateMediaStream(const OpalMediaFormat &
mediaFormat,
unsigned
sessionID,BOOL isSource)
{
PSoundChannel * soundChannel = CreateSoundChannel(mediaFormat,
isSource);
if (soundChannel == NULL)
return NULL;

return new OpalAudioMediaStream(mediaFormat, sessionID, isSource,
soundChannelBuffers, soundChannel);
}

OpalAudioFormat::OpalAudioFormat (OPAL_G711_ULAW_64K,
RTP_DataFrame::PCMU, "PCMU", 8, 8, 240, 30, 256);
mediaFormats+= OpalMediaFormat::OpalMediaFormat(OPAL_G711_ULAW_64K);


This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
opensipstack-devel mailing list
opensipstack-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensipstack-devel


This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
opensipstack-devel mailing list
opensipstack-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensipstack-devel