blob: 549e4049e93184556f2e5af2e7a56137303c6789 [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,
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000084 int max_bitrate_bps,
85 int max_qp,
86 int max_framerate);
87
88// Set the codec->simulcastStreams, codec->width, and codec->height
89// based on the number of ssrcs to use and the bitrate mode to use.
90bool ConfigureSimulcastCodec(int number_ssrcs,
91 SimulcastBitrateMode bitrate_mode,
92 webrtc::VideoCodec* codec);
93
94// Set the codec->simulcastStreams, codec->width, and codec->height
95// based on the video options (to get the simulcast bitrate mode) and
96// the stream params (to get the number of ssrcs). This is really a
97// convenience function.
98bool ConfigureSimulcastCodec(const StreamParams& sp,
99 const VideoOptions& options,
100 webrtc::VideoCodec* codec);
101
102// Set the numberOfTemporalLayers in each codec->simulcastStreams[i].
103// Apparently it is useful to do this at a different time than
104// ConfigureSimulcastCodec.
105// TODO(pthatcher): Figure out why and put this code into
106// ConfigureSimulcastCodec.
107void ConfigureSimulcastTemporalLayers(
108 int num_temporal_layers, webrtc::VideoCodec* codec);
109
110// Turn off all simulcasting for the given codec.
111void DisableSimulcastCodec(webrtc::VideoCodec* codec);
112
113// Log useful info about each of the simulcast substreams of the
114// codec.
115void LogSimulcastSubstreams(const webrtc::VideoCodec& codec);
116
117// Configure the codec's bitrate and temporal layers so that it's good
118// for a screencast in conference mode. Technically, this shouldn't
119// go in simulcast.cc. But it's closely related.
120void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec);
121
122} // namespace cricket
123
124#endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_