[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); |