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 */ 10 #ifndef WEBRTC_CALL_H_ 11 #define WEBRTC_CALL_H_ 12 13 #include <string> 14 #include <vector> 15 16 #include "webrtc/common_types.h" 17 #include "webrtc/video_receive_stream.h" 18 #include "webrtc/video_send_stream.h" 19 20 namespace webrtc { 21 22 class VoiceEngine; 23 24 const char* Version(); 25 26 class PacketReceiver { 27 public: 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; 36 37 protected: 38 virtual ~PacketReceiver() {} 39 }; 40 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 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 { 58 public: 59 struct Config { 60 explicit Config(newapi::Transport* send_transport) 61 : webrtc_config(NULL), 62 send_transport(send_transport), 63 voice_engine(NULL), 64 overuse_callback(NULL), 65 start_bitrate_bps(-1) {} 66 67 webrtc::Config* webrtc_config; 68 69 newapi::Transport* send_transport; 70 71 // VoiceEngine used for audio/video synchronization for this Call. 72 VoiceEngine* voice_engine; 73 74 // Callback for overuse and normal usage based on the jitter of incoming 75 // captured frames. 'NULL' disables the callback. 76 OveruseCallback* overuse_callback; 77 78 // Start bitrate used before a valid bitrate estimate is calculated. '-1' 79 // lets the call decide start bitrate. 80 // Note: This currently only affects video. 81 int start_bitrate_bps; 82 }; 83 84 static Call* Create(const Call::Config& config); 85 86 static Call* Create(const Call::Config& config, 87 const webrtc::Config& webrtc_config); 88 89 virtual VideoSendStream::Config GetDefaultSendConfig() = 0; 90 91 virtual VideoSendStream* CreateVideoSendStream( 92 const VideoSendStream::Config& config, 93 const std::vector<VideoStream>& video_streams, 94 const void* encoder_settings) = 0; 95 96 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0; 97 98 virtual VideoReceiveStream::Config GetDefaultReceiveConfig() = 0; 99 100 virtual VideoReceiveStream* CreateVideoReceiveStream( 101 const VideoReceiveStream::Config& config) = 0; 102 virtual void DestroyVideoReceiveStream( 103 VideoReceiveStream* receive_stream) = 0; 104 105 // All received RTP and RTCP packets for the call should be inserted to this 106 // PacketReceiver. The PacketReceiver pointer is valid as long as the 107 // Call instance exists. 108 virtual PacketReceiver* Receiver() = 0; 109 110 // Returns the estimated total send bandwidth. Note: this can differ from the 111 // actual encoded bitrate. 112 virtual uint32_t SendBitrateEstimate() = 0; 113 114 // Returns the total estimated receive bandwidth for the call. Note: this can 115 // differ from the actual receive bitrate. 116 virtual uint32_t ReceiveBitrateEstimate() = 0; 117 118 virtual ~Call() {} 119 }; 120 } // namespace webrtc 121 122 #endif // WEBRTC_CALL_H_ 123