Commit d5f33df6 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

Use the first PA device if the prefered one is not available.

parent de90927d
......@@ -33,7 +33,7 @@
#include <iostream>
Opus::Opus() : sfl::AudioCodec(payloadType, "Opus", CLOCK_RATE, FRAME_SIZE, CHANNELS),
Opus::Opus() : sfl::AudioCodec(PAYLOAD_TYPE, "Opus", CLOCK_RATE, FRAME_SIZE, CHANNELS),
encoder_(0),
decoder_(0)
{
......
......@@ -42,7 +42,7 @@ public:
Opus();
~Opus();
static const int payloadType = 104; // dynamic payload type, out of range of video (96-99)
static const int PAYLOAD_TYPE = 104; // dynamic payload type, out of range of video (96-99)
private:
virtual int decode(short *dst, unsigned char *buf, size_t buffer_size);
......
......@@ -273,20 +273,38 @@ void PulseLayer::createStreams(pa_context* c)
std::string ringtoneDevice(preference_.getPulseDeviceRingtone());
std::string defaultDevice = "";
DEBUG("Devices:\n playback: %s\n record: %s\n ringtone: %s",
DEBUG("Devices: playback: %s record: %s ringtone: %s",
playbackDevice.c_str(), captureDevice.c_str(), ringtoneDevice.c_str());
playback_ = new AudioStream(c, mainloop_, "SFLphone playback", PLAYBACK_STREAM, sampleRate_, getDeviceInfos(sinkList_, playbackDevice));
// Create playback stream
const PaDeviceInfos* dev_infos = getDeviceInfos(sinkList_, playbackDevice);
if(dev_infos == NULL) {
dev_infos = &sinkList_[0];
DEBUG("Prefered playback device not found in device list, selecting %s instead.", dev_infos->name.c_str());
}
playback_ = new AudioStream(c, mainloop_, "SFLphone playback", PLAYBACK_STREAM, sampleRate_, dev_infos);
pa_stream_set_write_callback(playback_->pulseStream(), playback_callback, this);
pa_stream_set_moved_callback(playback_->pulseStream(), stream_moved_callback, this);
record_ = new AudioStream(c, mainloop_, "SFLphone capture", CAPTURE_STREAM, sampleRate_, getDeviceInfos(sourceList_, captureDevice));
// Create capture stream
dev_infos = getDeviceInfos(sourceList_, captureDevice);
if(dev_infos == NULL) {
dev_infos = &sourceList_[0];
DEBUG("Prefered capture device not found in device list, selecting %s instead.", dev_infos->name.c_str());
}
record_ = new AudioStream(c, mainloop_, "SFLphone capture", CAPTURE_STREAM, sampleRate_, dev_infos);
pa_stream_set_read_callback(record_->pulseStream() , capture_callback, this);
pa_stream_set_moved_callback(record_->pulseStream(), stream_moved_callback, this);
ringtone_ = new AudioStream(c, mainloop_, "SFLphone ringtone", RINGTONE_STREAM, sampleRate_, getDeviceInfos(sinkList_, ringtoneDevice));
// Create ringtone stream
dev_infos = getDeviceInfos(sinkList_, ringtoneDevice);
if(dev_infos == NULL) {
dev_infos = &sinkList_[0];
DEBUG("Prefered ringtone device not found in device list, selecting %s instead.", dev_infos->name.c_str());
}
ringtone_ = new AudioStream(c, mainloop_, "SFLphone ringtone", RINGTONE_STREAM, sampleRate_, dev_infos);
pa_stream_set_write_callback(ringtone_->pulseStream(), ringtone_callback, this);
pa_stream_set_moved_callback(ringtone_->pulseStream(), stream_moved_callback, this);
......
......@@ -255,7 +255,7 @@ Sdp::setMediaDescriptorLines(bool audio)
#ifdef HAVE_OPUS
// Opus sample rate is allways declared as 48000 and channel num is allways 2 in rtpmap as per
// http://tools.ietf.org/html/draft-spittka-payload-rtp-opus-03#section-6.2
if(payload == Opus::payloadType) {
if(payload == Opus::PAYLOAD_TYPE) {
rtpmap.clock_rate = 48000;
rtpmap.param.ptr = ((char* const)"2");
rtpmap.param.slen = 1;
......@@ -273,7 +273,7 @@ Sdp::setMediaDescriptorLines(bool audio)
#ifdef HAVE_OPUS
// Declare stereo support for opus
if(payload == Opus::payloadType) {
if(payload == Opus::PAYLOAD_TYPE) {
std::ostringstream os;
os << "fmtp:" << dynamic_payload << " stereo=1; sprop-stereo=" << (channels>1 ? 1 : 0);
med->attr[med->attr_count++] = pjmedia_sdp_attr_create(memPool_, os.str().c_str(), NULL);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment