From a837030f8fdb541ab16bc75fb06477316e85fe2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 2 Sep 2019 15:16:49 +0200 Subject: [PATCH] Split out RtpSource from libjingle_peerconnection_api And moved declaration into a new api directory, as api/transport/rtp/rtp_source.h. Bug: webrtc:8733 Change-Id: Ia73b7b0630e6065de4707a37633adddfa00a2b8a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150880 Commit-Queue: Niels Moller Reviewed-by: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#29039} --- api/BUILD.gn | 1 + api/rtp_receiver_interface.cc | 15 ----- api/rtp_receiver_interface.h | 53 +--------------- api/transport/rtp/BUILD.gn | 20 ++++++ api/transport/rtp/rtp_source.h | 80 ++++++++++++++++++++++++ audio/BUILD.gn | 1 + audio/channel_receive.cc | 1 + audio/channel_receive.h | 2 +- call/BUILD.gn | 3 + call/audio_receive_stream.h | 4 +- call/call_perf_tests.cc | 1 + call/video_receive_stream.h | 5 +- media/BUILD.gn | 2 + media/base/media_channel.h | 3 +- media/engine/webrtc_voice_engine.h | 2 +- modules/rtp_rtcp/BUILD.gn | 1 + modules/rtp_rtcp/source/source_tracker.h | 2 +- pc/BUILD.gn | 1 + pc/track_media_info_map_unittest.cc | 2 +- test/scenario/stats_collection.cc | 1 + 20 files changed, 124 insertions(+), 76 deletions(-) create mode 100644 api/transport/rtp/BUILD.gn create mode 100644 api/transport/rtp/rtp_source.h diff --git a/api/BUILD.gn b/api/BUILD.gn index 925f32fc71..1777648932 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -177,6 +177,7 @@ rtc_static_library("libjingle_peerconnection_api") { "transport:network_control", "transport/media:audio_interfaces", "transport/media:video_interfaces", + "transport/rtp:rtp_source", "units:data_rate", "units:timestamp", "video:encoded_image", diff --git a/api/rtp_receiver_interface.cc b/api/rtp_receiver_interface.cc index adc832ba38..d20516b67c 100644 --- a/api/rtp_receiver_interface.cc +++ b/api/rtp_receiver_interface.cc @@ -12,21 +12,6 @@ namespace webrtc { -RtpSource::RtpSource(int64_t timestamp_ms, - uint32_t source_id, - RtpSourceType source_type, - absl::optional audio_level, - uint32_t rtp_timestamp) - : timestamp_ms_(timestamp_ms), - source_id_(source_id), - source_type_(source_type), - audio_level_(audio_level), - rtp_timestamp_(rtp_timestamp) {} - -RtpSource::RtpSource(const RtpSource&) = default; -RtpSource& RtpSource::operator=(const RtpSource&) = default; -RtpSource::~RtpSource() = default; - std::vector RtpReceiverInterface::stream_ids() const { return {}; } diff --git a/api/rtp_receiver_interface.h b/api/rtp_receiver_interface.h index a6ee546d9e..ffd7497a1b 100644 --- a/api/rtp_receiver_interface.h +++ b/api/rtp_receiver_interface.h @@ -24,63 +24,12 @@ #include "api/proxy.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" +#include "api/transport/rtp/rtp_source.h" #include "rtc_base/deprecation.h" #include "rtc_base/ref_count.h" namespace webrtc { -enum class RtpSourceType { - SSRC, - CSRC, -}; - -class RtpSource { - public: - RtpSource() = delete; - - RtpSource(int64_t timestamp_ms, - uint32_t source_id, - RtpSourceType source_type, - absl::optional audio_level, - uint32_t rtp_timestamp); - - RtpSource(const RtpSource&); - RtpSource& operator=(const RtpSource&); - ~RtpSource(); - - int64_t timestamp_ms() const { return timestamp_ms_; } - void update_timestamp_ms(int64_t timestamp_ms) { - RTC_DCHECK_LE(timestamp_ms_, timestamp_ms); - timestamp_ms_ = timestamp_ms; - } - - // The identifier of the source can be the CSRC or the SSRC. - uint32_t source_id() const { return source_id_; } - - // The source can be either a contributing source or a synchronization source. - RtpSourceType source_type() const { return source_type_; } - - absl::optional audio_level() const { return audio_level_; } - void set_audio_level(const absl::optional& level) { - audio_level_ = level; - } - - uint32_t rtp_timestamp() const { return rtp_timestamp_; } - - bool operator==(const RtpSource& o) const { - return timestamp_ms_ == o.timestamp_ms() && source_id_ == o.source_id() && - source_type_ == o.source_type() && audio_level_ == o.audio_level_ && - rtp_timestamp_ == o.rtp_timestamp(); - } - - private: - int64_t timestamp_ms_; - uint32_t source_id_; - RtpSourceType source_type_; - absl::optional audio_level_; - uint32_t rtp_timestamp_; -}; - class RtpReceiverObserverInterface { public: // Note: Currently if there are multiple RtpReceivers of the same media type, diff --git a/api/transport/rtp/BUILD.gn b/api/transport/rtp/BUILD.gn new file mode 100644 index 0000000000..04298e3902 --- /dev/null +++ b/api/transport/rtp/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2019 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. + +import("../../../webrtc.gni") + +rtc_source_set("rtp_source") { + visibility = [ "*" ] + sources = [ + "rtp_source.h", + ] + deps = [ + "../../../rtc_base:checks", + "//third_party/abseil-cpp/absl/types:optional", + ] +} diff --git a/api/transport/rtp/rtp_source.h b/api/transport/rtp/rtp_source.h new file mode 100644 index 0000000000..d26572c933 --- /dev/null +++ b/api/transport/rtp/rtp_source.h @@ -0,0 +1,80 @@ +/* + * Copyright 2019 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. + */ + +#ifndef API_TRANSPORT_RTP_RTP_SOURCE_H_ +#define API_TRANSPORT_RTP_RTP_SOURCE_H_ + +#include + +#include "absl/types/optional.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +enum class RtpSourceType { + SSRC, + CSRC, +}; + +class RtpSource { + public: + RtpSource() = delete; + + RtpSource(int64_t timestamp_ms, + uint32_t source_id, + RtpSourceType source_type, + absl::optional audio_level, + uint32_t rtp_timestamp) + : timestamp_ms_(timestamp_ms), + source_id_(source_id), + source_type_(source_type), + audio_level_(audio_level), + rtp_timestamp_(rtp_timestamp) {} + + RtpSource(const RtpSource&) = default; + RtpSource& operator=(const RtpSource&) = default; + ~RtpSource() = default; + + int64_t timestamp_ms() const { return timestamp_ms_; } + void update_timestamp_ms(int64_t timestamp_ms) { + RTC_DCHECK_LE(timestamp_ms_, timestamp_ms); + timestamp_ms_ = timestamp_ms; + } + + // The identifier of the source can be the CSRC or the SSRC. + uint32_t source_id() const { return source_id_; } + + // The source can be either a contributing source or a synchronization source. + RtpSourceType source_type() const { return source_type_; } + + absl::optional audio_level() const { return audio_level_; } + void set_audio_level(const absl::optional& level) { + audio_level_ = level; + } + + uint32_t rtp_timestamp() const { return rtp_timestamp_; } + + bool operator==(const RtpSource& o) const { + return timestamp_ms_ == o.timestamp_ms() && source_id_ == o.source_id() && + source_type_ == o.source_type() && audio_level_ == o.audio_level_ && + rtp_timestamp_ == o.rtp_timestamp(); + } + + private: + int64_t timestamp_ms_; + uint32_t source_id_; + RtpSourceType source_type_; + absl::optional audio_level_; + uint32_t rtp_timestamp_; +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_RTP_RTP_SOURCE_H_ diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 4bd6f57d15..abf4c67270 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -54,6 +54,7 @@ rtc_static_library("audio") { "../api/audio_codecs:audio_codecs_api", "../api/rtc_event_log", "../api/task_queue", + "../api/transport/rtp:rtp_source", "../call:bitrate_allocator", "../call:call_interfaces", "../call:rtp_interfaces", diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 2df6a5c572..603a52f791 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -18,6 +18,7 @@ #include #include "absl/memory/memory.h" +#include "api/crypto/frame_decryptor_interface.h" #include "api/rtc_event_log/rtc_event_log.h" #include "audio/audio_level.h" #include "audio/channel_send.h" diff --git a/audio/channel_receive.h b/audio/channel_receive.h index 6d9c246a3b..a7151bcb8e 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -24,7 +24,7 @@ #include "api/crypto/crypto_options.h" #include "api/media_transport_config.h" #include "api/media_transport_interface.h" -#include "api/rtp_receiver_interface.h" +#include "api/transport/rtp/rtp_source.h" #include "call/rtp_packet_sink_interface.h" #include "call/syncable.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" diff --git a/call/BUILD.gn b/call/BUILD.gn index c044a806e5..b91d18b93b 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -43,6 +43,7 @@ rtc_source_set("call_interfaces") { "../api/audio_codecs:audio_codecs_api", "../api/task_queue", "../api/transport:network_control", + "../api/transport/rtp:rtp_source", "../modules/audio_device", "../modules/audio_processing", "../modules/audio_processing:api", @@ -284,6 +285,7 @@ rtc_source_set("video_stream_api") { "../api:rtp_headers", "../api:rtp_parameters", "../api:transport_api", + "../api/transport/rtp:rtp_source", "../api/video:video_frame", "../api/video:video_rtp_headers", "../api/video:video_stream_encoder", @@ -449,6 +451,7 @@ if (rtc_include_tests) { "../modules/audio_device:audio_device_impl", "../modules/audio_mixer:audio_mixer_impl", "../modules/rtp_rtcp", + "../rtc_base", "../rtc_base:checks", "../rtc_base:rtc_base_approved", "../system_wrappers", diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index 2bb8be1068..0b764a1995 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h @@ -20,15 +20,15 @@ #include "api/audio_codecs/audio_decoder_factory.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" +#include "api/crypto/frame_decryptor_interface.h" #include "api/media_transport_config.h" #include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" #include "api/scoped_refptr.h" +#include "api/transport/rtp/rtp_source.h" #include "call/rtp_config.h" namespace webrtc { class AudioSinkInterface; -class FrameDecryptorInterface; class AudioReceiveStream { public: diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 5da1fae2c5..91d0bc3a03 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -28,6 +28,7 @@ #include "modules/audio_device/include/test_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "rtc_base/checks.h" +#include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/metrics.h" #include "test/call_test.h" diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index fa37fe895f..3869c8117a 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -19,12 +19,14 @@ #include "api/call/transport.h" #include "api/crypto/crypto_options.h" +#include "api/crypto/frame_decryptor_interface.h" #include "api/media_transport_config.h" #include "api/media_transport_interface.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" +#include "api/transport/rtp/rtp_source.h" #include "api/video/video_content_type.h" +#include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video/video_timing.h" #include "api/video_codecs/sdp_video_format.h" @@ -34,7 +36,6 @@ namespace webrtc { -class FrameDecryptorInterface; class RtpPacketSinkInterface; class VideoDecoderFactory; diff --git a/media/BUILD.gn b/media/BUILD.gn index fd995e64d9..533840da00 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -78,6 +78,7 @@ rtc_static_library("rtc_media_base") { "../api:rtp_parameters", "../api:scoped_refptr", "../api/audio_codecs:audio_codecs_api", + "../api/transport/rtp:rtp_source", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator_factory", "../api/video:video_frame", @@ -264,6 +265,7 @@ rtc_static_library("rtc_audio_video") { "../api/audio:audio_mixer_api", "../api/audio_codecs:audio_codecs_api", "../api/task_queue", + "../api/transport/rtp:rtp_source", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator_factory", "../api/video:video_codec_constants", diff --git a/media/base/media_channel.h b/media/base/media_channel.h index c2378747aa..0f502d3438 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -25,7 +25,7 @@ #include "api/media_transport_config.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" +#include "api/transport/rtp/rtp_source.h" #include "api/video/video_content_type.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" @@ -42,6 +42,7 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" #include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/critical_section.h" #include "rtc_base/dscp.h" #include "rtc_base/logging.h" #include "rtc_base/network_route.h" diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index 4451978fac..c1a687b301 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -17,9 +17,9 @@ #include #include "api/audio_codecs/audio_encoder_factory.h" -#include "api/rtp_receiver_interface.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_factory.h" +#include "api/transport/rtp/rtp_source.h" #include "call/audio_state.h" #include "call/call.h" #include "media/base/media_engine.h" diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 24ed0d2206..73f378f8d9 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -228,6 +228,7 @@ rtc_static_library("rtp_rtcp") { "../../api/rtc_event_log", "../../api/transport:field_trial_based_config", "../../api/transport:webrtc_key_value_config", + "../../api/transport/rtp:rtp_source", "../../api/units:time_delta", "../../api/units:timestamp", "../../api/video:video_bitrate_allocation", diff --git a/modules/rtp_rtcp/source/source_tracker.h b/modules/rtp_rtcp/source/source_tracker.h index 035b9ec0f6..3ea16e9db8 100644 --- a/modules/rtp_rtcp/source/source_tracker.h +++ b/modules/rtp_rtcp/source/source_tracker.h @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "api/rtp_packet_infos.h" -#include "api/rtp_receiver_interface.h" +#include "api/transport/rtp/rtp_source.h" #include "rtc_base/critical_section.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 64706c1b69..6f868c24c4 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -541,6 +541,7 @@ if (rtc_include_tests) { "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", + "../api/transport/rtp:rtp_source", "../api/units:time_delta", "../api/video:builtin_video_bitrate_allocator_factory", "../logging:fake_rtc_event_log", diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc index 3b0022c4a5..4fa8a4ae03 100644 --- a/pc/track_media_info_map_unittest.cc +++ b/pc/track_media_info_map_unittest.cc @@ -16,8 +16,8 @@ #include #include -#include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" +#include "api/transport/rtp/rtp_source.h" #include "media/base/media_channel.h" #include "pc/audio_track.h" #include "pc/test/fake_video_track_source.h" diff --git a/test/scenario/stats_collection.cc b/test/scenario/stats_collection.cc index a78fb7eb3e..4161149d2c 100644 --- a/test/scenario/stats_collection.cc +++ b/test/scenario/stats_collection.cc @@ -12,6 +12,7 @@ #include "common_video/libyuv/include/webrtc_libyuv.h" #include "rtc_base/memory_usage.h" +#include "rtc_base/thread.h" namespace webrtc { namespace test {