2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-12 00:05:01 -08:00
|
|
|
* Copyright 2004 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-12 00:05:01 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-03-07 17:34:13 -08:00
|
|
|
#ifndef WEBRTC_PC_CHANNEL_H_
|
|
|
|
|
#define WEBRTC_PC_CHANNEL_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
#include <map>
|
2016-03-11 14:18:21 -08:00
|
|
|
#include <memory>
|
2015-09-23 11:50:27 -07:00
|
|
|
#include <set>
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include <string>
|
2015-09-23 11:50:27 -07:00
|
|
|
#include <utility>
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-08-31 07:33:05 -07:00
|
|
|
#include "webrtc/api/call/audio_sink.h"
|
2016-05-11 19:55:27 +02:00
|
|
|
#include "webrtc/base/asyncinvoker.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/asyncudpsocket.h"
|
|
|
|
|
#include "webrtc/base/criticalsection.h"
|
|
|
|
|
#include "webrtc/base/network.h"
|
|
|
|
|
#include "webrtc/base/sigslot.h"
|
|
|
|
|
#include "webrtc/base/window.h"
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include "webrtc/media/base/mediachannel.h"
|
|
|
|
|
#include "webrtc/media/base/mediaengine.h"
|
|
|
|
|
#include "webrtc/media/base/streamparams.h"
|
2016-02-04 01:24:52 -08:00
|
|
|
#include "webrtc/media/base/videosinkinterface.h"
|
2016-04-08 02:23:55 -07:00
|
|
|
#include "webrtc/media/base/videosourceinterface.h"
|
2015-12-12 01:37:01 +01:00
|
|
|
#include "webrtc/p2p/base/transportcontroller.h"
|
|
|
|
|
#include "webrtc/p2p/client/socketmonitor.h"
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/audiomonitor.h"
|
|
|
|
|
#include "webrtc/pc/bundlefilter.h"
|
|
|
|
|
#include "webrtc/pc/mediamonitor.h"
|
|
|
|
|
#include "webrtc/pc/mediasession.h"
|
|
|
|
|
#include "webrtc/pc/rtcpmuxfilter.h"
|
|
|
|
|
#include "webrtc/pc/srtpfilter.h"
|
2015-12-12 01:37:01 +01:00
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
namespace rtc {
|
|
|
|
|
class PacketTransportInterface;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-12 01:37:01 +01:00
|
|
|
namespace webrtc {
|
|
|
|
|
class AudioSinkInterface;
|
|
|
|
|
} // namespace webrtc
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
struct CryptoParams;
|
|
|
|
|
class MediaContentDescription;
|
|
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
// BaseChannel contains logic common to voice and video, including enable,
|
|
|
|
|
// marshaling calls to a worker and network threads, and connection and media
|
|
|
|
|
// monitors.
|
|
|
|
|
//
|
2016-05-11 19:55:27 +02:00
|
|
|
// BaseChannel assumes signaling and other threads are allowed to make
|
|
|
|
|
// synchronous calls to the worker thread, the worker thread makes synchronous
|
|
|
|
|
// calls only to the network thread, and the network thread can't be blocked by
|
|
|
|
|
// other threads.
|
|
|
|
|
// All methods with _n suffix must be called on network thread,
|
2016-08-26 21:42:15 -07:00
|
|
|
// methods with _w suffix on worker thread
|
2016-05-11 19:55:27 +02:00
|
|
|
// and methods with _s suffix on signaling thread.
|
|
|
|
|
// Network and worker threads may be the same thread.
|
2013-10-07 23:32:02 +00:00
|
|
|
//
|
|
|
|
|
// WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS!
|
|
|
|
|
// This is required to avoid a data race between the destructor modifying the
|
|
|
|
|
// vtable, and the media channel's thread using BaseChannel as the
|
|
|
|
|
// NetworkInterface.
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
class BaseChannel
|
2014-07-29 17:36:52 +00:00
|
|
|
: public rtc::MessageHandler, public sigslot::has_slots<>,
|
2015-03-13 18:25:21 +00:00
|
|
|
public MediaChannel::NetworkInterface,
|
|
|
|
|
public ConnectionStatsGetter {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2016-08-22 16:00:30 -07:00
|
|
|
// |rtcp| represents whether or not this channel uses RTCP.
|
2016-12-13 11:29:11 -08:00
|
|
|
// If |srtp_required| is true, the channel will not send or receive any
|
|
|
|
|
// RTP/RTCP packets without using SRTP (either using SDES or DTLS-SRTP).
|
2016-05-11 19:55:27 +02:00
|
|
|
BaseChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
MediaChannel* channel,
|
|
|
|
|
const std::string& content_name,
|
2017-01-12 21:59:29 -08:00
|
|
|
bool rtcp_mux_required,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual ~BaseChannel();
|
2017-01-19 16:54:25 -08:00
|
|
|
bool Init_w(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2016-05-11 19:55:27 +02:00
|
|
|
// Deinit may be called multiple times and is simply ignored if it's already
|
2013-10-07 23:32:02 +00:00
|
|
|
// done.
|
|
|
|
|
void Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* worker_thread() const { return worker_thread_; }
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* network_thread() const { return network_thread_; }
|
2015-09-23 11:50:27 -07:00
|
|
|
const std::string& content_name() const { return content_name_; }
|
|
|
|
|
const std::string& transport_name() const { return transport_name_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
bool enabled() const { return enabled_; }
|
|
|
|
|
|
|
|
|
|
// This function returns true if we are using SRTP.
|
|
|
|
|
bool secure() const { return srtp_filter_.IsActive(); }
|
|
|
|
|
// The following function returns true if we are using
|
|
|
|
|
// DTLS-based keying. If you turned off SRTP later, however
|
|
|
|
|
// you could have secure() == false and dtls_secure() == true.
|
|
|
|
|
bool secure_dtls() const { return dtls_keyed_; }
|
|
|
|
|
|
|
|
|
|
bool writable() const { return writable_; }
|
|
|
|
|
|
2017-01-17 18:32:35 -08:00
|
|
|
// Set the transport(s), and update writability and "ready-to-send" state.
|
|
|
|
|
// |rtp_transport| must be non-null.
|
|
|
|
|
// |rtcp_transport| must be supplied if NeedsRtcpTransport() is true (meaning
|
|
|
|
|
// RTCP muxing is not fully active yet).
|
|
|
|
|
// |rtp_transport| and |rtcp_transport| must share the same transport name as
|
|
|
|
|
// well.
|
2017-01-19 16:54:25 -08:00
|
|
|
void SetTransports(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2015-03-16 21:15:37 +00:00
|
|
|
bool PushdownLocalDescription(const SessionDescription* local_desc,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
bool PushdownRemoteDescription(const SessionDescription* remote_desc,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Channel control
|
|
|
|
|
bool SetLocalContent(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool SetRemoteContent(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool Enable(bool enable);
|
|
|
|
|
|
|
|
|
|
// Multiplexing
|
|
|
|
|
bool AddRecvStream(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool RemoveRecvStream(uint32_t ssrc);
|
2013-08-30 21:24:16 +00:00
|
|
|
bool AddSendStream(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool RemoveSendStream(uint32_t ssrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Monitoring
|
|
|
|
|
void StartConnectionMonitor(int cms);
|
|
|
|
|
void StopConnectionMonitor();
|
2015-03-13 18:25:21 +00:00
|
|
|
// For ConnectionStatsGetter, used by ConnectionMonitor
|
2015-09-23 11:50:27 -07:00
|
|
|
bool GetConnectionStats(ConnectionInfos* infos) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-05-05 20:18:08 +00:00
|
|
|
BundleFilter* bundle_filter() { return &bundle_filter_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
const std::vector<StreamParams>& local_streams() const {
|
|
|
|
|
return local_streams_;
|
|
|
|
|
}
|
|
|
|
|
const std::vector<StreamParams>& remote_streams() const {
|
|
|
|
|
return remote_streams_;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure;
|
|
|
|
|
void SignalDtlsSrtpSetupFailure_n(bool rtcp);
|
|
|
|
|
void SignalDtlsSrtpSetupFailure_s(bool rtcp);
|
2015-03-16 19:34:23 +00:00
|
|
|
|
2014-05-15 16:15:59 +00:00
|
|
|
// Used for latency measurements.
|
2013-07-10 00:45:36 +00:00
|
|
|
sigslot::signal1<BaseChannel*> SignalFirstPacketReceived;
|
|
|
|
|
|
2017-01-19 16:54:25 -08:00
|
|
|
// Forward SignalSentPacket to worker thread.
|
2016-05-11 19:55:27 +02:00
|
|
|
sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
|
|
|
|
|
|
2017-01-12 21:59:29 -08:00
|
|
|
// Emitted whenever rtcp-mux is fully negotiated and the rtcp-transport can
|
|
|
|
|
// be destroyed.
|
|
|
|
|
// Fired on the network thread.
|
|
|
|
|
sigslot::signal1<const std::string&> SignalRtcpMuxFullyActive;
|
2017-01-12 19:37:48 -08:00
|
|
|
|
2017-01-19 16:54:25 -08:00
|
|
|
// Only public for unit tests. Otherwise, consider private.
|
|
|
|
|
DtlsTransportInternal* rtp_dtls_transport() const {
|
|
|
|
|
return rtp_dtls_transport_;
|
|
|
|
|
}
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport() const {
|
|
|
|
|
return rtcp_dtls_transport_;
|
|
|
|
|
}
|
2017-01-12 19:37:48 -08:00
|
|
|
|
|
|
|
|
bool NeedsRtcpTransport();
|
2016-05-11 19:55:27 +02:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Made public for easier testing.
|
2016-08-25 13:31:14 -07:00
|
|
|
//
|
|
|
|
|
// Updates "ready to send" for an individual channel, and informs the media
|
|
|
|
|
// channel that the transport is ready to send if each channel (in use) is
|
|
|
|
|
// ready to send. This is more specific than just "writable"; it means the
|
|
|
|
|
// last send didn't return ENOTCONN.
|
|
|
|
|
//
|
|
|
|
|
// This should be called whenever a channel's ready-to-send state changes,
|
|
|
|
|
// or when RTCP muxing becomes active/inactive.
|
|
|
|
|
void SetTransportChannelReadyToSend(bool rtcp, bool ready);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-03-12 20:09:44 +00:00
|
|
|
// Only public for unit tests. Otherwise, consider protected.
|
2015-10-27 14:22:16 -07:00
|
|
|
int SetOption(SocketType type, rtc::Socket::Option o, int val)
|
|
|
|
|
override;
|
2016-05-11 19:55:27 +02:00
|
|
|
int SetOption_n(SocketType type, rtc::Socket::Option o, int val);
|
2015-03-12 20:09:44 +00:00
|
|
|
|
2015-10-01 04:10:31 -07:00
|
|
|
SrtpFilter* srtp_filter() { return &srtp_filter_; }
|
|
|
|
|
|
2016-06-14 11:47:14 -07:00
|
|
|
virtual cricket::MediaType media_type() = 0;
|
|
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options);
|
|
|
|
|
|
2016-12-13 11:29:11 -08:00
|
|
|
// This function returns true if we require SRTP for call setup.
|
|
|
|
|
bool srtp_required_for_testing() const { return srtp_required_; }
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
|
|
|
|
virtual MediaChannel* media_channel() const { return media_channel_; }
|
2016-08-25 13:31:14 -07:00
|
|
|
|
2017-01-19 16:54:25 -08:00
|
|
|
void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2015-12-17 16:45:59 -08:00
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
// This does not update writability or "ready-to-send" state; it just
|
|
|
|
|
// disconnects from the old channel and connects to the new one.
|
2017-01-19 16:54:25 -08:00
|
|
|
void SetTransport_n(bool rtcp, DtlsTransportInternal* new_transport);
|
2015-12-17 16:45:59 -08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool was_ever_writable() const { return was_ever_writable_; }
|
|
|
|
|
void set_local_content_direction(MediaContentDirection direction) {
|
|
|
|
|
local_content_direction_ = direction;
|
|
|
|
|
}
|
|
|
|
|
void set_remote_content_direction(MediaContentDirection direction) {
|
|
|
|
|
remote_content_direction_ = direction;
|
|
|
|
|
}
|
2016-08-25 13:31:14 -07:00
|
|
|
// These methods verify that:
|
|
|
|
|
// * The required content description directions have been set.
|
|
|
|
|
// * The channel is enabled.
|
|
|
|
|
// * And for sending:
|
|
|
|
|
// - The SRTP filter is active if it's needed.
|
|
|
|
|
// - The transport has been writable before, meaning it should be at least
|
|
|
|
|
// possible to succeed in sending a packet.
|
|
|
|
|
//
|
|
|
|
|
// When any of these properties change, UpdateMediaSendRecvState_w should be
|
|
|
|
|
// called.
|
|
|
|
|
bool IsReadyToReceiveMedia_w() const;
|
|
|
|
|
bool IsReadyToSendMedia_w() const;
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread() { return signaling_thread_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-01-19 16:54:25 -08:00
|
|
|
void ConnectToTransport(DtlsTransportInternal* transport);
|
|
|
|
|
void DisconnectFromTransport(DtlsTransportInternal* transport);
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void FlushRtcpMessages_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// NetworkInterface implementation, called by MediaEngine
|
2016-03-20 06:15:43 -07:00
|
|
|
bool SendPacket(rtc::CopyOnWriteBuffer* packet,
|
|
|
|
|
const rtc::PacketOptions& options) override;
|
|
|
|
|
bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
|
|
|
|
|
const rtc::PacketOptions& options) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// From TransportChannel
|
2016-10-25 10:50:32 -07:00
|
|
|
void OnWritableState(rtc::PacketTransportInterface* transport);
|
|
|
|
|
virtual void OnPacketRead(rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const rtc::PacketTime& packet_time,
|
|
|
|
|
int flags);
|
|
|
|
|
void OnReadyToSend(rtc::PacketTransportInterface* transport);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-01-19 16:54:25 -08:00
|
|
|
void OnDtlsState(DtlsTransportInternal* transport, DtlsTransportState state);
|
2015-12-05 09:59:56 -08:00
|
|
|
|
2016-03-29 17:27:21 -07:00
|
|
|
void OnSelectedCandidatePairChanged(
|
2017-01-19 16:54:25 -08:00
|
|
|
IceTransportInternal* ice_transport,
|
2016-03-31 12:37:31 -07:00
|
|
|
CandidatePairInterface* selected_candidate_pair,
|
2016-06-27 18:09:03 -07:00
|
|
|
int last_sent_packet_id,
|
|
|
|
|
bool ready_to_send);
|
2016-03-29 17:27:21 -07:00
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
bool PacketIsRtcp(const rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
2013-07-10 00:45:36 +00:00
|
|
|
size_t len);
|
2015-10-15 07:26:07 -07:00
|
|
|
bool SendPacket(bool rtcp,
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer* packet,
|
2015-10-15 07:26:07 -07:00
|
|
|
const rtc::PacketOptions& options);
|
2016-05-11 19:55:27 +02:00
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet);
|
2016-03-20 06:15:43 -07:00
|
|
|
void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time);
|
2016-05-11 19:55:27 +02:00
|
|
|
void OnPacketReceived(bool rtcp,
|
|
|
|
|
const rtc::CopyOnWriteBuffer& packet,
|
|
|
|
|
const rtc::PacketTime& packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
void EnableMedia_w();
|
|
|
|
|
void DisableMedia_w();
|
2016-08-25 13:31:14 -07:00
|
|
|
|
|
|
|
|
// Performs actions if the RTP/RTCP writable state changed. This should
|
|
|
|
|
// be called whenever a channel's writable state changes or when RTCP muxing
|
|
|
|
|
// becomes active/inactive.
|
2016-05-11 19:55:27 +02:00
|
|
|
void UpdateWritableState_n();
|
|
|
|
|
void ChannelWritable_n();
|
|
|
|
|
void ChannelNotWritable_n();
|
2016-08-25 13:31:14 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool AddRecvStream_w(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool RemoveRecvStream_w(uint32_t ssrc);
|
2013-08-30 21:24:16 +00:00
|
|
|
bool AddSendStream_w(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool RemoveSendStream_w(uint32_t ssrc);
|
2017-01-09 14:53:41 -08:00
|
|
|
bool ShouldSetupDtlsSrtp_n() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
// Do the DTLS key expansion and impose it on the SRTP/SRTCP filters.
|
|
|
|
|
// |rtcp_channel| indicates whether to set up the RTP or RTCP filter.
|
2017-01-19 16:54:25 -08:00
|
|
|
bool SetupDtlsSrtp_n(bool rtcp);
|
2016-05-11 19:55:27 +02:00
|
|
|
void MaybeSetupDtlsSrtp_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
// Set the DTLS-SRTP cipher policy on this channel as appropriate.
|
2017-01-19 16:54:25 -08:00
|
|
|
bool SetDtlsSrtpCryptoSuites_n(DtlsTransportInternal* transport, bool rtcp);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
// Should be called whenever the conditions for
|
|
|
|
|
// IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied).
|
|
|
|
|
// Updates the send/recv state of the media channel.
|
|
|
|
|
void UpdateMediaSendRecvState();
|
|
|
|
|
virtual void UpdateMediaSendRecvState_w() = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Gets the content info appropriate to the channel (audio or video).
|
|
|
|
|
virtual const ContentInfo* GetFirstContent(
|
|
|
|
|
const SessionDescription* sdesc) = 0;
|
|
|
|
|
bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual bool SetLocalContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual bool SetRemoteContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) = 0;
|
2016-05-11 19:55:27 +02:00
|
|
|
bool SetRtpTransportParameters(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
bool SetRtpTransportParameters_n(const MediaContentDescription* content,
|
2015-08-07 16:05:34 -07:00
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc);
|
2014-01-15 23:15:54 +00:00
|
|
|
|
2014-02-21 23:43:24 +00:00
|
|
|
// Helper method to get RTP Absoulute SendTime extension header id if
|
|
|
|
|
// present in remote supported extensions list.
|
2016-05-11 19:55:27 +02:00
|
|
|
void MaybeCacheRtpAbsSendTimeHeaderExtension_w(
|
2016-05-26 11:24:55 -07:00
|
|
|
const std::vector<webrtc::RtpExtension>& extensions);
|
2014-02-21 23:43:24 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos,
|
|
|
|
|
bool* dtls,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
bool SetSrtp_n(const std::vector<CryptoParams>& params,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc);
|
2016-05-11 19:55:27 +02:00
|
|
|
bool SetRtcpMux_n(bool enable,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// From MessageHandler
|
2015-10-27 14:22:16 -07:00
|
|
|
void OnMessage(rtc::Message* pmsg) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
const rtc::CryptoOptions& crypto_options() const {
|
|
|
|
|
return crypto_options_;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Handled in derived classes
|
2015-11-18 19:41:53 -08:00
|
|
|
// Get the SRTP crypto suites to use for RTP media
|
2016-05-11 19:55:27 +02:00
|
|
|
virtual void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const = 0;
|
2015-03-13 18:25:21 +00:00
|
|
|
virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor,
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::vector<ConnectionInfo>& infos) = 0;
|
|
|
|
|
|
2014-02-07 19:03:26 +00:00
|
|
|
// Helper function for invoking bool-returning methods on the worker thread.
|
|
|
|
|
template <class FunctorT>
|
2016-06-10 14:17:27 -07:00
|
|
|
bool InvokeOnWorker(const rtc::Location& posted_from,
|
|
|
|
|
const FunctorT& functor) {
|
|
|
|
|
return worker_thread_->Invoke<bool>(posted_from, functor);
|
2014-02-07 19:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
2017-01-19 16:54:25 -08:00
|
|
|
bool InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2016-05-14 01:43:50 +02:00
|
|
|
void DisconnectTransportChannels_n();
|
2016-10-25 10:50:32 -07:00
|
|
|
void SignalSentPacket_n(rtc::PacketTransportInterface* transport,
|
2016-05-11 19:55:27 +02:00
|
|
|
const rtc::SentPacket& sent_packet);
|
|
|
|
|
void SignalSentPacket_w(const rtc::SentPacket& sent_packet);
|
2016-08-25 13:31:14 -07:00
|
|
|
bool IsReadyToSendMedia_n() const;
|
2016-05-11 19:55:27 +02:00
|
|
|
void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id);
|
2016-11-08 02:50:09 -08:00
|
|
|
int GetTransportOverheadPerPacket() const;
|
|
|
|
|
void UpdateTransportOverhead();
|
2016-05-11 19:55:27 +02:00
|
|
|
|
|
|
|
|
rtc::Thread* const worker_thread_;
|
|
|
|
|
rtc::Thread* const network_thread_;
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* const signaling_thread_;
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::AsyncInvoker invoker_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-03-13 18:20:33 +00:00
|
|
|
const std::string content_name_;
|
2016-05-11 19:55:27 +02:00
|
|
|
std::unique_ptr<ConnectionMonitor> connection_monitor_;
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
std::string transport_name_;
|
2017-01-12 21:59:29 -08:00
|
|
|
// True if RTCP-multiplexing is required. In other words, no standalone RTCP
|
|
|
|
|
// transport will ever be used for this channel.
|
|
|
|
|
const bool rtcp_mux_required_;
|
2017-01-19 16:54:25 -08:00
|
|
|
|
|
|
|
|
DtlsTransportInternal* rtp_dtls_transport_ = nullptr;
|
2015-09-23 11:50:27 -07:00
|
|
|
std::vector<std::pair<rtc::Socket::Option, int> > socket_options_;
|
2017-01-19 16:54:25 -08:00
|
|
|
DtlsTransportInternal* rtcp_dtls_transport_ = nullptr;
|
2015-09-23 11:50:27 -07:00
|
|
|
std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
|
2013-07-10 00:45:36 +00:00
|
|
|
SrtpFilter srtp_filter_;
|
|
|
|
|
RtcpMuxFilter rtcp_mux_filter_;
|
2014-05-05 20:18:08 +00:00
|
|
|
BundleFilter bundle_filter_;
|
2016-08-22 16:00:30 -07:00
|
|
|
bool rtp_ready_to_send_ = false;
|
|
|
|
|
bool rtcp_ready_to_send_ = false;
|
|
|
|
|
bool writable_ = false;
|
|
|
|
|
bool was_ever_writable_ = false;
|
|
|
|
|
bool has_received_packet_ = false;
|
|
|
|
|
bool dtls_keyed_ = false;
|
2016-12-13 11:29:11 -08:00
|
|
|
const bool srtp_required_ = true;
|
2016-08-04 05:20:32 -07:00
|
|
|
rtc::CryptoOptions crypto_options_;
|
2016-08-22 16:00:30 -07:00
|
|
|
int rtp_abs_sendtime_extn_id_ = -1;
|
2016-05-11 19:55:27 +02:00
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
// MediaChannel related members that should be accessed from the worker
|
|
|
|
|
// thread.
|
2016-05-11 19:55:27 +02:00
|
|
|
MediaChannel* const media_channel_;
|
2016-08-25 13:31:14 -07:00
|
|
|
// Currently the |enabled_| flag is accessed from the signaling thread as
|
|
|
|
|
// well, but it can be changed only when signaling thread does a synchronous
|
|
|
|
|
// call to the worker thread, so it should be safe.
|
2016-08-22 16:00:30 -07:00
|
|
|
bool enabled_ = false;
|
2016-05-11 19:55:27 +02:00
|
|
|
std::vector<StreamParams> local_streams_;
|
|
|
|
|
std::vector<StreamParams> remote_streams_;
|
2016-08-22 16:00:30 -07:00
|
|
|
MediaContentDirection local_content_direction_ = MD_INACTIVE;
|
|
|
|
|
MediaContentDirection remote_content_direction_ = MD_INACTIVE;
|
2016-11-08 02:50:09 -08:00
|
|
|
CandidatePairInterface* selected_candidate_pair_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// VoiceChannel is a specialization that adds support for early media, DTMF,
|
|
|
|
|
// and input/output level monitoring.
|
|
|
|
|
class VoiceChannel : public BaseChannel {
|
|
|
|
|
public:
|
2016-05-11 19:55:27 +02:00
|
|
|
VoiceChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
MediaEngineInterface* media_engine,
|
|
|
|
|
VoiceMediaChannel* channel,
|
|
|
|
|
const std::string& content_name,
|
2017-01-12 21:59:29 -08:00
|
|
|
bool rtcp_mux_required,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required);
|
2013-07-10 00:45:36 +00:00
|
|
|
~VoiceChannel();
|
2017-01-19 16:54:25 -08:00
|
|
|
bool Init_w(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2015-09-10 01:57:14 -07:00
|
|
|
|
|
|
|
|
// Configure sending media on the stream with SSRC |ssrc|
|
|
|
|
|
// If there is only one sending stream SSRC 0 can be used.
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool SetAudioSend(uint32_t ssrc,
|
2015-10-01 02:31:10 -07:00
|
|
|
bool enable,
|
2015-09-23 11:50:27 -07:00
|
|
|
const AudioOptions* options,
|
2016-03-08 12:37:39 -08:00
|
|
|
AudioSource* source);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// downcasts a MediaChannel
|
2016-05-11 19:55:27 +02:00
|
|
|
VoiceMediaChannel* media_channel() const override {
|
2013-07-10 00:45:36 +00:00
|
|
|
return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetEarlyMedia(bool enable);
|
|
|
|
|
// This signal is emitted when we have gone a period of time without
|
|
|
|
|
// receiving early media. When received, a UI should start playing its
|
|
|
|
|
// own ringing sound
|
|
|
|
|
sigslot::signal1<VoiceChannel*> SignalEarlyMediaTimeout;
|
|
|
|
|
|
|
|
|
|
// Returns if the telephone-event has been negotiated.
|
|
|
|
|
bool CanInsertDtmf();
|
|
|
|
|
// Send and/or play a DTMF |event| according to the |flags|.
|
|
|
|
|
// The DTMF out-of-band signal will be used on sending.
|
|
|
|
|
// The |ssrc| should be either 0 or a valid send stream ssrc.
|
2013-07-17 14:42:53 +00:00
|
|
|
// The valid value for the |event| are 0 which corresponding to DTMF
|
|
|
|
|
// event 0-9, *, #, A-D.
|
2015-12-02 12:35:09 -08:00
|
|
|
bool InsertDtmf(uint32_t ssrc, int event_code, int duration);
|
2015-10-09 02:32:53 -07:00
|
|
|
bool SetOutputVolume(uint32_t ssrc, double volume);
|
2016-01-13 12:00:26 -08:00
|
|
|
void SetRawAudioSink(uint32_t ssrc,
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<webrtc::AudioSinkInterface> sink);
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpSendParameters(uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters);
|
|
|
|
|
webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpReceiveParameters(uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters);
|
2015-12-12 01:37:01 +01:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Get statistics about the current media session.
|
|
|
|
|
bool GetStats(VoiceMediaInfo* stats);
|
|
|
|
|
|
|
|
|
|
// Monitoring functions
|
|
|
|
|
sigslot::signal2<VoiceChannel*, const std::vector<ConnectionInfo>&>
|
|
|
|
|
SignalConnectionMonitor;
|
|
|
|
|
|
|
|
|
|
void StartMediaMonitor(int cms);
|
|
|
|
|
void StopMediaMonitor();
|
|
|
|
|
sigslot::signal2<VoiceChannel*, const VoiceMediaInfo&> SignalMediaMonitor;
|
|
|
|
|
|
|
|
|
|
void StartAudioMonitor(int cms);
|
|
|
|
|
void StopAudioMonitor();
|
|
|
|
|
bool IsAudioMonitorRunning() const;
|
|
|
|
|
sigslot::signal2<VoiceChannel*, const AudioInfo&> SignalAudioMonitor;
|
|
|
|
|
|
|
|
|
|
int GetInputLevel_w();
|
|
|
|
|
int GetOutputLevel_w();
|
|
|
|
|
void GetActiveStreams_w(AudioInfo::StreamList* actives);
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
|
|
|
|
|
webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpReceiveParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters);
|
2016-06-14 11:47:14 -07:00
|
|
|
cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// overrides from BaseChannel
|
2016-10-25 10:50:32 -07:00
|
|
|
void OnPacketRead(rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const rtc::PacketTime& packet_time,
|
|
|
|
|
int flags) override;
|
2016-08-25 13:31:14 -07:00
|
|
|
void UpdateMediaSendRecvState_w() override;
|
2016-05-11 19:55:27 +02:00
|
|
|
const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
|
|
|
|
|
bool SetLocalContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
|
|
|
|
bool SetRemoteContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
void HandleEarlyMediaTimeout();
|
2015-12-02 12:35:09 -08:00
|
|
|
bool InsertDtmf_w(uint32_t ssrc, int event, int duration);
|
2015-10-09 02:32:53 -07:00
|
|
|
bool SetOutputVolume_w(uint32_t ssrc, double volume);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool GetStats_w(VoiceMediaInfo* stats);
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void OnMessage(rtc::Message* pmsg) override;
|
|
|
|
|
void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override;
|
|
|
|
|
void OnConnectionMonitorUpdate(
|
|
|
|
|
ConnectionMonitor* monitor,
|
|
|
|
|
const std::vector<ConnectionInfo>& infos) override;
|
|
|
|
|
void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel,
|
|
|
|
|
const VoiceMediaInfo& info);
|
2013-07-10 00:45:36 +00:00
|
|
|
void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info);
|
|
|
|
|
|
|
|
|
|
static const int kEarlyMediaTimeout = 1000;
|
2015-08-05 12:25:22 +02:00
|
|
|
MediaEngineInterface* media_engine_;
|
2013-07-10 00:45:36 +00:00
|
|
|
bool received_media_;
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<VoiceMediaMonitor> media_monitor_;
|
|
|
|
|
std::unique_ptr<AudioMonitor> audio_monitor_;
|
2015-08-07 16:05:34 -07:00
|
|
|
|
|
|
|
|
// Last AudioSendParameters sent down to the media_channel() via
|
|
|
|
|
// SetSendParameters.
|
|
|
|
|
AudioSendParameters last_send_params_;
|
|
|
|
|
// Last AudioRecvParameters sent down to the media_channel() via
|
|
|
|
|
// SetRecvParameters.
|
|
|
|
|
AudioRecvParameters last_recv_params_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// VideoChannel is a specialization for video.
|
|
|
|
|
class VideoChannel : public BaseChannel {
|
|
|
|
|
public:
|
2016-05-11 19:55:27 +02:00
|
|
|
VideoChannel(rtc::Thread* worker_thread,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* network_thread,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
VideoMediaChannel* channel,
|
|
|
|
|
const std::string& content_name,
|
2017-01-12 21:59:29 -08:00
|
|
|
bool rtcp_mux_required,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required);
|
2013-07-10 00:45:36 +00:00
|
|
|
~VideoChannel();
|
2017-01-19 16:54:25 -08:00
|
|
|
bool Init_w(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-05-07 14:07:48 +02:00
|
|
|
// downcasts a MediaChannel
|
2016-05-11 19:55:27 +02:00
|
|
|
VideoMediaChannel* media_channel() const override {
|
2015-05-07 14:07:48 +02:00
|
|
|
return static_cast<VideoMediaChannel*>(BaseChannel::media_channel());
|
|
|
|
|
}
|
|
|
|
|
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
bool SetSink(uint32_t ssrc,
|
|
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Get statistics about the current media session.
|
2015-03-04 08:54:32 +00:00
|
|
|
bool GetStats(VideoMediaInfo* stats);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
sigslot::signal2<VideoChannel*, const std::vector<ConnectionInfo>&>
|
|
|
|
|
SignalConnectionMonitor;
|
|
|
|
|
|
|
|
|
|
void StartMediaMonitor(int cms);
|
|
|
|
|
void StopMediaMonitor();
|
|
|
|
|
sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor;
|
|
|
|
|
|
2016-06-02 16:23:38 -07:00
|
|
|
// Register a source and set options.
|
|
|
|
|
// The |ssrc| must correspond to a registered send stream.
|
|
|
|
|
bool SetVideoSend(uint32_t ssrc,
|
|
|
|
|
bool enable,
|
|
|
|
|
const VideoOptions* options,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSourceInterface<webrtc::VideoFrame>* source);
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpSendParameters(uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters);
|
|
|
|
|
webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpReceiveParameters(uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters);
|
2016-06-14 11:47:14 -07:00
|
|
|
cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// overrides from BaseChannel
|
2016-08-25 13:31:14 -07:00
|
|
|
void UpdateMediaSendRecvState_w() override;
|
2016-05-11 19:55:27 +02:00
|
|
|
const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
|
|
|
|
|
bool SetLocalContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
|
|
|
|
bool SetRemoteContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
bool GetStats_w(VideoMediaInfo* stats);
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
|
|
|
|
|
webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const;
|
|
|
|
|
bool SetRtpReceiveParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void OnMessage(rtc::Message* pmsg) override;
|
|
|
|
|
void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override;
|
|
|
|
|
void OnConnectionMonitorUpdate(
|
|
|
|
|
ConnectionMonitor* monitor,
|
|
|
|
|
const std::vector<ConnectionInfo>& infos) override;
|
|
|
|
|
void OnMediaMonitorUpdate(VideoMediaChannel* media_channel,
|
|
|
|
|
const VideoMediaInfo& info);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<VideoMediaMonitor> media_monitor_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// Last VideoSendParameters sent down to the media_channel() via
|
|
|
|
|
// SetSendParameters.
|
|
|
|
|
VideoSendParameters last_send_params_;
|
|
|
|
|
// Last VideoRecvParameters sent down to the media_channel() via
|
|
|
|
|
// SetRecvParameters.
|
|
|
|
|
VideoRecvParameters last_recv_params_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
// RtpDataChannel is a specialization for data.
|
|
|
|
|
class RtpDataChannel : public BaseChannel {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2017-01-09 14:53:41 -08:00
|
|
|
RtpDataChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
DataMediaChannel* channel,
|
2017-01-09 14:53:41 -08:00
|
|
|
const std::string& content_name,
|
2017-01-12 21:59:29 -08:00
|
|
|
bool rtcp_mux_required,
|
2017-01-09 14:53:41 -08:00
|
|
|
bool srtp_required);
|
|
|
|
|
~RtpDataChannel();
|
2017-01-19 16:54:25 -08:00
|
|
|
bool Init_w(DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-08-01 00:00:07 +00:00
|
|
|
virtual bool SendData(const SendDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer& payload,
|
2013-08-01 00:00:07 +00:00
|
|
|
SendDataResult* result);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
void StartMediaMonitor(int cms);
|
|
|
|
|
void StopMediaMonitor();
|
|
|
|
|
|
2013-11-04 18:41:34 +00:00
|
|
|
// Should be called on the signaling thread only.
|
|
|
|
|
bool ready_to_send_data() const {
|
|
|
|
|
return ready_to_send_data_;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
sigslot::signal2<RtpDataChannel*, const DataMediaInfo&> SignalMediaMonitor;
|
|
|
|
|
sigslot::signal2<RtpDataChannel*, const std::vector<ConnectionInfo>&>
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalConnectionMonitor;
|
2017-01-09 14:53:41 -08:00
|
|
|
|
|
|
|
|
sigslot::signal2<const ReceiveDataParams&, const rtc::CopyOnWriteBuffer&>
|
|
|
|
|
SignalDataReceived;
|
2013-07-10 00:45:36 +00:00
|
|
|
// Signal for notifying when the channel becomes ready to send data.
|
2013-08-01 00:00:07 +00:00
|
|
|
// That occurs when the channel is enabled, the transport is writable,
|
|
|
|
|
// both local and remote descriptions are set, and the channel is unblocked.
|
2013-07-10 00:45:36 +00:00
|
|
|
sigslot::signal1<bool> SignalReadyToSendData;
|
2016-06-14 11:47:14 -07:00
|
|
|
cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_DATA; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-08-30 21:24:16 +00:00
|
|
|
protected:
|
|
|
|
|
// downcasts a MediaChannel.
|
2016-05-11 19:55:27 +02:00
|
|
|
DataMediaChannel* media_channel() const override {
|
2013-08-30 21:24:16 +00:00
|
|
|
return static_cast<DataMediaChannel*>(BaseChannel::media_channel());
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
2014-07-29 17:36:52 +00:00
|
|
|
struct SendDataMessageData : public rtc::MessageData {
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataMessageData(const SendDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer* payload,
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataResult* result)
|
|
|
|
|
: params(params),
|
|
|
|
|
payload(payload),
|
|
|
|
|
result(result),
|
|
|
|
|
succeeded(false) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SendDataParams& params;
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer* payload;
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataResult* result;
|
|
|
|
|
bool succeeded;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
struct DataReceivedMessageData : public rtc::MessageData {
|
2013-07-10 00:45:36 +00:00
|
|
|
// We copy the data because the data will become invalid after we
|
|
|
|
|
// handle DataMediaChannel::SignalDataReceived but before we fire
|
|
|
|
|
// SignalDataReceived.
|
|
|
|
|
DataReceivedMessageData(
|
|
|
|
|
const ReceiveDataParams& params, const char* data, size_t len)
|
|
|
|
|
: params(params),
|
|
|
|
|
payload(data, len) {
|
|
|
|
|
}
|
|
|
|
|
const ReceiveDataParams params;
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer payload;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData;
|
2013-08-01 00:00:07 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// overrides from BaseChannel
|
2016-05-11 19:55:27 +02:00
|
|
|
const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
|
2017-01-09 14:53:41 -08:00
|
|
|
// Checks that data channel type is RTP.
|
|
|
|
|
bool CheckDataChannelTypeFromContent(const DataContentDescription* content,
|
|
|
|
|
std::string* error_desc);
|
2016-05-11 19:55:27 +02:00
|
|
|
bool SetLocalContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
|
|
|
|
bool SetRemoteContent_w(const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) override;
|
2016-08-25 13:31:14 -07:00
|
|
|
void UpdateMediaSendRecvState_w() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void OnMessage(rtc::Message* pmsg) override;
|
|
|
|
|
void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override;
|
|
|
|
|
void OnConnectionMonitorUpdate(
|
|
|
|
|
ConnectionMonitor* monitor,
|
|
|
|
|
const std::vector<ConnectionInfo>& infos) override;
|
|
|
|
|
void OnMediaMonitorUpdate(DataMediaChannel* media_channel,
|
|
|
|
|
const DataMediaInfo& info);
|
2013-07-10 00:45:36 +00:00
|
|
|
void OnDataReceived(
|
|
|
|
|
const ReceiveDataParams& params, const char* data, size_t len);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error);
|
2013-08-01 00:00:07 +00:00
|
|
|
void OnDataChannelReadyToSend(bool writable);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<DataMediaMonitor> media_monitor_;
|
2017-01-09 14:53:41 -08:00
|
|
|
bool ready_to_send_data_ = false;
|
2015-08-07 16:05:34 -07:00
|
|
|
|
|
|
|
|
// Last DataSendParameters sent down to the media_channel() via
|
|
|
|
|
// SetSendParameters.
|
|
|
|
|
DataSendParameters last_send_params_;
|
|
|
|
|
// Last DataRecvParameters sent down to the media_channel() via
|
|
|
|
|
// SetRecvParameters.
|
|
|
|
|
DataRecvParameters last_recv_params_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
2016-03-07 17:34:13 -08:00
|
|
|
#endif // WEBRTC_PC_CHANNEL_H_
|