blob: 1b95c298890ab320c751a2c749d8ac2a91d9b5ca [file] [log] [blame]
mflodman@webrtc.org06e80262013-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.org5e0cbcf2013-12-18 09:46:22 +000010#ifndef WEBRTC_CALL_H_
11#define WEBRTC_CALL_H_
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000012
13#include <string>
14#include <vector>
15
16#include "webrtc/common_types.h"
pbos@webrtc.org24e20892013-10-28 16:32:01 +000017#include "webrtc/video_receive_stream.h"
18#include "webrtc/video_send_stream.h"
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000019
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000020namespace webrtc {
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000021
22class VoiceEngine;
23
24const char* Version();
25
26class PacketReceiver {
27 public:
pbos@webrtc.org78ab5112013-08-05 12:49:22 +000028 virtual bool DeliverPacket(const uint8_t* packet, size_t length) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000029
30 protected:
31 virtual ~PacketReceiver() {}
32};
33
asapersson@webrtc.org8ef65482014-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.orgbf6d5722013-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.org06e80262013-04-18 12:02:52 +000051 public:
mflodman@webrtc.orgbf76ae22013-07-23 11:35:00 +000052 struct Config {
pbos@webrtc.orgc1797062013-08-23 09:19:30 +000053 explicit Config(newapi::Transport* send_transport)
stefan@webrtc.org47f0c412013-12-04 10:24:26 +000054 : webrtc_config(NULL),
55 send_transport(send_transport),
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +000056 voice_engine(NULL),
57 trace_callback(NULL),
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +000058 trace_filter(kTraceDefault),
59 overuse_callback(NULL) {}
mflodman@webrtc.orgbf76ae22013-07-23 11:35:00 +000060
stefan@webrtc.org47f0c412013-12-04 10:24:26 +000061 webrtc::Config* webrtc_config;
62
pbos@webrtc.orgc1797062013-08-23 09:19:30 +000063 newapi::Transport* send_transport;
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +000064
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +000065 // VoiceEngine used for audio/video synchronization for this Call.
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +000066 VoiceEngine* voice_engine;
67
68 TraceCallback* trace_callback;
69 uint32_t trace_filter;
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +000070
71 // Callback for overuse and normal usage based on the jitter of incoming
72 // captured frames. 'NULL' disables the callback.
73 OveruseCallback* overuse_callback;
mflodman@webrtc.orgbf76ae22013-07-23 11:35:00 +000074 };
75
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +000076 static Call* Create(const Call::Config& config);
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +000077
stefan@webrtc.org47f0c412013-12-04 10:24:26 +000078 static Call* Create(const Call::Config& config,
79 const webrtc::Config& webrtc_config);
80
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +000081 virtual std::vector<VideoCodec> GetVideoCodecs() = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000082
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000083 virtual VideoSendStream::Config GetDefaultSendConfig() = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000084
pbos@webrtc.org964d78e2013-11-20 10:40:25 +000085 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000086 const VideoSendStream::Config& config) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000087
pbos@webrtc.org12a93e02013-11-21 13:49:43 +000088 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000089
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000090 virtual VideoReceiveStream::Config GetDefaultReceiveConfig() = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000091
pbos@webrtc.org964d78e2013-11-20 10:40:25 +000092 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000093 const VideoReceiveStream::Config& config) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43 +000094 virtual void DestroyVideoReceiveStream(
95 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000096
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.orgbf6d5722013-09-09 15:04:25 +000099 // Call instance exists.
mflodman@webrtc.org06e80262013-04-18 12:02:52 +0000100 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.orgbf6d5722013-09-09 15:04:25 +0000110 virtual ~Call() {}
mflodman@webrtc.org06e80262013-04-18 12:02:52 +0000111};
mflodman@webrtc.org06e80262013-04-18 12:02:52 +0000112} // namespace webrtc
113
mflodman@webrtc.org5e0cbcf2013-12-18 09:46:22 +0000114#endif // WEBRTC_CALL_H_