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-02-29 12:07:35 +01:00
|
|
|
#ifndef WEBRTC_PC_CHANNELMANAGER_H_
|
|
|
|
|
#define WEBRTC_PC_CHANNELMANAGER_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-11 14:18:21 -08:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
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/mediaengine.h"
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/voicechannel.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/fileutils.h"
|
|
|
|
|
#include "webrtc/rtc_base/thread.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
class VoiceChannel;
|
|
|
|
|
|
|
|
|
|
// ChannelManager allows the MediaEngine to run on a separate thread, and takes
|
|
|
|
|
// care of marshalling calls between threads. It also creates and keeps track of
|
|
|
|
|
// voice and video channels; by doing so, it can temporarily pause all the
|
|
|
|
|
// channels when a new audio or video device is chosen. The voice and video
|
|
|
|
|
// channels are stored in separate vectors, to easily allow operations on just
|
|
|
|
|
// voice or just video channels.
|
|
|
|
|
// ChannelManager also allows the application to discover what devices it has
|
|
|
|
|
// using device manager.
|
2016-03-07 17:34:13 -08:00
|
|
|
class ChannelManager {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
// For testing purposes. Allows the media engine and data media
|
2017-02-10 20:13:37 -08:00
|
|
|
// engine and dev manager to be mocks.
|
|
|
|
|
ChannelManager(std::unique_ptr<MediaEngineInterface> me,
|
|
|
|
|
std::unique_ptr<DataEngineInterface> dme,
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* worker_and_network);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Same as above, but gives an easier default DataEngine.
|
2017-02-10 20:13:37 -08:00
|
|
|
ChannelManager(std::unique_ptr<MediaEngineInterface> me,
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* worker,
|
|
|
|
|
rtc::Thread* network);
|
2013-07-10 00:45:36 +00:00
|
|
|
~ChannelManager();
|
|
|
|
|
|
|
|
|
|
// Accessors for the worker thread, allowing it to be set after construction,
|
|
|
|
|
// but before Init. set_worker_thread will return false if called after Init.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* worker_thread() const { return worker_thread_; }
|
|
|
|
|
bool set_worker_thread(rtc::Thread* thread) {
|
2016-05-11 19:55:27 +02:00
|
|
|
if (initialized_) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
worker_thread_ = thread;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* network_thread() const { return network_thread_; }
|
|
|
|
|
bool set_network_thread(rtc::Thread* thread) {
|
|
|
|
|
if (initialized_) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
network_thread_ = thread;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-15 12:26:33 +02:00
|
|
|
MediaEngineInterface* media_engine() { return media_engine_.get(); }
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Retrieves the list of supported audio & video codec types.
|
|
|
|
|
// Can be called before starting the media engine.
|
2016-06-14 07:12:39 -07:00
|
|
|
void GetSupportedAudioSendCodecs(std::vector<AudioCodec>* codecs) const;
|
|
|
|
|
void GetSupportedAudioReceiveCodecs(std::vector<AudioCodec>* codecs) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
void GetSupportedAudioRtpHeaderExtensions(RtpHeaderExtensions* ext) const;
|
2016-11-10 03:36:53 -08:00
|
|
|
void GetSupportedVideoCodecs(std::vector<VideoCodec>* codecs) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
void GetSupportedVideoRtpHeaderExtensions(RtpHeaderExtensions* ext) const;
|
|
|
|
|
void GetSupportedDataCodecs(std::vector<DataCodec>* codecs) const;
|
|
|
|
|
|
|
|
|
|
// Indicates whether the media engine is started.
|
|
|
|
|
bool initialized() const { return initialized_; }
|
|
|
|
|
// Starts up the media engine.
|
|
|
|
|
bool Init();
|
|
|
|
|
// Shuts down the media engine.
|
|
|
|
|
void Terminate();
|
|
|
|
|
|
|
|
|
|
// The operations below all occur on the worker thread.
|
|
|
|
|
// Creates a voice channel, to be associated with the specified session.
|
2015-09-15 12:26:33 +02:00
|
|
|
VoiceChannel* CreateVoiceChannel(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-01-19 16:54:25 -08:00
|
|
|
DtlsTransportInternal* rtp_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-15 12:26:33 +02:00
|
|
|
const std::string& content_name,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required,
|
2015-09-15 12:26:33 +02:00
|
|
|
const AudioOptions& options);
|
2017-02-25 18:15:09 -08:00
|
|
|
// Version of the above that takes PacketTransportInternal.
|
|
|
|
|
VoiceChannel* CreateVoiceChannel(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-02-25 18:15:09 -08:00
|
|
|
rtc::PacketTransportInternal* rtp_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtcp_transport,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool srtp_required,
|
|
|
|
|
const AudioOptions& options);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Destroys a voice channel created with the Create API.
|
2015-09-15 12:26:33 +02:00
|
|
|
void DestroyVoiceChannel(VoiceChannel* voice_channel);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Creates a video channel, synced with the specified voice channel, and
|
|
|
|
|
// associated with the specified session.
|
2015-09-15 12:26:33 +02:00
|
|
|
VideoChannel* CreateVideoChannel(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-01-19 16:54:25 -08:00
|
|
|
DtlsTransportInternal* rtp_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-15 12:26:33 +02:00
|
|
|
const std::string& content_name,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required,
|
2015-09-15 12:26:33 +02:00
|
|
|
const VideoOptions& options);
|
2017-02-25 18:15:09 -08:00
|
|
|
// Version of the above that takes PacketTransportInternal.
|
|
|
|
|
VideoChannel* CreateVideoChannel(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-02-25 18:15:09 -08:00
|
|
|
rtc::PacketTransportInternal* rtp_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtcp_transport,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool srtp_required,
|
|
|
|
|
const VideoOptions& options);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Destroys a video channel created with the Create API.
|
|
|
|
|
void DestroyVideoChannel(VideoChannel* video_channel);
|
2017-01-09 14:53:41 -08:00
|
|
|
RtpDataChannel* CreateRtpDataChannel(
|
2017-05-05 02:23:02 -07:00
|
|
|
const cricket::MediaConfig& media_config,
|
2017-01-19 16:54:25 -08:00
|
|
|
DtlsTransportInternal* rtp_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2016-12-06 10:45:42 -08:00
|
|
|
const std::string& content_name,
|
2017-01-09 14:53:41 -08:00
|
|
|
bool srtp_required);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Destroys a data channel created with the Create API.
|
2017-01-09 14:53:41 -08:00
|
|
|
void DestroyRtpDataChannel(RtpDataChannel* data_channel);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Indicates whether any channels exist.
|
|
|
|
|
bool has_channels() const {
|
2015-05-19 11:37:56 +02:00
|
|
|
return (!voice_channels_.empty() || !video_channels_.empty());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RTX will be enabled/disabled in engines that support it. The supporting
|
|
|
|
|
// engines will start offering an RTX codec. Must be called before Init().
|
|
|
|
|
bool SetVideoRtxEnabled(bool enable);
|
|
|
|
|
|
|
|
|
|
// Starts/stops the local microphone and enables polling of the input level.
|
|
|
|
|
bool capturing() const { return capturing_; }
|
|
|
|
|
|
|
|
|
|
// The operations below occur on the main thread.
|
|
|
|
|
|
2016-01-15 03:06:36 -08:00
|
|
|
// Starts AEC dump using existing file, with a specified maximum file size in
|
|
|
|
|
// bytes. When the limit is reached, logging will stop and the file will be
|
|
|
|
|
// closed. If max_size_bytes is set to <= 0, no limit will be used.
|
|
|
|
|
bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes);
|
2013-12-13 00:21:03 +00:00
|
|
|
|
2015-10-22 03:25:41 -07:00
|
|
|
// Stops recording AEC dump.
|
|
|
|
|
void StopAecDump();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
|
|
|
|
typedef std::vector<VoiceChannel*> VoiceChannels;
|
|
|
|
|
typedef std::vector<VideoChannel*> VideoChannels;
|
2017-01-09 14:53:41 -08:00
|
|
|
typedef std::vector<RtpDataChannel*> RtpDataChannels;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-02-10 20:13:37 -08:00
|
|
|
void Construct(std::unique_ptr<MediaEngineInterface> me,
|
|
|
|
|
std::unique_ptr<DataEngineInterface> dme,
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread);
|
2015-02-11 08:38:35 +00:00
|
|
|
bool InitMediaEngine_w();
|
2015-02-25 10:09:05 +00:00
|
|
|
void DestructorDeletes_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
void Terminate_w();
|
2015-09-15 12:26:33 +02:00
|
|
|
VoiceChannel* CreateVoiceChannel_w(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-02-25 18:15:09 -08:00
|
|
|
DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtp_packet_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtcp_packet_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-15 12:26:33 +02:00
|
|
|
const std::string& content_name,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required,
|
2015-09-15 12:26:33 +02:00
|
|
|
const AudioOptions& options);
|
|
|
|
|
void DestroyVoiceChannel_w(VoiceChannel* voice_channel);
|
|
|
|
|
VideoChannel* CreateVideoChannel_w(
|
2017-05-05 02:23:02 -07:00
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
2017-02-25 18:15:09 -08:00
|
|
|
DtlsTransportInternal* rtp_dtls_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_dtls_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtp_packet_transport,
|
|
|
|
|
rtc::PacketTransportInternal* rtcp_packet_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2015-09-15 12:26:33 +02:00
|
|
|
const std::string& content_name,
|
2016-12-13 11:29:11 -08:00
|
|
|
bool srtp_required,
|
2015-09-15 12:26:33 +02:00
|
|
|
const VideoOptions& options);
|
2013-07-10 00:45:36 +00:00
|
|
|
void DestroyVideoChannel_w(VideoChannel* video_channel);
|
2017-01-09 14:53:41 -08:00
|
|
|
RtpDataChannel* CreateRtpDataChannel_w(
|
2017-05-05 02:23:02 -07:00
|
|
|
const cricket::MediaConfig& media_config,
|
2017-01-19 16:54:25 -08:00
|
|
|
DtlsTransportInternal* rtp_transport,
|
|
|
|
|
DtlsTransportInternal* rtcp_transport,
|
2017-01-12 19:37:48 -08:00
|
|
|
rtc::Thread* signaling_thread,
|
2016-12-06 10:45:42 -08:00
|
|
|
const std::string& content_name,
|
2017-01-09 14:53:41 -08:00
|
|
|
bool srtp_required);
|
|
|
|
|
void DestroyRtpDataChannel_w(RtpDataChannel* data_channel);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<MediaEngineInterface> media_engine_;
|
|
|
|
|
std::unique_ptr<DataEngineInterface> data_media_engine_;
|
2013-07-10 00:45:36 +00:00
|
|
|
bool initialized_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* main_thread_;
|
|
|
|
|
rtc::Thread* worker_thread_;
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Thread* network_thread_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
VoiceChannels voice_channels_;
|
|
|
|
|
VideoChannels video_channels_;
|
2017-01-09 14:53:41 -08:00
|
|
|
RtpDataChannels data_channels_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool enable_rtx_;
|
|
|
|
|
bool capturing_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
2016-02-29 12:07:35 +01:00
|
|
|
#endif // WEBRTC_PC_CHANNELMANAGER_H_
|