blob: 4a7eecaba49f84d870a46c79b146acc955b7a011 [file] [log] [blame]
buildbot@webrtc.orga8530772014-12-10 09:01:18 +00001/*
2 * libjingle
3 * Copyright 2014 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef TALK_MEDIA_WEBRTC_SIMULCAST_H_
28#define TALK_MEDIA_WEBRTC_SIMULCAST_H_
29
30#include <vector>
31
32#include "webrtc/base/basictypes.h"
33#include "webrtc/config.h"
34
35namespace webrtc {
36struct VideoCodec;
37}
38
39namespace cricket {
40struct VideoOptions;
41struct StreamParams;
42
43enum SimulcastBitrateMode {
44 SBM_NORMAL = 0,
45 SBM_HIGH,
46 SBM_VERY_HIGH,
47 SBM_COUNT
48};
49
sprang@webrtc.org46d4d292014-12-23 15:19:35 +000050// Config for use with screen cast when temporal layers are enabled.
51struct ScreenshareLayerConfig {
52 public:
53 ScreenshareLayerConfig(int tl0_bitrate, int tl1_bitrate);
54
55 // Bitrates, for temporal layers 0 and 1.
56 int tl0_bitrate_kbps;
57 int tl1_bitrate_kbps;
58
59 static ScreenshareLayerConfig GetDefault();
60
61 // Parse bitrate from group name on format "(tl0_bitrate)-(tl1_bitrate)",
62 // eg. "100-1000" for the default rates.
63 static bool FromFieldTrialGroup(const std::string& group,
64 ScreenshareLayerConfig* config);
65};
66
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000067// TODO(pthatcher): Write unit tests just for these functions,
68// independent of WebrtcVideoEngine.
69
70// Get the simulcast bitrate mode to use based on
71// options.video_highest_bitrate.
72SimulcastBitrateMode GetSimulcastBitrateMode(
73 const VideoOptions& options);
74
75// Get the ssrcs of the SIM group from the stream params.
76void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32>* ssrcs);
77
78// Get simulcast settings.
79std::vector<webrtc::VideoStream> GetSimulcastConfig(
80 size_t max_streams,
81 SimulcastBitrateMode bitrate_mode,
82 int width,
83 int height,
84 int min_bitrate_bps,
85 int max_bitrate_bps,
86 int max_qp,
87 int max_framerate);
88
89// Set the codec->simulcastStreams, codec->width, and codec->height
90// based on the number of ssrcs to use and the bitrate mode to use.
91bool ConfigureSimulcastCodec(int number_ssrcs,
92 SimulcastBitrateMode bitrate_mode,
93 webrtc::VideoCodec* codec);
94
95// Set the codec->simulcastStreams, codec->width, and codec->height
96// based on the video options (to get the simulcast bitrate mode) and
97// the stream params (to get the number of ssrcs). This is really a
98// convenience function.
99bool ConfigureSimulcastCodec(const StreamParams& sp,
100 const VideoOptions& options,
101 webrtc::VideoCodec* codec);
102
103// Set the numberOfTemporalLayers in each codec->simulcastStreams[i].
104// Apparently it is useful to do this at a different time than
105// ConfigureSimulcastCodec.
106// TODO(pthatcher): Figure out why and put this code into
107// ConfigureSimulcastCodec.
108void ConfigureSimulcastTemporalLayers(
109 int num_temporal_layers, webrtc::VideoCodec* codec);
110
111// Turn off all simulcasting for the given codec.
112void DisableSimulcastCodec(webrtc::VideoCodec* codec);
113
114// Log useful info about each of the simulcast substreams of the
115// codec.
116void LogSimulcastSubstreams(const webrtc::VideoCodec& codec);
117
118// Configure the codec's bitrate and temporal layers so that it's good
119// for a screencast in conference mode. Technically, this shouldn't
120// go in simulcast.cc. But it's closely related.
121void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec);
122
123} // namespace cricket
124
125#endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_