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
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef PC_CHANNEL_MANAGER_H_
|
|
|
|
|
#define PC_CHANNEL_MANAGER_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stdint.h>
|
2019-05-21 11:12:57 -07:00
|
|
|
|
2016-03-11 14:18:21 -08:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/audio_options.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/crypto_options.h"
|
2021-01-29 14:45:08 +00:00
|
|
|
#include "api/rtp_parameters.h"
|
|
|
|
|
#include "api/video/video_bitrate_allocator_factory.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "call/call.h"
|
|
|
|
|
#include "media/base/codec.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "media/base/media_channel.h"
|
|
|
|
|
#include "media/base/media_config.h"
|
|
|
|
|
#include "media/base/media_engine.h"
|
2017-11-06 15:40:09 -08:00
|
|
|
#include "pc/channel.h"
|
2022-02-23 13:44:59 +00:00
|
|
|
#include "pc/channel_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/session_description.h"
|
2019-06-11 14:04:16 +02:00
|
|
|
#include "rtc_base/system/file_wrapper.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/thread.h"
|
2022-02-23 13:44:59 +00:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2021-01-29 14:45:08 +00:00
|
|
|
#include "rtc_base/unique_id_generator.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
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.
|
2022-01-26 10:21:57 +01:00
|
|
|
class ChannelManager : public ChannelFactoryInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2021-04-01 16:49:42 +02:00
|
|
|
// Returns an initialized instance of ChannelManager.
|
|
|
|
|
// If media_engine is non-nullptr, then the returned ChannelManager instance
|
|
|
|
|
// will own that reference and media engine initialization
|
|
|
|
|
static std::unique_ptr<ChannelManager> Create(
|
|
|
|
|
std::unique_ptr<MediaEngineInterface> media_engine,
|
|
|
|
|
bool enable_rtx,
|
|
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread);
|
|
|
|
|
|
|
|
|
|
ChannelManager() = delete;
|
2022-01-24 08:45:26 +01:00
|
|
|
~ChannelManager() override;
|
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-15 12:26:33 +02:00
|
|
|
MediaEngineInterface* media_engine() { return media_engine_.get(); }
|
2022-01-24 08:45:26 +01:00
|
|
|
rtc::UniqueRandomIdGenerator& ssrc_generator() { return ssrc_generator_; }
|
2015-09-15 12:26:33 +02:00
|
|
|
|
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;
|
2020-03-29 22:17:00 +02:00
|
|
|
void GetSupportedVideoSendCodecs(std::vector<VideoCodec>* codecs) const;
|
|
|
|
|
void GetSupportedVideoReceiveCodecs(std::vector<VideoCodec>* codecs) const;
|
2020-03-16 13:40:51 +01:00
|
|
|
RtpHeaderExtensions GetDefaultEnabledAudioRtpHeaderExtensions() const;
|
|
|
|
|
std::vector<webrtc::RtpHeaderExtensionCapability>
|
|
|
|
|
GetSupportedAudioRtpHeaderExtensions() const;
|
|
|
|
|
RtpHeaderExtensions GetDefaultEnabledVideoRtpHeaderExtensions() const;
|
|
|
|
|
std::vector<webrtc::RtpHeaderExtensionCapability>
|
|
|
|
|
GetSupportedVideoRtpHeaderExtensions() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// The operations below all occur on the worker thread.
|
2017-08-30 10:48:46 -07:00
|
|
|
// ChannelManager retains ownership of the created channels, so clients should
|
|
|
|
|
// call the appropriate Destroy*Channel method when done.
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Creates a voice channel, to be associated with the specified session.
|
2020-09-02 13:25:31 -07:00
|
|
|
VoiceChannel* CreateVoiceChannel(webrtc::Call* call,
|
2021-04-01 16:49:42 +02:00
|
|
|
const MediaConfig& media_config,
|
2022-01-24 08:45:26 +01:00
|
|
|
const std::string& mid,
|
2020-09-02 13:25:31 -07:00
|
|
|
bool srtp_required,
|
|
|
|
|
const webrtc::CryptoOptions& crypto_options,
|
2022-01-24 08:45:26 +01:00
|
|
|
const AudioOptions& options) override;
|
2017-08-30 10:48:46 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Creates a video channel, synced with the specified voice channel, and
|
|
|
|
|
// associated with the specified session.
|
2017-02-25 18:15:09 -08:00
|
|
|
// Version of the above that takes PacketTransportInternal.
|
2019-01-07 15:54:47 +01:00
|
|
|
VideoChannel* CreateVideoChannel(
|
|
|
|
|
webrtc::Call* call,
|
2021-04-01 16:49:42 +02:00
|
|
|
const MediaConfig& media_config,
|
2022-01-24 08:45:26 +01:00
|
|
|
const std::string& mid,
|
2019-01-07 15:54:47 +01:00
|
|
|
bool srtp_required,
|
|
|
|
|
const webrtc::CryptoOptions& crypto_options,
|
2019-04-17 07:38:40 +02:00
|
|
|
const VideoOptions& options,
|
2022-01-24 08:45:26 +01:00
|
|
|
webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory)
|
|
|
|
|
override;
|
|
|
|
|
|
|
|
|
|
void DestroyChannel(ChannelInterface* channel) override;
|
2017-08-30 10:48:46 -07:00
|
|
|
|
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.
|
2019-06-11 14:04:16 +02:00
|
|
|
bool StartAecDump(webrtc::FileWrapper 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();
|
|
|
|
|
|
2022-01-26 10:21:57 +01:00
|
|
|
protected:
|
2021-04-01 16:49:42 +02:00
|
|
|
ChannelManager(std::unique_ptr<MediaEngineInterface> media_engine,
|
|
|
|
|
bool enable_rtx,
|
|
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread);
|
|
|
|
|
|
2022-01-24 08:45:26 +01:00
|
|
|
// Destroys a voice channel created by CreateVoiceChannel.
|
|
|
|
|
void DestroyVoiceChannel(VoiceChannel* voice_channel);
|
|
|
|
|
|
|
|
|
|
// Destroys a video channel created by CreateVideoChannel.
|
|
|
|
|
void DestroyVideoChannel(VideoChannel* video_channel);
|
|
|
|
|
|
2022-01-26 10:21:57 +01:00
|
|
|
private:
|
2021-04-01 16:49:42 +02:00
|
|
|
const std::unique_ptr<MediaEngineInterface> media_engine_; // Nullable.
|
2022-01-24 08:45:26 +01:00
|
|
|
rtc::Thread* const signaling_thread_;
|
2021-03-30 23:47:49 +02:00
|
|
|
rtc::Thread* const worker_thread_;
|
|
|
|
|
rtc::Thread* const network_thread_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2022-01-24 08:45:26 +01:00
|
|
|
// This object should be used to generate any SSRC that is not explicitly
|
|
|
|
|
// specified by the user (or by the remote party).
|
|
|
|
|
// TODO(bugs.webrtc.org/12666): This variable is used from both the signaling
|
|
|
|
|
// and worker threads. See if we can't restrict usage to a single thread.
|
|
|
|
|
rtc::UniqueRandomIdGenerator ssrc_generator_;
|
|
|
|
|
|
2017-11-06 15:40:09 -08:00
|
|
|
// Vector contents are non-null.
|
2021-04-01 16:49:42 +02:00
|
|
|
std::vector<std::unique_ptr<VoiceChannel>> voice_channels_
|
|
|
|
|
RTC_GUARDED_BY(worker_thread_);
|
|
|
|
|
std::vector<std::unique_ptr<VideoChannel>> video_channels_
|
|
|
|
|
RTC_GUARDED_BY(worker_thread_);
|
|
|
|
|
|
|
|
|
|
const bool enable_rtx_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // PC_CHANNEL_MANAGER_H_
|