| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | // This file contains classes that implement RtpReceiverInterface. |
| 12 | // An RtpReceiver associates a MediaStreamTrackInterface with an underlying |
| 13 | // transport (provided by cricket::VoiceChannel/cricket::VideoChannel) |
| 14 |
| 15 | #ifndef PC_RTP_RECEIVER_H_ |
| 16 | #define PC_RTP_RECEIVER_H_ |
| 17 |
| 18 | #include <stdint.h> |
| 19 |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 |
| 23 | #include "absl/types/optional.h" |
| 24 | #include "api/crypto/frame_decryptor_interface.h" |
| 25 | #include "api/dtls_transport_interface.h" |
| 26 | #include "api/media_stream_interface.h" |
| 27 | #include "api/media_types.h" |
| 28 | #include "api/rtp_parameters.h" |
| 29 | #include "api/rtp_receiver_interface.h" |
| 30 | #include "api/scoped_refptr.h" |
| 31 | #include "api/video/video_frame.h" |
| 32 | #include "api/video/video_sink_interface.h" |
| 33 | #include "api/video/video_source_interface.h" |
| 34 | #include "media/base/media_channel.h" |
| 35 | #include "media/base/video_broadcaster.h" |
| 36 | #include "pc/video_track_source.h" |
| 37 | #include "rtc_base/thread.h" |
| 38 |
| 39 | namespace webrtc { |
| 40 |
| 41 | // Internal class used by PeerConnection. |
| 42 | class RtpReceiverInternal : public RtpReceiverInterface { |
| 43 | public: |
| 44 | // Call on the signaling thread, to let the receiver know that the the |
| 45 | // embedded source object should enter a stopped/ended state and the track's |
| 46 | // state set to `kEnded`, a final state that cannot be reversed. |
| 47 | virtual void Stop() = 0; |
| 48 |
| 49 | // Sets the underlying MediaEngine channel associated with this RtpSender. |
| 50 | // A VoiceMediaChannel should be used for audio RtpSenders and |
| 51 | // a VideoMediaChannel should be used for video RtpSenders. |
| 52 | // NOTE: |
| 53 | // * SetMediaChannel(nullptr) must be called before the media channel is |
| 54 | // destroyed. |
| 55 | // * This method must be invoked on the worker thread. |
| 56 | virtual void SetMediaChannel( |
| 57 | cricket::MediaReceiveChannelInterface* media_channel) = 0; |
| 58 |
| 59 | // Configures the RtpReceiver with the underlying media channel, with the |
| 60 | // given SSRC as the stream identifier. |
| 61 | virtual void SetupMediaChannel(uint32_t ssrc) = 0; |
| 62 |
| 63 | // Configures the RtpReceiver with the underlying media channel to receive an |
| 64 | // unsignaled receive stream. |
| 65 | virtual void SetupUnsignaledMediaChannel() = 0; |
| 66 |
| 67 | virtual void set_transport( |
| 68 | rtc::scoped_refptr<DtlsTransportInterface> dtls_transport) = 0; |
| 69 | // This SSRC is used as an identifier for the receiver between the API layer |
| 70 | // and the WebRtcVideoEngine, WebRtcVoiceEngine layer. |
| 71 | virtual absl::optional<uint32_t> ssrc() const = 0; |
| 72 |
| 73 | // Call this to notify the RtpReceiver when the first packet has been received |
| 74 | // on the corresponding channel. |
| 75 | virtual void NotifyFirstPacketReceived() = 0; |
| 76 |
| 77 | // Set the associated remote media streams for this receiver. The remote track |
| 78 | // will be removed from any streams that are no longer present and added to |
| 79 | // any new streams. |
| 80 | virtual void set_stream_ids(std::vector<std::string> stream_ids) = 0; |
| 81 | // TODO(https://crbug.com/webrtc/9480): Remove SetStreams() in favor of |
| 82 | // set_stream_ids() as soon as downstream projects are no longer dependent on |
| 83 | // stream objects. |
| 84 | virtual void SetStreams( |
| 85 | const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) = 0; |
| 86 |
| 87 | // Returns an ID that changes if the attached track changes, but |
| 88 | // otherwise remains constant. Used to generate IDs for stats. |
| 89 | // The special value zero means that no track is attached. |
| 90 | virtual int AttachmentId() const = 0; |
| 91 |
| 92 | protected: |
| 93 | static int GenerateUniqueId(); |
| 94 |
| 95 | static std::vector<rtc::scoped_refptr<MediaStreamInterface>> |
| 96 | CreateStreamsFromIds(std::vector<std::string> stream_ids); |
| 97 | }; |
| 98 |
| 99 | } // namespace webrtc |
| 100 |
| 101 | #endif // PC_RTP_RECEIVER_H_ |
| 102 |