Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | #ifndef WEBRTC_STREAM_H_ |
| 11 | #define WEBRTC_STREAM_H_ |
| 12 | |
| 13 | #include "webrtc/common_types.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | enum NetworkState { |
| 18 | kNetworkUp, |
| 19 | kNetworkDown, |
| 20 | }; |
| 21 | |
| 22 | // Common base class for streams. |
| 23 | class Stream { |
| 24 | public: |
| 25 | // Starts stream activity. |
| 26 | // When a stream is active, it can receive, process and deliver packets. |
| 27 | virtual void Start() = 0; |
| 28 | // Stops stream activity. |
| 29 | // When a stream is stopped, it can't receive, process or deliver packets. |
| 30 | virtual void Stop() = 0; |
| 31 | // Called to notify that network state has changed, so that the stream can |
| 32 | // respond, e.g. by pausing or resuming activity. |
| 33 | virtual void SignalNetworkState(NetworkState state) = 0; |
| 34 | // Called when a RTCP packet is received. |
| 35 | virtual bool DeliverRtcp(const uint8_t* packet, size_t length) = 0; |
| 36 | |
| 37 | protected: |
| 38 | virtual ~Stream() {} |
| 39 | }; |
| 40 | |
| 41 | // Common base class for receive streams. |
| 42 | class ReceiveStream : public Stream { |
| 43 | public: |
| 44 | // Called when a RTP packet is received. |
stefan | 68786d2 | 2015-09-08 05:36:15 -0700 | [diff] [blame] | 45 | virtual bool DeliverRtp(const uint8_t* packet, |
| 46 | size_t length, |
| 47 | const PacketTime& packet_time) = 0; |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | // Common base class for send streams. |
| 51 | // A tag class that denotes send stream type. |
| 52 | class SendStream : public Stream {}; |
| 53 | |
| 54 | } // namespace webrtc |
| 55 | |
| 56 | #endif // WEBRTC_STREAM_H_ |