Ring Daemon
Loading...
Searching...
No Matches
media_codec.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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
24#include <string>
25
26namespace jami {
27
28/*
29 * SystemCodecInfo
30 */
32 unsigned avcodecId,
33 const std::string& longName,
34 const std::string& name,
35 const std::string& libName,
36 MediaType mediaType,
37 CodecType codecType,
38 unsigned bitrate,
39 unsigned payloadType,
40 unsigned minQuality,
41 unsigned maxQuality)
42 : id(codecId)
43 , avcodecId(avcodecId)
44 , longName(longName)
45 , name(name)
46 , libName(libName)
47 , codecType(codecType)
48 , mediaType(mediaType)
49 , payloadType(payloadType)
50 , bitrate(bitrate)
51 , minQuality(minQuality)
52 , maxQuality(maxQuality)
53{}
54
56
57std::map<std::string, std::string>
64
65/*
66 * SystemAudioCodecInfo
67 */
69 unsigned m_avcodecId,
70 const std::string& longName,
71 const std::string& m_name,
72 const std::string& m_libName,
74 unsigned m_bitrate,
75 unsigned m_sampleRate,
76 unsigned m_nbChannels,
77 unsigned m_payloadType,
78 AVSampleFormat sampleFormat)
80 , audioformat {m_sampleRate, m_nbChannels, sampleFormat}
81{}
82
84
85std::map<std::string, std::string>
94
95bool
100
101void
102SystemAudioCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details)
103{
107
108 // copy back if no exception was raised
111}
112
113/*
114 * SystemVideoCodecInfo
115 */
117 unsigned m_avcodecId,
118 const std::string& longName,
119 const std::string& m_name,
120 const std::string& m_libName,
122 unsigned m_bitrate,
123 unsigned m_minQuality,
124 unsigned m_maxQuality,
125 unsigned m_payloadType,
126 unsigned m_frameRate,
127 unsigned m_profileId)
130 longName,
131 m_name,
132 m_libName,
134 m_type,
135 m_bitrate,
139 , frameRate(m_frameRate)
140 , profileId(m_profileId)
141{}
142
144
145std::map<std::string, std::string>
157
158void
159SystemVideoCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details)
160{
161 auto copy = *this;
162
164 if (it != details.end())
165 copy.bitrate = std::stoi(it->second);
166
168 if (it != details.end())
169 copy.frameRate = std::stoi(it->second);
170
172 if (it != details.end())
173 copy.quality = std::stoi(it->second);
174
176 if (it != details.end())
177 copy.isAutoQualityEnabled = (it->second == TRUE_STR) ? true : false;
178
179 // copy back if no exception was raised
180 *this = std::move(copy);
181}
182} // namespace jami
static constexpr const char TRUE_STR[]
void emitSignal(Args... args)
Definition jami_signal.h:64
@ MEDIA_AUDIO
Definition media_codec.h:46
@ MEDIA_VIDEO
Definition media_codec.h:47
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)