root / src / gst / engine / audioReceiver.cpp @ 07c11e3e
History | View | Annotate | Download (2.4 kB)
| 1 |
/* audioReceiver.cpp
|
|---|---|
| 2 |
* Copyright (C) 2008-2009 Société des arts technologiques (SAT) |
| 3 |
* http://www.sat.qc.ca |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* This file is part of [propulse]ART. |
| 7 |
* |
| 8 |
* [propulse]ART is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* [propulse]ART is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with [propulse]ART. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "util.h" |
| 24 |
|
| 25 |
#include "pipeline.h" |
| 26 |
#include "gstLinkable.h" |
| 27 |
#include "audioReceiver.h" |
| 28 |
#include "audioConfig.h" |
| 29 |
#include "remoteConfig.h" |
| 30 |
#include "rtpPay.h" |
| 31 |
#include "codec.h" |
| 32 |
#include "audioSink.h" |
| 33 |
|
| 34 |
#include <boost/shared_ptr.hpp> |
| 35 |
|
| 36 |
using boost::shared_ptr;
|
| 37 |
|
| 38 |
/** Constructor parameterized by an AudioSinkConfig
|
| 39 |
* and a ReceiverConfig */ |
| 40 |
AudioReceiver::AudioReceiver(shared_ptr<AudioSinkConfig> aConfig, |
| 41 |
shared_ptr<ReceiverConfig> rConfig) : |
| 42 |
audioConfig_(aConfig), |
| 43 |
remoteConfig_(rConfig), |
| 44 |
session_(), |
| 45 |
gotCaps_(false),
|
| 46 |
depayloader_(0),
|
| 47 |
decoder_(0),
|
| 48 |
sink_(0)
|
| 49 |
{
|
| 50 |
tassert(remoteConfig_->hasCodec()); |
| 51 |
remoteConfig_->checkPorts(); |
| 52 |
} |
| 53 |
|
| 54 |
/// Destructor
|
| 55 |
AudioReceiver::~AudioReceiver() |
| 56 |
{
|
| 57 |
remoteConfig_->cleanupPorts(); |
| 58 |
delete sink_;
|
| 59 |
delete decoder_;
|
| 60 |
delete depayloader_;
|
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
void AudioReceiver::init_codec()
|
| 65 |
{
|
| 66 |
tassert(decoder_ = remoteConfig_->createAudioDecoder()); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
void AudioReceiver::init_depayloader()
|
| 71 |
{
|
| 72 |
tassert(depayloader_ = decoder_->createDepayloader()); |
| 73 |
gstlinkable::link(*depayloader_, *decoder_); |
| 74 |
session_.add(depayloader_, *remoteConfig_); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
void AudioReceiver::init_sink()
|
| 79 |
{
|
| 80 |
tassert(sink_ = audioConfig_->createSink()); |
| 81 |
gstlinkable::link(*decoder_, *sink_); |
| 82 |
setCaps(); |
| 83 |
tassert(gotCaps_); |
| 84 |
tassert(remoteConfig_->capsMatchCodec()); |
| 85 |
if (decoder_->adjustsBufferTime())
|
| 86 |
sink_->adjustBufferTime(decoder_->minimumBufferTime()); // increase jitterbuffer as needed
|
| 87 |
} |
| 88 |
|
| 89 |
/// Used to set this AudioReceiver's RtpReceiver's caps
|
| 90 |
void AudioReceiver::setCaps()
|
| 91 |
{
|
| 92 |
session_.setCaps(remoteConfig_->caps()); |
| 93 |
gotCaps_ = true;
|
| 94 |
} |
| 95 |
|
| 96 |
|
