218 lines
5.7 KiB
C
Raw Normal View History

/*
* Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
Move talk/media to webrtc/media I removed the 'libjingle' target in talk/libjingle.gyp and replaced all users of it with base/base.gyp:rtc_base. It seems the jsoncpp and expat dependencies were not used by it's previous references. The files in talk/media/testdata were uploaded to Google Storage and added .sha1 files in resources/media instead of simply moving them. The previously disabled warnings that were inherited from talk/build/common.gypi are now replaced by target-specific disabling of only the failing warnings. Additional disabling was needed since the stricter compilation warnings that applies to code in webrtc/. License headers will be updated in a follow-up CL in order to not break Git history. Other modifications: * Updated the header guards. * Sorted the includes using chromium/src/tools/sort-headers.py except for these files: talk/app/webrtc/peerconnectionendtoend_unittest.cc talk/app/webrtc/java/jni/androidmediadecoder_jni.cc talk/app/webrtc/java/jni/androidmediaencoder_jni.cc webrtc/media/devices/win32devicemanager.cc. * Unused GYP reference to libjingle_tests_additional_deps was removed. * Removed duplicated GYP entries of webrtc/base/testutils.cc webrtc/base/testutils.h The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media, so they were moved to the media.gyp. I also checked that none of EXPAT_RELATIVE_PATH, FEATURE_ENABLE_VOICEMAIL, GTEST_RELATIVE_PATH, JSONCPP_RELATIVE_PATH, LOGGING=1, SRTP_RELATIVE_PATH, FEATURE_ENABLE_SSL, FEATURE_ENABLE_VOICEMAIL, FEATURE_ENABLE_PSTN, HAVE_SCTP, HAVE_SRTP, are used by the talk/media code. For Chromium, the following changes will need to be applied to the roll CL that updates the DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/ BUG=webrtc:5420 NOPRESUBMIT=True TBR=tommi@webrtc.org Review URL: https://codereview.webrtc.org/1587193006 Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
#ifndef WEBRTC_MEDIA_BASE_CODEC_H_
#define WEBRTC_MEDIA_BASE_CODEC_H_
#include <map>
#include <set>
#include <string>
#include <vector>
#include "webrtc/api/rtpparameters.h"
#include "webrtc/media/base/mediaconstants.h"
namespace cricket {
typedef std::map<std::string, std::string> CodecParameterMap;
extern const int kMaxPayloadId;
class FeedbackParam {
public:
FeedbackParam(const std::string& id, const std::string& param)
: id_(id),
param_(param) {
}
explicit FeedbackParam(const std::string& id)
: id_(id),
param_(kParamValueEmpty) {
}
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:
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;
// Creates a codec with the given parameters.
Codec(int id, const std::string& name, int clockrate);
// 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
Codec();
Codec(const Codec& c);
~Codec();
// 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);
// 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);
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);
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);
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;
bool operator!=(const Codec& c) const {
return !(*this == c);
}
};
struct AudioCodec : public Codec {
int bitrate;
size_t channels;
// Creates a codec with the given parameters.
AudioCodec(int id,
const std::string& name,
int clockrate,
int bitrate,
size_t channels);
// 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);
~AudioCodec() = default;
// Indicates if this codec is compatible with the specified codec.
bool Matches(const AudioCodec& codec) const;
std::string ToString() const;
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);
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;
bool operator!=(const AudioCodec& c) const {
return !(*this == c);
}
};
struct VideoCodec : public Codec {
int width;
int height;
int framerate;
// Creates a codec with the given parameters.
VideoCodec(int id,
const std::string& name,
int width,
int height,
int framerate);
VideoCodec(int id, const std::string& name);
// 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);
~VideoCodec() = default;
std::string ToString() 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
VideoCodec& operator=(const VideoCodec& c);
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;
bool operator!=(const VideoCodec& c) const {
return !(*this == c);
}
static VideoCodec CreateRtxCodec(int rtx_payload_type,
int associated_payload_type);
enum CodecType {
CODEC_VIDEO,
CODEC_RED,
CODEC_ULPFEC,
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;
};
struct DataCodec : public Codec {
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);
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);
std::string ToString() const;
};
// Get the codec setting associated with |payload_type|. If there
// is no codec associated with that payload type it returns false.
template <class Codec>
bool FindCodecById(const std::vector<Codec>& codecs,
int payload_type,
Codec* codec_out) {
for (const auto& codec : codecs) {
if (codec.id == payload_type) {
*codec_out = codec;
return true;
}
}
return false;
}
bool CodecNamesEq(const std::string& name1, const std::string& name2);
bool HasNack(const Codec& codec);
bool HasRemb(const Codec& codec);
bool HasTransportCc(const Codec& codec);
} // namespace cricket
Move talk/media to webrtc/media I removed the 'libjingle' target in talk/libjingle.gyp and replaced all users of it with base/base.gyp:rtc_base. It seems the jsoncpp and expat dependencies were not used by it's previous references. The files in talk/media/testdata were uploaded to Google Storage and added .sha1 files in resources/media instead of simply moving them. The previously disabled warnings that were inherited from talk/build/common.gypi are now replaced by target-specific disabling of only the failing warnings. Additional disabling was needed since the stricter compilation warnings that applies to code in webrtc/. License headers will be updated in a follow-up CL in order to not break Git history. Other modifications: * Updated the header guards. * Sorted the includes using chromium/src/tools/sort-headers.py except for these files: talk/app/webrtc/peerconnectionendtoend_unittest.cc talk/app/webrtc/java/jni/androidmediadecoder_jni.cc talk/app/webrtc/java/jni/androidmediaencoder_jni.cc webrtc/media/devices/win32devicemanager.cc. * Unused GYP reference to libjingle_tests_additional_deps was removed. * Removed duplicated GYP entries of webrtc/base/testutils.cc webrtc/base/testutils.h The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media, so they were moved to the media.gyp. I also checked that none of EXPAT_RELATIVE_PATH, FEATURE_ENABLE_VOICEMAIL, GTEST_RELATIVE_PATH, JSONCPP_RELATIVE_PATH, LOGGING=1, SRTP_RELATIVE_PATH, FEATURE_ENABLE_SSL, FEATURE_ENABLE_VOICEMAIL, FEATURE_ENABLE_PSTN, HAVE_SCTP, HAVE_SRTP, are used by the talk/media code. For Chromium, the following changes will need to be applied to the roll CL that updates the DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/ BUG=webrtc:5420 NOPRESUBMIT=True TBR=tommi@webrtc.org Review URL: https://codereview.webrtc.org/1587193006 Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
#endif // WEBRTC_MEDIA_BASE_CODEC_H_