1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 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 #ifndef CALL_RECEIVE_STREAM_H_ 12 #define CALL_RECEIVE_STREAM_H_ 13 14 #include <vector> 15 16 #include "api/crypto/frame_decryptor_interface.h" 17 #include "api/frame_transformer_interface.h" 18 #include "api/media_types.h" 19 #include "api/scoped_refptr.h" 20 #include "api/transport/rtp/rtp_source.h" 21 #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" 22 23 namespace webrtc { 24 25 // Common base interface for MediaReceiveStreamInterface based classes and 26 // FlexfecReceiveStream. 27 class ReceiveStreamInterface { 28 public: 29 // Receive-stream specific RTP settings. 30 // TODO(tommi): This struct isn't needed at this level anymore. Move it closer 31 // to where it's used. 32 struct ReceiveStreamRtpConfig { 33 // Synchronization source (stream identifier) to be received. 34 // This member will not change mid-stream and can be assumed to be const 35 // post initialization. 36 uint32_t remote_ssrc = 0; 37 38 // Sender SSRC used for sending RTCP (such as receiver reports). 39 // This value may change mid-stream and must be done on the same thread 40 // that the value is read on (i.e. packet delivery). 41 uint32_t local_ssrc = 0; 42 43 // Enable feedback for send side bandwidth estimation. 44 // See 45 // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions 46 // for details. 47 // This value may change mid-stream and must be done on the same thread 48 // that the value is read on (i.e. packet delivery). 49 bool transport_cc = false; 50 51 // RTP header extensions used for the received stream. 52 // This value may change mid-stream and must be done on the same thread 53 // that the value is read on (i.e. packet delivery). 54 std::vector<RtpExtension> extensions; 55 }; 56 57 // Set/change the rtp header extensions. Must be called on the packet 58 // delivery thread. 59 virtual void SetRtpExtensions(std::vector<RtpExtension> extensions) = 0; 60 virtual RtpHeaderExtensionMap GetRtpExtensionMap() const = 0; 61 62 // Returns a bool for whether feedback for send side bandwidth estimation is 63 // enabled. See 64 // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions 65 // for details. 66 // This value may change mid-stream and must be done on the same thread 67 // that the value is read on (i.e. packet delivery). 68 virtual bool transport_cc() const = 0; 69 70 virtual void SetTransportCc(bool transport_cc) = 0; 71 72 protected: ~ReceiveStreamInterface()73 virtual ~ReceiveStreamInterface() {} 74 }; 75 76 // Either an audio or video receive stream. 77 class MediaReceiveStreamInterface : public ReceiveStreamInterface { 78 public: 79 // Starts stream activity. 80 // When a stream is active, it can receive, process and deliver packets. 81 virtual void Start() = 0; 82 83 // Stops stream activity. Must be called to match with a previous call to 84 // `Start()`. When a stream has been stopped, it won't receive, decode, 85 // process or deliver packets to downstream objects such as callback pointers 86 // set in the config struct. 87 virtual void Stop() = 0; 88 89 virtual void SetDepacketizerToDecoderFrameTransformer( 90 rtc::scoped_refptr<webrtc::FrameTransformerInterface> 91 frame_transformer) = 0; 92 93 virtual void SetFrameDecryptor( 94 rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) = 0; 95 96 virtual std::vector<RtpSource> GetSources() const = 0; 97 }; 98 99 } // namespace webrtc 100 101 #endif // CALL_RECEIVE_STREAM_H_ 102