2015-09-24 16:47:53 -07:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
2015-09-24 16:47:53 -07:00
|
|
|
*
|
2016-02-10 07:54:43 -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.
|
2015-09-24 16:47:53 -07:00
|
|
|
*/
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// This file contains classes that implement RtpReceiverInterface.
|
|
|
|
|
// An RtpReceiver associates a MediaStreamTrackInterface with an underlying
|
2016-06-27 16:30:35 -07:00
|
|
|
// transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef PC_RTP_RECEIVER_H_
|
|
|
|
|
#define PC_RTP_RECEIVER_H_
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2017-01-02 08:42:32 -08:00
|
|
|
#include <stdint.h>
|
2015-09-28 16:53:55 -07:00
|
|
|
#include <string>
|
2017-10-30 09:57:42 -07:00
|
|
|
#include <vector>
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "absl/types/optional.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/frame_decryptor_interface.h"
|
|
|
|
|
#include "api/media_stream_interface.h"
|
|
|
|
|
#include "api/media_types.h"
|
|
|
|
|
#include "api/rtp_parameters.h"
|
|
|
|
|
#include "api/rtp_receiver_interface.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "api/video/video_sink_interface.h"
|
|
|
|
|
#include "api/video/video_source_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "media/base/media_channel.h"
|
|
|
|
|
#include "media/base/video_broadcaster.h"
|
|
|
|
|
#include "pc/video_track_source.h"
|
|
|
|
|
#include "rtc_base/ref_counted_object.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/thread.h"
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
// Internal class used by PeerConnection.
|
|
|
|
|
class RtpReceiverInternal : public RtpReceiverInterface {
|
|
|
|
|
public:
|
|
|
|
|
virtual void Stop() = 0;
|
2018-01-10 17:15:20 -08:00
|
|
|
|
2018-02-15 15:19:50 -08:00
|
|
|
// Sets the underlying MediaEngine channel associated with this RtpSender.
|
2018-11-13 16:26:05 -08:00
|
|
|
// 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.
|
|
|
|
|
virtual void SetMediaChannel(cricket::MediaChannel* media_channel) = 0;
|
2018-02-15 15:19:50 -08:00
|
|
|
|
2018-01-17 17:41:02 -08:00
|
|
|
// Configures the RtpReceiver with the underlying media channel, with the
|
|
|
|
|
// given SSRC as the stream identifier. If |ssrc| is 0, the receiver will
|
|
|
|
|
// receive packets on unsignaled SSRCs.
|
|
|
|
|
virtual void SetupMediaChannel(uint32_t ssrc) = 0;
|
|
|
|
|
|
2019-01-17 10:39:40 +01:00
|
|
|
virtual void set_transport(
|
|
|
|
|
rtc::scoped_refptr<DtlsTransportInterface> dtls_transport) = 0;
|
2017-02-25 18:15:09 -08:00
|
|
|
// This SSRC is used as an identifier for the receiver between the API layer
|
2017-06-12 01:16:46 -07:00
|
|
|
// and the WebRtcVideoEngine, WebRtcVoiceEngine layer.
|
2017-02-25 18:15:09 -08:00
|
|
|
virtual uint32_t ssrc() const = 0;
|
2018-01-10 11:51:34 -08:00
|
|
|
|
|
|
|
|
// Call this to notify the RtpReceiver when the first packet has been received
|
|
|
|
|
// on the corresponding channel.
|
|
|
|
|
virtual void NotifyFirstPacketReceived() = 0;
|
2018-01-10 17:15:20 -08:00
|
|
|
|
|
|
|
|
// Set the associated remote media streams for this receiver. The remote track
|
|
|
|
|
// will be removed from any streams that are no longer present and added to
|
|
|
|
|
// any new streams.
|
2018-07-04 20:51:53 +02:00
|
|
|
virtual void set_stream_ids(std::vector<std::string> stream_ids) = 0;
|
|
|
|
|
// TODO(https://crbug.com/webrtc/9480): Remove SetStreams() in favor of
|
|
|
|
|
// set_stream_ids() as soon as downstream projects are no longer dependent on
|
|
|
|
|
// stream objects.
|
2018-01-10 17:15:20 -08:00
|
|
|
virtual void SetStreams(
|
|
|
|
|
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) = 0;
|
2018-02-15 15:19:50 -08:00
|
|
|
|
|
|
|
|
// Returns an ID that changes if the attached track changes, but
|
|
|
|
|
// otherwise remains constant. Used to generate IDs for stats.
|
|
|
|
|
// The special value zero means that no track is attached.
|
|
|
|
|
virtual int AttachmentId() const = 0;
|
2016-06-27 16:30:35 -07:00
|
|
|
|
2019-02-11 10:29:19 +01:00
|
|
|
protected:
|
|
|
|
|
static int GenerateUniqueId();
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2019-02-11 10:29:19 +01:00
|
|
|
static std::vector<rtc::scoped_refptr<MediaStreamInterface>>
|
|
|
|
|
CreateStreamsFromIds(std::vector<std::string> stream_ids);
|
2016-05-16 11:40:30 -07:00
|
|
|
|
2019-02-11 10:29:19 +01:00
|
|
|
static void MaybeAttachFrameDecryptorToMediaChannel(
|
|
|
|
|
const absl::optional<uint32_t>& ssrc,
|
2018-01-10 11:51:34 -08:00
|
|
|
rtc::Thread* worker_thread,
|
2019-02-11 10:29:19 +01:00
|
|
|
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
|
|
|
|
|
cricket::MediaChannel* media_channel,
|
|
|
|
|
bool stopped);
|
2015-09-28 16:53:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // PC_RTP_RECEIVER_H_
|