Ring Daemon 16.0.0
Loading...
Searching...
No Matches
media_codec.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#include "libav_deps.h" // MUST BE INCLUDED FIRST
19#include "media_codec.h"
20#include "account_const.h"
21
22#include "string_utils.h"
23#include "logger.h"
24
25#include <string>
26#include <sstream>
27
28namespace jami {
29
30/*
31 * SystemCodecInfo
32 */
34 unsigned avcodecId,
35 const std::string& longName,
36 const std::string& name,
37 const std::string& libName,
38 MediaType mediaType,
39 CodecType codecType,
40 unsigned bitrate,
41 unsigned payloadType,
42 unsigned minQuality,
43 unsigned maxQuality)
44 : id(codecId)
45 , avcodecId(avcodecId)
46 , longName(longName)
47 , name(name)
48 , libName(libName)
49 , codecType(codecType)
50 , mediaType(mediaType)
51 , payloadType(payloadType)
52 , bitrate(bitrate)
53 , minQuality(minQuality)
54 , maxQuality(maxQuality)
55{}
56
58
59std::map<std::string, std::string>
67
68/*
69 * SystemAudioCodecInfo
70 */
72 unsigned m_avcodecId,
73 const std::string& longName,
74 const std::string& m_name,
75 const std::string& m_libName,
77 unsigned m_bitrate,
78 unsigned m_sampleRate,
79 unsigned m_nbChannels,
80 unsigned m_payloadType,
81 AVSampleFormat sampleFormat)
84 longName,
85 m_name,
88 m_type,
91 , audioformat {m_sampleRate, m_nbChannels, sampleFormat}
92{}
93
95
96std::map<std::string, std::string>
108
109
110bool
115
116void
117SystemAudioCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details)
118{
119 decltype(bitrate) tmp_bitrate = std::stoi(
122 tmp_audioformat.sample_rate = std::stoi(
124
125 // copy back if no exception was raised
128}
129
130/*
131 * SystemVideoCodecInfo
132 */
134 unsigned m_avcodecId,
135 const std::string& longName,
136 const std::string& m_name,
137 const std::string& m_libName,
139 unsigned m_bitrate,
140 unsigned m_minQuality,
141 unsigned m_maxQuality,
142 unsigned m_payloadType,
143 unsigned m_frameRate,
144 unsigned m_profileId)
147 longName,
148 m_name,
149 m_libName,
151 m_type,
152 m_bitrate,
156 , frameRate(m_frameRate)
157 , profileId(m_profileId)
158{}
159
161
162std::map<std::string, std::string>
175
176void
177SystemVideoCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details)
178{
179 auto copy = *this;
180
182 if (it != details.end())
183 copy.bitrate = std::stoi(it->second);
184
186 if (it != details.end())
187 copy.frameRate = std::stoi(it->second);
188
190 if (it != details.end())
191 copy.quality = std::stoi(it->second);
192
194 if (it != details.end())
195 copy.isAutoQualityEnabled = (it->second == TRUE_STR) ? true : false;
196
197 // copy back if no exception was raised
198 *this = std::move(copy);
199}
200} // namespace jami
static constexpr const char TRUE_STR[]
void emitSignal(Args... args)
Definition ring_signal.h:64
@ MEDIA_AUDIO
Definition media_codec.h:47
@ MEDIA_VIDEO
Definition media_codec.h:48
static constexpr const char QUALITY[]
static constexpr const char FRAME_RATE[]
static constexpr const char BITRATE[]
static constexpr const char SAMPLE_RATE[]
static constexpr const char CHANNEL_NUMBER[]
static constexpr const char MIN_BITRATE[]
static constexpr const char AUTO_QUALITY_ENABLED[]
static constexpr const char MAX_BITRATE[]
SystemAudioCodecInfo(unsigned codecId, unsigned avcodecId, const std::string &longName, const std::string &name, const std::string &libName, CodecType type, unsigned bitrate=0, unsigned sampleRate=0, unsigned nbChannels=0, unsigned payloadType=0, AVSampleFormat sampleFormat=AV_SAMPLE_FMT_S16)
void setCodecSpecifications(const std::map< std::string, std::string > &details)
std::map< std::string, std::string > getCodecSpecifications() const override
SystemCodecInfo(unsigned codecId, unsigned avcodecId, const std::string &longName, const std::string &name, const std::string &libName, MediaType mediaType, CodecType codecType=CODEC_NONE, unsigned bitrate=0, unsigned payloadType=0, unsigned m_minQuality=DEFAULT_NO_QUALITY, unsigned m_maxQuality=DEFAULT_NO_QUALITY)
virtual std::map< std::string, std::string > getCodecSpecifications() const
SystemVideoCodecInfo(unsigned codecId, unsigned avcodecId, const std::string &longName, const std::string &name, const std::string &libName, CodecType type=CODEC_NONE, unsigned bitrate=0, unsigned m_minQuality=0, unsigned m_maxQuality=0, unsigned payloadType=0, unsigned frameRate=0, unsigned profileId=0)
std::map< std::string, std::string > getCodecSpecifications() const override
void setCodecSpecifications(const std::map< std::string, std::string > &details)