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