blob: 0f238733da56b4b75944ac9edd052d4cd68e6888 [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 */
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +000027
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000028#ifndef TALK_MEDIA_WEBRTC_SIMULCAST_H_
29#define TALK_MEDIA_WEBRTC_SIMULCAST_H_
30
31#include <vector>
32
33#include "webrtc/base/basictypes.h"
34#include "webrtc/config.h"
35
36namespace webrtc {
37struct VideoCodec;
38}
39
40namespace cricket {
41struct VideoOptions;
42struct StreamParams;
43
44enum SimulcastBitrateMode {
45 SBM_NORMAL = 0,
46 SBM_HIGH,
47 SBM_VERY_HIGH,
48 SBM_COUNT
49};
50
sprang@webrtc.org46d4d292014-12-23 15:19:35 +000051// Config for use with screen cast when temporal layers are enabled.
52struct ScreenshareLayerConfig {
53 public:
54 ScreenshareLayerConfig(int tl0_bitrate, int tl1_bitrate);
55
56 // Bitrates, for temporal layers 0 and 1.
57 int tl0_bitrate_kbps;
58 int tl1_bitrate_kbps;
59
60 static ScreenshareLayerConfig GetDefault();
61
62 // Parse bitrate from group name on format "(tl0_bitrate)-(tl1_bitrate)",
63 // eg. "100-1000" for the default rates.
64 static bool FromFieldTrialGroup(const std::string& group,
65 ScreenshareLayerConfig* config);
66};
67
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000068// TODO(pthatcher): Write unit tests just for these functions,
69// independent of WebrtcVideoEngine.
70
71// Get the simulcast bitrate mode to use based on
72// options.video_highest_bitrate.
73SimulcastBitrateMode GetSimulcastBitrateMode(
74 const VideoOptions& options);
75
76// Get the ssrcs of the SIM group from the stream params.
Peter Boström0c4e06b2015-10-07 12:23:21 +020077void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs);
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000078
79// Get simulcast settings.
80std::vector<webrtc::VideoStream> GetSimulcastConfig(
81 size_t max_streams,
82 SimulcastBitrateMode bitrate_mode,
83 int width,
84 int height,
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000085 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_