~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/audio/codecs/audiocodec.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author:  Alexandre Savard <alexandre.savard@savoirfairelinux.com>
4
4
 *
5
5
 *  Mostly borrowed from asterisk's sources (Steve Underwood <steveu@coppice.org>)
32
32
 
33
33
#include "audiocodec.h"
34
34
using std::ptrdiff_t;
35
 
#include <ccrtp/rtp.h>
36
35
 
37
36
namespace sfl {
38
37
 
39
 
AudioCodec::AudioCodec(uint8 payload, const std::string &codecName,
40
 
                       int clockRate, int frameSize, int channel) :
 
38
AudioCodec::AudioCodec(uint8_t payload, const std::string &codecName,
 
39
                       int clockRate, int frameSize, unsigned channels) :
41
40
    codecName_(codecName),
42
41
    clockRate_(clockRate),
43
 
    channel_(channel),
 
42
    channel_(channels),
44
43
    frameSize_(frameSize),
45
44
    bitrate_(0.0),
46
45
    payload_(payload),
47
 
    payloadFormat_(payload, clockRate_),
48
46
    hasDynamicPayload_((payload_ >= 96 and payload_ <= 127) or payload_ == 9)
49
47
{}
50
48
 
55
53
    frameSize_(c.frameSize_),
56
54
    bitrate_(c.bitrate_),
57
55
    payload_(c.payload_),
58
 
    payloadFormat_(c.payloadFormat_),
59
56
    hasDynamicPayload_(c.hasDynamicPayload_)
60
57
{}
61
58
 
 
59
// Mono only, subclasses must implement multichannel support
 
60
int AudioCodec::decode(std::vector<std::vector<SFLAudioSample> > &dst, unsigned char *buf, size_t buffer_size)
 
61
{
 
62
    return decode(dst[0].data(), buf, buffer_size);
 
63
}
 
64
 
 
65
// Mono only, subclasses must implement multichannel support
 
66
int AudioCodec::encode(unsigned char *dst, std::vector<std::vector<SFLAudioSample> > &src, size_t buffer_size)
 
67
{
 
68
    return encode(dst, src[0].data(), buffer_size);
 
69
}
 
70
 
62
71
std::string AudioCodec::getMimeSubtype() const
63
72
{
64
73
    return codecName_;
65
74
}
66
75
 
67
 
uint8 AudioCodec::getPayloadType() const
 
76
uint8_t AudioCodec::getPayloadType() const
68
77
{
69
78
    return payload_;
70
79
}
74
83
    return hasDynamicPayload_;
75
84
}
76
85
 
77
 
uint32 AudioCodec::getClockRate() const
 
86
uint32_t AudioCodec::getClockRate() const
 
87
{
 
88
    return clockRate_;
 
89
}
 
90
 
 
91
uint32_t AudioCodec::getSDPClockRate() const
78
92
{
79
93
    return clockRate_;
80
94
}
89
103
    return bitrate_;
90
104
}
91
105
 
 
106
unsigned AudioCodec::getChannels() const
 
107
{
 
108
    return channel_;
 
109
}
 
110
 
 
111
const char *
 
112
AudioCodec::getSDPChannels() const
 
113
{
 
114
    return "";
 
115
}
 
116
 
92
117
} // end namespace sfl