mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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 | */ |
mflodman@webrtc.org | 2a4595a | 2013-12-18 09:46:22 +0000 | [diff] [blame] | 10 | #ifndef WEBRTC_CALL_H_ |
| 11 | #define WEBRTC_CALL_H_ |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 12 | |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "webrtc/common_types.h" |
pbos@webrtc.org | b581c90 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 17 | #include "webrtc/video_receive_stream.h" |
| 18 | #include "webrtc/video_send_stream.h" |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 19 | |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 20 | namespace webrtc { |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 21 | |
| 22 | class VoiceEngine; |
| 23 | |
| 24 | const char* Version(); |
| 25 | |
| 26 | class PacketReceiver { |
| 27 | public: |
pbos@webrtc.org | 2c00af7 | 2013-08-05 12:49:22 +0000 | [diff] [blame] | 28 | virtual bool DeliverPacket(const uint8_t* packet, size_t length) = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 29 | |
| 30 | protected: |
| 31 | virtual ~PacketReceiver() {} |
| 32 | }; |
| 33 | |
asapersson@webrtc.org | 4b1817f | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 34 | // Callback interface for reporting when a system overuse is detected. |
| 35 | // The detection is based on the jitter of incoming captured frames. |
| 36 | class OveruseCallback { |
| 37 | public: |
| 38 | // Called as soon as an overuse is detected. |
| 39 | virtual void OnOveruse() = 0; |
| 40 | // Called periodically when the system is not overused any longer. |
| 41 | virtual void OnNormalUse() = 0; |
| 42 | |
| 43 | protected: |
| 44 | virtual ~OveruseCallback() {} |
| 45 | }; |
| 46 | |
pbos@webrtc.org | fdc4352 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 47 | // A Call instance can contain several send and/or receive streams. All streams |
| 48 | // are assumed to have the same remote endpoint and will share bitrate estimates |
| 49 | // etc. |
| 50 | class Call { |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 51 | public: |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 52 | struct Config { |
pbos@webrtc.org | d8e92c9 | 2013-08-23 09:19:30 +0000 | [diff] [blame] | 53 | explicit Config(newapi::Transport* send_transport) |
stefan@webrtc.org | da3ae7c | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 54 | : webrtc_config(NULL), |
| 55 | send_transport(send_transport), |
pbos@webrtc.org | 297e5ed | 2013-08-14 13:52:52 +0000 | [diff] [blame] | 56 | voice_engine(NULL), |
asapersson@webrtc.org | 4b1817f | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 57 | overuse_callback(NULL) {} |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 58 | |
stefan@webrtc.org | da3ae7c | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 59 | webrtc::Config* webrtc_config; |
| 60 | |
pbos@webrtc.org | d8e92c9 | 2013-08-23 09:19:30 +0000 | [diff] [blame] | 61 | newapi::Transport* send_transport; |
pbos@webrtc.org | 297e5ed | 2013-08-14 13:52:52 +0000 | [diff] [blame] | 62 | |
pbos@webrtc.org | fdc4352 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 63 | // VoiceEngine used for audio/video synchronization for this Call. |
pbos@webrtc.org | 297e5ed | 2013-08-14 13:52:52 +0000 | [diff] [blame] | 64 | VoiceEngine* voice_engine; |
| 65 | |
asapersson@webrtc.org | 4b1817f | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 66 | // Callback for overuse and normal usage based on the jitter of incoming |
| 67 | // captured frames. 'NULL' disables the callback. |
| 68 | OveruseCallback* overuse_callback; |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
pbos@webrtc.org | fdc4352 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 71 | static Call* Create(const Call::Config& config); |
pbos@webrtc.org | 297e5ed | 2013-08-14 13:52:52 +0000 | [diff] [blame] | 72 | |
stefan@webrtc.org | da3ae7c | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 73 | static Call* Create(const Call::Config& config, |
| 74 | const webrtc::Config& webrtc_config); |
| 75 | |
pbos@webrtc.org | 2c343fc | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 76 | virtual VideoSendStream::Config GetDefaultSendConfig() = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 77 | |
pbos@webrtc.org | 162021c | 2013-11-20 10:40:25 +0000 | [diff] [blame] | 78 | virtual VideoSendStream* CreateVideoSendStream( |
pbos@webrtc.org | 2c343fc | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 79 | const VideoSendStream::Config& config) = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 80 | |
pbos@webrtc.org | f8486d0 | 2013-11-21 13:49:43 +0000 | [diff] [blame] | 81 | virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 82 | |
pbos@webrtc.org | 2c343fc | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 83 | virtual VideoReceiveStream::Config GetDefaultReceiveConfig() = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 84 | |
pbos@webrtc.org | 162021c | 2013-11-20 10:40:25 +0000 | [diff] [blame] | 85 | virtual VideoReceiveStream* CreateVideoReceiveStream( |
pbos@webrtc.org | 2c343fc | 2013-06-05 11:33:21 +0000 | [diff] [blame] | 86 | const VideoReceiveStream::Config& config) = 0; |
pbos@webrtc.org | f8486d0 | 2013-11-21 13:49:43 +0000 | [diff] [blame] | 87 | virtual void DestroyVideoReceiveStream( |
| 88 | VideoReceiveStream* receive_stream) = 0; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 89 | |
| 90 | // All received RTP and RTCP packets for the call should be inserted to this |
| 91 | // PacketReceiver. The PacketReceiver pointer is valid as long as the |
pbos@webrtc.org | fdc4352 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 92 | // Call instance exists. |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 93 | virtual PacketReceiver* Receiver() = 0; |
| 94 | |
| 95 | // Returns the estimated total send bandwidth. Note: this can differ from the |
| 96 | // actual encoded bitrate. |
| 97 | virtual uint32_t SendBitrateEstimate() = 0; |
| 98 | |
| 99 | // Returns the total estimated receive bandwidth for the call. Note: this can |
| 100 | // differ from the actual receive bitrate. |
| 101 | virtual uint32_t ReceiveBitrateEstimate() = 0; |
| 102 | |
pbos@webrtc.org | fdc4352 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 103 | virtual ~Call() {} |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 104 | }; |
mflodman@webrtc.org | 69b0d2c | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 105 | } // namespace webrtc |
| 106 | |
mflodman@webrtc.org | 2a4595a | 2013-12-18 09:46:22 +0000 | [diff] [blame] | 107 | #endif // WEBRTC_CALL_H_ |