blob: 932770d4d9d99246bd6a43fa72aa9ac9b67f2d7f [file] [log] [blame]
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +00001/*
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.org2a4595a2013-12-18 09:46:22 +000010#ifndef WEBRTC_CALL_H_
11#define WEBRTC_CALL_H_
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000012
13#include <string>
14#include <vector>
15
16#include "webrtc/common_types.h"
pbos@webrtc.orgb581c902013-10-28 16:32:01 +000017#include "webrtc/video_receive_stream.h"
18#include "webrtc/video_send_stream.h"
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000019
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000020namespace webrtc {
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000021
22class VoiceEngine;
23
24const char* Version();
25
26class PacketReceiver {
27 public:
pbos@webrtc.org2c00af72013-08-05 12:49:22 +000028 virtual bool DeliverPacket(const uint8_t* packet, size_t length) = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000029
30 protected:
31 virtual ~PacketReceiver() {}
32};
33
asapersson@webrtc.org4b1817f2014-01-31 10:05:07 +000034// Callback interface for reporting when a system overuse is detected.
35// The detection is based on the jitter of incoming captured frames.
36class 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.orgfdc43522013-09-09 15:04:25 +000047// 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.
50class Call {
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000051 public:
mflodman@webrtc.orgecbeb2b2013-07-23 11:35:00 +000052 struct Config {
pbos@webrtc.orgd8e92c92013-08-23 09:19:30 +000053 explicit Config(newapi::Transport* send_transport)
stefan@webrtc.orgda3ae7c2013-12-04 10:24:26 +000054 : webrtc_config(NULL),
55 send_transport(send_transport),
pbos@webrtc.org297e5ed2013-08-14 13:52:52 +000056 voice_engine(NULL),
asapersson@webrtc.org4b1817f2014-01-31 10:05:07 +000057 overuse_callback(NULL) {}
mflodman@webrtc.orgecbeb2b2013-07-23 11:35:00 +000058
stefan@webrtc.orgda3ae7c2013-12-04 10:24:26 +000059 webrtc::Config* webrtc_config;
60
pbos@webrtc.orgd8e92c92013-08-23 09:19:30 +000061 newapi::Transport* send_transport;
pbos@webrtc.org297e5ed2013-08-14 13:52:52 +000062
pbos@webrtc.orgfdc43522013-09-09 15:04:25 +000063 // VoiceEngine used for audio/video synchronization for this Call.
pbos@webrtc.org297e5ed2013-08-14 13:52:52 +000064 VoiceEngine* voice_engine;
65
asapersson@webrtc.org4b1817f2014-01-31 10:05:07 +000066 // 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.orgecbeb2b2013-07-23 11:35:00 +000069 };
70
pbos@webrtc.orgfdc43522013-09-09 15:04:25 +000071 static Call* Create(const Call::Config& config);
pbos@webrtc.org297e5ed2013-08-14 13:52:52 +000072
stefan@webrtc.orgda3ae7c2013-12-04 10:24:26 +000073 static Call* Create(const Call::Config& config,
74 const webrtc::Config& webrtc_config);
75
pbos@webrtc.org2c343fc2013-06-05 11:33:21 +000076 virtual VideoSendStream::Config GetDefaultSendConfig() = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000077
pbos@webrtc.org162021c2013-11-20 10:40:25 +000078 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.org2c343fc2013-06-05 11:33:21 +000079 const VideoSendStream::Config& config) = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000080
pbos@webrtc.orgf8486d02013-11-21 13:49:43 +000081 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000082
pbos@webrtc.org2c343fc2013-06-05 11:33:21 +000083 virtual VideoReceiveStream::Config GetDefaultReceiveConfig() = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000084
pbos@webrtc.org162021c2013-11-20 10:40:25 +000085 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org2c343fc2013-06-05 11:33:21 +000086 const VideoReceiveStream::Config& config) = 0;
pbos@webrtc.orgf8486d02013-11-21 13:49:43 +000087 virtual void DestroyVideoReceiveStream(
88 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000089
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.orgfdc43522013-09-09 15:04:25 +000092 // Call instance exists.
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +000093 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.orgfdc43522013-09-09 15:04:25 +0000103 virtual ~Call() {}
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +0000104};
mflodman@webrtc.org69b0d2c2013-04-18 12:02:52 +0000105} // namespace webrtc
106
mflodman@webrtc.org2a4595a2013-12-18 09:46:22 +0000107#endif // WEBRTC_CALL_H_