webrtc_m130/pc/channel_manager.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
6.6 KiB
C
Raw Normal View History

/*
* Copyright 2004 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 PC_CHANNEL_MANAGER_H_
#define PC_CHANNEL_MANAGER_H_
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
#include "api/audio_options.h"
#include "api/crypto/crypto_options.h"
#include "api/media_transport_interface.h"
#include "call/call.h"
#include "media/base/codec.h"
#include "media/base/media_channel.h"
#include "media/base/media_config.h"
#include "media/base/media_engine.h"
#include "pc/channel.h"
#include "pc/rtp_transport_internal.h"
#include "pc/session_description.h"
#include "rtc_base/platform_file.h"
#include "rtc_base/thread.h"
namespace cricket {
// 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.
class ChannelManager final {
public:
// Construct a ChannelManager with the specified media engine and data engine.
ChannelManager(std::unique_ptr<MediaEngineInterface> media_engine,
std::unique_ptr<DataEngineInterface> data_engine,
rtc::Thread* worker_thread,
rtc::Thread* network_thread);
~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.
rtc::Thread* worker_thread() const { return worker_thread_; }
bool set_worker_thread(rtc::Thread* thread) {
if (initialized_) {
return false;
}
worker_thread_ = thread;
return true;
}
rtc::Thread* network_thread() const { return network_thread_; }
bool set_network_thread(rtc::Thread* thread) {
if (initialized_) {
return false;
}
network_thread_ = thread;
return true;
}
MediaEngineInterface* media_engine() { return media_engine_.get(); }
// Retrieves the list of supported audio & video codec types.
// Can be called before starting the media engine.
void GetSupportedAudioSendCodecs(std::vector<AudioCodec>* codecs) const;
void GetSupportedAudioReceiveCodecs(std::vector<AudioCodec>* codecs) const;
void GetSupportedAudioRtpHeaderExtensions(RtpHeaderExtensions* ext) const;
void GetSupportedVideoCodecs(std::vector<VideoCodec>* codecs) const;
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.
// ChannelManager retains ownership of the created channels, so clients should
// call the appropriate Destroy*Channel method when done.
// Creates a voice channel, to be associated with the specified session.
Reland "Reland "Propagate media transport to media channel."" This is a reland of da65ed2adcfa57ff3288ce01c1602c973fcab00d Original change's description: > Reland "Propagate media transport to media channel." > > This reverts commit 37cf2455a420124b341ad06ac27fa3c4dbd29d3c. > > Reason for revert: <INSERT REASONING HERE> > > Original change's description: > > Revert "Propagate media transport to media channel." > > > > This reverts commit 8c16f745ab92cb6d305283e87fa8a661ae500ce4. > > > > Reason for revert: Breaks downstream project > > > > Original change's description: > > > Propagate media transport to media channel. > > > > > > 1. Pass media transport factory to JSEP transport controller. > > > 2. Pass media transport to voice media channel. > > > 3. Add basic unit test that make sure if peer connection is created with media transport, it is propagated to voice media channel. > > > > > > Change-Id: Ie922db78ade0efd893e019cd2b4441a9947a2f71 > > > Bug: webrtc:9719 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/105542 > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > > Reviewed-by: Peter Slatala <psla@webrtc.org> > > > Commit-Queue: Anton Sukhanov <sukhanov@google.com> > > > Cr-Commit-Position: refs/heads/master@{#25152} > > > > TBR=steveanton@webrtc.org,nisse@webrtc.org,psla@webrtc.org,sukhanov@google.com > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9719 > > Change-Id: Ic78cdc142a2145682ad74eac8b72c71c50f0a5c1 > > Reviewed-on: https://webrtc-review.googlesource.com/c/105840 > > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > > Commit-Queue: Oleh Prypin <oprypin@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#25154} > > TBR=steveanton@webrtc.org,oprypin@webrtc.org,nisse@webrtc.org,sukhanov@webrtc.org,psla@webrtc.org,sukhanov@google.com > > Change-Id: I505ff3451eae81573531faef155ff35d7f894022 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9719 > Reviewed-on: https://webrtc-review.googlesource.com/c/106500 > Reviewed-by: Anton Sukhanov <sukhanov@webrtc.org> > Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#25220} Bug: webrtc:9719 Tbr: Steve Anton <steveanton@webrtc.org> Tbr: Niels Moller <nisse@webrtc.org> Change-Id: Ib45691ba8be9abb89ff8c6dac1861bdf59be4c8d Reviewed-on: https://webrtc-review.googlesource.com/c/106561 Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> Reviewed-by: Peter Slatala <psla@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25240}
2018-10-17 13:15:42 -07:00
VoiceChannel* CreateVoiceChannel(
webrtc::Call* call,
const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport,
rtc::Thread* signaling_thread,
const std::string& content_name,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const AudioOptions& options);
// Destroys a voice channel created by CreateVoiceChannel.
void DestroyVoiceChannel(VoiceChannel* voice_channel);
// Creates a video channel, synced with the specified voice channel, and
// associated with the specified session.
// Version of the above that takes PacketTransportInternal.
VideoChannel* CreateVideoChannel(
webrtc::Call* call,
const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport,
rtc::Thread* signaling_thread,
const std::string& content_name,
bool srtp_required,
const webrtc::CryptoOptions& crypto_options,
const VideoOptions& options);
// Destroys a video channel created by CreateVideoChannel.
void DestroyVideoChannel(VideoChannel* video_channel);
RtpDataChannel* CreateRtpDataChannel(
const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport,
rtc::Thread* signaling_thread,
const std::string& content_name,
bool srtp_required,
Reland "Move CryptoOptions to api/crypto from rtc_base/sslstreamadapter.h" Promotes rtc::CryptoOptions to webrtc::CryptoOptions converting it from class that only handles SRTP configuration to a more generic structure that can be used and extended for all per peer connection CryptoOptions that can be on a given PeerConnection. Now all SRTP related options are under webrtc::CryptoOptions::Srtp and can be accessed as crypto_options.srtp.whatever_option_name. This is more inline with other structures we have in WebRTC such as VideoConfig. As additional features are added over time this will allow the structure to remain compartmentalized and concerned components can only request a subset of the overall configuration structure e.g: void MySrtpFunction(const webrtc::CryptoOptions::Srtp& srtp_config); In addition to this it made little sense for sslstreamadapter.h to hold all Srtp related configuration options. The header has become loo large and takes on too many responsibilities and spilting this up will lead to more maintainable code going forward. This will be used in a future CL to enable configuration options for the newly supported Frame Crypto. Reland Fix: - cryptooptions.h - now has enable_aes128_sha1_32_crypto_cipher as an optional root level configuration. - peerconnectionfactory - If this optional is set will now overwrite the underyling value. This along with the other field will be deprecated once dependent projects are updated. TBR=sakal@webrtc.org,kthelgason@webrtc.org,emadomara@webrtc.org,qingsi@webrtc.org Bug: webrtc:9681 Change-Id: Iaa6b741baafb85d352e42f54226119f19d97151d Reviewed-on: https://webrtc-review.googlesource.com/c/105560 Reviewed-by: Benjamin Wright <benwright@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Reviewed-by: Emad Omara <emadomara@webrtc.org> Commit-Queue: Benjamin Wright <benwright@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25135}
2018-10-11 15:33:17 -07:00
const webrtc::CryptoOptions& crypto_options);
// Destroys a data channel created by CreateRtpDataChannel.
void DestroyRtpDataChannel(RtpDataChannel* data_channel);
// Indicates whether any channels exist.
bool has_channels() const {
return (!voice_channels_.empty() || !video_channels_.empty() ||
!data_channels_.empty());
}
// 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.
// 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);
// Stops recording AEC dump.
void StopAecDump();
private:
std::unique_ptr<MediaEngineInterface> media_engine_; // Nullable.
std::unique_ptr<DataEngineInterface> data_engine_; // Non-null.
bool initialized_ = false;
rtc::Thread* main_thread_;
rtc::Thread* worker_thread_;
rtc::Thread* network_thread_;
// Vector contents are non-null.
std::vector<std::unique_ptr<VoiceChannel>> voice_channels_;
std::vector<std::unique_ptr<VideoChannel>> video_channels_;
std::vector<std::unique_ptr<RtpDataChannel>> data_channels_;
bool enable_rtx_ = false;
bool capturing_ = false;
};
} // namespace cricket
#endif // PC_CHANNEL_MANAGER_H_