Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 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 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Common base interface for MediaReceiveStream based classes and |
| 25 | // FlexfecReceiveStream. |
| 26 | class ReceiveStream { |
| 27 | public: |
| 28 | // Receive-stream specific RTP settings. |
| 29 | struct RtpConfig { |
| 30 | // Synchronization source (stream identifier) to be received. |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 31 | // This member will not change mid-stream and can be assumed to be const |
| 32 | // post initialization. |
Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 33 | uint32_t remote_ssrc = 0; |
| 34 | |
| 35 | // Sender SSRC used for sending RTCP (such as receiver reports). |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 36 | // This value may change mid-stream and must be done on the same thread |
| 37 | // that the value is read on (i.e. packet delivery). |
Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 38 | uint32_t local_ssrc = 0; |
| 39 | |
| 40 | // Enable feedback for send side bandwidth estimation. |
| 41 | // See |
| 42 | // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions |
| 43 | // for details. |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 44 | // This value may change mid-stream and must be done on the same thread |
| 45 | // that the value is read on (i.e. packet delivery). |
Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 46 | bool transport_cc = false; |
| 47 | |
| 48 | // RTP header extensions used for the received stream. |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 49 | // This value may change mid-stream and must be done on the same thread |
| 50 | // that the value is read on (i.e. packet delivery). |
Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 51 | std::vector<RtpExtension> extensions; |
| 52 | }; |
| 53 | |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 54 | // Called on the packet delivery thread since some members of the config may |
| 55 | // change mid-stream (e.g. the local ssrc). All mutation must also happen on |
| 56 | // the packet delivery thread. Return value can be assumed to |
| 57 | // only be used in the calling context (on the stack basically). |
| 58 | virtual const RtpConfig& rtp_config() const = 0; |
| 59 | |
Tommi | 1c1f540 | 2021-06-14 10:54:20 +0200 | [diff] [blame] | 60 | protected: |
| 61 | virtual ~ReceiveStream() {} |
| 62 | }; |
| 63 | |
| 64 | // Either an audio or video receive stream. |
| 65 | class MediaReceiveStream : public ReceiveStream { |
| 66 | public: |
| 67 | // Starts stream activity. |
| 68 | // When a stream is active, it can receive, process and deliver packets. |
| 69 | virtual void Start() = 0; |
| 70 | |
| 71 | // Stops stream activity. Must be called to match with a previous call to |
| 72 | // `Start()`. When a stream has been stopped, it won't receive, decode, |
| 73 | // process or deliver packets to downstream objects such as callback pointers |
| 74 | // set in the config struct. |
| 75 | virtual void Stop() = 0; |
| 76 | |
| 77 | virtual void SetDepacketizerToDecoderFrameTransformer( |
| 78 | rtc::scoped_refptr<webrtc::FrameTransformerInterface> |
| 79 | frame_transformer) = 0; |
| 80 | |
| 81 | virtual void SetFrameDecryptor( |
| 82 | rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) = 0; |
| 83 | |
| 84 | virtual std::vector<RtpSource> GetSources() const = 0; |
| 85 | }; |
| 86 | |
| 87 | } // namespace webrtc |
| 88 | |
| 89 | #endif // CALL_RECEIVE_STREAM_H_ |