/* * Copyright 2015 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.
*/
// This file contains classes that implement RtpSenderInterface. // An RtpSender associates a MediaStreamTrackInterface with an underlying // transport (provided by AudioProviderInterface/VideoProviderInterface)
// Internal interface used by PeerConnection. class RtpSenderInternal : public RtpSenderInterface { public: // Sets the underlying MediaEngine channel associated with this RtpSender. // A VoiceMediaChannel should be used for audio RtpSenders and // a VideoMediaChannel should be used for video RtpSenders. // Must call SetMediaChannel(nullptr) before the media channel is destroyed. virtualvoid SetMediaChannel(
cricket::MediaSendChannelInterface* media_channel) = 0;
// Used to set the SSRC of the sender, once a local description has been set. // If `ssrc` is 0, this indiates that the sender should disconnect from the // underlying transport (this occurs if the sender isn't seen in a local // description). virtualvoid SetSsrc(uint32_t ssrc) = 0;
// `GetParameters` and `SetParameters` operate with a transactional model. // Allow access to get/set parameters without invalidating transaction id. virtual RtpParameters GetParametersInternal() const = 0; virtualvoid SetParametersInternal(const RtpParameters& parameters,
SetParametersCallback, bool blocking) = 0;
// GetParameters and SetParameters will remove deactivated simulcast layers // and restore them on SetParameters. This is probably a Bad Idea, but we // do not know who depends on this behavior virtual RtpParameters GetParametersInternalWithAllLayers() const = 0; virtual RTCError SetParametersInternalWithAllLayers( const RtpParameters& parameters) = 0;
// Additional checks that are specific to the current codec settings virtual RTCError CheckCodecParameters(const RtpParameters& parameters) = 0;
// Returns an ID that changes every time SetTrack() is called, but // otherwise remains constant. Used to generate IDs for stats. // The special value zero means that no track is attached. virtualint AttachmentId() const = 0;
// Disables the layers identified by the specified RIDs. // If the specified list is empty, this is a no-op. virtual RTCError DisableEncodingLayers( const std::vector<std::string>& rid) = 0;
virtualvoid SetTransceiverAsStopped() = 0;
// Used by the owning transceiver to inform the sender on the currently // selected codecs. virtualvoid SetSendCodecs(std::vector<cricket::Codec> send_codecs) = 0; virtual std::vector<cricket::Codec> GetSendCodecs() const = 0;
virtualvoid NotifyFirstPacketSent() = 0;
};
// Shared implementation for RtpSenderInternal interface. class RtpSenderBase : public RtpSenderInternal, public ObserverInterface { public: class SetStreamsObserver { public: virtual ~SetStreamsObserver() = default; virtualvoid OnSetStreams() = 0;
};
// Sets the underlying MediaEngine channel associated with this RtpSender. // A VoiceMediaChannel should be used for audio RtpSenders and // a VideoMediaChannel should be used for video RtpSenders. // Must call SetMediaChannel(nullptr) before the media channel is destroyed. void SetMediaChannel(
cricket::MediaSendChannelInterface* media_channel) override;
bool SetTrack(MediaStreamTrackInterface* track) override;
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { // This method is currently called from the worker thread by // RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n. // RTC_DCHECK_RUN_ON(signaling_thread_); return track_;
}
// Used to set the SSRC of the sender, once a local description has been set. // If `ssrc` is 0, this indiates that the sender should disconnect from the // underlying transport (this occurs if the sender isn't seen in a local // description). void SetSsrc(uint32_t ssrc) override;
uint32_t ssrc() const override { // This method is currently called from the worker thread by // RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n. // RTC_DCHECK_RUN_ON(signaling_thread_); return ssrc_;
}
// Returns an ID that changes every time SetTrack() is called, but // otherwise remains constant. Used to generate IDs for stats. // The special value zero means that no track is attached. int AttachmentId() const override { return attachment_id_; }
// Disables the layers identified by the specified RIDs. // If the specified list is empty, this is a no-op.
RTCError DisableEncodingLayers(const std::vector<std::string>& rid) override;
protected: // If `set_streams_observer` is not null, it is invoked when SetStreams() // is called. `set_streams_observer` is not owned by this object. If not // null, it must be valid at least until this sender becomes stopped.
RtpSenderBase(const Environment& env,
rtc::Thread* worker_thread, const std::string& id,
SetStreamsObserver* set_streams_observer); // TODO(bugs.webrtc.org/8694): Since SSRC == 0 is technically valid, figure // out some other way to test if we have a valid SSRC. bool can_send_track() const { return track_ && ssrc_; }
virtual std::string track_kind() const = 0;
// Enable sending on the media channel. virtualvoid SetSend() = 0; // Disable sending on the media channel. virtualvoid ClearSend() = 0;
// Template method pattern to allow subclasses to add custom behavior for // when tracks are attached, detached, and for adding tracks to statistics. virtualvoid AttachTrack() {} virtualvoid DetachTrack() {} virtualvoid AddTrackToStats() {} virtualvoid RemoveTrackFromStats() {}
// TODO(tommi): `media_channel_` and several other member variables in this // class (ssrc_, stopped_, etc) are accessed from more than one thread without // a guard or lock. Internally there are also several Invoke()s that we could // remove since the upstream code may already be performing several operations // on the worker thread.
cricket::MediaSendChannelInterface* media_channel_ = nullptr;
rtc::scoped_refptr<MediaStreamTrackInterface> track_;
rtc::scoped_refptr<DtlsTransportInterface> dtls_transport_;
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor_; // `last_transaction_id_` is used to verify that `SetParameters` is receiving // the parameters object that was last returned from `GetParameters`. // As such, it is used for internal verification and is not observable by the // the client. It is marked as mutable to enable `GetParameters` to be a // const method. mutable std::optional<std::string> last_transaction_id_;
std::vector<std::string> disabled_rids_;
// LocalAudioSinkAdapter receives data callback as a sink to the local // AudioTrack, and passes the data to the sink of AudioSource. class LocalAudioSinkAdapter : public AudioTrackSinkInterface, public cricket::AudioSource { public:
LocalAudioSinkAdapter(); virtual ~LocalAudioSinkAdapter();
private: // AudioSinkInterface implementation. void OnData(constvoid* audio_data, int bits_per_sample, int sample_rate,
size_t number_of_channels,
size_t number_of_frames,
std::optional<int64_t> absolute_capture_timestamp_ms) override;
class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase { public: // Construct an RtpSender for audio with the given sender ID. // The sender is initialized with no track to send and no associated streams. // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called // at the appropriate times. // If `set_streams_observer` is not null, it is invoked when SetStreams() // is called. `set_streams_observer` is not owned by this object. If not // null, it must be valid at least until this sender becomes stopped. static rtc::scoped_refptr<AudioRtpSender> Create( const Environment& env,
rtc::Thread* worker_thread, const std::string& id,
LegacyStatsCollectorInterface* stats,
SetStreamsObserver* set_streams_observer); virtual ~AudioRtpSender();
// Used to pass the data callback from the `track_` to the other end of // cricket::AudioSource.
std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
};
class VideoRtpSender : public RtpSenderBase { public: // Construct an RtpSender for video with the given sender ID. // The sender is initialized with no track to send and no associated streams. // If `set_streams_observer` is not null, it is invoked when SetStreams() // is called. `set_streams_observer` is not owned by this object. If not // null, it must be valid at least until this sender becomes stopped. static rtc::scoped_refptr<VideoRtpSender> Create( const Environment& env,
rtc::Thread* worker_thread, const std::string& id,
SetStreamsObserver* set_streams_observer); virtual ~VideoRtpSender();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.