diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 5633f28df1..e067791a18 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -284,7 +284,6 @@ if (!build_with_chromium) { ":video_engine_tests", ":webrtc_nonparallel_tests", ":webrtc_perf_tests", - "api:peerconnection_unittests", "base:rtc_base_tests_utils", "common_audio:common_audio_unittests", "common_video:common_video_unittests", @@ -295,6 +294,7 @@ if (!build_with_chromium) { "modules/audio_processing:audio_processing_tests", "modules/rtp_rtcp:test_packet_masks_metrics", "modules/video_capture:video_capture_internal_impl", + "pc:peerconnection_unittests", "pc:rtc_pc_unittests", "stats:rtc_stats_unittests", "system_wrappers:system_wrappers_unittests", diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn index fa3c629524..9d893e0c01 100644 --- a/webrtc/api/BUILD.gn +++ b/webrtc/api/BUILD.gn @@ -14,7 +14,7 @@ if (is_android) { group("api") { public_deps = [ - ":libjingle_peerconnection", + ":libjingle_peerconnection_api", ] } @@ -34,122 +34,63 @@ rtc_source_set("call_api") { ] } -config("libjingle_peerconnection_warnings_config") { - # GN orders flags on a target before flags from configs. The default config - # adds these flags so to cancel them out they need to come from a config and - # cannot be on the target directly. - if (!is_win && !is_clang) { - cflags = [ "-Wno-maybe-uninitialized" ] # Only exists for GCC. - } -} - -rtc_static_library("libjingle_peerconnection") { +rtc_static_library("libjingle_peerconnection_api") { check_includes = false # TODO(kjellander): Remove (bugs.webrtc.org/6828) cflags = [] sources = [ - "audiotrack.cc", - "audiotrack.h", - "datachannel.cc", "datachannel.h", "datachannelinterface.h", - "dtmfsender.cc", - "dtmfsender.h", "dtmfsenderinterface.h", "jsep.h", - "jsepicecandidate.cc", "jsepicecandidate.h", - "jsepsessiondescription.cc", "jsepsessiondescription.h", - "localaudiosource.cc", - "localaudiosource.h", "mediaconstraintsinterface.cc", "mediaconstraintsinterface.h", - "mediacontroller.cc", "mediacontroller.h", - "mediastream.cc", "mediastream.h", + "mediastreaminterface.cc", "mediastreaminterface.h", - "mediastreamobserver.cc", - "mediastreamobserver.h", "mediastreamproxy.h", "mediastreamtrack.h", "mediastreamtrackproxy.h", + "mediatypes.cc", + "mediatypes.h", "notifier.h", - "ortcfactory.cc", - "ortcfactory.h", "ortcfactoryinterface.h", - "peerconnection.cc", - "peerconnection.h", - "peerconnectionfactory.cc", - "peerconnectionfactory.h", "peerconnectionfactoryproxy.h", "peerconnectioninterface.h", "peerconnectionproxy.h", "proxy.h", - "remoteaudiosource.cc", - "remoteaudiosource.h", - "rtcstatscollector.cc", - "rtcstatscollector.h", "rtpparameters.h", - "rtpreceiver.cc", - "rtpreceiver.h", "rtpreceiverinterface.h", - "rtpsender.cc", "rtpsender.h", "rtpsenderinterface.h", - "sctputils.cc", - "sctputils.h", - "statscollector.cc", - "statscollector.h", "statstypes.cc", "statstypes.h", "streamcollection.h", "trackmediainfomap.cc", "trackmediainfomap.h", "udptransportinterface.h", - "videocapturertracksource.cc", - "videocapturertracksource.h", + "umametrics.h", "videosourceproxy.h", - "videotrack.cc", - "videotrack.h", - "videotracksource.cc", "videotracksource.h", - "webrtcsdp.cc", - "webrtcsdp.h", - "webrtcsession.cc", - "webrtcsession.h", - "webrtcsessiondescriptionfactory.cc", - "webrtcsessiondescriptionfactory.h", ] - configs += [ ":libjingle_peerconnection_warnings_config" ] - if (!build_with_chromium && is_clang) { # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] } deps = [ - ":call_api", ":rtc_stats_api", - "../call", - "../media", - "../pc", - "../stats", ] +} - if (rtc_use_quic) { - sources += [ - "quicdatachannel.cc", - "quicdatachannel.h", - "quicdatatransport.cc", - "quicdatatransport.h", - ] - deps += [ "//third_party/libquic" ] - public_deps = [ - "//third_party/libquic", - ] - } +# TODO(ossu): Remove once downstream projects have updated. +rtc_source_set("libjingle_peerconnection") { + deps = [ + "../pc:libjingle_peerconnection", + ] } rtc_source_set("rtc_stats_api") { @@ -157,6 +98,7 @@ rtc_source_set("rtc_stats_api") { sources = [ "stats/rtcstats.h", "stats/rtcstats_objects.h", + "stats/rtcstatscollectorcallback.h", "stats/rtcstatsreport.h", ] @@ -210,134 +152,6 @@ rtc_source_set("video_frame_api") { } if (rtc_include_tests) { - config("peerconnection_unittests_config") { - # The warnings below are enabled by default. Since GN orders compiler flags - # for a target before flags from configs, the only way to disable such - # warnings is by having them in a separate config, loaded from the target. - # TODO(kjellander): Make the code compile without disabling these flags. - # See https://bugs.webrtc.org/3307. - if (is_clang && is_win) { - cflags = [ - # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6267 - # for -Wno-sign-compare - "-Wno-sign-compare", - "-Wno-unused-function", - ] - } - - if (!is_win) { - cflags = [ "-Wno-sign-compare" ] - } - } - - rtc_test("peerconnection_unittests") { - check_includes = false # TODO(kjellander): Remove (bugs.webrtc.org/6828) - testonly = true - sources = [ - "datachannel_unittest.cc", - "dtmfsender_unittest.cc", - "jsepsessiondescription_unittest.cc", - "localaudiosource_unittest.cc", - "mediaconstraintsinterface_unittest.cc", - "mediastream_unittest.cc", - "ortcfactory_unittest.cc", - "peerconnection_unittest.cc", - "peerconnectionendtoend_unittest.cc", - "peerconnectionfactory_unittest.cc", - "peerconnectioninterface_unittest.cc", - "proxy_unittest.cc", - "rtcstats_integrationtest.cc", - "rtcstatscollector_unittest.cc", - "rtpsenderreceiver_unittest.cc", - "sctputils_unittest.cc", - "statscollector_unittest.cc", - "test/fakeaudiocapturemodule.cc", - "test/fakeaudiocapturemodule.h", - "test/fakeaudiocapturemodule_unittest.cc", - "test/fakeconstraints.h", - "test/fakedatachannelprovider.h", - "test/fakeperiodicvideocapturer.h", - "test/fakertccertificategenerator.h", - "test/fakevideotrackrenderer.h", - "test/mock_datachannel.h", - "test/mock_peerconnection.h", - "test/mock_rtpreceiver.h", - "test/mock_rtpsender.h", - "test/mock_webrtcsession.h", - "test/mockpeerconnectionobservers.h", - "test/peerconnectiontestwrapper.cc", - "test/peerconnectiontestwrapper.h", - "test/rtcstatsobtainer.h", - "test/testsdpstrings.h", - "trackmediainfomap_unittest.cc", - "videocapturertracksource_unittest.cc", - "videotrack_unittest.cc", - "webrtcsdp_unittest.cc", - "webrtcsession_unittest.cc", - ] - - if (rtc_enable_sctp) { - defines = [ "HAVE_SCTP" ] - } - - configs += [ ":peerconnection_unittests_config" ] - - if (!build_with_chromium && is_clang) { - # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). - suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] - } - - # TODO(jschuh): Bug 1348: fix this warning. - configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] - - if (is_win) { - cflags = [ - "/wd4245", # conversion from int to size_t, signed/unsigned mismatch. - "/wd4389", # signed/unsigned mismatch. - ] - } - - if (rtc_use_quic) { - public_deps = [ - "//third_party/libquic", - ] - sources += [ - "quicdatachannel_unittest.cc", - "quicdatatransport_unittest.cc", - ] - } - - deps = [] - if (is_android) { - sources += [ - "test/androidtestinitializer.cc", - "test/androidtestinitializer.h", - ] - deps += [ - "//testing/android/native_test:native_test_support", - "//webrtc/sdk/android:libjingle_peerconnection_java", - "//webrtc/sdk/android:libjingle_peerconnection_jni", - ] - } - - deps += [ - ":fakemetricsobserver", - ":libjingle_peerconnection", - "..:webrtc_common", - "../base:rtc_base_tests_utils", - "../media:rtc_unittest_main", - "../pc:rtc_pc", - "../system_wrappers:metrics_default", - "//testing/gmock", - ] - - if (is_android) { - deps += [ "//testing/android/native_test:native_test_support" ] - - shard_timeout = 900 - } - } - rtc_source_set("mock_audio_mixer") { testonly = true sources = [ @@ -354,6 +168,22 @@ if (rtc_include_tests) { ] } + rtc_source_set("libjingle_peerconnection_test_api") { + testonly = true + sources = [ + "test/fakeconstraints.h", + ] + + public_deps = [ + ":libjingle_peerconnection_api", + ] + + deps = [ + "../base:rtc_base_approved", + "//webrtc/test:test_support", + ] + } + rtc_source_set("fakemetricsobserver") { testonly = true sources = [ @@ -361,7 +191,7 @@ if (rtc_include_tests) { "fakemetricsobserver.h", ] deps = [ - ":libjingle_peerconnection", + ":libjingle_peerconnection_api", "../base:rtc_base_approved", ] if (!build_with_chromium && is_clang) { diff --git a/webrtc/api/DEPS b/webrtc/api/DEPS index 75f756de05..01d719a129 100644 --- a/webrtc/api/DEPS +++ b/webrtc/api/DEPS @@ -5,35 +5,10 @@ include_rules = [ "+webrtc/media", "+webrtc/p2p", "+webrtc/pc", - "+webrtc/logging/rtc_event_log", - "+webrtc/modules/audio_device", - "+webrtc/modules/rtp_rtcp", - "+webrtc/modules/video_coding", - "+webrtc/modules/video_render", - "+webrtc/system_wrappers", ] specific_include_rules = { - "androidtestinitializer\.cc": [ - "+base/android", # Allowed only for Android tests. - "+webrtc/voice_engine", - ], - # The call/call.h exceptions are here only until the peerconnection - # implementation has been moved out of api/. See: - # http://bugs.webrtc.org/5883 - "mediacontroller\.cc": [ - "+webrtc/call/call.h" - ], - "peerconnection\.cc": [ - "+webrtc/call/call.h" - ], "peerconnection_jni\.cc": [ "+webrtc/voice_engine", ], - "peerconnectionfactory\.cc": [ - "+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h", - ], - "webrtcsession\.cc": [ - "+webrtc/call/call.h" - ], } diff --git a/webrtc/api/datachannel.h b/webrtc/api/datachannel.h index cdb2e627b6..28112addbb 100644 --- a/webrtc/api/datachannel.h +++ b/webrtc/api/datachannel.h @@ -11,288 +11,8 @@ #ifndef WEBRTC_API_DATACHANNEL_H_ #define WEBRTC_API_DATACHANNEL_H_ -#include -#include -#include - -#include "webrtc/api/datachannelinterface.h" -#include "webrtc/api/proxy.h" -#include "webrtc/base/messagehandler.h" -#include "webrtc/base/scoped_ref_ptr.h" -#include "webrtc/base/sigslot.h" -#include "webrtc/media/base/mediachannel.h" -#include "webrtc/pc/channel.h" - -namespace webrtc { - -class DataChannel; - -class DataChannelProviderInterface { - public: - // Sends the data to the transport. - virtual bool SendData(const cricket::SendDataParams& params, - const rtc::CopyOnWriteBuffer& payload, - cricket::SendDataResult* result) = 0; - // Connects to the transport signals. - virtual bool ConnectDataChannel(DataChannel* data_channel) = 0; - // Disconnects from the transport signals. - virtual void DisconnectDataChannel(DataChannel* data_channel) = 0; - // Adds the data channel SID to the transport for SCTP. - virtual void AddSctpDataStream(int sid) = 0; - // Removes the data channel SID from the transport for SCTP. - virtual void RemoveSctpDataStream(int sid) = 0; - // Returns true if the transport channel is ready to send data. - virtual bool ReadyToSendData() const = 0; - - protected: - virtual ~DataChannelProviderInterface() {} -}; - -struct InternalDataChannelInit : public DataChannelInit { - enum OpenHandshakeRole { - kOpener, - kAcker, - kNone - }; - // The default role is kOpener because the default |negotiated| is false. - InternalDataChannelInit() : open_handshake_role(kOpener) {} - explicit InternalDataChannelInit(const DataChannelInit& base) - : DataChannelInit(base), open_handshake_role(kOpener) { - // If the channel is externally negotiated, do not send the OPEN message. - if (base.negotiated) { - open_handshake_role = kNone; - } - } - - OpenHandshakeRole open_handshake_role; -}; - -// Helper class to allocate unique IDs for SCTP DataChannels -class SctpSidAllocator { - public: - // Gets the first unused odd/even id based on the DTLS role. If |role| is - // SSL_CLIENT, the allocated id starts from 0 and takes even numbers; - // otherwise, the id starts from 1 and takes odd numbers. - // Returns false if no id can be allocated. - bool AllocateSid(rtc::SSLRole role, int* sid); - - // Attempts to reserve a specific sid. Returns false if it's unavailable. - bool ReserveSid(int sid); - - // Indicates that |sid| isn't in use any more, and is thus available again. - void ReleaseSid(int sid); - - private: - // Checks if |sid| is available to be assigned to a new SCTP data channel. - bool IsSidAvailable(int sid) const; - - std::set used_sids_; -}; - -// DataChannel is a an implementation of the DataChannelInterface based on -// libjingle's data engine. It provides an implementation of unreliable or -// reliabledata channels. Currently this class is specifically designed to use -// both RtpDataEngine and SctpDataEngine. - -// DataChannel states: -// kConnecting: The channel has been created the transport might not yet be -// ready. -// kOpen: The channel have a local SSRC set by a call to UpdateSendSsrc -// and a remote SSRC set by call to UpdateReceiveSsrc and the transport -// has been writable once. -// kClosing: DataChannelInterface::Close has been called or UpdateReceiveSsrc -// has been called with SSRC==0 -// kClosed: Both UpdateReceiveSsrc and UpdateSendSsrc has been called with -// SSRC==0. -class DataChannel : public DataChannelInterface, - public sigslot::has_slots<>, - public rtc::MessageHandler { - public: - static rtc::scoped_refptr Create( - DataChannelProviderInterface* provider, - cricket::DataChannelType dct, - const std::string& label, - const InternalDataChannelInit& config); - - virtual void RegisterObserver(DataChannelObserver* observer); - virtual void UnregisterObserver(); - - virtual std::string label() const { return label_; } - virtual bool reliable() const; - virtual bool ordered() const { return config_.ordered; } - virtual uint16_t maxRetransmitTime() const { - return config_.maxRetransmitTime; - } - virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; } - virtual std::string protocol() const { return config_.protocol; } - virtual bool negotiated() const { return config_.negotiated; } - virtual int id() const { return config_.id; } - virtual uint64_t buffered_amount() const; - virtual void Close(); - virtual DataState state() const { return state_; } - virtual uint32_t messages_sent() const { return messages_sent_; } - virtual uint64_t bytes_sent() const { return bytes_sent_; } - virtual uint32_t messages_received() const { return messages_received_; } - virtual uint64_t bytes_received() const { return bytes_received_; } - virtual bool Send(const DataBuffer& buffer); - - // rtc::MessageHandler override. - virtual void OnMessage(rtc::Message* msg); - - // Called when the channel's ready to use. That can happen when the - // underlying DataMediaChannel becomes ready, or when this channel is a new - // stream on an existing DataMediaChannel, and we've finished negotiation. - void OnChannelReady(bool writable); - - // Slots for provider to connect signals to. - void OnDataReceived(const cricket::ReceiveDataParams& params, - const rtc::CopyOnWriteBuffer& payload); - void OnStreamClosedRemotely(int sid); - - // The remote peer request that this channel should be closed. - void RemotePeerRequestClose(); - - // The following methods are for SCTP only. - - // Sets the SCTP sid and adds to transport layer if not set yet. Should only - // be called once. - void SetSctpSid(int sid); - // Called when the transport channel is created. - // Only needs to be called for SCTP data channels. - void OnTransportChannelCreated(); - // Called when the transport channel is destroyed. - // This method makes sure the DataChannel is disconnected and changes state - // to kClosed. - void OnTransportChannelDestroyed(); - - // The following methods are for RTP only. - - // Set the SSRC this channel should use to send data on the - // underlying data engine. |send_ssrc| == 0 means that the channel is no - // longer part of the session negotiation. - void SetSendSsrc(uint32_t send_ssrc); - // Set the SSRC this channel should use to receive data from the - // underlying data engine. - void SetReceiveSsrc(uint32_t receive_ssrc); - - cricket::DataChannelType data_channel_type() const { - return data_channel_type_; - } - - // Emitted when state transitions to kOpen. - sigslot::signal1 SignalOpened; - // Emitted when state transitions to kClosed. - // In the case of SCTP channels, this signal can be used to tell when the - // channel's sid is free. - sigslot::signal1 SignalClosed; - - protected: - DataChannel(DataChannelProviderInterface* client, - cricket::DataChannelType dct, - const std::string& label); - virtual ~DataChannel(); - - private: - // A packet queue which tracks the total queued bytes. Queued packets are - // owned by this class. - class PacketQueue { - public: - PacketQueue(); - ~PacketQueue(); - - size_t byte_count() const { - return byte_count_; - } - - bool Empty() const; - - DataBuffer* Front(); - - void Pop(); - - void Push(DataBuffer* packet); - - void Clear(); - - void Swap(PacketQueue* other); - - private: - std::deque packets_; - size_t byte_count_; - }; - - // The OPEN(_ACK) signaling state. - enum HandshakeState { - kHandshakeInit, - kHandshakeShouldSendOpen, - kHandshakeShouldSendAck, - kHandshakeWaitingForAck, - kHandshakeReady - }; - - bool Init(const InternalDataChannelInit& config); - void DoClose(); - void UpdateState(); - void SetState(DataState state); - void DisconnectFromProvider(); - - void DeliverQueuedReceivedData(); - - void SendQueuedDataMessages(); - bool SendDataMessage(const DataBuffer& buffer, bool queue_if_blocked); - bool QueueSendDataMessage(const DataBuffer& buffer); - - void SendQueuedControlMessages(); - void QueueControlMessage(const rtc::CopyOnWriteBuffer& buffer); - bool SendControlMessage(const rtc::CopyOnWriteBuffer& buffer); - - std::string label_; - InternalDataChannelInit config_; - DataChannelObserver* observer_; - DataState state_; - uint32_t messages_sent_; - uint64_t bytes_sent_; - uint32_t messages_received_; - uint64_t bytes_received_; - cricket::DataChannelType data_channel_type_; - DataChannelProviderInterface* provider_; - HandshakeState handshake_state_; - bool connected_to_provider_; - bool send_ssrc_set_; - bool receive_ssrc_set_; - bool writable_; - uint32_t send_ssrc_; - uint32_t receive_ssrc_; - // Control messages that always have to get sent out before any queued - // data. - PacketQueue queued_control_data_; - PacketQueue queued_received_data_; - PacketQueue queued_send_data_; -}; - -// Define proxy for DataChannelInterface. -BEGIN_SIGNALING_PROXY_MAP(DataChannel) - PROXY_SIGNALING_THREAD_DESTRUCTOR() - PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*) - PROXY_METHOD0(void, UnregisterObserver) - PROXY_CONSTMETHOD0(std::string, label) - PROXY_CONSTMETHOD0(bool, reliable) - PROXY_CONSTMETHOD0(bool, ordered) - PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) - PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) - PROXY_CONSTMETHOD0(std::string, protocol) - PROXY_CONSTMETHOD0(bool, negotiated) - PROXY_CONSTMETHOD0(int, id) - PROXY_CONSTMETHOD0(DataState, state) - PROXY_CONSTMETHOD0(uint32_t, messages_sent) - PROXY_CONSTMETHOD0(uint64_t, bytes_sent) - PROXY_CONSTMETHOD0(uint32_t, messages_received) - PROXY_CONSTMETHOD0(uint64_t, bytes_received) - PROXY_CONSTMETHOD0(uint64_t, buffered_amount) - PROXY_METHOD0(void, Close) - PROXY_METHOD1(bool, Send, const DataBuffer&) -END_PROXY_MAP() - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/datachannel.h" #endif // WEBRTC_API_DATACHANNEL_H_ diff --git a/webrtc/api/mediacontroller.h b/webrtc/api/mediacontroller.h index 5ada20d228..9c2b708500 100644 --- a/webrtc/api/mediacontroller.h +++ b/webrtc/api/mediacontroller.h @@ -11,34 +11,8 @@ #ifndef WEBRTC_API_MEDIACONTROLLER_H_ #define WEBRTC_API_MEDIACONTROLLER_H_ -#include "webrtc/base/thread.h" - -namespace cricket { -class ChannelManager; -struct MediaConfig; -} // namespace cricket - -namespace webrtc { -class Call; -class VoiceEngine; -class RtcEventLog; - -// The MediaController currently owns shared state between media channels, but -// in the future will create and own RtpSenders and RtpReceivers. -class MediaControllerInterface { - public: - static MediaControllerInterface* Create( - const cricket::MediaConfig& config, - rtc::Thread* worker_thread, - cricket::ChannelManager* channel_manager, - webrtc::RtcEventLog* event_log); - - virtual ~MediaControllerInterface() {} - virtual void Close() = 0; - virtual webrtc::Call* call_w() = 0; - virtual cricket::ChannelManager* channel_manager() const = 0; - virtual const cricket::MediaConfig& config() const = 0; -}; -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/mediacontroller.h" #endif // WEBRTC_API_MEDIACONTROLLER_H_ diff --git a/webrtc/api/mediastream.h b/webrtc/api/mediastream.h index 1f80f25207..e6556c5833 100644 --- a/webrtc/api/mediastream.h +++ b/webrtc/api/mediastream.h @@ -1,5 +1,5 @@ /* - * Copyright 2011 The WebRTC project authors. All Rights Reserved. + * Copyright 2015 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 @@ -8,51 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This file contains the implementation of MediaStreamInterface interface. - #ifndef WEBRTC_API_MEDIASTREAM_H_ #define WEBRTC_API_MEDIASTREAM_H_ -#include -#include - -#include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/notifier.h" - -namespace webrtc { - -class MediaStream : public Notifier { - public: - static rtc::scoped_refptr Create(const std::string& label); - - std::string label() const override { return label_; } - - bool AddTrack(AudioTrackInterface* track) override; - bool AddTrack(VideoTrackInterface* track) override; - bool RemoveTrack(AudioTrackInterface* track) override; - bool RemoveTrack(VideoTrackInterface* track) override; - rtc::scoped_refptr - FindAudioTrack(const std::string& track_id) override; - rtc::scoped_refptr - FindVideoTrack(const std::string& track_id) override; - - AudioTrackVector GetAudioTracks() override { return audio_tracks_; } - VideoTrackVector GetVideoTracks() override { return video_tracks_; } - - protected: - explicit MediaStream(const std::string& label); - - private: - template - bool AddTrack(TrackVector* Tracks, Track* track); - template - bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track); - - std::string label_; - AudioTrackVector audio_tracks_; - VideoTrackVector video_tracks_; -}; - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/mediastream.h" #endif // WEBRTC_API_MEDIASTREAM_H_ diff --git a/webrtc/api/mediastreaminterface.cc b/webrtc/api/mediastreaminterface.cc new file mode 100644 index 0000000000..d4fe5cbc2b --- /dev/null +++ b/webrtc/api/mediastreaminterface.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2017 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 "webrtc/api/mediastreaminterface.h" + +namespace webrtc { + +const char MediaStreamTrackInterface::kVideoKind[] = "video"; +const char MediaStreamTrackInterface::kAudioKind[] = "audio"; + +} // namespace webrtc diff --git a/webrtc/api/mediastreamtrack.h b/webrtc/api/mediastreamtrack.h index 9ba042010f..6075abec63 100644 --- a/webrtc/api/mediastreamtrack.h +++ b/webrtc/api/mediastreamtrack.h @@ -11,52 +11,8 @@ #ifndef WEBRTC_API_MEDIASTREAMTRACK_H_ #define WEBRTC_API_MEDIASTREAMTRACK_H_ -#include - -#include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/notifier.h" - -namespace webrtc { - -// MediaTrack implements the interface common to AudioTrackInterface and -// VideoTrackInterface. -template -class MediaStreamTrack : public Notifier { - public: - typedef typename T::TrackState TypedTrackState; - - std::string id() const override { return id_; } - MediaStreamTrackInterface::TrackState state() const override { - return state_; - } - bool enabled() const override { return enabled_; } - bool set_enabled(bool enable) override { - bool fire_on_change = (enable != enabled_); - enabled_ = enable; - if (fire_on_change) { - Notifier::FireOnChanged(); - } - return fire_on_change; - } - - protected: - explicit MediaStreamTrack(const std::string& id) - : enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {} - - bool set_state(MediaStreamTrackInterface::TrackState new_state) { - bool fire_on_change = (state_ != new_state); - state_ = new_state; - if (fire_on_change) - Notifier::FireOnChanged(); - return true; - } - - private: - bool enabled_; - std::string id_; - MediaStreamTrackInterface::TrackState state_; -}; - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/mediastreamtrack.h" #endif // WEBRTC_API_MEDIASTREAMTRACK_H_ diff --git a/webrtc/api/mediatypes.cc b/webrtc/api/mediatypes.cc new file mode 100644 index 0000000000..97b0189b7a --- /dev/null +++ b/webrtc/api/mediatypes.cc @@ -0,0 +1,35 @@ +/* + * Copyright 2016 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 "webrtc/api/mediatypes.h" +#include "webrtc/base/checks.h" + +namespace cricket { + +std::string MediaTypeToString(MediaType type) { + std::string type_str; + switch (type) { + case MEDIA_TYPE_AUDIO: + type_str = "audio"; + break; + case MEDIA_TYPE_VIDEO: + type_str = "video"; + break; + case MEDIA_TYPE_DATA: + type_str = "data"; + break; + default: + RTC_NOTREACHED(); + break; + } + return type_str; +} + +} // namespace cricket diff --git a/webrtc/api/mediatypes.h b/webrtc/api/mediatypes.h new file mode 100644 index 0000000000..19acf4b94e --- /dev/null +++ b/webrtc/api/mediatypes.h @@ -0,0 +1,28 @@ +/* + * Copyright 2016 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 WEBRTC_API_MEDIATYPES_H_ +#define WEBRTC_API_MEDIATYPES_H_ + +#include + +namespace cricket { + +enum MediaType { + MEDIA_TYPE_AUDIO, + MEDIA_TYPE_VIDEO, + MEDIA_TYPE_DATA +}; + +std::string MediaTypeToString(MediaType type); + +} // namespace cricket + +#endif // WEBRTC_API_MEDIATYPES_H_ diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h index e622e525c4..e42c60f4d6 100644 --- a/webrtc/api/peerconnectioninterface.h +++ b/webrtc/api/peerconnectioninterface.h @@ -61,7 +61,7 @@ #include "webrtc/api/dtmfsenderinterface.h" #include "webrtc/api/jsep.h" #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/rtcstatscollector.h" +#include "webrtc/api/stats/rtcstatscollectorcallback.h" #include "webrtc/api/rtpreceiverinterface.h" #include "webrtc/api/rtpsenderinterface.h" #include "webrtc/api/statstypes.h" diff --git a/webrtc/api/rtpreceiverinterface.h b/webrtc/api/rtpreceiverinterface.h index 103df473e3..4e47c9abab 100644 --- a/webrtc/api/rtpreceiverinterface.h +++ b/webrtc/api/rtpreceiverinterface.h @@ -16,12 +16,12 @@ #include +#include "webrtc/api/mediatypes.h" #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/proxy.h" #include "webrtc/api/rtpparameters.h" #include "webrtc/base/refcount.h" #include "webrtc/base/scoped_ref_ptr.h" -#include "webrtc/pc/mediasession.h" namespace webrtc { diff --git a/webrtc/api/rtpsender.h b/webrtc/api/rtpsender.h index 6c0592148b..3b7faec631 100644 --- a/webrtc/api/rtpsender.h +++ b/webrtc/api/rtpsender.h @@ -8,228 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This file contains classes that implement RtpSenderInterface. -// An RtpSender associates a MediaStreamTrackInterface with an underlying -// transport (provided by AudioProviderInterface/VideoProviderInterface) - #ifndef WEBRTC_API_RTPSENDER_H_ #define WEBRTC_API_RTPSENDER_H_ -#include -#include - -#include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/rtpsenderinterface.h" -#include "webrtc/api/statscollector.h" -#include "webrtc/base/basictypes.h" -#include "webrtc/base/criticalsection.h" -#include "webrtc/media/base/audiosource.h" -#include "webrtc/pc/channel.h" - -namespace webrtc { - -// Internal interface used by PeerConnection. -class RtpSenderInternal : public RtpSenderInterface { - public: - // Used to set the SSRC of the sender, once a local description has been set. - // If |ssrc| is 0, this indiates that the sender should disconnect from the - // underlying transport (this occurs if the sender isn't seen in a local - // description). - virtual void SetSsrc(uint32_t ssrc) = 0; - - // TODO(deadbeef): Support one sender having multiple stream ids. - virtual void set_stream_id(const std::string& stream_id) = 0; - virtual std::string stream_id() const = 0; - - virtual void Stop() = 0; -}; - -// LocalAudioSinkAdapter receives data callback as a sink to the local -// AudioTrack, and passes the data to the sink of AudioSource. -class LocalAudioSinkAdapter : public AudioTrackSinkInterface, - public cricket::AudioSource { - public: - LocalAudioSinkAdapter(); - virtual ~LocalAudioSinkAdapter(); - - private: - // AudioSinkInterface implementation. - void OnData(const void* audio_data, - int bits_per_sample, - int sample_rate, - size_t number_of_channels, - size_t number_of_frames) override; - - // cricket::AudioSource implementation. - void SetSink(cricket::AudioSource::Sink* sink) override; - - cricket::AudioSource::Sink* sink_; - // Critical section protecting |sink_|. - rtc::CriticalSection lock_; -}; - -class AudioRtpSender : public ObserverInterface, - public rtc::RefCountedObject { - public: - // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called - // at the appropriate times. - // |channel| can be null if one does not exist yet. - AudioRtpSender(AudioTrackInterface* track, - const std::string& stream_id, - cricket::VoiceChannel* channel, - StatsCollector* stats); - - // Randomly generates stream_id. - // |channel| can be null if one does not exist yet. - AudioRtpSender(AudioTrackInterface* track, - cricket::VoiceChannel* channel, - StatsCollector* stats); - - // Randomly generates id and stream_id. - // |channel| can be null if one does not exist yet. - AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats); - - virtual ~AudioRtpSender(); - - // ObserverInterface implementation - void OnChanged() override; - - // RtpSenderInterface implementation - bool SetTrack(MediaStreamTrackInterface* track) override; - rtc::scoped_refptr track() const override { - return track_; - } - - uint32_t ssrc() const override { return ssrc_; } - - cricket::MediaType media_type() const override { - return cricket::MEDIA_TYPE_AUDIO; - } - - std::string id() const override { return id_; } - - std::vector stream_ids() const override { - std::vector ret = {stream_id_}; - return ret; - } - - RtpParameters GetParameters() const override; - bool SetParameters(const RtpParameters& parameters) override; - - // RtpSenderInternal implementation. - void SetSsrc(uint32_t ssrc) override; - - void set_stream_id(const std::string& stream_id) override { - stream_id_ = stream_id; - } - std::string stream_id() const override { return stream_id_; } - - void Stop() override; - - // Does not take ownership. - // Should call SetChannel(nullptr) before |channel| is destroyed. - void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; } - - private: - // TODO(nisse): Since SSRC == 0 is technically valid, figure out - // some other way to test if we have a valid SSRC. - bool can_send_track() const { return track_ && ssrc_; } - // Helper function to construct options for - // AudioProviderInterface::SetAudioSend. - void SetAudioSend(); - // Helper function to call SetAudioSend with "stop sending" parameters. - void ClearAudioSend(); - - std::string id_; - std::string stream_id_; - cricket::VoiceChannel* channel_ = nullptr; - StatsCollector* stats_; - rtc::scoped_refptr track_; - uint32_t ssrc_ = 0; - bool cached_track_enabled_ = false; - bool stopped_ = false; - - // Used to pass the data callback from the |track_| to the other end of - // cricket::AudioSource. - std::unique_ptr sink_adapter_; -}; - -class VideoRtpSender : public ObserverInterface, - public rtc::RefCountedObject { - public: - // |channel| can be null if one does not exist yet. - VideoRtpSender(VideoTrackInterface* track, - const std::string& stream_id, - cricket::VideoChannel* channel); - - // Randomly generates stream_id. - // |channel| can be null if one does not exist yet. - VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel); - - // Randomly generates id and stream_id. - // |channel| can be null if one does not exist yet. - explicit VideoRtpSender(cricket::VideoChannel* channel); - - virtual ~VideoRtpSender(); - - // ObserverInterface implementation - void OnChanged() override; - - // RtpSenderInterface implementation - bool SetTrack(MediaStreamTrackInterface* track) override; - rtc::scoped_refptr track() const override { - return track_; - } - - uint32_t ssrc() const override { return ssrc_; } - - cricket::MediaType media_type() const override { - return cricket::MEDIA_TYPE_VIDEO; - } - - std::string id() const override { return id_; } - - std::vector stream_ids() const override { - std::vector ret = {stream_id_}; - return ret; - } - - RtpParameters GetParameters() const override; - bool SetParameters(const RtpParameters& parameters) override; - - // RtpSenderInternal implementation. - void SetSsrc(uint32_t ssrc) override; - - void set_stream_id(const std::string& stream_id) override { - stream_id_ = stream_id; - } - std::string stream_id() const override { return stream_id_; } - - void Stop() override; - - // Does not take ownership. - // Should call SetChannel(nullptr) before |channel| is destroyed. - void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; } - - private: - bool can_send_track() const { return track_ && ssrc_; } - // Helper function to construct options for - // VideoProviderInterface::SetVideoSend. - void SetVideoSend(); - // Helper function to call SetVideoSend with "stop sending" parameters. - void ClearVideoSend(); - - std::string id_; - std::string stream_id_; - cricket::VideoChannel* channel_ = nullptr; - rtc::scoped_refptr track_; - uint32_t ssrc_ = 0; - bool cached_track_enabled_ = false; - VideoTrackInterface::ContentHint cached_track_content_hint_ = - VideoTrackInterface::ContentHint::kNone; - bool stopped_ = false; -}; - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/rtpsender.h" #endif // WEBRTC_API_RTPSENDER_H_ diff --git a/webrtc/api/rtpsenderinterface.h b/webrtc/api/rtpsenderinterface.h index 2e6b7427a1..7129376d42 100644 --- a/webrtc/api/rtpsenderinterface.h +++ b/webrtc/api/rtpsenderinterface.h @@ -17,12 +17,12 @@ #include #include +#include "webrtc/api/mediatypes.h" #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/proxy.h" #include "webrtc/api/rtpparameters.h" #include "webrtc/base/refcount.h" #include "webrtc/base/scoped_ref_ptr.h" -#include "webrtc/pc/mediasession.h" namespace webrtc { diff --git a/webrtc/api/stats/rtcstatscollectorcallback.h b/webrtc/api/stats/rtcstatscollectorcallback.h new file mode 100644 index 0000000000..2493e49ce2 --- /dev/null +++ b/webrtc/api/stats/rtcstatscollectorcallback.h @@ -0,0 +1,30 @@ +/* + * Copyright 2016 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 WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_ +#define WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_ + +#include "webrtc/api/stats/rtcstatsreport.h" +#include "webrtc/base/refcount.h" +#include "webrtc/base/scoped_ref_ptr.h" + +namespace webrtc { + +class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { + public: + virtual ~RTCStatsCollectorCallback() {} + + virtual void OnStatsDelivered( + const rtc::scoped_refptr& report) = 0; +}; + +} // namespace webrtc + +#endif // WEBRTC_API_STATS_RTCSTATSCOLLECTORCALLBACK_H_ diff --git a/webrtc/api/statstypes.cc b/webrtc/api/statstypes.cc index 80b0d76680..300bb4a933 100644 --- a/webrtc/api/statstypes.cc +++ b/webrtc/api/statstypes.cc @@ -632,6 +632,8 @@ StatsReport::StatsReport(const Id& id) : id_(id), timestamp_(0.0) { RTC_DCHECK(id_.get()); } +StatsReport::~StatsReport() = default; + // static StatsReport::Id StatsReport::NewBandwidthEstimationId() { return Id(new RefCountedObject()); diff --git a/webrtc/api/statstypes.h b/webrtc/api/statstypes.h index 788c2c403f..26e2ac4546 100644 --- a/webrtc/api/statstypes.h +++ b/webrtc/api/statstypes.h @@ -342,6 +342,7 @@ class StatsReport { // Ownership of |id| is passed to |this|. explicit StatsReport(const Id& id); + ~StatsReport(); // Factory functions for various types of stats IDs. static Id NewBandwidthEstimationId(); diff --git a/webrtc/api/streamcollection.h b/webrtc/api/streamcollection.h index bedad83202..0f847f11f7 100644 --- a/webrtc/api/streamcollection.h +++ b/webrtc/api/streamcollection.h @@ -11,98 +11,8 @@ #ifndef WEBRTC_API_STREAMCOLLECTION_H_ #define WEBRTC_API_STREAMCOLLECTION_H_ -#include -#include - -#include "webrtc/api/peerconnectioninterface.h" - -namespace webrtc { - -// Implementation of StreamCollection. -class StreamCollection : public StreamCollectionInterface { - public: - static rtc::scoped_refptr Create() { - rtc::RefCountedObject* implementation = - new rtc::RefCountedObject(); - return implementation; - } - - static rtc::scoped_refptr Create( - StreamCollection* streams) { - rtc::RefCountedObject* implementation = - new rtc::RefCountedObject(streams); - return implementation; - } - - virtual size_t count() { - return media_streams_.size(); - } - - virtual MediaStreamInterface* at(size_t index) { - return media_streams_.at(index); - } - - virtual MediaStreamInterface* find(const std::string& label) { - for (StreamVector::iterator it = media_streams_.begin(); - it != media_streams_.end(); ++it) { - if ((*it)->label().compare(label) == 0) { - return (*it); - } - } - return NULL; - } - - virtual MediaStreamTrackInterface* FindAudioTrack( - const std::string& id) { - for (size_t i = 0; i < media_streams_.size(); ++i) { - MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id); - if (track) { - return track; - } - } - return NULL; - } - - virtual MediaStreamTrackInterface* FindVideoTrack( - const std::string& id) { - for (size_t i = 0; i < media_streams_.size(); ++i) { - MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id); - if (track) { - return track; - } - } - return NULL; - } - - void AddStream(MediaStreamInterface* stream) { - for (StreamVector::iterator it = media_streams_.begin(); - it != media_streams_.end(); ++it) { - if ((*it)->label().compare(stream->label()) == 0) - return; - } - media_streams_.push_back(stream); - } - - void RemoveStream(MediaStreamInterface* remove_stream) { - for (StreamVector::iterator it = media_streams_.begin(); - it != media_streams_.end(); ++it) { - if ((*it)->label().compare(remove_stream->label()) == 0) { - media_streams_.erase(it); - break; - } - } - } - - protected: - StreamCollection() {} - explicit StreamCollection(StreamCollection* original) - : media_streams_(original->media_streams_) { - } - typedef std::vector > - StreamVector; - StreamVector media_streams_; -}; - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/streamcollection.h" #endif // WEBRTC_API_STREAMCOLLECTION_H_ diff --git a/webrtc/api/videotracksource.h b/webrtc/api/videotracksource.h index 330af2332e..45366cd152 100644 --- a/webrtc/api/videotracksource.h +++ b/webrtc/api/videotracksource.h @@ -11,45 +11,8 @@ #ifndef WEBRTC_API_VIDEOTRACKSOURCE_H_ #define WEBRTC_API_VIDEOTRACKSOURCE_H_ -#include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/notifier.h" -#include "webrtc/base/thread_checker.h" -#include "webrtc/media/base/mediachannel.h" -#include "webrtc/media/base/videosinkinterface.h" - -// VideoTrackSource implements VideoTrackSourceInterface. -namespace webrtc { - -class VideoTrackSource : public Notifier { - public: - VideoTrackSource(rtc::VideoSourceInterface* source, bool remote); - void SetState(SourceState new_state); - // OnSourceDestroyed clears this instance pointer to |source_|. It is useful - // when the underlying rtc::VideoSourceInterface is destroyed before the - // reference counted VideoTrackSource. - void OnSourceDestroyed(); - - SourceState state() const override { return state_; } - bool remote() const override { return remote_; } - - bool is_screencast() const override { return false; } - rtc::Optional needs_denoising() const override { - return rtc::Optional(); } - - bool GetStats(Stats* stats) override { return false; } - - void AddOrUpdateSink(rtc::VideoSinkInterface* sink, - const rtc::VideoSinkWants& wants) override; - void RemoveSink(rtc::VideoSinkInterface* sink) override; - - private: - rtc::ThreadChecker worker_thread_checker_; - rtc::VideoSourceInterface* source_; - cricket::VideoOptions options_; - SourceState state_; - const bool remote_; -}; - -} // namespace webrtc +// Including this file is deprecated. It is no longer part of the public API. +// This only includes the file in its new location for backwards compatibility. +#include "webrtc/pc/videotracksource.h" #endif // WEBRTC_API_VIDEOTRACKSOURCE_H_ diff --git a/webrtc/build/gn_isolate_map.pyl b/webrtc/build/gn_isolate_map.pyl index ed56777af0..a6e357e5fa 100644 --- a/webrtc/build/gn_isolate_map.pyl +++ b/webrtc/build/gn_isolate_map.pyl @@ -52,7 +52,7 @@ "type": "windowed_test_launcher", }, "peerconnection_unittests": { - "label": "//webrtc/api:peerconnection_unittests", + "label": "//webrtc/pc:peerconnection_unittests", "type": "console_test_launcher", }, "rtc_media_unittests": { diff --git a/webrtc/examples/BUILD.gn b/webrtc/examples/BUILD.gn index eaa3bc9183..6f7eaa702b 100644 --- a/webrtc/examples/BUILD.gn +++ b/webrtc/examples/BUILD.gn @@ -505,7 +505,7 @@ if (is_linux || is_win) { } deps = [ "//third_party/libyuv", - "//webrtc/api:libjingle_peerconnection", + "//webrtc/pc:libjingle_peerconnection", "//webrtc/system_wrappers:field_trial_default", "//webrtc/system_wrappers:metrics_default", ] diff --git a/webrtc/examples/DEPS b/webrtc/examples/DEPS index f065c89458..524aa26376 100644 --- a/webrtc/examples/DEPS +++ b/webrtc/examples/DEPS @@ -6,4 +6,5 @@ include_rules = [ "+webrtc/modules/audio_device", "+webrtc/modules/video_capture", "+webrtc/p2p", + "+webrtc/pc", ] diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index e5fa8a1dde..b35bc1bbf9 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -12,13 +12,6 @@ #include #include "webrtc/api/fakemetricsobserver.h" -#include "webrtc/p2p/base/fakeportallocator.h" -#include "webrtc/p2p/base/packettransportinterface.h" -#include "webrtc/p2p/base/p2ptransportchannel.h" -#include "webrtc/p2p/base/testrelayserver.h" -#include "webrtc/p2p/base/teststunserver.h" -#include "webrtc/p2p/base/testturnserver.h" -#include "webrtc/p2p/client/basicportallocator.h" #include "webrtc/base/checks.h" #include "webrtc/base/dscp.h" #include "webrtc/base/fakeclock.h" @@ -36,6 +29,13 @@ #include "webrtc/base/thread.h" #include "webrtc/base/virtualsocketserver.h" #include "webrtc/p2p/base/icetransportinternal.h" +#include "webrtc/p2p/base/fakeportallocator.h" +#include "webrtc/p2p/base/p2ptransportchannel.h" +#include "webrtc/p2p/base/packettransportinterface.h" +#include "webrtc/p2p/base/testrelayserver.h" +#include "webrtc/p2p/base/teststunserver.h" +#include "webrtc/p2p/base/testturnserver.h" +#include "webrtc/p2p/client/basicportallocator.h" namespace { diff --git a/webrtc/pc/BUILD.gn b/webrtc/pc/BUILD.gn index f2bdbc3568..5c4d87c677 100644 --- a/webrtc/pc/BUILD.gn +++ b/webrtc/pc/BUILD.gn @@ -7,6 +7,10 @@ # be found in the AUTHORS file in the root of the source tree. import("../build/webrtc.gni") +if (is_android) { + import("//build/config/android/config.gni") + import("//build/config/android/rules.gni") +} group("pc") { public_deps = [ @@ -69,6 +73,100 @@ rtc_static_library("rtc_pc") { } } +config("libjingle_peerconnection_warnings_config") { + # GN orders flags on a target before flags from configs. The default config + # adds these flags so to cancel them out they need to come from a config and + # cannot be on the target directly. + if (!is_win && !is_clang) { + cflags = [ "-Wno-maybe-uninitialized" ] # Only exists for GCC. + } +} + +rtc_static_library("libjingle_peerconnection") { + check_includes = false # TODO(kjellander): Remove (bugs.webrtc.org/6828) + cflags = [] + sources = [ + "audiotrack.cc", + "audiotrack.h", + "datachannel.cc", + "datachannel.h", + "dtmfsender.cc", + "dtmfsender.h", + "jsepicecandidate.cc", + "jsepsessiondescription.cc", + "localaudiosource.cc", + "localaudiosource.h", + "mediacontroller.cc", + "mediacontroller.h", + "mediastream.cc", + "mediastream.h", + "mediastreamobserver.cc", + "mediastreamobserver.h", + "mediastreamtrack.h", + "ortcfactory.cc", + "ortcfactory.h", + "peerconnection.cc", + "peerconnection.h", + "peerconnectionfactory.cc", + "peerconnectionfactory.h", + "remoteaudiosource.cc", + "remoteaudiosource.h", + "rtcstatscollector.cc", + "rtcstatscollector.h", + "rtpreceiver.cc", + "rtpreceiver.h", + "rtpsender.cc", + "rtpsender.h", + "sctputils.cc", + "sctputils.h", + "statscollector.cc", + "statscollector.h", + "streamcollection.h", + "videocapturertracksource.cc", + "videocapturertracksource.h", + "videotrack.cc", + "videotrack.h", + "videotracksource.cc", + "videotracksource.h", + "webrtcsdp.cc", + "webrtcsdp.h", + "webrtcsession.cc", + "webrtcsession.h", + "webrtcsessiondescriptionfactory.cc", + "webrtcsessiondescriptionfactory.h", + ] + + configs += [ ":libjingle_peerconnection_warnings_config" ] + + if (!build_with_chromium && is_clang) { + # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). + suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + ":rtc_pc", + "../api:call_api", + "../api:libjingle_peerconnection_api", + "../api:rtc_stats_api", + "../call", + "../media", + "../stats", + ] + + if (rtc_use_quic) { + sources += [ + "quicdatachannel.cc", + "quicdatachannel.h", + "quicdatatransport.cc", + "quicdatatransport.h", + ] + deps += [ "//third_party/libquic" ] + public_deps = [ + "//third_party/libquic", + ] + } +} + if (rtc_include_tests) { config("rtc_pc_unittests_config") { # GN orders flags on a target before flags from configs. The default config @@ -106,8 +204,8 @@ if (rtc_include_tests) { } deps = [ + ":libjingle_peerconnection", ":rtc_pc", - "../api:libjingle_peerconnection", "../base:rtc_base_tests_utils", "../media:rtc_unittest_main", "../system_wrappers:metrics_default", @@ -121,4 +219,130 @@ if (rtc_include_tests) { deps += [ "//testing/android/native_test:native_test_support" ] } } + + config("peerconnection_unittests_config") { + # The warnings below are enabled by default. Since GN orders compiler flags + # for a target before flags from configs, the only way to disable such + # warnings is by having them in a separate config, loaded from the target. + # TODO(kjellander): Make the code compile without disabling these flags. + # See https://bugs.webrtc.org/3307. + if (is_clang && is_win) { + cflags = [ + # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6267 + # for -Wno-sign-compare + "-Wno-sign-compare", + "-Wno-unused-function", + ] + } + + if (!is_win) { + cflags = [ "-Wno-sign-compare" ] + } + } + + rtc_test("peerconnection_unittests") { + check_includes = false # TODO(kjellander): Remove (bugs.webrtc.org/6828) + testonly = true + sources = [ + "datachannel_unittest.cc", + "dtmfsender_unittest.cc", + "fakemediacontroller.h", + "jsepsessiondescription_unittest.cc", + "localaudiosource_unittest.cc", + "mediaconstraintsinterface_unittest.cc", + "mediastream_unittest.cc", + "ortcfactory_unittest.cc", + "peerconnection_unittest.cc", + "peerconnectionendtoend_unittest.cc", + "peerconnectionfactory_unittest.cc", + "peerconnectioninterface_unittest.cc", + "proxy_unittest.cc", + "rtcstats_integrationtest.cc", + "rtcstatscollector_unittest.cc", + "rtpsenderreceiver_unittest.cc", + "sctputils_unittest.cc", + "statscollector_unittest.cc", + "test/fakeaudiocapturemodule.cc", + "test/fakeaudiocapturemodule.h", + "test/fakeaudiocapturemodule_unittest.cc", + "test/fakedatachannelprovider.h", + "test/fakeperiodicvideocapturer.h", + "test/fakertccertificategenerator.h", + "test/fakevideotrackrenderer.h", + "test/fakevideotracksource.h", + "test/mock_datachannel.h", + "test/mock_peerconnection.h", + "test/mock_webrtcsession.h", + "test/mockpeerconnectionobservers.h", + "test/peerconnectiontestwrapper.cc", + "test/peerconnectiontestwrapper.h", + "test/rtcstatsobtainer.h", + "test/testsdpstrings.h", + "videocapturertracksource_unittest.cc", + "videotrack_unittest.cc", + "webrtcsdp_unittest.cc", + "webrtcsession_unittest.cc", + ] + + if (rtc_enable_sctp) { + defines = [ "HAVE_SCTP" ] + } + + configs += [ ":peerconnection_unittests_config" ] + + if (!build_with_chromium && is_clang) { + # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). + suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] + } + + # TODO(jschuh): Bug 1348: fix this warning. + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + + if (is_win) { + cflags = [ + "/wd4245", # conversion from int to size_t, signed/unsigned mismatch. + "/wd4389", # signed/unsigned mismatch. + ] + } + + if (rtc_use_quic) { + public_deps = [ + "//third_party/libquic", + ] + sources += [ + "quicdatachannel_unittest.cc", + "quicdatatransport_unittest.cc", + ] + } + + deps = [] + if (is_android) { + sources += [ + "test/androidtestinitializer.cc", + "test/androidtestinitializer.h", + ] + deps += [ + "//testing/android/native_test:native_test_support", + "//webrtc/sdk/android:libjingle_peerconnection_java", + "//webrtc/sdk/android:libjingle_peerconnection_jni", + ] + } + + deps += [ + ":libjingle_peerconnection", + "..:webrtc_common", + "../api:fakemetricsobserver", + "../base:rtc_base_tests_utils", + "../media:rtc_unittest_main", + "../pc:rtc_pc", + "../system_wrappers:metrics_default", + "//testing/gmock", + ] + + if (is_android) { + deps += [ "//testing/android/native_test:native_test_support" ] + + shard_timeout = 900 + } + } } diff --git a/webrtc/pc/DEPS b/webrtc/pc/DEPS index 2bb6253519..5da778c5f7 100644 --- a/webrtc/pc/DEPS +++ b/webrtc/pc/DEPS @@ -1,15 +1,29 @@ include_rules = [ + "+third_party/libsrtp" "+webrtc/api", "+webrtc/base", + "+webrtc/call", "+webrtc/common_video/h264", "+webrtc/logging/rtc_event_log", + "+webrtc/logging/rtc_event_log", "+webrtc/media", + "+webrtc/modules/audio_device", + "+webrtc/modules/rtp_rtcp", + "+webrtc/modules/video_coding", + "+webrtc/modules/video_render", "+webrtc/p2p", - "+third_party/libsrtp" + "+webrtc/system_wrappers", ] specific_include_rules = { + "androidtestinitializer\.cc": [ + "+base/android", # Allowed only for Android tests. + "+webrtc/voice_engine", + ], "srtpfilter_unittest\.cc": [ "+crypto", ], + "peerconnectionfactory\.cc": [ + "+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h", + ], } diff --git a/webrtc/api/audiotrack.cc b/webrtc/pc/audiotrack.cc similarity index 95% rename from webrtc/api/audiotrack.cc rename to webrtc/pc/audiotrack.cc index c2c9557c9e..951acbf93e 100644 --- a/webrtc/api/audiotrack.cc +++ b/webrtc/pc/audiotrack.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/audiotrack.h" +#include "webrtc/pc/audiotrack.h" #include "webrtc/base/checks.h" @@ -16,8 +16,6 @@ using rtc::scoped_refptr; namespace webrtc { -const char MediaStreamTrackInterface::kAudioKind[] = "audio"; - // static scoped_refptr AudioTrack::Create( const std::string& id, diff --git a/webrtc/api/audiotrack.h b/webrtc/pc/audiotrack.h similarity index 92% rename from webrtc/api/audiotrack.h rename to webrtc/pc/audiotrack.h index 096caf9d0e..33f4b1fcd7 100644 --- a/webrtc/api/audiotrack.h +++ b/webrtc/pc/audiotrack.h @@ -8,17 +8,17 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_AUDIOTRACK_H_ -#define WEBRTC_API_AUDIOTRACK_H_ +#ifndef WEBRTC_PC_AUDIOTRACK_H_ +#define WEBRTC_PC_AUDIOTRACK_H_ #include #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/mediastreamtrack.h" #include "webrtc/api/notifier.h" #include "webrtc/base/constructormagic.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/thread_checker.h" +#include "webrtc/pc/mediastreamtrack.h" namespace webrtc { @@ -56,4 +56,4 @@ class AudioTrack : public MediaStreamTrack, } // namespace webrtc -#endif // WEBRTC_API_AUDIOTRACK_H_ +#endif // WEBRTC_PC_AUDIOTRACK_H_ diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index 0570267568..f667900d3e 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -12,7 +12,6 @@ #include -#include "webrtc/api/mediacontroller.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" #include "webrtc/base/common.h" @@ -23,6 +22,7 @@ #include "webrtc/media/base/device.h" #include "webrtc/media/base/rtpdataengine.h" #include "webrtc/pc/srtpfilter.h" +#include "webrtc/pc/mediacontroller.h" namespace cricket { diff --git a/webrtc/pc/channelmanager_unittest.cc b/webrtc/pc/channelmanager_unittest.cc index cf54b913b8..74c359012c 100644 --- a/webrtc/pc/channelmanager_unittest.cc +++ b/webrtc/pc/channelmanager_unittest.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/fakemediacontroller.h" #include "webrtc/base/gunit.h" #include "webrtc/base/logging.h" #include "webrtc/base/thread.h" @@ -19,6 +18,7 @@ #include "webrtc/media/engine/fakewebrtccall.h" #include "webrtc/p2p/base/faketransportcontroller.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/fakemediacontroller.h" namespace cricket { const bool kDefaultRtcpMuxRequired = true; diff --git a/webrtc/api/datachannel.cc b/webrtc/pc/datachannel.cc similarity index 99% rename from webrtc/api/datachannel.cc rename to webrtc/pc/datachannel.cc index c0bc3dc42b..5606a64c6e 100644 --- a/webrtc/api/datachannel.cc +++ b/webrtc/pc/datachannel.cc @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/datachannel.h" +#include "webrtc/pc/datachannel.h" #include #include -#include "webrtc/api/sctputils.h" #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" #include "webrtc/base/refcount.h" #include "webrtc/media/sctp/sctptransportinternal.h" +#include "webrtc/pc/sctputils.h" namespace webrtc { diff --git a/webrtc/pc/datachannel.h b/webrtc/pc/datachannel.h new file mode 100644 index 0000000000..2619a852fb --- /dev/null +++ b/webrtc/pc/datachannel.h @@ -0,0 +1,298 @@ +/* + * Copyright 2012 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 WEBRTC_PC_DATACHANNEL_H_ +#define WEBRTC_PC_DATACHANNEL_H_ + +#include +#include +#include + +#include "webrtc/api/datachannelinterface.h" +#include "webrtc/api/proxy.h" +#include "webrtc/base/messagehandler.h" +#include "webrtc/base/scoped_ref_ptr.h" +#include "webrtc/base/sigslot.h" +#include "webrtc/media/base/mediachannel.h" +#include "webrtc/pc/channel.h" + +namespace webrtc { + +class DataChannel; + +class DataChannelProviderInterface { + public: + // Sends the data to the transport. + virtual bool SendData(const cricket::SendDataParams& params, + const rtc::CopyOnWriteBuffer& payload, + cricket::SendDataResult* result) = 0; + // Connects to the transport signals. + virtual bool ConnectDataChannel(DataChannel* data_channel) = 0; + // Disconnects from the transport signals. + virtual void DisconnectDataChannel(DataChannel* data_channel) = 0; + // Adds the data channel SID to the transport for SCTP. + virtual void AddSctpDataStream(int sid) = 0; + // Removes the data channel SID from the transport for SCTP. + virtual void RemoveSctpDataStream(int sid) = 0; + // Returns true if the transport channel is ready to send data. + virtual bool ReadyToSendData() const = 0; + + protected: + virtual ~DataChannelProviderInterface() {} +}; + +struct InternalDataChannelInit : public DataChannelInit { + enum OpenHandshakeRole { + kOpener, + kAcker, + kNone + }; + // The default role is kOpener because the default |negotiated| is false. + InternalDataChannelInit() : open_handshake_role(kOpener) {} + explicit InternalDataChannelInit(const DataChannelInit& base) + : DataChannelInit(base), open_handshake_role(kOpener) { + // If the channel is externally negotiated, do not send the OPEN message. + if (base.negotiated) { + open_handshake_role = kNone; + } + } + + OpenHandshakeRole open_handshake_role; +}; + +// Helper class to allocate unique IDs for SCTP DataChannels +class SctpSidAllocator { + public: + // Gets the first unused odd/even id based on the DTLS role. If |role| is + // SSL_CLIENT, the allocated id starts from 0 and takes even numbers; + // otherwise, the id starts from 1 and takes odd numbers. + // Returns false if no id can be allocated. + bool AllocateSid(rtc::SSLRole role, int* sid); + + // Attempts to reserve a specific sid. Returns false if it's unavailable. + bool ReserveSid(int sid); + + // Indicates that |sid| isn't in use any more, and is thus available again. + void ReleaseSid(int sid); + + private: + // Checks if |sid| is available to be assigned to a new SCTP data channel. + bool IsSidAvailable(int sid) const; + + std::set used_sids_; +}; + +// DataChannel is a an implementation of the DataChannelInterface based on +// libjingle's data engine. It provides an implementation of unreliable or +// reliabledata channels. Currently this class is specifically designed to use +// both RtpDataEngine and SctpDataEngine. + +// DataChannel states: +// kConnecting: The channel has been created the transport might not yet be +// ready. +// kOpen: The channel have a local SSRC set by a call to UpdateSendSsrc +// and a remote SSRC set by call to UpdateReceiveSsrc and the transport +// has been writable once. +// kClosing: DataChannelInterface::Close has been called or UpdateReceiveSsrc +// has been called with SSRC==0 +// kClosed: Both UpdateReceiveSsrc and UpdateSendSsrc has been called with +// SSRC==0. +class DataChannel : public DataChannelInterface, + public sigslot::has_slots<>, + public rtc::MessageHandler { + public: + static rtc::scoped_refptr Create( + DataChannelProviderInterface* provider, + cricket::DataChannelType dct, + const std::string& label, + const InternalDataChannelInit& config); + + virtual void RegisterObserver(DataChannelObserver* observer); + virtual void UnregisterObserver(); + + virtual std::string label() const { return label_; } + virtual bool reliable() const; + virtual bool ordered() const { return config_.ordered; } + virtual uint16_t maxRetransmitTime() const { + return config_.maxRetransmitTime; + } + virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; } + virtual std::string protocol() const { return config_.protocol; } + virtual bool negotiated() const { return config_.negotiated; } + virtual int id() const { return config_.id; } + virtual uint64_t buffered_amount() const; + virtual void Close(); + virtual DataState state() const { return state_; } + virtual uint32_t messages_sent() const { return messages_sent_; } + virtual uint64_t bytes_sent() const { return bytes_sent_; } + virtual uint32_t messages_received() const { return messages_received_; } + virtual uint64_t bytes_received() const { return bytes_received_; } + virtual bool Send(const DataBuffer& buffer); + + // rtc::MessageHandler override. + virtual void OnMessage(rtc::Message* msg); + + // Called when the channel's ready to use. That can happen when the + // underlying DataMediaChannel becomes ready, or when this channel is a new + // stream on an existing DataMediaChannel, and we've finished negotiation. + void OnChannelReady(bool writable); + + // Slots for provider to connect signals to. + void OnDataReceived(const cricket::ReceiveDataParams& params, + const rtc::CopyOnWriteBuffer& payload); + void OnStreamClosedRemotely(int sid); + + // The remote peer request that this channel should be closed. + void RemotePeerRequestClose(); + + // The following methods are for SCTP only. + + // Sets the SCTP sid and adds to transport layer if not set yet. Should only + // be called once. + void SetSctpSid(int sid); + // Called when the transport channel is created. + // Only needs to be called for SCTP data channels. + void OnTransportChannelCreated(); + // Called when the transport channel is destroyed. + // This method makes sure the DataChannel is disconnected and changes state + // to kClosed. + void OnTransportChannelDestroyed(); + + // The following methods are for RTP only. + + // Set the SSRC this channel should use to send data on the + // underlying data engine. |send_ssrc| == 0 means that the channel is no + // longer part of the session negotiation. + void SetSendSsrc(uint32_t send_ssrc); + // Set the SSRC this channel should use to receive data from the + // underlying data engine. + void SetReceiveSsrc(uint32_t receive_ssrc); + + cricket::DataChannelType data_channel_type() const { + return data_channel_type_; + } + + // Emitted when state transitions to kOpen. + sigslot::signal1 SignalOpened; + // Emitted when state transitions to kClosed. + // In the case of SCTP channels, this signal can be used to tell when the + // channel's sid is free. + sigslot::signal1 SignalClosed; + + protected: + DataChannel(DataChannelProviderInterface* client, + cricket::DataChannelType dct, + const std::string& label); + virtual ~DataChannel(); + + private: + // A packet queue which tracks the total queued bytes. Queued packets are + // owned by this class. + class PacketQueue { + public: + PacketQueue(); + ~PacketQueue(); + + size_t byte_count() const { + return byte_count_; + } + + bool Empty() const; + + DataBuffer* Front(); + + void Pop(); + + void Push(DataBuffer* packet); + + void Clear(); + + void Swap(PacketQueue* other); + + private: + std::deque packets_; + size_t byte_count_; + }; + + // The OPEN(_ACK) signaling state. + enum HandshakeState { + kHandshakeInit, + kHandshakeShouldSendOpen, + kHandshakeShouldSendAck, + kHandshakeWaitingForAck, + kHandshakeReady + }; + + bool Init(const InternalDataChannelInit& config); + void DoClose(); + void UpdateState(); + void SetState(DataState state); + void DisconnectFromProvider(); + + void DeliverQueuedReceivedData(); + + void SendQueuedDataMessages(); + bool SendDataMessage(const DataBuffer& buffer, bool queue_if_blocked); + bool QueueSendDataMessage(const DataBuffer& buffer); + + void SendQueuedControlMessages(); + void QueueControlMessage(const rtc::CopyOnWriteBuffer& buffer); + bool SendControlMessage(const rtc::CopyOnWriteBuffer& buffer); + + std::string label_; + InternalDataChannelInit config_; + DataChannelObserver* observer_; + DataState state_; + uint32_t messages_sent_; + uint64_t bytes_sent_; + uint32_t messages_received_; + uint64_t bytes_received_; + cricket::DataChannelType data_channel_type_; + DataChannelProviderInterface* provider_; + HandshakeState handshake_state_; + bool connected_to_provider_; + bool send_ssrc_set_; + bool receive_ssrc_set_; + bool writable_; + uint32_t send_ssrc_; + uint32_t receive_ssrc_; + // Control messages that always have to get sent out before any queued + // data. + PacketQueue queued_control_data_; + PacketQueue queued_received_data_; + PacketQueue queued_send_data_; +}; + +// Define proxy for DataChannelInterface. +BEGIN_SIGNALING_PROXY_MAP(DataChannel) + PROXY_SIGNALING_THREAD_DESTRUCTOR() + PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*) + PROXY_METHOD0(void, UnregisterObserver) + PROXY_CONSTMETHOD0(std::string, label) + PROXY_CONSTMETHOD0(bool, reliable) + PROXY_CONSTMETHOD0(bool, ordered) + PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) + PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) + PROXY_CONSTMETHOD0(std::string, protocol) + PROXY_CONSTMETHOD0(bool, negotiated) + PROXY_CONSTMETHOD0(int, id) + PROXY_CONSTMETHOD0(DataState, state) + PROXY_CONSTMETHOD0(uint32_t, messages_sent) + PROXY_CONSTMETHOD0(uint64_t, bytes_sent) + PROXY_CONSTMETHOD0(uint32_t, messages_received) + PROXY_CONSTMETHOD0(uint64_t, bytes_received) + PROXY_CONSTMETHOD0(uint64_t, buffered_amount) + PROXY_METHOD0(void, Close) + PROXY_METHOD1(bool, Send, const DataBuffer&) +END_PROXY_MAP() + +} // namespace webrtc + +#endif // WEBRTC_PC_DATACHANNEL_H_ diff --git a/webrtc/api/datachannel_unittest.cc b/webrtc/pc/datachannel_unittest.cc similarity index 99% rename from webrtc/api/datachannel_unittest.cc rename to webrtc/pc/datachannel_unittest.cc index 4ce1be5736..13ab63cdfa 100644 --- a/webrtc/api/datachannel_unittest.cc +++ b/webrtc/pc/datachannel_unittest.cc @@ -10,10 +10,10 @@ #include -#include "webrtc/api/datachannel.h" -#include "webrtc/api/sctputils.h" -#include "webrtc/api/test/fakedatachannelprovider.h" #include "webrtc/base/gunit.h" +#include "webrtc/pc/datachannel.h" +#include "webrtc/pc/sctputils.h" +#include "webrtc/pc/test/fakedatachannelprovider.h" using webrtc::DataChannel; using webrtc::SctpSidAllocator; diff --git a/webrtc/api/dtmfsender.cc b/webrtc/pc/dtmfsender.cc similarity index 99% rename from webrtc/api/dtmfsender.cc rename to webrtc/pc/dtmfsender.cc index c715d3df84..2ef921bdc1 100644 --- a/webrtc/api/dtmfsender.cc +++ b/webrtc/pc/dtmfsender.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/dtmfsender.h" +#include "webrtc/pc/dtmfsender.h" #include diff --git a/webrtc/api/dtmfsender.h b/webrtc/pc/dtmfsender.h similarity index 97% rename from webrtc/api/dtmfsender.h rename to webrtc/pc/dtmfsender.h index d4e8f06d9e..1163adfaed 100644 --- a/webrtc/api/dtmfsender.h +++ b/webrtc/pc/dtmfsender.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_DTMFSENDER_H_ -#define WEBRTC_API_DTMFSENDER_H_ +#ifndef WEBRTC_PC_DTMFSENDER_H_ +#define WEBRTC_PC_DTMFSENDER_H_ #include @@ -121,4 +121,4 @@ bool GetDtmfCode(char tone, int* code); } // namespace webrtc -#endif // WEBRTC_API_DTMFSENDER_H_ +#endif // WEBRTC_PC_DTMFSENDER_H_ diff --git a/webrtc/api/dtmfsender_unittest.cc b/webrtc/pc/dtmfsender_unittest.cc similarity index 99% rename from webrtc/api/dtmfsender_unittest.cc rename to webrtc/pc/dtmfsender_unittest.cc index 54f3a7b96d..a58c1ec91f 100644 --- a/webrtc/api/dtmfsender_unittest.cc +++ b/webrtc/pc/dtmfsender_unittest.cc @@ -8,18 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/dtmfsender.h" +#include "webrtc/pc/dtmfsender.h" #include #include #include #include -#include "webrtc/api/audiotrack.h" #include "webrtc/base/fakeclock.h" #include "webrtc/base/gunit.h" #include "webrtc/base/logging.h" #include "webrtc/base/timeutils.h" +#include "webrtc/pc/audiotrack.h" using webrtc::AudioTrackInterface; using webrtc::AudioTrack; diff --git a/webrtc/api/fakemediacontroller.h b/webrtc/pc/fakemediacontroller.h similarity index 88% rename from webrtc/api/fakemediacontroller.h rename to webrtc/pc/fakemediacontroller.h index bc3f3e2fdd..6d639ed18e 100644 --- a/webrtc/api/fakemediacontroller.h +++ b/webrtc/pc/fakemediacontroller.h @@ -8,12 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_FAKEMEDIACONTROLLER_H_ -#define WEBRTC_API_FAKEMEDIACONTROLLER_H_ +#ifndef WEBRTC_PC_FAKEMEDIACONTROLLER_H_ +#define WEBRTC_PC_FAKEMEDIACONTROLLER_H_ -#include "webrtc/api/mediacontroller.h" #include "webrtc/base/checks.h" #include "webrtc/media/base/mediachannel.h" +#include "webrtc/pc/mediacontroller.h" namespace cricket { @@ -39,4 +39,4 @@ class FakeMediaController : public webrtc::MediaControllerInterface { webrtc::Call* call_; }; } // namespace cricket -#endif // WEBRTC_API_FAKEMEDIACONTROLLER_H_ +#endif // WEBRTC_PC_FAKEMEDIACONTROLLER_H_ diff --git a/webrtc/api/jsepicecandidate.cc b/webrtc/pc/jsepicecandidate.cc similarity index 98% rename from webrtc/api/jsepicecandidate.cc rename to webrtc/pc/jsepicecandidate.cc index cced1b4d6a..51faa0739f 100644 --- a/webrtc/api/jsepicecandidate.cc +++ b/webrtc/pc/jsepicecandidate.cc @@ -12,8 +12,8 @@ #include -#include "webrtc/api/webrtcsdp.h" #include "webrtc/base/stringencode.h" +#include "webrtc/pc/webrtcsdp.h" namespace webrtc { diff --git a/webrtc/api/jsepsessiondescription.cc b/webrtc/pc/jsepsessiondescription.cc similarity index 99% rename from webrtc/api/jsepsessiondescription.cc rename to webrtc/pc/jsepsessiondescription.cc index 6f73a1e9fd..02919b6bf8 100644 --- a/webrtc/api/jsepsessiondescription.cc +++ b/webrtc/pc/jsepsessiondescription.cc @@ -12,10 +12,10 @@ #include -#include "webrtc/api/webrtcsdp.h" #include "webrtc/base/arraysize.h" #include "webrtc/base/stringencode.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/pc/webrtcsdp.h" using cricket::SessionDescription; diff --git a/webrtc/api/jsepsessiondescription_unittest.cc b/webrtc/pc/jsepsessiondescription_unittest.cc similarity index 100% rename from webrtc/api/jsepsessiondescription_unittest.cc rename to webrtc/pc/jsepsessiondescription_unittest.cc diff --git a/webrtc/api/localaudiosource.cc b/webrtc/pc/localaudiosource.cc similarity index 97% rename from webrtc/api/localaudiosource.cc rename to webrtc/pc/localaudiosource.cc index 57cfdf8fd4..3d79da96c5 100644 --- a/webrtc/api/localaudiosource.cc +++ b/webrtc/pc/localaudiosource.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/localaudiosource.h" +#include "webrtc/pc/localaudiosource.h" #include diff --git a/webrtc/api/localaudiosource.h b/webrtc/pc/localaudiosource.h similarity index 94% rename from webrtc/api/localaudiosource.h rename to webrtc/pc/localaudiosource.h index e1c023e542..58e90af8ae 100644 --- a/webrtc/api/localaudiosource.h +++ b/webrtc/pc/localaudiosource.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_LOCALAUDIOSOURCE_H_ -#define WEBRTC_API_LOCALAUDIOSOURCE_H_ +#ifndef WEBRTC_PC_LOCALAUDIOSOURCE_H_ +#define WEBRTC_PC_LOCALAUDIOSOURCE_H_ #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/notifier.h" @@ -57,4 +57,4 @@ class LocalAudioSource : public Notifier { } // namespace webrtc -#endif // WEBRTC_API_LOCALAUDIOSOURCE_H_ +#endif // WEBRTC_PC_LOCALAUDIOSOURCE_H_ diff --git a/webrtc/api/localaudiosource_unittest.cc b/webrtc/pc/localaudiosource_unittest.cc similarity index 99% rename from webrtc/api/localaudiosource_unittest.cc rename to webrtc/pc/localaudiosource_unittest.cc index 12f46b79f9..394a2eae01 100644 --- a/webrtc/api/localaudiosource_unittest.cc +++ b/webrtc/pc/localaudiosource_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/localaudiosource.h" +#include "webrtc/pc/localaudiosource.h" #include #include diff --git a/webrtc/api/mediaconstraintsinterface_unittest.cc b/webrtc/pc/mediaconstraintsinterface_unittest.cc similarity index 100% rename from webrtc/api/mediaconstraintsinterface_unittest.cc rename to webrtc/pc/mediaconstraintsinterface_unittest.cc diff --git a/webrtc/api/mediacontroller.cc b/webrtc/pc/mediacontroller.cc similarity index 98% rename from webrtc/api/mediacontroller.cc rename to webrtc/pc/mediacontroller.cc index c64ff018b8..fa8acadddc 100644 --- a/webrtc/api/mediacontroller.cc +++ b/webrtc/pc/mediacontroller.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/mediacontroller.h" +#include "webrtc/pc/mediacontroller.h" #include diff --git a/webrtc/pc/mediacontroller.h b/webrtc/pc/mediacontroller.h new file mode 100644 index 0000000000..85617aff0a --- /dev/null +++ b/webrtc/pc/mediacontroller.h @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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 WEBRTC_PC_MEDIACONTROLLER_H_ +#define WEBRTC_PC_MEDIACONTROLLER_H_ + +#include "webrtc/base/thread.h" + +namespace cricket { +class ChannelManager; +struct MediaConfig; +} // namespace cricket + +namespace webrtc { +class Call; +class VoiceEngine; +class RtcEventLog; + +// The MediaController currently owns shared state between media channels, but +// in the future will create and own RtpSenders and RtpReceivers. +class MediaControllerInterface { + public: + static MediaControllerInterface* Create( + const cricket::MediaConfig& config, + rtc::Thread* worker_thread, + cricket::ChannelManager* channel_manager, + webrtc::RtcEventLog* event_log); + + virtual ~MediaControllerInterface() {} + virtual void Close() = 0; + virtual webrtc::Call* call_w() = 0; + virtual cricket::ChannelManager* channel_manager() const = 0; + virtual const cricket::MediaConfig& config() const = 0; +}; +} // namespace webrtc + +#endif // WEBRTC_PC_MEDIACONTROLLER_H_ diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc index 5e6942384a..910c72b2f0 100644 --- a/webrtc/pc/mediasession.cc +++ b/webrtc/pc/mediasession.cc @@ -1193,25 +1193,6 @@ static bool IsDtlsActive( return current_tdesc->secure(); } -std::string MediaTypeToString(MediaType type) { - std::string type_str; - switch (type) { - case MEDIA_TYPE_AUDIO: - type_str = "audio"; - break; - case MEDIA_TYPE_VIDEO: - type_str = "video"; - break; - case MEDIA_TYPE_DATA: - type_str = "data"; - break; - default: - RTC_NOTREACHED(); - break; - } - return type_str; -} - std::string MediaContentDirectionToString(MediaContentDirection direction) { std::string dir_str; switch (direction) { diff --git a/webrtc/pc/mediasession.h b/webrtc/pc/mediasession.h index ee2126d912..06815ecba3 100644 --- a/webrtc/pc/mediasession.h +++ b/webrtc/pc/mediasession.h @@ -18,6 +18,7 @@ #include #include +#include "webrtc/api/mediatypes.h" #include "webrtc/media/base/codec.h" #include "webrtc/media/base/cryptoparams.h" #include "webrtc/media/base/mediachannel.h" @@ -37,14 +38,6 @@ typedef std::vector DataCodecs; typedef std::vector CryptoParamsVec; typedef std::vector RtpHeaderExtensions; -enum MediaType { - MEDIA_TYPE_AUDIO, - MEDIA_TYPE_VIDEO, - MEDIA_TYPE_DATA -}; - -std::string MediaTypeToString(MediaType type); - enum MediaContentDirection { MD_INACTIVE, MD_SENDONLY, diff --git a/webrtc/api/mediastream.cc b/webrtc/pc/mediastream.cc similarity index 98% rename from webrtc/api/mediastream.cc rename to webrtc/pc/mediastream.cc index bef04ae8bd..18307923ac 100644 --- a/webrtc/api/mediastream.cc +++ b/webrtc/pc/mediastream.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/mediastream.h" +#include "webrtc/pc/mediastream.h" #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" diff --git a/webrtc/pc/mediastream.h b/webrtc/pc/mediastream.h new file mode 100644 index 0000000000..56fbed95ba --- /dev/null +++ b/webrtc/pc/mediastream.h @@ -0,0 +1,58 @@ +/* + * Copyright 2011 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. + */ + +// This file contains the implementation of MediaStreamInterface interface. + +#ifndef WEBRTC_PC_MEDIASTREAM_H_ +#define WEBRTC_PC_MEDIASTREAM_H_ + +#include +#include + +#include "webrtc/api/mediastreaminterface.h" +#include "webrtc/api/notifier.h" + +namespace webrtc { + +class MediaStream : public Notifier { + public: + static rtc::scoped_refptr Create(const std::string& label); + + std::string label() const override { return label_; } + + bool AddTrack(AudioTrackInterface* track) override; + bool AddTrack(VideoTrackInterface* track) override; + bool RemoveTrack(AudioTrackInterface* track) override; + bool RemoveTrack(VideoTrackInterface* track) override; + rtc::scoped_refptr + FindAudioTrack(const std::string& track_id) override; + rtc::scoped_refptr + FindVideoTrack(const std::string& track_id) override; + + AudioTrackVector GetAudioTracks() override { return audio_tracks_; } + VideoTrackVector GetVideoTracks() override { return video_tracks_; } + + protected: + explicit MediaStream(const std::string& label); + + private: + template + bool AddTrack(TrackVector* Tracks, Track* track); + template + bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track); + + std::string label_; + AudioTrackVector audio_tracks_; + VideoTrackVector video_tracks_; +}; + +} // namespace webrtc + +#endif // WEBRTC_PC_MEDIASTREAM_H_ diff --git a/webrtc/api/mediastream_unittest.cc b/webrtc/pc/mediastream_unittest.cc similarity index 96% rename from webrtc/api/mediastream_unittest.cc rename to webrtc/pc/mediastream_unittest.cc index 5df08ce9cc..e2e3985507 100644 --- a/webrtc/api/mediastream_unittest.cc +++ b/webrtc/pc/mediastream_unittest.cc @@ -10,14 +10,14 @@ #include -#include "webrtc/api/audiotrack.h" -#include "webrtc/api/mediastream.h" -#include "webrtc/api/test/fakevideotracksource.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/gunit.h" #include "webrtc/base/refcount.h" #include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" +#include "webrtc/pc/audiotrack.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/test/fakevideotracksource.h" +#include "webrtc/pc/videotrack.h" static const char kStreamLabel1[] = "local_stream_1"; static const char kVideoTrackId[] = "dummy_video_cam_1"; diff --git a/webrtc/api/mediastreamobserver.cc b/webrtc/pc/mediastreamobserver.cc similarity index 98% rename from webrtc/api/mediastreamobserver.cc rename to webrtc/pc/mediastreamobserver.cc index 0cf52b4d2a..bf17582b5e 100644 --- a/webrtc/api/mediastreamobserver.cc +++ b/webrtc/pc/mediastreamobserver.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/mediastreamobserver.h" +#include "webrtc/pc/mediastreamobserver.h" #include diff --git a/webrtc/api/mediastreamobserver.h b/webrtc/pc/mediastreamobserver.h similarity index 91% rename from webrtc/api/mediastreamobserver.h rename to webrtc/pc/mediastreamobserver.h index 3179976404..5d9012be60 100644 --- a/webrtc/api/mediastreamobserver.h +++ b/webrtc/pc/mediastreamobserver.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_MEDIASTREAMOBSERVER_H_ -#define WEBRTC_API_MEDIASTREAMOBSERVER_H_ +#ifndef WEBRTC_PC_MEDIASTREAMOBSERVER_H_ +#define WEBRTC_PC_MEDIASTREAMOBSERVER_H_ #include "webrtc/api/mediastreaminterface.h" #include "webrtc/base/scoped_ref_ptr.h" @@ -45,4 +45,4 @@ class MediaStreamObserver : public ObserverInterface { } // namespace webrtc -#endif // WEBRTC_API_MEDIASTREAMOBSERVER_H_ +#endif // WEBRTC_PC_MEDIASTREAMOBSERVER_H_ diff --git a/webrtc/pc/mediastreamtrack.h b/webrtc/pc/mediastreamtrack.h new file mode 100644 index 0000000000..0fb2de2ddc --- /dev/null +++ b/webrtc/pc/mediastreamtrack.h @@ -0,0 +1,62 @@ +/* + * Copyright 2011 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 WEBRTC_PC_MEDIASTREAMTRACK_H_ +#define WEBRTC_PC_MEDIASTREAMTRACK_H_ + +#include + +#include "webrtc/api/mediastreaminterface.h" +#include "webrtc/api/notifier.h" + +namespace webrtc { + +// MediaTrack implements the interface common to AudioTrackInterface and +// VideoTrackInterface. +template +class MediaStreamTrack : public Notifier { + public: + typedef typename T::TrackState TypedTrackState; + + std::string id() const override { return id_; } + MediaStreamTrackInterface::TrackState state() const override { + return state_; + } + bool enabled() const override { return enabled_; } + bool set_enabled(bool enable) override { + bool fire_on_change = (enable != enabled_); + enabled_ = enable; + if (fire_on_change) { + Notifier::FireOnChanged(); + } + return fire_on_change; + } + + protected: + explicit MediaStreamTrack(const std::string& id) + : enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {} + + bool set_state(MediaStreamTrackInterface::TrackState new_state) { + bool fire_on_change = (state_ != new_state); + state_ = new_state; + if (fire_on_change) + Notifier::FireOnChanged(); + return true; + } + + private: + bool enabled_; + std::string id_; + MediaStreamTrackInterface::TrackState state_; +}; + +} // namespace webrtc + +#endif // WEBRTC_PC_MEDIASTREAMTRACK_H_ diff --git a/webrtc/api/ortcfactory.cc b/webrtc/pc/ortcfactory.cc similarity index 99% rename from webrtc/api/ortcfactory.cc rename to webrtc/pc/ortcfactory.cc index ba41a03ca5..47d39b7cb0 100644 --- a/webrtc/api/ortcfactory.cc +++ b/webrtc/pc/ortcfactory.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/ortcfactory.h" +#include "webrtc/pc/ortcfactory.h" #include #include // For std::move. diff --git a/webrtc/api/ortcfactory.h b/webrtc/pc/ortcfactory.h similarity index 95% rename from webrtc/api/ortcfactory.h rename to webrtc/pc/ortcfactory.h index dc92774ff4..65fe10fd53 100644 --- a/webrtc/api/ortcfactory.h +++ b/webrtc/pc/ortcfactory.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_ORTCFACTORY_H_ -#define WEBRTC_API_ORTCFACTORY_H_ +#ifndef WEBRTC_PC_ORTCFACTORY_H_ +#define WEBRTC_PC_ORTCFACTORY_H_ #include @@ -61,4 +61,4 @@ END_PROXY_MAP() } // namespace webrtc -#endif // WEBRTC_API_ORTCFACTORY_H_ +#endif // WEBRTC_PC_ORTCFACTORY_H_ diff --git a/webrtc/api/ortcfactory_unittest.cc b/webrtc/pc/ortcfactory_unittest.cc similarity index 100% rename from webrtc/api/ortcfactory_unittest.cc rename to webrtc/pc/ortcfactory_unittest.cc diff --git a/webrtc/api/peerconnection.cc b/webrtc/pc/peerconnection.cc similarity index 99% rename from webrtc/api/peerconnection.cc rename to webrtc/pc/peerconnection.cc index 78e6790dd7..cbd0d4b25a 100644 --- a/webrtc/api/peerconnection.cc +++ b/webrtc/pc/peerconnection.cc @@ -8,28 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/peerconnection.h" +#include "webrtc/pc/peerconnection.h" #include #include // for isdigit #include #include -#include "webrtc/api/audiotrack.h" -#include "webrtc/api/dtmfsender.h" #include "webrtc/api/jsepicecandidate.h" #include "webrtc/api/jsepsessiondescription.h" #include "webrtc/api/mediaconstraintsinterface.h" -#include "webrtc/api/mediastream.h" -#include "webrtc/api/mediastreamobserver.h" #include "webrtc/api/mediastreamproxy.h" #include "webrtc/api/mediastreamtrackproxy.h" -#include "webrtc/api/remoteaudiosource.h" -#include "webrtc/api/rtpreceiver.h" -#include "webrtc/api/rtpsender.h" -#include "webrtc/api/streamcollection.h" -#include "webrtc/api/videocapturertracksource.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/arraysize.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" @@ -40,7 +30,18 @@ #include "webrtc/call/call.h" #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/media/sctp/sctptransport.h" +#include "webrtc/pc/audiotrack.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/dtmfsender.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/mediastreamobserver.h" +#include "webrtc/pc/remoteaudiosource.h" +#include "webrtc/pc/rtpreceiver.h" +#include "webrtc/pc/rtpsender.h" +#include "webrtc/pc/streamcollection.h" +#include "webrtc/pc/videocapturertracksource.h" +#include "webrtc/pc/videotrack.h" +#include "webrtc/system_wrappers/include/clock.h" #include "webrtc/system_wrappers/include/field_trial.h" namespace { diff --git a/webrtc/api/peerconnection.h b/webrtc/pc/peerconnection.h similarity index 98% rename from webrtc/api/peerconnection.h rename to webrtc/pc/peerconnection.h index 82dc8edfe6..ac8f33c705 100644 --- a/webrtc/api/peerconnection.h +++ b/webrtc/pc/peerconnection.h @@ -8,22 +8,22 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_PEERCONNECTION_H_ -#define WEBRTC_API_PEERCONNECTION_H_ +#ifndef WEBRTC_PC_PEERCONNECTION_H_ +#define WEBRTC_PC_PEERCONNECTION_H_ #include #include #include #include -#include "webrtc/api/peerconnectionfactory.h" #include "webrtc/api/peerconnectioninterface.h" -#include "webrtc/api/rtcstatscollector.h" -#include "webrtc/api/rtpreceiver.h" -#include "webrtc/api/rtpsender.h" -#include "webrtc/api/statscollector.h" -#include "webrtc/api/streamcollection.h" -#include "webrtc/api/webrtcsession.h" +#include "webrtc/pc/peerconnectionfactory.h" +#include "webrtc/pc/rtcstatscollector.h" +#include "webrtc/pc/rtpreceiver.h" +#include "webrtc/pc/rtpsender.h" +#include "webrtc/pc/statscollector.h" +#include "webrtc/pc/streamcollection.h" +#include "webrtc/pc/webrtcsession.h" namespace webrtc { @@ -452,4 +452,4 @@ class PeerConnection : public PeerConnectionInterface, } // namespace webrtc -#endif // WEBRTC_API_PEERCONNECTION_H_ +#endif // WEBRTC_PC_PEERCONNECTION_H_ diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/pc/peerconnection_unittest.cc similarity index 99% rename from webrtc/api/peerconnection_unittest.cc rename to webrtc/pc/peerconnection_unittest.cc index c27e53ffc4..a172a605b5 100644 --- a/webrtc/api/peerconnection_unittest.cc +++ b/webrtc/pc/peerconnection_unittest.cc @@ -17,19 +17,10 @@ #include #include -#include "webrtc/api/dtmfsender.h" #include "webrtc/api/fakemetricsobserver.h" -#include "webrtc/api/localaudiosource.h" #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/peerconnection.h" -#include "webrtc/api/peerconnectionfactory.h" #include "webrtc/api/peerconnectioninterface.h" -#include "webrtc/api/test/fakeaudiocapturemodule.h" #include "webrtc/api/test/fakeconstraints.h" -#include "webrtc/api/test/fakeperiodicvideocapturer.h" -#include "webrtc/api/test/fakertccertificategenerator.h" -#include "webrtc/api/test/fakevideotrackrenderer.h" -#include "webrtc/api/test/mockpeerconnectionobservers.h" #include "webrtc/base/fakenetwork.h" #include "webrtc/base/gunit.h" #include "webrtc/base/helpers.h" @@ -44,7 +35,16 @@ #include "webrtc/p2p/base/sessiondescription.h" #include "webrtc/p2p/base/testturnserver.h" #include "webrtc/p2p/client/basicportallocator.h" +#include "webrtc/pc/dtmfsender.h" +#include "webrtc/pc/localaudiosource.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/peerconnectionfactory.h" +#include "webrtc/pc/test/fakeaudiocapturemodule.h" +#include "webrtc/pc/test/fakeperiodicvideocapturer.h" +#include "webrtc/pc/test/fakertccertificategenerator.h" +#include "webrtc/pc/test/fakevideotrackrenderer.h" +#include "webrtc/pc/test/mockpeerconnectionobservers.h" #define MAYBE_SKIP_TEST(feature) \ if (!(feature())) { \ diff --git a/webrtc/api/peerconnectionendtoend_unittest.cc b/webrtc/pc/peerconnectionendtoend_unittest.cc similarity index 99% rename from webrtc/api/peerconnectionendtoend_unittest.cc rename to webrtc/pc/peerconnectionendtoend_unittest.cc index 4110db07c9..4327e1de40 100644 --- a/webrtc/api/peerconnectionendtoend_unittest.cc +++ b/webrtc/pc/peerconnectionendtoend_unittest.cc @@ -10,12 +10,6 @@ #include -#include "webrtc/api/test/peerconnectiontestwrapper.h" -// Notice that mockpeerconnectionobservers.h must be included after the above! -#include "webrtc/api/test/mockpeerconnectionobservers.h" -#ifdef WEBRTC_ANDROID -#include "webrtc/api/test/androidtestinitializer.h" -#endif #include "webrtc/base/gunit.h" #include "webrtc/base/logging.h" #include "webrtc/base/ssladapter.h" @@ -23,6 +17,12 @@ #include "webrtc/base/sslstreamadapter.h" #include "webrtc/base/stringencode.h" #include "webrtc/base/stringutils.h" +#ifdef WEBRTC_ANDROID +#include "webrtc/pc/test/androidtestinitializer.h" +#endif +#include "webrtc/pc/test/peerconnectiontestwrapper.h" +// Notice that mockpeerconnectionobservers.h must be included after the above! +#include "webrtc/pc/test/mockpeerconnectionobservers.h" #define MAYBE_SKIP_TEST(feature) \ if (!(feature())) { \ diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/pc/peerconnectionfactory.cc similarity index 97% rename from webrtc/api/peerconnectionfactory.cc rename to webrtc/pc/peerconnectionfactory.cc index 32f461e3bf..99a1daaa2e 100644 --- a/webrtc/api/peerconnectionfactory.cc +++ b/webrtc/pc/peerconnectionfactory.cc @@ -8,22 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/peerconnectionfactory.h" +#include "webrtc/pc/peerconnectionfactory.h" #include -#include "webrtc/api/audiotrack.h" -#include "webrtc/api/localaudiosource.h" #include "webrtc/api/mediaconstraintsinterface.h" -#include "webrtc/api/mediastream.h" #include "webrtc/api/mediastreamproxy.h" #include "webrtc/api/mediastreamtrackproxy.h" -#include "webrtc/api/peerconnection.h" #include "webrtc/api/peerconnectionfactoryproxy.h" #include "webrtc/api/peerconnectionproxy.h" -#include "webrtc/api/videocapturertracksource.h" #include "webrtc/api/videosourceproxy.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" #include "webrtc/media/engine/webrtcmediaengine.h" @@ -33,6 +27,12 @@ #include "webrtc/modules/audio_device/include/audio_device.h" #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/client/basicportallocator.h" +#include "webrtc/pc/audiotrack.h" +#include "webrtc/pc/localaudiosource.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/videocapturertracksource.h" +#include "webrtc/pc/videotrack.h" namespace webrtc { diff --git a/webrtc/api/peerconnectionfactory.h b/webrtc/pc/peerconnectionfactory.h similarity index 97% rename from webrtc/api/peerconnectionfactory.h rename to webrtc/pc/peerconnectionfactory.h index 4b412bacb9..6e77d91267 100644 --- a/webrtc/api/peerconnectionfactory.h +++ b/webrtc/pc/peerconnectionfactory.h @@ -8,19 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_PEERCONNECTIONFACTORY_H_ -#define WEBRTC_API_PEERCONNECTIONFACTORY_H_ +#ifndef WEBRTC_PC_PEERCONNECTIONFACTORY_H_ +#define WEBRTC_PC_PEERCONNECTIONFACTORY_H_ #include #include -#include "webrtc/api/mediacontroller.h" #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/thread.h" #include "webrtc/base/rtccertificategenerator.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/mediacontroller.h" namespace rtc { class BasicNetworkManager; @@ -143,4 +143,4 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { } // namespace webrtc -#endif // WEBRTC_API_PEERCONNECTIONFACTORY_H_ +#endif // WEBRTC_PC_PEERCONNECTIONFACTORY_H_ diff --git a/webrtc/api/peerconnectionfactory_unittest.cc b/webrtc/pc/peerconnectionfactory_unittest.cc similarity index 98% rename from webrtc/api/peerconnectionfactory_unittest.cc rename to webrtc/pc/peerconnectionfactory_unittest.cc index 8b5b335f93..a178998622 100644 --- a/webrtc/api/peerconnectionfactory_unittest.cc +++ b/webrtc/pc/peerconnectionfactory_unittest.cc @@ -13,18 +13,18 @@ #include #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/peerconnectionfactory.h" -#ifdef WEBRTC_ANDROID -#include "webrtc/api/test/androidtestinitializer.h" -#endif -#include "webrtc/api/test/fakertccertificategenerator.h" -#include "webrtc/api/test/fakevideotrackrenderer.h" #include "webrtc/base/gunit.h" #include "webrtc/base/thread.h" #include "webrtc/media/base/fakevideocapturer.h" #include "webrtc/media/engine/webrtccommon.h" #include "webrtc/media/engine/webrtcvoe.h" #include "webrtc/p2p/base/fakeportallocator.h" +#include "webrtc/pc/peerconnectionfactory.h" +#ifdef WEBRTC_ANDROID +#include "webrtc/pc/test/androidtestinitializer.h" +#endif +#include "webrtc/pc/test/fakertccertificategenerator.h" +#include "webrtc/pc/test/fakevideotrackrenderer.h" using webrtc::DataChannelInterface; using webrtc::FakeVideoTrackRenderer; diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc similarity index 99% rename from webrtc/api/peerconnectioninterface_unittest.cc rename to webrtc/pc/peerconnectioninterface_unittest.cc index be3825ce0f..09395a4b89 100644 --- a/webrtc/api/peerconnectioninterface_unittest.cc +++ b/webrtc/pc/peerconnectioninterface_unittest.cc @@ -13,22 +13,12 @@ #include #include -#include "webrtc/api/audiotrack.h" #include "webrtc/api/jsepsessiondescription.h" -#include "webrtc/api/mediastream.h" #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/peerconnection.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/rtpreceiverinterface.h" #include "webrtc/api/rtpsenderinterface.h" -#include "webrtc/api/streamcollection.h" #include "webrtc/api/test/fakeconstraints.h" -#include "webrtc/api/test/fakertccertificategenerator.h" -#include "webrtc/api/test/fakevideotracksource.h" -#include "webrtc/api/test/mockpeerconnectionobservers.h" -#include "webrtc/api/test/testsdpstrings.h" -#include "webrtc/api/videocapturertracksource.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/gunit.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/sslstreamadapter.h" @@ -38,11 +28,21 @@ #include "webrtc/media/sctp/sctptransportinternal.h" #include "webrtc/p2p/base/fakeportallocator.h" #include "webrtc/p2p/base/faketransportcontroller.h" +#include "webrtc/pc/audiotrack.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/streamcollection.h" +#include "webrtc/pc/test/fakertccertificategenerator.h" +#include "webrtc/pc/test/fakevideotracksource.h" +#include "webrtc/pc/test/mockpeerconnectionobservers.h" +#include "webrtc/pc/test/testsdpstrings.h" +#include "webrtc/pc/videocapturertracksource.h" +#include "webrtc/pc/videotrack.h" #include "webrtc/test/gmock.h" #ifdef WEBRTC_ANDROID -#include "webrtc/api/test/androidtestinitializer.h" +#include "webrtc/pc/test/androidtestinitializer.h" #endif static const char kStreamLabel1[] = "local_stream_1"; diff --git a/webrtc/api/proxy_unittest.cc b/webrtc/pc/proxy_unittest.cc similarity index 100% rename from webrtc/api/proxy_unittest.cc rename to webrtc/pc/proxy_unittest.cc diff --git a/webrtc/api/quicdatachannel.cc b/webrtc/pc/quicdatachannel.cc similarity index 99% rename from webrtc/api/quicdatachannel.cc rename to webrtc/pc/quicdatachannel.cc index 2ab2a3444f..8907ce767f 100644 --- a/webrtc/api/quicdatachannel.cc +++ b/webrtc/pc/quicdatachannel.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/quicdatachannel.h" +#include "webrtc/pc/quicdatachannel.h" #include "webrtc/base/bind.h" #include "webrtc/base/bytebuffer.h" diff --git a/webrtc/api/quicdatachannel.h b/webrtc/pc/quicdatachannel.h similarity index 98% rename from webrtc/api/quicdatachannel.h rename to webrtc/pc/quicdatachannel.h index 18a10acbdf..2f6288b7de 100644 --- a/webrtc/api/quicdatachannel.h +++ b/webrtc/pc/quicdatachannel.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_QUICDATACHANNEL_H_ -#define WEBRTC_API_QUICDATACHANNEL_H_ +#ifndef WEBRTC_PC_QUICDATACHANNEL_H_ +#define WEBRTC_PC_QUICDATACHANNEL_H_ #include #include @@ -217,4 +217,4 @@ class QuicDataChannel : public rtc::RefCountedObject, } // namespace webrtc -#endif // WEBRTC_API_QUICDATACHANNEL_H_ +#endif // WEBRTC_PC_QUICDATACHANNEL_H_ diff --git a/webrtc/api/quicdatachannel_unittest.cc b/webrtc/pc/quicdatachannel_unittest.cc similarity index 99% rename from webrtc/api/quicdatachannel_unittest.cc rename to webrtc/pc/quicdatachannel_unittest.cc index 7245ccfa21..649c36feb9 100644 --- a/webrtc/api/quicdatachannel_unittest.cc +++ b/webrtc/pc/quicdatachannel_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/quicdatachannel.h" +#include "webrtc/pc/quicdatachannel.h" #include #include diff --git a/webrtc/api/quicdatatransport.cc b/webrtc/pc/quicdatatransport.cc similarity index 99% rename from webrtc/api/quicdatatransport.cc rename to webrtc/pc/quicdatatransport.cc index 44143ccdf7..8b0a93f085 100644 --- a/webrtc/api/quicdatatransport.cc +++ b/webrtc/pc/quicdatatransport.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/quicdatatransport.h" +#include "webrtc/pc/quicdatatransport.h" #include "webrtc/base/bind.h" #include "webrtc/base/logging.h" diff --git a/webrtc/api/quicdatatransport.h b/webrtc/pc/quicdatatransport.h similarity index 96% rename from webrtc/api/quicdatatransport.h rename to webrtc/pc/quicdatatransport.h index b8d3f84bfb..6b35a104f1 100644 --- a/webrtc/api/quicdatatransport.h +++ b/webrtc/pc/quicdatatransport.h @@ -8,18 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_QUICDATATRANSPORT_H_ -#define WEBRTC_API_QUICDATATRANSPORT_H_ +#ifndef WEBRTC_PC_QUICDATATRANSPORT_H_ +#define WEBRTC_PC_QUICDATATRANSPORT_H_ #include #include #include "webrtc/api/datachannelinterface.h" -#include "webrtc/api/quicdatachannel.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/sigslot.h" #include "webrtc/base/thread.h" #include "webrtc/p2p/base/transportcontroller.h" +#include "webrtc/pc/quicdatachannel.h" namespace cricket { class QuicTransportChannel; @@ -112,4 +112,4 @@ class QuicDataTransport : public sigslot::has_slots<> { } // namespace webrtc -#endif // WEBRTC_API_QUICDATATRANSPORT_H_ +#endif // WEBRTC_PC_QUICDATATRANSPORT_H_ diff --git a/webrtc/api/quicdatatransport_unittest.cc b/webrtc/pc/quicdatatransport_unittest.cc similarity index 99% rename from webrtc/api/quicdatatransport_unittest.cc rename to webrtc/pc/quicdatatransport_unittest.cc index a9c605ff2a..af28159aea 100644 --- a/webrtc/api/quicdatatransport_unittest.cc +++ b/webrtc/pc/quicdatatransport_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/quicdatatransport.h" +#include "webrtc/pc/quicdatatransport.h" #include #include @@ -16,12 +16,12 @@ #include #include -#include "webrtc/api/quicdatachannel.h" #include "webrtc/base/bytebuffer.h" #include "webrtc/base/gunit.h" #include "webrtc/p2p/base/faketransportcontroller.h" #include "webrtc/p2p/quic/quictransportchannel.h" #include "webrtc/p2p/quic/reliablequicstream.h" +#include "webrtc/pc/quicdatachannel.h" using webrtc::DataBuffer; using webrtc::DataChannelInit; diff --git a/webrtc/api/remoteaudiosource.cc b/webrtc/pc/remoteaudiosource.cc similarity index 99% rename from webrtc/api/remoteaudiosource.cc rename to webrtc/pc/remoteaudiosource.cc index 47213fa299..b2568191bd 100644 --- a/webrtc/api/remoteaudiosource.cc +++ b/webrtc/pc/remoteaudiosource.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/remoteaudiosource.h" +#include "webrtc/pc/remoteaudiosource.h" #include #include diff --git a/webrtc/api/remoteaudiosource.h b/webrtc/pc/remoteaudiosource.h similarity index 94% rename from webrtc/api/remoteaudiosource.h rename to webrtc/pc/remoteaudiosource.h index a67b89553e..b84a016aad 100644 --- a/webrtc/api/remoteaudiosource.h +++ b/webrtc/pc/remoteaudiosource.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_REMOTEAUDIOSOURCE_H_ -#define WEBRTC_API_REMOTEAUDIOSOURCE_H_ +#ifndef WEBRTC_PC_REMOTEAUDIOSOURCE_H_ +#define WEBRTC_PC_REMOTEAUDIOSOURCE_H_ #include #include @@ -73,4 +73,4 @@ class RemoteAudioSource : public Notifier { } // namespace webrtc -#endif // WEBRTC_API_REMOTEAUDIOSOURCE_H_ +#endif // WEBRTC_PC_REMOTEAUDIOSOURCE_H_ diff --git a/webrtc/api/rtcstats_integrationtest.cc b/webrtc/pc/rtcstats_integrationtest.cc similarity index 99% rename from webrtc/api/rtcstats_integrationtest.cc rename to webrtc/pc/rtcstats_integrationtest.cc index 6d14c46e6c..6bba2cbce1 100644 --- a/webrtc/api/rtcstats_integrationtest.cc +++ b/webrtc/pc/rtcstats_integrationtest.cc @@ -15,14 +15,14 @@ #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/stats/rtcstats_objects.h" #include "webrtc/api/stats/rtcstatsreport.h" -#include "webrtc/api/test/peerconnectiontestwrapper.h" -#include "webrtc/api/test/rtcstatsobtainer.h" #include "webrtc/base/checks.h" #include "webrtc/base/gunit.h" #include "webrtc/base/physicalsocketserver.h" #include "webrtc/base/refcountedobject.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/virtualsocketserver.h" +#include "webrtc/pc/test/peerconnectiontestwrapper.h" +#include "webrtc/pc/test/rtcstatsobtainer.h" namespace webrtc { diff --git a/webrtc/api/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc similarity index 99% rename from webrtc/api/rtcstatscollector.cc rename to webrtc/pc/rtcstatscollector.cc index e7929cb15a..1a25f32a9c 100644 --- a/webrtc/api/rtcstatscollector.cc +++ b/webrtc/pc/rtcstatscollector.cc @@ -8,23 +8,23 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/rtcstatscollector.h" +#include "webrtc/pc/rtcstatscollector.h" #include #include #include #include -#include "webrtc/api/peerconnection.h" -#include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/webrtcsession.h" +#include "webrtc/api/peerconnectioninterface.h" #include "webrtc/base/checks.h" #include "webrtc/base/timeutils.h" #include "webrtc/media/base/mediachannel.h" #include "webrtc/p2p/base/candidate.h" #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/p2p/base/port.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/webrtcsession.h" namespace webrtc { diff --git a/webrtc/api/rtcstatscollector.h b/webrtc/pc/rtcstatscollector.h similarity index 94% rename from webrtc/api/rtcstatscollector.h rename to webrtc/pc/rtcstatscollector.h index cd3c55ee89..de0af33914 100644 --- a/webrtc/api/rtcstatscollector.h +++ b/webrtc/pc/rtcstatscollector.h @@ -8,17 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_RTCSTATSCOLLECTOR_H_ -#define WEBRTC_API_RTCSTATSCOLLECTOR_H_ +#ifndef WEBRTC_PC_RTCSTATSCOLLECTOR_H_ +#define WEBRTC_PC_RTCSTATSCOLLECTOR_H_ #include #include #include #include -#include "webrtc/api/datachannel.h" -#include "webrtc/api/datachannelinterface.h" #include "webrtc/api/stats/rtcstats_objects.h" +#include "webrtc/api/stats/rtcstatscollectorcallback.h" #include "webrtc/api/stats/rtcstatsreport.h" #include "webrtc/api/trackmediainfomap.h" #include "webrtc/base/asyncinvoker.h" @@ -29,6 +28,7 @@ #include "webrtc/base/sslidentity.h" #include "webrtc/base/timeutils.h" #include "webrtc/media/base/mediachannel.h" +#include "webrtc/pc/datachannel.h" namespace cricket { class Candidate; @@ -44,14 +44,6 @@ class PeerConnection; struct SessionStats; struct ChannelNamePairs; -class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { - public: - virtual ~RTCStatsCollectorCallback() {} - - virtual void OnStatsDelivered( - const rtc::scoped_refptr& report) = 0; -}; - // All public methods of the collector are to be called on the signaling thread. // Stats are gathered on the signaling, worker and network threads // asynchronously. The callback is invoked on the signaling thread. Resulting @@ -197,4 +189,4 @@ const char* DataStateToRTCDataChannelStateForTesting( } // namespace webrtc -#endif // WEBRTC_API_RTCSTATSCOLLECTOR_H_ +#endif // WEBRTC_PC_RTCSTATSCOLLECTOR_H_ diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/pc/rtcstatscollector_unittest.cc similarity index 99% rename from webrtc/api/rtcstatscollector_unittest.cc rename to webrtc/pc/rtcstatscollector_unittest.cc index c5e8a9ceae..fd6e1ba641 100644 --- a/webrtc/api/rtcstatscollector_unittest.cc +++ b/webrtc/pc/rtcstatscollector_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/rtcstatscollector.h" +#include "webrtc/pc/rtcstatscollector.h" #include #include @@ -17,17 +17,11 @@ #include #include "webrtc/api/jsepsessiondescription.h" -#include "webrtc/api/mediastream.h" -#include "webrtc/api/mediastreamtrack.h" #include "webrtc/api/rtpparameters.h" #include "webrtc/api/stats/rtcstats_objects.h" #include "webrtc/api/stats/rtcstatsreport.h" -#include "webrtc/api/test/mock_datachannel.h" -#include "webrtc/api/test/mock_peerconnection.h" #include "webrtc/api/test/mock_rtpreceiver.h" #include "webrtc/api/test/mock_rtpsender.h" -#include "webrtc/api/test/mock_webrtcsession.h" -#include "webrtc/api/test/rtcstatsobtainer.h" #include "webrtc/base/checks.h" #include "webrtc/base/fakeclock.h" #include "webrtc/base/fakesslidentity.h" @@ -42,6 +36,12 @@ #include "webrtc/media/base/test/mock_mediachannel.h" #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/p2p/base/port.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/mediastreamtrack.h" +#include "webrtc/pc/test/mock_datachannel.h" +#include "webrtc/pc/test/mock_peerconnection.h" +#include "webrtc/pc/test/mock_webrtcsession.h" +#include "webrtc/pc/test/rtcstatsobtainer.h" using testing::_; using testing::Invoke; diff --git a/webrtc/api/rtpreceiver.cc b/webrtc/pc/rtpreceiver.cc similarity index 98% rename from webrtc/api/rtpreceiver.cc rename to webrtc/pc/rtpreceiver.cc index a5a764c048..f57babb4d4 100644 --- a/webrtc/api/rtpreceiver.cc +++ b/webrtc/pc/rtpreceiver.cc @@ -8,13 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/rtpreceiver.h" +#include "webrtc/pc/rtpreceiver.h" #include "webrtc/api/mediastreamtrackproxy.h" -#include "webrtc/api/audiotrack.h" #include "webrtc/api/videosourceproxy.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/trace_event.h" +#include "webrtc/pc/audiotrack.h" +#include "webrtc/pc/videotrack.h" namespace webrtc { diff --git a/webrtc/api/rtpreceiver.h b/webrtc/pc/rtpreceiver.h similarity index 95% rename from webrtc/api/rtpreceiver.h rename to webrtc/pc/rtpreceiver.h index b6807c43b7..c135f227c0 100644 --- a/webrtc/api/rtpreceiver.h +++ b/webrtc/pc/rtpreceiver.h @@ -12,8 +12,8 @@ // An RtpReceiver associates a MediaStreamTrackInterface with an underlying // transport (provided by cricket::VoiceChannel/cricket::VideoChannel) -#ifndef WEBRTC_API_RTPRECEIVER_H_ -#define WEBRTC_API_RTPRECEIVER_H_ +#ifndef WEBRTC_PC_RTPRECEIVER_H_ +#define WEBRTC_PC_RTPRECEIVER_H_ #include @@ -21,11 +21,12 @@ #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/rtpreceiverinterface.h" -#include "webrtc/api/remoteaudiosource.h" -#include "webrtc/api/videotracksource.h" +#include "webrtc/base/basictypes.h" #include "webrtc/base/sigslot.h" #include "webrtc/media/base/videobroadcaster.h" #include "webrtc/pc/channel.h" +#include "webrtc/pc/remoteaudiosource.h" +#include "webrtc/pc/videotracksource.h" namespace webrtc { @@ -154,4 +155,4 @@ class VideoRtpReceiver : public rtc::RefCountedObject, } // namespace webrtc -#endif // WEBRTC_API_RTPRECEIVER_H_ +#endif // WEBRTC_PC_RTPRECEIVER_H_ diff --git a/webrtc/api/rtpsender.cc b/webrtc/pc/rtpsender.cc similarity index 99% rename from webrtc/api/rtpsender.cc rename to webrtc/pc/rtpsender.cc index b2e246120f..3e8c7e122e 100644 --- a/webrtc/api/rtpsender.cc +++ b/webrtc/pc/rtpsender.cc @@ -8,13 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/rtpsender.h" +#include "webrtc/pc/rtpsender.h" -#include "webrtc/api/localaudiosource.h" #include "webrtc/api/mediastreaminterface.h" #include "webrtc/base/checks.h" #include "webrtc/base/helpers.h" #include "webrtc/base/trace_event.h" +#include "webrtc/pc/localaudiosource.h" namespace webrtc { diff --git a/webrtc/pc/rtpsender.h b/webrtc/pc/rtpsender.h new file mode 100644 index 0000000000..ed244b416a --- /dev/null +++ b/webrtc/pc/rtpsender.h @@ -0,0 +1,235 @@ +/* + * Copyright 2015 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. + */ + +// This file contains classes that implement RtpSenderInterface. +// An RtpSender associates a MediaStreamTrackInterface with an underlying +// transport (provided by AudioProviderInterface/VideoProviderInterface) + +#ifndef WEBRTC_PC_RTPSENDER_H_ +#define WEBRTC_PC_RTPSENDER_H_ + +#include +#include + +#include "webrtc/api/mediastreaminterface.h" +#include "webrtc/api/rtpsenderinterface.h" +#include "webrtc/base/basictypes.h" +#include "webrtc/base/criticalsection.h" +#include "webrtc/media/base/audiosource.h" +#include "webrtc/pc/channel.h" +#include "webrtc/pc/statscollector.h" + +namespace webrtc { + +// Internal interface used by PeerConnection. +class RtpSenderInternal : public RtpSenderInterface { + public: + // Used to set the SSRC of the sender, once a local description has been set. + // If |ssrc| is 0, this indiates that the sender should disconnect from the + // underlying transport (this occurs if the sender isn't seen in a local + // description). + virtual void SetSsrc(uint32_t ssrc) = 0; + + // TODO(deadbeef): Support one sender having multiple stream ids. + virtual void set_stream_id(const std::string& stream_id) = 0; + virtual std::string stream_id() const = 0; + + virtual void Stop() = 0; +}; + +// LocalAudioSinkAdapter receives data callback as a sink to the local +// AudioTrack, and passes the data to the sink of AudioSource. +class LocalAudioSinkAdapter : public AudioTrackSinkInterface, + public cricket::AudioSource { + public: + LocalAudioSinkAdapter(); + virtual ~LocalAudioSinkAdapter(); + + private: + // AudioSinkInterface implementation. + void OnData(const void* audio_data, + int bits_per_sample, + int sample_rate, + size_t number_of_channels, + size_t number_of_frames) override; + + // cricket::AudioSource implementation. + void SetSink(cricket::AudioSource::Sink* sink) override; + + cricket::AudioSource::Sink* sink_; + // Critical section protecting |sink_|. + rtc::CriticalSection lock_; +}; + +class AudioRtpSender : public ObserverInterface, + public rtc::RefCountedObject { + public: + // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called + // at the appropriate times. + // |channel| can be null if one does not exist yet. + AudioRtpSender(AudioTrackInterface* track, + const std::string& stream_id, + cricket::VoiceChannel* channel, + StatsCollector* stats); + + // Randomly generates stream_id. + // |channel| can be null if one does not exist yet. + AudioRtpSender(AudioTrackInterface* track, + cricket::VoiceChannel* channel, + StatsCollector* stats); + + // Randomly generates id and stream_id. + // |channel| can be null if one does not exist yet. + AudioRtpSender(cricket::VoiceChannel* channel, StatsCollector* stats); + + virtual ~AudioRtpSender(); + + // ObserverInterface implementation + void OnChanged() override; + + // RtpSenderInterface implementation + bool SetTrack(MediaStreamTrackInterface* track) override; + rtc::scoped_refptr track() const override { + return track_; + } + + uint32_t ssrc() const override { return ssrc_; } + + cricket::MediaType media_type() const override { + return cricket::MEDIA_TYPE_AUDIO; + } + + std::string id() const override { return id_; } + + std::vector stream_ids() const override { + std::vector ret = {stream_id_}; + return ret; + } + + RtpParameters GetParameters() const override; + bool SetParameters(const RtpParameters& parameters) override; + + // RtpSenderInternal implementation. + void SetSsrc(uint32_t ssrc) override; + + void set_stream_id(const std::string& stream_id) override { + stream_id_ = stream_id; + } + std::string stream_id() const override { return stream_id_; } + + void Stop() override; + + // Does not take ownership. + // Should call SetChannel(nullptr) before |channel| is destroyed. + void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; } + + private: + // TODO(nisse): Since SSRC == 0 is technically valid, figure out + // some other way to test if we have a valid SSRC. + bool can_send_track() const { return track_ && ssrc_; } + // Helper function to construct options for + // AudioProviderInterface::SetAudioSend. + void SetAudioSend(); + // Helper function to call SetAudioSend with "stop sending" parameters. + void ClearAudioSend(); + + std::string id_; + std::string stream_id_; + cricket::VoiceChannel* channel_ = nullptr; + StatsCollector* stats_; + rtc::scoped_refptr track_; + uint32_t ssrc_ = 0; + bool cached_track_enabled_ = false; + bool stopped_ = false; + + // Used to pass the data callback from the |track_| to the other end of + // cricket::AudioSource. + std::unique_ptr sink_adapter_; +}; + +class VideoRtpSender : public ObserverInterface, + public rtc::RefCountedObject { + public: + // |channel| can be null if one does not exist yet. + VideoRtpSender(VideoTrackInterface* track, + const std::string& stream_id, + cricket::VideoChannel* channel); + + // Randomly generates stream_id. + // |channel| can be null if one does not exist yet. + VideoRtpSender(VideoTrackInterface* track, cricket::VideoChannel* channel); + + // Randomly generates id and stream_id. + // |channel| can be null if one does not exist yet. + explicit VideoRtpSender(cricket::VideoChannel* channel); + + virtual ~VideoRtpSender(); + + // ObserverInterface implementation + void OnChanged() override; + + // RtpSenderInterface implementation + bool SetTrack(MediaStreamTrackInterface* track) override; + rtc::scoped_refptr track() const override { + return track_; + } + + uint32_t ssrc() const override { return ssrc_; } + + cricket::MediaType media_type() const override { + return cricket::MEDIA_TYPE_VIDEO; + } + + std::string id() const override { return id_; } + + std::vector stream_ids() const override { + std::vector ret = {stream_id_}; + return ret; + } + + RtpParameters GetParameters() const override; + bool SetParameters(const RtpParameters& parameters) override; + + // RtpSenderInternal implementation. + void SetSsrc(uint32_t ssrc) override; + + void set_stream_id(const std::string& stream_id) override { + stream_id_ = stream_id; + } + std::string stream_id() const override { return stream_id_; } + + void Stop() override; + + // Does not take ownership. + // Should call SetChannel(nullptr) before |channel| is destroyed. + void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; } + + private: + bool can_send_track() const { return track_ && ssrc_; } + // Helper function to construct options for + // VideoProviderInterface::SetVideoSend. + void SetVideoSend(); + // Helper function to call SetVideoSend with "stop sending" parameters. + void ClearVideoSend(); + + std::string id_; + std::string stream_id_; + cricket::VideoChannel* channel_ = nullptr; + rtc::scoped_refptr track_; + uint32_t ssrc_ = 0; + bool cached_track_enabled_ = false; + VideoTrackInterface::ContentHint cached_track_content_hint_ = + VideoTrackInterface::ContentHint::kNone; + bool stopped_ = false; +}; + +} // namespace webrtc + +#endif // WEBRTC_PC_RTPSENDER_H_ diff --git a/webrtc/api/rtpsenderreceiver_unittest.cc b/webrtc/pc/rtpsenderreceiver_unittest.cc similarity index 98% rename from webrtc/api/rtpsenderreceiver_unittest.cc rename to webrtc/pc/rtpsenderreceiver_unittest.cc index fc1b748034..86c0612114 100644 --- a/webrtc/api/rtpsenderreceiver_unittest.cc +++ b/webrtc/pc/rtpsenderreceiver_unittest.cc @@ -12,24 +12,24 @@ #include #include -#include "webrtc/api/audiotrack.h" -#include "webrtc/api/fakemediacontroller.h" -#include "webrtc/api/localaudiosource.h" -#include "webrtc/api/mediastream.h" -#include "webrtc/api/remoteaudiosource.h" -#include "webrtc/api/rtpreceiver.h" -#include "webrtc/api/rtpsender.h" -#include "webrtc/api/streamcollection.h" -#include "webrtc/api/test/fakevideotracksource.h" -#include "webrtc/api/videotrack.h" -#include "webrtc/api/videotracksource.h" #include "webrtc/base/gunit.h" #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/media/base/fakemediaengine.h" #include "webrtc/media/base/mediachannel.h" #include "webrtc/media/engine/fakewebrtccall.h" #include "webrtc/p2p/base/faketransportcontroller.h" +#include "webrtc/pc/audiotrack.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/fakemediacontroller.h" +#include "webrtc/pc/localaudiosource.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/remoteaudiosource.h" +#include "webrtc/pc/rtpreceiver.h" +#include "webrtc/pc/rtpsender.h" +#include "webrtc/pc/streamcollection.h" +#include "webrtc/pc/test/fakevideotracksource.h" +#include "webrtc/pc/videotrack.h" +#include "webrtc/pc/videotracksource.h" #include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" diff --git a/webrtc/api/sctputils.cc b/webrtc/pc/sctputils.cc similarity index 99% rename from webrtc/api/sctputils.cc rename to webrtc/pc/sctputils.cc index d6ea601fc3..1c2f76f496 100644 --- a/webrtc/api/sctputils.cc +++ b/webrtc/pc/sctputils.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/sctputils.h" +#include "webrtc/pc/sctputils.h" #include "webrtc/base/bytebuffer.h" #include "webrtc/base/copyonwritebuffer.h" diff --git a/webrtc/api/sctputils.h b/webrtc/pc/sctputils.h similarity index 92% rename from webrtc/api/sctputils.h rename to webrtc/pc/sctputils.h index 2fb194330c..940bd365a9 100644 --- a/webrtc/api/sctputils.h +++ b/webrtc/pc/sctputils.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_SCTPUTILS_H_ -#define WEBRTC_API_SCTPUTILS_H_ +#ifndef WEBRTC_PC_SCTPUTILS_H_ +#define WEBRTC_PC_SCTPUTILS_H_ #include @@ -38,4 +38,4 @@ bool WriteDataChannelOpenMessage(const std::string& label, void WriteDataChannelOpenAckMessage(rtc::CopyOnWriteBuffer* payload); } // namespace webrtc -#endif // WEBRTC_API_SCTPUTILS_H_ +#endif // WEBRTC_PC_SCTPUTILS_H_ diff --git a/webrtc/api/sctputils_unittest.cc b/webrtc/pc/sctputils_unittest.cc similarity index 99% rename from webrtc/api/sctputils_unittest.cc rename to webrtc/pc/sctputils_unittest.cc index 45a127d1d6..dc56e94d31 100644 --- a/webrtc/api/sctputils_unittest.cc +++ b/webrtc/pc/sctputils_unittest.cc @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/sctputils.h" #include "webrtc/base/bytebuffer.h" #include "webrtc/base/copyonwritebuffer.h" #include "webrtc/base/gunit.h" +#include "webrtc/pc/sctputils.h" class SctpUtilsTest : public testing::Test { public: diff --git a/webrtc/api/statscollector.cc b/webrtc/pc/statscollector.cc similarity index 99% rename from webrtc/api/statscollector.cc rename to webrtc/pc/statscollector.cc index 7761d1079a..3e0c2bf441 100644 --- a/webrtc/api/statscollector.cc +++ b/webrtc/pc/statscollector.cc @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/statscollector.h" +#include "webrtc/pc/statscollector.h" #include #include #include -#include "webrtc/api/peerconnection.h" #include "webrtc/base/base64.h" #include "webrtc/base/checks.h" #include "webrtc/pc/channel.h" +#include "webrtc/pc/peerconnection.h" namespace webrtc { namespace { diff --git a/webrtc/api/statscollector.h b/webrtc/pc/statscollector.h similarity index 97% rename from webrtc/api/statscollector.h rename to webrtc/pc/statscollector.h index 7c198217e8..bf895ed811 100644 --- a/webrtc/api/statscollector.h +++ b/webrtc/pc/statscollector.h @@ -11,8 +11,8 @@ // This file contains a class used for gathering statistics from an ongoing // libjingle PeerConnection. -#ifndef WEBRTC_API_STATSCOLLECTOR_H_ -#define WEBRTC_API_STATSCOLLECTOR_H_ +#ifndef WEBRTC_PC_STATSCOLLECTOR_H_ +#define WEBRTC_PC_STATSCOLLECTOR_H_ #include #include @@ -21,7 +21,7 @@ #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/statstypes.h" -#include "webrtc/api/webrtcsession.h" +#include "webrtc/pc/webrtcsession.h" namespace webrtc { @@ -149,4 +149,4 @@ class StatsCollector { } // namespace webrtc -#endif // WEBRTC_API_STATSCOLLECTOR_H_ +#endif // WEBRTC_PC_STATSCOLLECTOR_H_ diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/pc/statscollector_unittest.cc similarity index 99% rename from webrtc/api/statscollector_unittest.cc rename to webrtc/pc/statscollector_unittest.cc index f72e355ac7..ef218c00c6 100644 --- a/webrtc/api/statscollector_unittest.cc +++ b/webrtc/pc/statscollector_unittest.cc @@ -13,18 +13,9 @@ #include #include -#include "webrtc/api/statscollector.h" +#include "webrtc/pc/statscollector.h" -#include "webrtc/api/mediastream.h" #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/mediastreamtrack.h" -#include "webrtc/api/peerconnection.h" -#include "webrtc/api/peerconnectionfactory.h" -#include "webrtc/api/test/fakedatachannelprovider.h" -#include "webrtc/api/test/fakevideotracksource.h" -#include "webrtc/api/test/mock_peerconnection.h" -#include "webrtc/api/test/mock_webrtcsession.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/base64.h" #include "webrtc/base/fakesslidentity.h" #include "webrtc/base/gunit.h" @@ -35,6 +26,15 @@ #include "webrtc/media/base/test/mock_mediachannel.h" #include "webrtc/p2p/base/faketransportcontroller.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/mediastream.h" +#include "webrtc/pc/mediastreamtrack.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/peerconnectionfactory.h" +#include "webrtc/pc/test/fakedatachannelprovider.h" +#include "webrtc/pc/test/fakevideotracksource.h" +#include "webrtc/pc/test/mock_peerconnection.h" +#include "webrtc/pc/test/mock_webrtcsession.h" +#include "webrtc/pc/videotrack.h" #include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" diff --git a/webrtc/pc/streamcollection.h b/webrtc/pc/streamcollection.h new file mode 100644 index 0000000000..b4d1f27331 --- /dev/null +++ b/webrtc/pc/streamcollection.h @@ -0,0 +1,108 @@ +/* + * Copyright 2011 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 WEBRTC_PC_STREAMCOLLECTION_H_ +#define WEBRTC_PC_STREAMCOLLECTION_H_ + +#include +#include + +#include "webrtc/api/peerconnectioninterface.h" + +namespace webrtc { + +// Implementation of StreamCollection. +class StreamCollection : public StreamCollectionInterface { + public: + static rtc::scoped_refptr Create() { + rtc::RefCountedObject* implementation = + new rtc::RefCountedObject(); + return implementation; + } + + static rtc::scoped_refptr Create( + StreamCollection* streams) { + rtc::RefCountedObject* implementation = + new rtc::RefCountedObject(streams); + return implementation; + } + + virtual size_t count() { + return media_streams_.size(); + } + + virtual MediaStreamInterface* at(size_t index) { + return media_streams_.at(index); + } + + virtual MediaStreamInterface* find(const std::string& label) { + for (StreamVector::iterator it = media_streams_.begin(); + it != media_streams_.end(); ++it) { + if ((*it)->label().compare(label) == 0) { + return (*it); + } + } + return NULL; + } + + virtual MediaStreamTrackInterface* FindAudioTrack( + const std::string& id) { + for (size_t i = 0; i < media_streams_.size(); ++i) { + MediaStreamTrackInterface* track = media_streams_[i]->FindAudioTrack(id); + if (track) { + return track; + } + } + return NULL; + } + + virtual MediaStreamTrackInterface* FindVideoTrack( + const std::string& id) { + for (size_t i = 0; i < media_streams_.size(); ++i) { + MediaStreamTrackInterface* track = media_streams_[i]->FindVideoTrack(id); + if (track) { + return track; + } + } + return NULL; + } + + void AddStream(MediaStreamInterface* stream) { + for (StreamVector::iterator it = media_streams_.begin(); + it != media_streams_.end(); ++it) { + if ((*it)->label().compare(stream->label()) == 0) + return; + } + media_streams_.push_back(stream); + } + + void RemoveStream(MediaStreamInterface* remove_stream) { + for (StreamVector::iterator it = media_streams_.begin(); + it != media_streams_.end(); ++it) { + if ((*it)->label().compare(remove_stream->label()) == 0) { + media_streams_.erase(it); + break; + } + } + } + + protected: + StreamCollection() {} + explicit StreamCollection(StreamCollection* original) + : media_streams_(original->media_streams_) { + } + typedef std::vector > + StreamVector; + StreamVector media_streams_; +}; + +} // namespace webrtc + +#endif // WEBRTC_PC_STREAMCOLLECTION_H_ diff --git a/webrtc/api/test/DEPS b/webrtc/pc/test/DEPS similarity index 100% rename from webrtc/api/test/DEPS rename to webrtc/pc/test/DEPS diff --git a/webrtc/api/test/androidtestinitializer.cc b/webrtc/pc/test/androidtestinitializer.cc similarity index 97% rename from webrtc/api/test/androidtestinitializer.cc rename to webrtc/pc/test/androidtestinitializer.cc index 7c1f5f8046..c95d7bcdd8 100644 --- a/webrtc/api/test/androidtestinitializer.cc +++ b/webrtc/pc/test/androidtestinitializer.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/test/androidtestinitializer.h" +#include "webrtc/pc/test/androidtestinitializer.h" #include diff --git a/webrtc/api/test/androidtestinitializer.h b/webrtc/pc/test/androidtestinitializer.h similarity index 76% rename from webrtc/api/test/androidtestinitializer.h rename to webrtc/pc/test/androidtestinitializer.h index b56783ee3e..48df9cc0fb 100644 --- a/webrtc/api/test/androidtestinitializer.h +++ b/webrtc/pc/test/androidtestinitializer.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_ -#define WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_ +#ifndef WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_ +#define WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_ namespace webrtc { @@ -17,4 +17,4 @@ void InitializeAndroidObjects(); } // namespace webrtc -#endif // WEBRTC_API_TEST_ANDROIDTESTINITIALIZER_H_ +#endif // WEBRTC_PC_TEST_ANDROIDTESTINITIALIZER_H_ diff --git a/webrtc/api/test/fakeaudiocapturemodule.cc b/webrtc/pc/test/fakeaudiocapturemodule.cc similarity index 99% rename from webrtc/api/test/fakeaudiocapturemodule.cc rename to webrtc/pc/test/fakeaudiocapturemodule.cc index c0b761fd3d..01fd5ee2b0 100644 --- a/webrtc/api/test/fakeaudiocapturemodule.cc +++ b/webrtc/pc/test/fakeaudiocapturemodule.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/test/fakeaudiocapturemodule.h" +#include "webrtc/pc/test/fakeaudiocapturemodule.h" #include "webrtc/base/checks.h" #include "webrtc/base/common.h" diff --git a/webrtc/api/test/fakeaudiocapturemodule.h b/webrtc/pc/test/fakeaudiocapturemodule.h similarity index 98% rename from webrtc/api/test/fakeaudiocapturemodule.h rename to webrtc/pc/test/fakeaudiocapturemodule.h index 34aa7e09db..72735b6fa7 100644 --- a/webrtc/api/test/fakeaudiocapturemodule.h +++ b/webrtc/pc/test/fakeaudiocapturemodule.h @@ -17,8 +17,8 @@ // Note P postfix of a function indicates that it should only be called by the // processing thread. -#ifndef WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ -#define WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ +#ifndef WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_ +#define WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_ #include @@ -278,4 +278,4 @@ class FakeAudioCaptureModule rtc::CriticalSection crit_callback_; }; -#endif // WEBRTC_API_TEST_FAKEAUDIOCAPTUREMODULE_H_ +#endif // WEBRTC_PC_TEST_FAKEAUDIOCAPTUREMODULE_H_ diff --git a/webrtc/api/test/fakeaudiocapturemodule_unittest.cc b/webrtc/pc/test/fakeaudiocapturemodule_unittest.cc similarity index 99% rename from webrtc/api/test/fakeaudiocapturemodule_unittest.cc rename to webrtc/pc/test/fakeaudiocapturemodule_unittest.cc index 53fb5f2036..aa40af79d0 100644 --- a/webrtc/api/test/fakeaudiocapturemodule_unittest.cc +++ b/webrtc/pc/test/fakeaudiocapturemodule_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/test/fakeaudiocapturemodule.h" +#include "webrtc/pc/test/fakeaudiocapturemodule.h" #include diff --git a/webrtc/api/test/fakedatachannelprovider.h b/webrtc/pc/test/fakedatachannelprovider.h similarity index 95% rename from webrtc/api/test/fakedatachannelprovider.h rename to webrtc/pc/test/fakedatachannelprovider.h index 3e796a33bc..114f3de7e6 100644 --- a/webrtc/api/test/fakedatachannelprovider.h +++ b/webrtc/pc/test/fakedatachannelprovider.h @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ -#define WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ +#ifndef WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_ +#define WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_ -#include "webrtc/api/datachannel.h" #include "webrtc/base/checks.h" +#include "webrtc/pc/datachannel.h" class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { public: @@ -144,4 +144,4 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { std::set send_ssrcs_; std::set recv_ssrcs_; }; -#endif // WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ +#endif // WEBRTC_PC_TEST_FAKEDATACHANNELPROVIDER_H_ diff --git a/webrtc/api/test/fakeperiodicvideocapturer.h b/webrtc/pc/test/fakeperiodicvideocapturer.h similarity index 93% rename from webrtc/api/test/fakeperiodicvideocapturer.h rename to webrtc/pc/test/fakeperiodicvideocapturer.h index 2c16195ac8..551df8b0e5 100644 --- a/webrtc/api/test/fakeperiodicvideocapturer.h +++ b/webrtc/pc/test/fakeperiodicvideocapturer.h @@ -11,8 +11,8 @@ // FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that // creates video frames periodically after it has been started. -#ifndef WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ -#define WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ +#ifndef WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ +#define WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ #include @@ -71,4 +71,4 @@ class FakePeriodicVideoCapturer : public cricket::FakeVideoCapturer, } // namespace webrtc -#endif // WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ +#endif // WEBRTC_PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ diff --git a/webrtc/api/test/fakertccertificategenerator.h b/webrtc/pc/test/fakertccertificategenerator.h similarity index 98% rename from webrtc/api/test/fakertccertificategenerator.h rename to webrtc/pc/test/fakertccertificategenerator.h index cd1e4bf5b8..ce36834817 100644 --- a/webrtc/api/test/fakertccertificategenerator.h +++ b/webrtc/pc/test/fakertccertificategenerator.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_ -#define WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_ +#ifndef WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_ +#define WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_ #include #include @@ -228,4 +228,4 @@ class FakeRTCCertificateGenerator int generated_certificates_ = 0; }; -#endif // WEBRTC_API_TEST_FAKERTCCERTIFICATEGENERATOR_H_ +#endif // WEBRTC_PC_TEST_FAKERTCCERTIFICATEGENERATOR_H_ diff --git a/webrtc/api/test/fakevideotrackrenderer.h b/webrtc/pc/test/fakevideotrackrenderer.h similarity index 85% rename from webrtc/api/test/fakevideotrackrenderer.h rename to webrtc/pc/test/fakevideotrackrenderer.h index 0d9b2488ab..9bf0b95575 100644 --- a/webrtc/api/test/fakevideotrackrenderer.h +++ b/webrtc/pc/test/fakevideotrackrenderer.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_ -#define WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_ +#ifndef WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_ +#define WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_ #include "webrtc/api/mediastreaminterface.h" #include "webrtc/media/base/fakevideorenderer.h" @@ -30,4 +30,4 @@ class FakeVideoTrackRenderer : public cricket::FakeVideoRenderer { } // namespace webrtc -#endif // WEBRTC_API_TEST_FAKEVIDEOTRACKRENDERER_H_ +#endif // WEBRTC_PC_TEST_FAKEVIDEOTRACKRENDERER_H_ diff --git a/webrtc/api/test/fakevideotracksource.h b/webrtc/pc/test/fakevideotracksource.h similarity index 87% rename from webrtc/api/test/fakevideotracksource.h rename to webrtc/pc/test/fakevideotracksource.h index 0638a1f16c..aa5f3f5d06 100644 --- a/webrtc/api/test/fakevideotracksource.h +++ b/webrtc/pc/test/fakevideotracksource.h @@ -8,12 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_ -#define WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_ +#ifndef WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_ +#define WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_ #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/videotracksource.h" #include "webrtc/media/base/fakevideocapturer.h" +#include "webrtc/pc/videotracksource.h" namespace webrtc { @@ -46,4 +46,4 @@ class FakeVideoTrackSource : public VideoTrackSource { } // namespace webrtc -#endif // WEBRTC_API_TEST_FAKEVIDEOTRACKSOURCE_H_ +#endif // WEBRTC_PC_TEST_FAKEVIDEOTRACKSOURCE_H_ diff --git a/webrtc/api/test/mock_datachannel.h b/webrtc/pc/test/mock_datachannel.h similarity index 91% rename from webrtc/api/test/mock_datachannel.h rename to webrtc/pc/test/mock_datachannel.h index 1cb1948f6e..105fcba760 100644 --- a/webrtc/api/test/mock_datachannel.h +++ b/webrtc/pc/test/mock_datachannel.h @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_MOCK_DATACHANNEL_H_ -#define WEBRTC_API_TEST_MOCK_DATACHANNEL_H_ +#ifndef WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_ +#define WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_ -#include "webrtc/api/datachannel.h" +#include "webrtc/pc/datachannel.h" #include "webrtc/test/gmock.h" namespace webrtc { @@ -55,4 +55,4 @@ class MockDataChannel : public rtc::RefCountedObject { } // namespace webrtc -#endif // WEBRTC_API_TEST_MOCK_DATACHANNEL_H_ +#endif // WEBRTC_PC_TEST_MOCK_DATACHANNEL_H_ diff --git a/webrtc/api/test/mock_peerconnection.h b/webrtc/pc/test/mock_peerconnection.h similarity index 89% rename from webrtc/api/test/mock_peerconnection.h rename to webrtc/pc/test/mock_peerconnection.h index ca39d2abb5..4dca0afad4 100644 --- a/webrtc/api/test/mock_peerconnection.h +++ b/webrtc/pc/test/mock_peerconnection.h @@ -8,12 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_ -#define WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_ +#ifndef WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_ +#define WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_ #include -#include "webrtc/api/peerconnection.h" +#include "webrtc/pc/peerconnection.h" #include "webrtc/test/gmock.h" namespace webrtc { @@ -43,4 +43,4 @@ class MockPeerConnection } // namespace webrtc -#endif // WEBRTC_API_TEST_MOCK_PEERCONNECTION_H_ +#endif // WEBRTC_PC_TEST_MOCK_PEERCONNECTION_H_ diff --git a/webrtc/api/test/mock_webrtcsession.h b/webrtc/pc/test/mock_webrtcsession.h similarity index 93% rename from webrtc/api/test/mock_webrtcsession.h rename to webrtc/pc/test/mock_webrtcsession.h index ae75035608..d476377370 100644 --- a/webrtc/api/test/mock_webrtcsession.h +++ b/webrtc/pc/test/mock_webrtcsession.h @@ -8,13 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_ -#define WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_ +#ifndef WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_ +#define WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_ #include #include -#include "webrtc/api/webrtcsession.h" +#include "webrtc/pc/webrtcsession.h" #include "webrtc/media/sctp/sctptransportinternal.h" #include "webrtc/test/gmock.h" @@ -62,4 +62,4 @@ class MockWebRtcSession : public webrtc::WebRtcSession { } // namespace webrtc -#endif // WEBRTC_API_TEST_MOCK_WEBRTCSESSION_H_ +#endif // WEBRTC_PC_TEST_MOCK_WEBRTCSESSION_H_ diff --git a/webrtc/api/test/mockpeerconnectionobservers.h b/webrtc/pc/test/mockpeerconnectionobservers.h similarity index 97% rename from webrtc/api/test/mockpeerconnectionobservers.h rename to webrtc/pc/test/mockpeerconnectionobservers.h index 1f000aff79..bde59a8d3f 100644 --- a/webrtc/api/test/mockpeerconnectionobservers.h +++ b/webrtc/pc/test/mockpeerconnectionobservers.h @@ -10,8 +10,8 @@ // This file contains mock implementations of observers used in PeerConnection. -#ifndef WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ -#define WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ +#ifndef WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ +#define WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ #include #include @@ -227,4 +227,4 @@ class MockStatsObserver : public webrtc::StatsObserver { } // namespace webrtc -#endif // WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ +#endif // WEBRTC_PC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ diff --git a/webrtc/api/test/peerconnectiontestwrapper.cc b/webrtc/pc/test/peerconnectiontestwrapper.cc similarity index 97% rename from webrtc/api/test/peerconnectiontestwrapper.cc rename to webrtc/pc/test/peerconnectiontestwrapper.cc index b1eb58677d..6404e2b3fc 100644 --- a/webrtc/api/test/peerconnectiontestwrapper.cc +++ b/webrtc/pc/test/peerconnectiontestwrapper.cc @@ -10,12 +10,12 @@ #include -#include "webrtc/api/test/fakeperiodicvideocapturer.h" -#include "webrtc/api/test/fakertccertificategenerator.h" -#include "webrtc/api/test/mockpeerconnectionobservers.h" -#include "webrtc/api/test/peerconnectiontestwrapper.h" #include "webrtc/base/gunit.h" #include "webrtc/p2p/base/fakeportallocator.h" +#include "webrtc/pc/test/fakeperiodicvideocapturer.h" +#include "webrtc/pc/test/fakertccertificategenerator.h" +#include "webrtc/pc/test/mockpeerconnectionobservers.h" +#include "webrtc/pc/test/peerconnectiontestwrapper.h" static const char kStreamLabelBase[] = "stream_label"; static const char kVideoTrackLabelBase[] = "video_track"; diff --git a/webrtc/api/test/peerconnectiontestwrapper.h b/webrtc/pc/test/peerconnectiontestwrapper.h similarity index 94% rename from webrtc/api/test/peerconnectiontestwrapper.h rename to webrtc/pc/test/peerconnectiontestwrapper.h index 6433e8fb05..59e6968f14 100644 --- a/webrtc/api/test/peerconnectiontestwrapper.h +++ b/webrtc/pc/test/peerconnectiontestwrapper.h @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_ -#define WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_ +#ifndef WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_ +#define WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_ #include #include "webrtc/api/peerconnectioninterface.h" -#include "webrtc/api/test/fakeaudiocapturemodule.h" #include "webrtc/api/test/fakeconstraints.h" -#include "webrtc/api/test/fakevideotrackrenderer.h" #include "webrtc/base/sigslot.h" +#include "webrtc/pc/test/fakeaudiocapturemodule.h" +#include "webrtc/pc/test/fakevideotrackrenderer.h" class PeerConnectionTestWrapper : public webrtc::PeerConnectionObserver, @@ -115,4 +115,4 @@ class PeerConnectionTestWrapper std::unique_ptr renderer_; }; -#endif // WEBRTC_API_TEST_PEERCONNECTIONTESTWRAPPER_H_ +#endif // WEBRTC_PC_TEST_PEERCONNECTIONTESTWRAPPER_H_ diff --git a/webrtc/api/test/rtcstatsobtainer.h b/webrtc/pc/test/rtcstatsobtainer.h similarity index 91% rename from webrtc/api/test/rtcstatsobtainer.h rename to webrtc/pc/test/rtcstatsobtainer.h index aeae87cddd..d0d4b61359 100644 --- a/webrtc/api/test/rtcstatsobtainer.h +++ b/webrtc/pc/test/rtcstatsobtainer.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_TEST_RTCSTATSOBTAINER_H_ -#define WEBRTC_API_TEST_RTCSTATSOBTAINER_H_ +#ifndef WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_ +#define WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_ #include "webrtc/api/stats/rtcstatsreport.h" #include "webrtc/base/gunit.h" @@ -50,4 +50,4 @@ class RTCStatsObtainer : public RTCStatsCollectorCallback { } // namespace webrtc -#endif // WEBRTC_API_TEST_RTCSTATSOBTAINER_H_ +#endif // WEBRTC_PC_TEST_RTCSTATSOBTAINER_H_ diff --git a/webrtc/api/test/testsdpstrings.h b/webrtc/pc/test/testsdpstrings.h similarity index 97% rename from webrtc/api/test/testsdpstrings.h rename to webrtc/pc/test/testsdpstrings.h index b203aad6a9..ff097b246f 100644 --- a/webrtc/api/test/testsdpstrings.h +++ b/webrtc/pc/test/testsdpstrings.h @@ -10,8 +10,8 @@ // This file contain SDP strings used for testing. -#ifndef WEBRTC_API_TEST_TESTSDPSTRINGS_H_ -#define WEBRTC_API_TEST_TESTSDPSTRINGS_H_ +#ifndef WEBRTC_PC_TEST_TESTSDPSTRINGS_H_ +#define WEBRTC_PC_TEST_TESTSDPSTRINGS_H_ namespace webrtc { @@ -129,4 +129,4 @@ static const char kAudioSdpWithUnsupportedCodecs[] = } // namespace webrtc -#endif // WEBRTC_API_TEST_TESTSDPSTRINGS_H_ +#endif // WEBRTC_PC_TEST_TESTSDPSTRINGS_H_ diff --git a/webrtc/api/videocapturertracksource.cc b/webrtc/pc/videocapturertracksource.cc similarity index 99% rename from webrtc/api/videocapturertracksource.cc rename to webrtc/pc/videocapturertracksource.cc index 0d6d46d609..771429aecd 100644 --- a/webrtc/api/videocapturertracksource.cc +++ b/webrtc/pc/videocapturertracksource.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/videocapturertracksource.h" +#include "webrtc/pc/videocapturertracksource.h" #include #include diff --git a/webrtc/api/videocapturertracksource.h b/webrtc/pc/videocapturertracksource.h similarity index 93% rename from webrtc/api/videocapturertracksource.h rename to webrtc/pc/videocapturertracksource.h index b0a2810b76..30991a11ac 100644 --- a/webrtc/api/videocapturertracksource.h +++ b/webrtc/pc/videocapturertracksource.h @@ -8,17 +8,17 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ -#define WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ +#ifndef WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_ +#define WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_ #include #include "webrtc/api/mediastreaminterface.h" -#include "webrtc/api/videotracksource.h" #include "webrtc/base/asyncinvoker.h" #include "webrtc/base/sigslot.h" #include "webrtc/media/base/videocapturer.h" #include "webrtc/media/base/videocommon.h" +#include "webrtc/pc/videotracksource.h" // VideoCapturerTrackSource implements VideoTrackSourceInterface. It owns a // cricket::VideoCapturer and make sure the camera is started at a resolution @@ -81,4 +81,4 @@ class VideoCapturerTrackSource : public VideoTrackSource, } // namespace webrtc -#endif // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ +#endif // WEBRTC_PC_VIDEOCAPTURERTRACKSOURCE_H_ diff --git a/webrtc/api/videocapturertracksource_unittest.cc b/webrtc/pc/videocapturertracksource_unittest.cc similarity index 99% rename from webrtc/api/videocapturertracksource_unittest.cc rename to webrtc/pc/videocapturertracksource_unittest.cc index a0350d999d..144d4b4b79 100644 --- a/webrtc/api/videocapturertracksource_unittest.cc +++ b/webrtc/pc/videocapturertracksource_unittest.cc @@ -13,11 +13,11 @@ #include #include "webrtc/api/test/fakeconstraints.h" -#include "webrtc/api/videocapturertracksource.h" #include "webrtc/base/gunit.h" #include "webrtc/media/base/fakemediaengine.h" #include "webrtc/media/base/fakevideocapturer.h" #include "webrtc/media/base/fakevideorenderer.h" +#include "webrtc/pc/videocapturertracksource.h" using webrtc::FakeConstraints; using webrtc::VideoCapturerTrackSource; diff --git a/webrtc/api/videotrack.cc b/webrtc/pc/videotrack.cc similarity index 96% rename from webrtc/api/videotrack.cc rename to webrtc/pc/videotrack.cc index 2fa2ba671a..494d728b1e 100644 --- a/webrtc/api/videotrack.cc +++ b/webrtc/pc/videotrack.cc @@ -8,14 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/videotrack.h" +#include "webrtc/pc/videotrack.h" #include namespace webrtc { -const char MediaStreamTrackInterface::kVideoKind[] = "video"; - VideoTrack::VideoTrack(const std::string& label, VideoTrackSourceInterface* video_source) : MediaStreamTrack(label), diff --git a/webrtc/api/videotrack.h b/webrtc/pc/videotrack.h similarity index 92% rename from webrtc/api/videotrack.h rename to webrtc/pc/videotrack.h index ebea848519..7e75e14d07 100644 --- a/webrtc/api/videotrack.h +++ b/webrtc/pc/videotrack.h @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_VIDEOTRACK_H_ -#define WEBRTC_API_VIDEOTRACK_H_ +#ifndef WEBRTC_PC_VIDEOTRACK_H_ +#define WEBRTC_PC_VIDEOTRACK_H_ #include #include -#include "webrtc/api/mediastreamtrack.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/base/thread_checker.h" #include "webrtc/media/base/videosourcebase.h" +#include "webrtc/pc/mediastreamtrack.h" namespace webrtc { @@ -57,4 +57,4 @@ class VideoTrack : public MediaStreamTrack, } // namespace webrtc -#endif // WEBRTC_API_VIDEOTRACK_H_ +#endif // WEBRTC_PC_VIDEOTRACK_H_ diff --git a/webrtc/api/videotrack_unittest.cc b/webrtc/pc/videotrack_unittest.cc similarity index 95% rename from webrtc/api/videotrack_unittest.cc rename to webrtc/pc/videotrack_unittest.cc index 53204827b2..6f4330fb33 100644 --- a/webrtc/api/videotrack_unittest.cc +++ b/webrtc/pc/videotrack_unittest.cc @@ -11,12 +11,12 @@ #include #include -#include "webrtc/api/test/fakevideotrackrenderer.h" -#include "webrtc/api/videocapturertracksource.h" -#include "webrtc/api/videotrack.h" #include "webrtc/base/gunit.h" #include "webrtc/media/base/fakevideocapturer.h" #include "webrtc/media/base/fakemediaengine.h" +#include "webrtc/pc/test/fakevideotrackrenderer.h" +#include "webrtc/pc/videocapturertracksource.h" +#include "webrtc/pc/videotrack.h" using webrtc::FakeVideoTrackRenderer; using webrtc::MediaSourceInterface; diff --git a/webrtc/api/videotracksource.cc b/webrtc/pc/videotracksource.cc similarity index 97% rename from webrtc/api/videotracksource.cc rename to webrtc/pc/videotracksource.cc index 83ae4932ff..f3ca8d72e0 100644 --- a/webrtc/api/videotracksource.cc +++ b/webrtc/pc/videotracksource.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/videotracksource.h" +#include "webrtc/pc/videotracksource.h" #include diff --git a/webrtc/pc/videotracksource.h b/webrtc/pc/videotracksource.h new file mode 100644 index 0000000000..259b1c305a --- /dev/null +++ b/webrtc/pc/videotracksource.h @@ -0,0 +1,55 @@ +/* + * Copyright 2016 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 WEBRTC_PC_VIDEOTRACKSOURCE_H_ +#define WEBRTC_PC_VIDEOTRACKSOURCE_H_ + +#include "webrtc/api/mediastreaminterface.h" +#include "webrtc/api/notifier.h" +#include "webrtc/base/thread_checker.h" +#include "webrtc/media/base/mediachannel.h" +#include "webrtc/media/base/videosinkinterface.h" + +// VideoTrackSource implements VideoTrackSourceInterface. +namespace webrtc { + +class VideoTrackSource : public Notifier { + public: + VideoTrackSource(rtc::VideoSourceInterface* source, bool remote); + void SetState(SourceState new_state); + // OnSourceDestroyed clears this instance pointer to |source_|. It is useful + // when the underlying rtc::VideoSourceInterface is destroyed before the + // reference counted VideoTrackSource. + void OnSourceDestroyed(); + + SourceState state() const override { return state_; } + bool remote() const override { return remote_; } + + bool is_screencast() const override { return false; } + rtc::Optional needs_denoising() const override { + return rtc::Optional(); } + + bool GetStats(Stats* stats) override { return false; } + + void AddOrUpdateSink(rtc::VideoSinkInterface* sink, + const rtc::VideoSinkWants& wants) override; + void RemoveSink(rtc::VideoSinkInterface* sink) override; + + private: + rtc::ThreadChecker worker_thread_checker_; + rtc::VideoSourceInterface* source_; + cricket::VideoOptions options_; + SourceState state_; + const bool remote_; +}; + +} // namespace webrtc + +#endif // WEBRTC_PC_VIDEOTRACKSOURCE_H_ diff --git a/webrtc/api/webrtcsdp.cc b/webrtc/pc/webrtcsdp.cc similarity index 99% rename from webrtc/api/webrtcsdp.cc rename to webrtc/pc/webrtcsdp.cc index c79c851c3a..d4003c2a02 100644 --- a/webrtc/api/webrtcsdp.cc +++ b/webrtc/pc/webrtcsdp.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/webrtcsdp.h" +#include "webrtc/pc/webrtcsdp.h" #include #include diff --git a/webrtc/api/webrtcsdp.h b/webrtc/pc/webrtcsdp.h similarity index 97% rename from webrtc/api/webrtcsdp.h rename to webrtc/pc/webrtcsdp.h index e7fdb34d01..beaf0c5751 100644 --- a/webrtc/api/webrtcsdp.h +++ b/webrtc/pc/webrtcsdp.h @@ -17,8 +17,8 @@ // * draft-lennox-mmusic-sdp-source-selection-02 - // Mechanisms for Media Source Selection in SDP -#ifndef WEBRTC_API_WEBRTCSDP_H_ -#define WEBRTC_API_WEBRTCSDP_H_ +#ifndef WEBRTC_PC_WEBRTCSDP_H_ +#define WEBRTC_PC_WEBRTCSDP_H_ #include @@ -84,4 +84,4 @@ bool SdpDeserializeCandidate(const std::string& transport_name, } // namespace webrtc -#endif // WEBRTC_API_WEBRTCSDP_H_ +#endif // WEBRTC_PC_WEBRTCSDP_H_ diff --git a/webrtc/api/webrtcsdp_unittest.cc b/webrtc/pc/webrtcsdp_unittest.cc similarity index 99% rename from webrtc/api/webrtcsdp_unittest.cc rename to webrtc/pc/webrtcsdp_unittest.cc index d4accba356..54eb22e11a 100644 --- a/webrtc/api/webrtcsdp_unittest.cc +++ b/webrtc/pc/webrtcsdp_unittest.cc @@ -14,10 +14,6 @@ #include #include "webrtc/api/jsepsessiondescription.h" -#ifdef WEBRTC_ANDROID -#include "webrtc/api/test/androidtestinitializer.h" -#endif -#include "webrtc/api/webrtcsdp.h" #include "webrtc/base/checks.h" #include "webrtc/base/gunit.h" #include "webrtc/base/logging.h" @@ -30,6 +26,10 @@ #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/pc/mediasession.h" +#ifdef WEBRTC_ANDROID +#include "webrtc/pc/test/androidtestinitializer.h" +#endif +#include "webrtc/pc/webrtcsdp.h" using cricket::AudioCodec; using cricket::AudioContentDescription; diff --git a/webrtc/api/webrtcsession.cc b/webrtc/pc/webrtcsession.cc similarity index 99% rename from webrtc/api/webrtcsession.cc rename to webrtc/pc/webrtcsession.cc index e98bcb0e7a..def02d408b 100644 --- a/webrtc/api/webrtcsession.cc +++ b/webrtc/pc/webrtcsession.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/webrtcsession.h" +#include "webrtc/pc/webrtcsession.h" #include @@ -21,8 +21,6 @@ #include "webrtc/api/jsepicecandidate.h" #include "webrtc/api/jsepsessiondescription.h" #include "webrtc/api/peerconnectioninterface.h" -#include "webrtc/api/sctputils.h" -#include "webrtc/api/webrtcsessiondescriptionfactory.h" #include "webrtc/base/basictypes.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" @@ -38,6 +36,8 @@ #include "webrtc/pc/channel.h" #include "webrtc/pc/channelmanager.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/pc/sctputils.h" +#include "webrtc/pc/webrtcsessiondescriptionfactory.h" #ifdef HAVE_QUIC #include "webrtc/p2p/quic/quictransportchannel.h" diff --git a/webrtc/api/webrtcsession.h b/webrtc/pc/webrtcsession.h similarity index 99% rename from webrtc/api/webrtcsession.h rename to webrtc/pc/webrtcsession.h index 0030342ee6..c250833307 100644 --- a/webrtc/api/webrtcsession.h +++ b/webrtc/pc/webrtcsession.h @@ -8,17 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_WEBRTCSESSION_H_ -#define WEBRTC_API_WEBRTCSESSION_H_ +#ifndef WEBRTC_PC_WEBRTCSESSION_H_ +#define WEBRTC_PC_WEBRTCSESSION_H_ #include #include #include #include -#include "webrtc/api/datachannel.h" -#include "webrtc/api/dtmfsender.h" -#include "webrtc/api/mediacontroller.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/statstypes.h" #include "webrtc/base/constructormagic.h" @@ -29,10 +26,13 @@ #include "webrtc/media/base/mediachannel.h" #include "webrtc/p2p/base/candidate.h" #include "webrtc/p2p/base/transportcontroller.h" +#include "webrtc/pc/datachannel.h" +#include "webrtc/pc/dtmfsender.h" +#include "webrtc/pc/mediacontroller.h" #include "webrtc/pc/mediasession.h" #ifdef HAVE_QUIC -#include "webrtc/api/quicdatatransport.h" +#include "webrtc/pc/quicdatatransport.h" #endif // HAVE_QUIC namespace cricket { @@ -651,4 +651,4 @@ class WebRtcSession : }; } // namespace webrtc -#endif // WEBRTC_API_WEBRTCSESSION_H_ +#endif // WEBRTC_PC_WEBRTCSESSION_H_ diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/pc/webrtcsession_unittest.cc similarity index 99% rename from webrtc/api/webrtcsession_unittest.cc rename to webrtc/pc/webrtcsession_unittest.cc index 1a7a02622c..053f64ceb3 100644 --- a/webrtc/api/webrtcsession_unittest.cc +++ b/webrtc/pc/webrtcsession_unittest.cc @@ -12,17 +12,9 @@ #include #include -#include "webrtc/api/audiotrack.h" -#include "webrtc/api/fakemediacontroller.h" #include "webrtc/api/fakemetricsobserver.h" #include "webrtc/api/jsepicecandidate.h" #include "webrtc/api/jsepsessiondescription.h" -#include "webrtc/api/peerconnection.h" -#include "webrtc/api/sctputils.h" -#include "webrtc/api/test/fakertccertificategenerator.h" -#include "webrtc/api/videotrack.h" -#include "webrtc/api/webrtcsession.h" -#include "webrtc/api/webrtcsessiondescriptionfactory.h" #include "webrtc/base/checks.h" #include "webrtc/base/fakenetwork.h" #include "webrtc/base/firewallsocketserver.h" @@ -47,8 +39,16 @@ #include "webrtc/p2p/base/teststunserver.h" #include "webrtc/p2p/base/testturnserver.h" #include "webrtc/p2p/client/basicportallocator.h" +#include "webrtc/pc/audiotrack.h" #include "webrtc/pc/channelmanager.h" +#include "webrtc/pc/fakemediacontroller.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/pc/peerconnection.h" +#include "webrtc/pc/sctputils.h" +#include "webrtc/pc/test/fakertccertificategenerator.h" +#include "webrtc/pc/videotrack.h" +#include "webrtc/pc/webrtcsession.h" +#include "webrtc/pc/webrtcsessiondescriptionfactory.h" #define MAYBE_SKIP_TEST(feature) \ if (!(feature())) { \ diff --git a/webrtc/api/webrtcsessiondescriptionfactory.cc b/webrtc/pc/webrtcsessiondescriptionfactory.cc similarity index 99% rename from webrtc/api/webrtcsessiondescriptionfactory.cc rename to webrtc/pc/webrtcsessiondescriptionfactory.cc index 65ee7ef128..168e5a2bc8 100644 --- a/webrtc/api/webrtcsessiondescriptionfactory.cc +++ b/webrtc/pc/webrtcsessiondescriptionfactory.cc @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/api/webrtcsessiondescriptionfactory.h" +#include "webrtc/pc/webrtcsessiondescriptionfactory.h" #include #include "webrtc/api/jsep.h" #include "webrtc/api/jsepsessiondescription.h" #include "webrtc/api/mediaconstraintsinterface.h" -#include "webrtc/api/webrtcsession.h" #include "webrtc/base/checks.h" #include "webrtc/base/sslidentity.h" +#include "webrtc/pc/webrtcsession.h" using cricket::MediaSessionOptions; diff --git a/webrtc/api/webrtcsessiondescriptionfactory.h b/webrtc/pc/webrtcsessiondescriptionfactory.h similarity index 97% rename from webrtc/api/webrtcsessiondescriptionfactory.h rename to webrtc/pc/webrtcsessiondescriptionfactory.h index 314679d24f..7572f244ec 100644 --- a/webrtc/api/webrtcsessiondescriptionfactory.h +++ b/webrtc/pc/webrtcsessiondescriptionfactory.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ -#define WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ +#ifndef WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ +#define WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ #include @@ -166,4 +166,4 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, }; } // namespace webrtc -#endif // WEBRTC_API_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ +#endif // WEBRTC_PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ diff --git a/webrtc/sdk/BUILD.gn b/webrtc/sdk/BUILD.gn index 4ccd53003a..e610242f63 100644 --- a/webrtc/sdk/BUILD.gn +++ b/webrtc/sdk/BUILD.gn @@ -219,7 +219,7 @@ if (is_ios || is_mac) { deps += [ ":rtc_sdk_common_objc", - "../api:libjingle_peerconnection", + "../pc:libjingle_peerconnection", ] if (rtc_build_libyuv) { diff --git a/webrtc/sdk/android/BUILD.gn b/webrtc/sdk/android/BUILD.gn index 2adcdb5c02..1df43e2e2a 100644 --- a/webrtc/sdk/android/BUILD.gn +++ b/webrtc/sdk/android/BUILD.gn @@ -67,7 +67,7 @@ rtc_static_library("libjingle_peerconnection_jni") { } deps = [ - "//webrtc/api:libjingle_peerconnection", + "//webrtc/pc:libjingle_peerconnection", ] if (rtc_build_libyuv) { @@ -89,7 +89,7 @@ rtc_static_library("libjingle_peerconnection_metrics_default_jni") { configs += [ ":libjingle_peerconnection_jni_warnings_config" ] deps = [ - "//webrtc/api:libjingle_peerconnection", + "//webrtc/pc:libjingle_peerconnection", "//webrtc/system_wrappers:field_trial_default", "//webrtc/system_wrappers:metrics_default", ] @@ -105,7 +105,7 @@ rtc_shared_library("libjingle_peerconnection_so") { deps = [ ":libjingle_peerconnection_jni", ":libjingle_peerconnection_metrics_default_jni", - "//webrtc/api:libjingle_peerconnection", + "//webrtc/pc:libjingle_peerconnection", ] output_extension = "so" } diff --git a/webrtc/sdk/android/src/jni/DEPS b/webrtc/sdk/android/src/jni/DEPS index e803553c71..95eff5e860 100644 --- a/webrtc/sdk/android/src/jni/DEPS +++ b/webrtc/sdk/android/src/jni/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+third_party/libyuv", "+webrtc/common_video/libyuv/include/webrtc_libyuv.h", + "+webrtc/pc", "+webrtc/voice_engine/include/voe_base.h", ] \ No newline at end of file diff --git a/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc b/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc index 0b2cdccbb2..dd6bd1edca 100644 --- a/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc +++ b/webrtc/sdk/android/src/jni/androidvideotracksource_jni.cc @@ -8,9 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/api/videosourceproxy.h" #include "webrtc/sdk/android/src/jni/androidvideotracksource.h" #include "webrtc/sdk/android/src/jni/classreferenceholder.h" -#include "webrtc/api/videosourceproxy.h" // Identifiers are over 80 characters long so this is needed to fit them on one // line. diff --git a/webrtc/sdk/android/src/jni/peerconnection_jni.cc b/webrtc/sdk/android/src/jni/peerconnection_jni.cc index 8c38a4689b..212fa43c92 100644 --- a/webrtc/sdk/android/src/jni/peerconnection_jni.cc +++ b/webrtc/sdk/android/src/jni/peerconnection_jni.cc @@ -45,19 +45,11 @@ #include "third_party/libyuv/include/libyuv/convert_from.h" #include "third_party/libyuv/include/libyuv/scale.h" -#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" -#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" -#include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h" -#include "webrtc/sdk/android/src/jni/androidvideotracksource.h" -#include "webrtc/sdk/android/src/jni/classreferenceholder.h" -#include "webrtc/sdk/android/src/jni/jni_helpers.h" -#include "webrtc/sdk/android/src/jni/native_handle_impl.h" #include "webrtc/api/mediaconstraintsinterface.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/rtpreceiverinterface.h" #include "webrtc/api/rtpsenderinterface.h" #include "webrtc/api/videosourceproxy.h" -#include "webrtc/api/webrtcsdp.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.h" #include "webrtc/base/event_tracer.h" @@ -72,6 +64,14 @@ #include "webrtc/media/engine/webrtcvideodecoderfactory.h" #include "webrtc/media/engine/webrtcvideoencoderfactory.h" #include "webrtc/system_wrappers/include/field_trial.h" +#include "webrtc/pc/webrtcsdp.h" +#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" +#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" +#include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h" +#include "webrtc/sdk/android/src/jni/androidvideotracksource.h" +#include "webrtc/sdk/android/src/jni/classreferenceholder.h" +#include "webrtc/sdk/android/src/jni/jni_helpers.h" +#include "webrtc/sdk/android/src/jni/native_handle_impl.h" #include "webrtc/system_wrappers/include/field_trial_default.h" #include "webrtc/system_wrappers/include/logcat_trace_context.h" #include "webrtc/system_wrappers/include/trace.h" diff --git a/webrtc/sdk/objc/DEPS b/webrtc/sdk/objc/DEPS index 137f67a2f1..46aeb8e029 100644 --- a/webrtc/sdk/objc/DEPS +++ b/webrtc/sdk/objc/DEPS @@ -1,9 +1,10 @@ include_rules = [ "+WebRTC", "+webrtc/api", - "+webrtc/common_video/include", "+webrtc/common_video/h264", + "+webrtc/common_video/include", "+webrtc/media", "+webrtc/modules/video_coding", + "+webrtc/pc", "+webrtc/system_wrappers", ] diff --git a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h index a7e453c917..ed1807783b 100644 --- a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h +++ b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory+Private.h @@ -10,7 +10,7 @@ #import "WebRTC/RTCPeerConnectionFactory.h" -#include "webrtc/api/peerconnectionfactory.h" +#include "webrtc/api/peerconnectioninterface.h" #include "webrtc/base/scoped_ref_ptr.h" NS_ASSUME_NONNULL_BEGIN diff --git a/webrtc/test/fuzzers/BUILD.gn b/webrtc/test/fuzzers/BUILD.gn index 224b212c11..1cb12d5a10 100644 --- a/webrtc/test/fuzzers/BUILD.gn +++ b/webrtc/test/fuzzers/BUILD.gn @@ -266,7 +266,7 @@ webrtc_fuzzer_test("sdp_parser_fuzzer") { "sdp_parser_fuzzer.cc", ] deps = [ - "../../api:libjingle_peerconnection", + "../../pc:libjingle_peerconnection", ] seed_corpus = "corpora/sdp-corpus" }