Thread: [OpenSIPStack] How can I add a mediaformat to a soundchannel ?
Brought to you by:
joegenbaclor
From: Claudio M. <cmi...@gm...> - 2008-04-17 18:33:12
|
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); |
From: Joegen E. B. <joe...@gm...> - 2008-04-18 08:50:19
|
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 \"" << 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 > ope...@li... > https://lists.sourceforge.net/lists/listinfo/opensipstack-devel > > > |