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