diff --git a/modules/BUILD.gn b/modules/BUILD.gn index 27615fbc48..b780bb3ce7 100644 --- a/modules/BUILD.gn +++ b/modules/BUILD.gn @@ -34,17 +34,12 @@ rtc_source_set("module_api_public") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } -rtc_library("module_api") { +rtc_source_set("module_api") { visibility = [ "*" ] sources = [ "include/module.h", - "include/module_common_types.cc", "include/module_common_types.h", ] - deps = [ - "../rtc_base:safe_conversions", - "../rtc_base/system:rtc_export", - ] } rtc_source_set("module_fec_api") { diff --git a/modules/include/module_common_types.cc b/modules/include/module_common_types.cc deleted file mode 100644 index a589312ec2..0000000000 --- a/modules/include/module_common_types.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -#include "modules/include/module_common_types.h" - -#include - -#include -#include - -#include "rtc_base/numerics/safe_conversions.h" - -namespace webrtc { - -RTPFragmentationHeader::RTPFragmentationHeader() - : fragmentationVectorSize(0), - fragmentationOffset(nullptr), - fragmentationLength(nullptr) {} - -RTPFragmentationHeader::RTPFragmentationHeader(RTPFragmentationHeader&& other) - : RTPFragmentationHeader() { - swap(*this, other); -} - -RTPFragmentationHeader& RTPFragmentationHeader::operator=( - RTPFragmentationHeader&& other) { - swap(*this, other); - return *this; -} - -RTPFragmentationHeader::~RTPFragmentationHeader() { - delete[] fragmentationOffset; - delete[] fragmentationLength; -} - -void swap(RTPFragmentationHeader& a, RTPFragmentationHeader& b) { - using std::swap; - swap(a.fragmentationVectorSize, b.fragmentationVectorSize); - swap(a.fragmentationOffset, b.fragmentationOffset); - swap(a.fragmentationLength, b.fragmentationLength); -} - -void RTPFragmentationHeader::CopyFrom(const RTPFragmentationHeader& src) { - if (this == &src) { - return; - } - - if (src.fragmentationVectorSize != fragmentationVectorSize) { - // new size of vectors - - // delete old - delete[] fragmentationOffset; - fragmentationOffset = nullptr; - delete[] fragmentationLength; - fragmentationLength = nullptr; - - if (src.fragmentationVectorSize > 0) { - // allocate new - if (src.fragmentationOffset) { - fragmentationOffset = new size_t[src.fragmentationVectorSize]; - } - if (src.fragmentationLength) { - fragmentationLength = new size_t[src.fragmentationVectorSize]; - } - } - // set new size - fragmentationVectorSize = src.fragmentationVectorSize; - } - - if (src.fragmentationVectorSize > 0) { - // copy values - if (src.fragmentationOffset) { - memcpy(fragmentationOffset, src.fragmentationOffset, - src.fragmentationVectorSize * sizeof(size_t)); - } - if (src.fragmentationLength) { - memcpy(fragmentationLength, src.fragmentationLength, - src.fragmentationVectorSize * sizeof(size_t)); - } - } -} - -void RTPFragmentationHeader::Resize(size_t size) { - const uint16_t size16 = rtc::dchecked_cast(size); - if (fragmentationVectorSize < size16) { - uint16_t old_vector_size = fragmentationVectorSize; - size_t* old_offsets = fragmentationOffset; - fragmentationOffset = new size_t[size16]; - memset(fragmentationOffset + old_vector_size, 0, - sizeof(size_t) * (size16 - old_vector_size)); - size_t* old_lengths = fragmentationLength; - fragmentationLength = new size_t[size16]; - memset(fragmentationLength + old_vector_size, 0, - sizeof(size_t) * (size16 - old_vector_size)); - - // copy old values - if (old_vector_size > 0) { - if (old_offsets != nullptr) { - memcpy(fragmentationOffset, old_offsets, - sizeof(size_t) * old_vector_size); - delete[] old_offsets; - } - if (old_lengths != nullptr) { - memcpy(fragmentationLength, old_lengths, - sizeof(size_t) * old_vector_size); - delete[] old_lengths; - } - } - fragmentationVectorSize = size16; - } -} - -} // namespace webrtc diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h index 3afd7b7d7a..7c9ef39cf0 100644 --- a/modules/include/module_common_types.h +++ b/modules/include/module_common_types.h @@ -11,44 +11,12 @@ #ifndef MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ #define MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ -#include #include #include -#include "rtc_base/system/rtc_export.h" - namespace webrtc { -class RTC_EXPORT RTPFragmentationHeader { - public: - RTPFragmentationHeader(); - RTPFragmentationHeader(const RTPFragmentationHeader&) = delete; - RTPFragmentationHeader(RTPFragmentationHeader&& other); - RTPFragmentationHeader& operator=(const RTPFragmentationHeader& other) = - delete; - RTPFragmentationHeader& operator=(RTPFragmentationHeader&& other); - ~RTPFragmentationHeader(); - - friend void swap(RTPFragmentationHeader& a, RTPFragmentationHeader& b); - - void CopyFrom(const RTPFragmentationHeader& src); - void VerifyAndAllocateFragmentationHeader(size_t size) { Resize(size); } - - void Resize(size_t size); - size_t Size() const { return fragmentationVectorSize; } - - size_t Offset(size_t index) const { return fragmentationOffset[index]; } - size_t Length(size_t index) const { return fragmentationLength[index]; } - - // TODO(danilchap): Move all members to private section, - // simplify by replacing raw arrays with single std::vector - uint16_t fragmentationVectorSize; // Number of fragmentations - size_t* fragmentationOffset; // Offset of pointer to data for each - // fragmentation - size_t* fragmentationLength; // Data size for each fragmentation -}; - // Interface used by the CallStats class to distribute call statistics. // Callbacks will be triggered as soon as the class has been registered to a // CallStats object using RegisterStatsObserver.