123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef PC_PEER_CONNECTION_WRAPPER_H_
- #define PC_PEER_CONNECTION_WRAPPER_H_
- #include <memory>
- #include <string>
- #include <vector>
- #include "api/data_channel_interface.h"
- #include "api/function_view.h"
- #include "api/jsep.h"
- #include "api/media_stream_interface.h"
- #include "api/media_types.h"
- #include "api/peer_connection_interface.h"
- #include "api/rtc_error.h"
- #include "api/rtp_sender_interface.h"
- #include "api/rtp_transceiver_interface.h"
- #include "api/scoped_refptr.h"
- #include "api/stats/rtc_stats_report.h"
- #include "pc/test/mock_peer_connection_observers.h"
- namespace webrtc {
- class PeerConnectionWrapper {
- public:
-
-
-
-
- PeerConnectionWrapper(
- rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
- rtc::scoped_refptr<PeerConnectionInterface> pc,
- std::unique_ptr<MockPeerConnectionObserver> observer);
- virtual ~PeerConnectionWrapper();
- PeerConnectionFactoryInterface* pc_factory();
- PeerConnectionInterface* pc();
- MockPeerConnectionObserver* observer();
-
-
-
- std::unique_ptr<SessionDescriptionInterface> CreateOffer(
- const PeerConnectionInterface::RTCOfferAnswerOptions& options,
- std::string* error_out = nullptr);
-
- std::unique_ptr<SessionDescriptionInterface> CreateOffer();
-
- std::unique_ptr<SessionDescriptionInterface> CreateOfferAndSetAsLocal(
- const PeerConnectionInterface::RTCOfferAnswerOptions& options);
-
- std::unique_ptr<SessionDescriptionInterface> CreateOfferAndSetAsLocal();
-
-
-
- std::unique_ptr<SessionDescriptionInterface> CreateAnswer(
- const PeerConnectionInterface::RTCOfferAnswerOptions& options,
- std::string* error_out = nullptr);
-
- std::unique_ptr<SessionDescriptionInterface> CreateAnswer();
-
- std::unique_ptr<SessionDescriptionInterface> CreateAnswerAndSetAsLocal(
- const PeerConnectionInterface::RTCOfferAnswerOptions& options);
-
- std::unique_ptr<SessionDescriptionInterface> CreateAnswerAndSetAsLocal();
- std::unique_ptr<SessionDescriptionInterface> CreateRollback();
-
-
-
- bool SetLocalDescription(std::unique_ptr<SessionDescriptionInterface> desc,
- std::string* error_out = nullptr);
-
-
-
- bool SetRemoteDescription(std::unique_ptr<SessionDescriptionInterface> desc,
- std::string* error_out = nullptr);
- bool SetRemoteDescription(std::unique_ptr<SessionDescriptionInterface> desc,
- RTCError* error_out);
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool ExchangeOfferAnswerWith(PeerConnectionWrapper* answerer);
- bool ExchangeOfferAnswerWith(
- PeerConnectionWrapper* answerer,
- const PeerConnectionInterface::RTCOfferAnswerOptions& offer_options,
- const PeerConnectionInterface::RTCOfferAnswerOptions& answer_options);
-
-
-
- rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
- cricket::MediaType media_type);
- rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
- cricket::MediaType media_type,
- const RtpTransceiverInit& init);
- rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
- rtc::scoped_refptr<MediaStreamTrackInterface> track);
- rtc::scoped_refptr<RtpTransceiverInterface> AddTransceiver(
- rtc::scoped_refptr<MediaStreamTrackInterface> track,
- const RtpTransceiverInit& init);
-
- rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
- const std::string& label);
-
- rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
- const std::string& label);
-
-
- rtc::scoped_refptr<RtpSenderInterface> AddTrack(
- rtc::scoped_refptr<MediaStreamTrackInterface> track,
- const std::vector<std::string>& stream_ids = {});
-
-
- rtc::scoped_refptr<RtpSenderInterface> AddAudioTrack(
- const std::string& track_label,
- const std::vector<std::string>& stream_ids = {});
-
-
- rtc::scoped_refptr<RtpSenderInterface> AddVideoTrack(
- const std::string& track_label,
- const std::vector<std::string>& stream_ids = {});
-
-
- rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
- const std::string& label);
-
- PeerConnectionInterface::SignalingState signaling_state();
-
- bool IsIceGatheringDone();
-
- bool IsIceConnected();
-
-
- rtc::scoped_refptr<const RTCStatsReport> GetStats();
- private:
- std::unique_ptr<SessionDescriptionInterface> CreateSdp(
- rtc::FunctionView<void(CreateSessionDescriptionObserver*)> fn,
- std::string* error_out);
- bool SetSdp(rtc::FunctionView<void(SetSessionDescriptionObserver*)> fn,
- std::string* error_out);
- rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
- std::unique_ptr<MockPeerConnectionObserver> observer_;
- rtc::scoped_refptr<PeerConnectionInterface> pc_;
- };
- }
- #endif
|