2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MEDIA_BASE_CODEC_H_
|
|
|
|
|
#define MEDIA_BASE_CODEC_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/rtpparameters.h"
|
2017-09-29 15:00:29 +02:00
|
|
|
#include "api/video_codecs/sdp_video_format.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "media/base/mediaconstants.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
typedef std::map<std::string, std::string> CodecParameterMap;
|
|
|
|
|
|
|
|
|
|
class FeedbackParam {
|
|
|
|
|
public:
|
2017-02-25 18:15:09 -08:00
|
|
|
FeedbackParam() = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
FeedbackParam(const std::string& id, const std::string& param)
|
|
|
|
|
: id_(id),
|
|
|
|
|
param_(param) {
|
|
|
|
|
}
|
2013-08-10 07:18:04 +00:00
|
|
|
explicit FeedbackParam(const std::string& id)
|
|
|
|
|
: id_(id),
|
|
|
|
|
param_(kParamValueEmpty) {
|
|
|
|
|
}
|
2018-04-05 11:42:24 +02:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool operator==(const FeedbackParam& other) const;
|
|
|
|
|
|
|
|
|
|
const std::string& id() const { return id_; }
|
|
|
|
|
const std::string& param() const { return param_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::string id_; // e.g. "nack", "ccm"
|
|
|
|
|
std::string param_; // e.g. "", "rpsi", "fir"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FeedbackParams {
|
|
|
|
|
public:
|
2017-09-28 21:19:18 +02:00
|
|
|
FeedbackParams();
|
2018-04-05 11:42:24 +02:00
|
|
|
~FeedbackParams();
|
2013-07-10 00:45:36 +00:00
|
|
|
bool operator==(const FeedbackParams& other) const;
|
|
|
|
|
|
|
|
|
|
bool Has(const FeedbackParam& param) const;
|
|
|
|
|
void Add(const FeedbackParam& param);
|
|
|
|
|
|
|
|
|
|
void Intersect(const FeedbackParams& from);
|
|
|
|
|
|
|
|
|
|
const std::vector<FeedbackParam>& params() const { return params_; }
|
|
|
|
|
private:
|
|
|
|
|
bool HasDuplicateEntries() const;
|
|
|
|
|
|
|
|
|
|
std::vector<FeedbackParam> params_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Codec {
|
|
|
|
|
int id;
|
|
|
|
|
std::string name;
|
|
|
|
|
int clockrate;
|
|
|
|
|
CodecParameterMap params;
|
|
|
|
|
FeedbackParams feedback_params;
|
|
|
|
|
|
2016-05-12 08:10:52 +02:00
|
|
|
virtual ~Codec();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Indicates if this codec is compatible with the specified codec.
|
|
|
|
|
bool Matches(const Codec& codec) const;
|
|
|
|
|
|
|
|
|
|
// Find the parameter for |name| and write the value to |out|.
|
|
|
|
|
bool GetParam(const std::string& name, std::string* out) const;
|
|
|
|
|
bool GetParam(const std::string& name, int* out) const;
|
|
|
|
|
|
|
|
|
|
void SetParam(const std::string& name, const std::string& value);
|
|
|
|
|
void SetParam(const std::string& name, int value);
|
|
|
|
|
|
2014-06-19 19:50:55 +00:00
|
|
|
// It is safe to input a non-existent parameter.
|
|
|
|
|
// Returns true if the parameter existed, false if it did not exist.
|
|
|
|
|
bool RemoveParam(const std::string& name);
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool HasFeedbackParam(const FeedbackParam& param) const;
|
|
|
|
|
void AddFeedbackParam(const FeedbackParam& param);
|
|
|
|
|
|
|
|
|
|
// Filter |this| feedbacks params such that only those shared by both |this|
|
|
|
|
|
// and |other| are kept.
|
|
|
|
|
void IntersectFeedbackParams(const Codec& other);
|
|
|
|
|
|
2016-04-20 16:23:10 -07:00
|
|
|
virtual webrtc::RtpCodecParameters ToCodecParameters() const;
|
|
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
Codec& operator=(const Codec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
Codec& operator=(Codec&& c);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
bool operator==(const Codec& c) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool operator!=(const Codec& c) const {
|
|
|
|
|
return !(*this == c);
|
|
|
|
|
}
|
2016-12-08 01:50:48 -08:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// A Codec can't be created without a subclass.
|
|
|
|
|
// Creates a codec with the given parameters.
|
|
|
|
|
Codec(int id, const std::string& name, int clockrate);
|
|
|
|
|
// Creates an empty codec.
|
|
|
|
|
Codec();
|
|
|
|
|
Codec(const Codec& c);
|
|
|
|
|
Codec(Codec&& c);
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AudioCodec : public Codec {
|
|
|
|
|
int bitrate;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t channels;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Creates a codec with the given parameters.
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
AudioCodec(int id,
|
|
|
|
|
const std::string& name,
|
|
|
|
|
int clockrate,
|
|
|
|
|
int bitrate,
|
2016-04-13 10:07:16 -07:00
|
|
|
size_t channels);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Creates an empty codec.
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
AudioCodec();
|
|
|
|
|
AudioCodec(const AudioCodec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
AudioCodec(AudioCodec&& c);
|
2017-09-28 21:19:18 +02:00
|
|
|
~AudioCodec() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Indicates if this codec is compatible with the specified codec.
|
|
|
|
|
bool Matches(const AudioCodec& codec) const;
|
|
|
|
|
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2016-04-20 16:23:10 -07:00
|
|
|
webrtc::RtpCodecParameters ToCodecParameters() const override;
|
|
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
AudioCodec& operator=(const AudioCodec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
AudioCodec& operator=(AudioCodec&& c);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
bool operator==(const AudioCodec& c) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool operator!=(const AudioCodec& c) const {
|
|
|
|
|
return !(*this == c);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-21 06:16:19 -08:00
|
|
|
inline std::ostream& operator<<(std::ostream& os, const AudioCodec& ac) {
|
|
|
|
|
os << "{id: " << ac.id;
|
|
|
|
|
os << ", name: " << ac.name;
|
|
|
|
|
os << ", clockrate: " << ac.clockrate;
|
|
|
|
|
os << ", bitrate: " << ac.bitrate;
|
|
|
|
|
os << ", channels: " << ac.channels;
|
|
|
|
|
os << ", params: {";
|
|
|
|
|
const char* sep = "";
|
|
|
|
|
for (const auto& kv : ac.params) {
|
|
|
|
|
os << sep << kv.first << ": " << kv.second;
|
|
|
|
|
sep = ", ";
|
|
|
|
|
}
|
|
|
|
|
os << "}, feedback_params: {";
|
|
|
|
|
sep = "";
|
|
|
|
|
for (const FeedbackParam& fp : ac.feedback_params.params()) {
|
|
|
|
|
os << sep << fp.id() << ": " << fp.param();
|
|
|
|
|
sep = ", ";
|
|
|
|
|
}
|
|
|
|
|
os << "}}";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
struct VideoCodec : public Codec {
|
|
|
|
|
// Creates a codec with the given parameters.
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
VideoCodec(int id, const std::string& name);
|
2016-10-28 07:43:45 -07:00
|
|
|
// Creates a codec with the given name and empty id.
|
|
|
|
|
explicit VideoCodec(const std::string& name);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Creates an empty codec.
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
VideoCodec();
|
|
|
|
|
VideoCodec(const VideoCodec& c);
|
2017-09-29 15:00:29 +02:00
|
|
|
explicit VideoCodec(const webrtc::SdpVideoFormat& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
VideoCodec(VideoCodec&& c);
|
2017-09-28 21:19:18 +02:00
|
|
|
~VideoCodec() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-11-12 09:53:04 -08:00
|
|
|
// Indicates if this video codec is the same as the other video codec, e.g. if
|
|
|
|
|
// they are both VP8 or VP9, or if they are both H264 with the same H264
|
|
|
|
|
// profile. H264 levels however are not compared.
|
|
|
|
|
bool Matches(const VideoCodec& codec) const;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2017-02-04 12:09:01 -08:00
|
|
|
webrtc::RtpCodecParameters ToCodecParameters() const override;
|
|
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
VideoCodec& operator=(const VideoCodec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
VideoCodec& operator=(VideoCodec&& c);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
bool operator==(const VideoCodec& c) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool operator!=(const VideoCodec& c) const {
|
|
|
|
|
return !(*this == c);
|
|
|
|
|
}
|
2014-05-13 11:07:01 +00:00
|
|
|
|
|
|
|
|
static VideoCodec CreateRtxCodec(int rtx_payload_type,
|
|
|
|
|
int associated_payload_type);
|
|
|
|
|
|
|
|
|
|
enum CodecType {
|
|
|
|
|
CODEC_VIDEO,
|
|
|
|
|
CODEC_RED,
|
|
|
|
|
CODEC_ULPFEC,
|
2016-11-07 03:03:41 -08:00
|
|
|
CODEC_FLEXFEC,
|
2014-05-13 11:07:01 +00:00
|
|
|
CODEC_RTX,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CodecType GetCodecType() const;
|
|
|
|
|
// Validates a VideoCodec's payload type, dimensions and bitrates etc. If they
|
|
|
|
|
// don't make sense (such as max < min bitrate), and error is logged and
|
|
|
|
|
// ValidateCodecFormat returns false.
|
|
|
|
|
bool ValidateCodecFormat() const;
|
2016-12-06 05:36:03 -08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void SetDefaultParameters();
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct DataCodec : public Codec {
|
2016-04-13 10:07:16 -07:00
|
|
|
DataCodec(int id, const std::string& name);
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
DataCodec();
|
|
|
|
|
DataCodec(const DataCodec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
DataCodec(DataCodec&& c);
|
2017-09-28 21:19:18 +02:00
|
|
|
~DataCodec() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
Make webrtc 50 KB smaller by not inlining Codec.
The Codec class is a big class and objects of the Codec class are passed
around by value. That means that inlined operations would be duplicated
at many places, in particular inside STL.
By not inlining Codec methods, webrtc shrinks by 50 KB in
a Linux x64 clang build.
Total change: -54147 bytes
==========================
+2810 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.cc - (gained 2920, lost 110)
-1003 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/codec.h - (gained 0, lost 1003)
-1129 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/sctp/sctpdataengine.cc - (gained 1660, lost 2789)
-1190 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/base/rtpdataengine.cc - (gained 1408, lost 2598)
-1747 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/session/media/mediasession.cc - (gained 803, lost 2550)
-2141 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine.cc - (gained 1679, lost 3820)
-2250 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsdp.cc - (gained 1224, lost 3474)
-2927 - Source: /usr/include/c++/4.8/bits/stl_vector.h - (gained 0, lost 2927)
-3729 - Source: /home/bratell/src/chromium/src/third_party/libjingle/source/talk/media/webrtc/webrtcvideoengine2.cc - (gained 10925, lost 14654)
-6369 - Source: /usr/include/c++/4.8/bits/vector.tcc - (gained 0, lost 6369)
-10582 - Source: /usr/include/c++/4.8/bits/stl_heap.h - (gained 0, lost 10582)
-19324 - Source: /usr/include/c++/4.8/bits/stl_algo.h - (gained 743, lost 20067)
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/40729005
Cr-Commit-Position: refs/heads/master@{#8436}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8436 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-19 17:55:18 +00:00
|
|
|
DataCodec& operator=(const DataCodec& c);
|
2016-11-07 10:14:36 -08:00
|
|
|
DataCodec& operator=(DataCodec&& c);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-16 04:14:34 +00:00
|
|
|
// Get the codec setting associated with |payload_type|. If there
|
2016-11-11 04:00:16 -08:00
|
|
|
// is no codec associated with that payload type it returns nullptr.
|
2015-03-16 04:14:34 +00:00
|
|
|
template <class Codec>
|
2016-11-11 04:00:16 -08:00
|
|
|
const Codec* FindCodecById(const std::vector<Codec>& codecs, int payload_type) {
|
2015-03-16 04:14:34 +00:00
|
|
|
for (const auto& codec : codecs) {
|
2016-11-11 04:00:16 -08:00
|
|
|
if (codec.id == payload_type)
|
|
|
|
|
return &codec;
|
2015-03-16 04:14:34 +00:00
|
|
|
}
|
2016-11-11 04:00:16 -08:00
|
|
|
return nullptr;
|
2015-03-16 04:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-21 20:24:50 +08:00
|
|
|
bool CodecNamesEq(const std::string& name1, const std::string& name2);
|
2016-10-28 07:43:45 -07:00
|
|
|
bool CodecNamesEq(const char* name1, const char* name2);
|
2016-02-04 04:12:24 -08:00
|
|
|
bool HasNack(const Codec& codec);
|
|
|
|
|
bool HasRemb(const Codec& codec);
|
|
|
|
|
bool HasTransportCc(const Codec& codec);
|
2016-11-12 09:53:04 -08:00
|
|
|
// Returns the first codec in |supported_codecs| that matches |codec|, or
|
|
|
|
|
// nullptr if no codec matches.
|
|
|
|
|
const VideoCodec* FindMatchingCodec(
|
|
|
|
|
const std::vector<VideoCodec>& supported_codecs,
|
|
|
|
|
const VideoCodec& codec);
|
2017-11-23 13:24:53 +01:00
|
|
|
bool IsSameCodec(const std::string& name1,
|
|
|
|
|
const CodecParameterMap& params1,
|
|
|
|
|
const std::string& name2,
|
|
|
|
|
const CodecParameterMap& params2);
|
2015-04-21 20:24:50 +08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MEDIA_BASE_CODEC_H_
|