blob: be8097369f190d1f85be629426581a0d987fae7e [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
50// TODO(pthatcher): Write unit tests just for these functions,
51// independent of WebrtcVideoEngine.
52
53// Get the simulcast bitrate mode to use based on
54// options.video_highest_bitrate.
55SimulcastBitrateMode GetSimulcastBitrateMode(
56 const VideoOptions& options);
57
58// Get the ssrcs of the SIM group from the stream params.
59void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32>* ssrcs);
60
61// Get simulcast settings.
62std::vector<webrtc::VideoStream> GetSimulcastConfig(
63 size_t max_streams,
64 SimulcastBitrateMode bitrate_mode,
65 int width,
66 int height,
67 int min_bitrate_bps,
68 int max_bitrate_bps,
69 int max_qp,
70 int max_framerate);
71
72// Set the codec->simulcastStreams, codec->width, and codec->height
73// based on the number of ssrcs to use and the bitrate mode to use.
74bool ConfigureSimulcastCodec(int number_ssrcs,
75 SimulcastBitrateMode bitrate_mode,
76 webrtc::VideoCodec* codec);
77
78// Set the codec->simulcastStreams, codec->width, and codec->height
79// based on the video options (to get the simulcast bitrate mode) and
80// the stream params (to get the number of ssrcs). This is really a
81// convenience function.
82bool ConfigureSimulcastCodec(const StreamParams& sp,
83 const VideoOptions& options,
84 webrtc::VideoCodec* codec);
85
86// Set the numberOfTemporalLayers in each codec->simulcastStreams[i].
87// Apparently it is useful to do this at a different time than
88// ConfigureSimulcastCodec.
89// TODO(pthatcher): Figure out why and put this code into
90// ConfigureSimulcastCodec.
91void ConfigureSimulcastTemporalLayers(
92 int num_temporal_layers, webrtc::VideoCodec* codec);
93
94// Turn off all simulcasting for the given codec.
95void DisableSimulcastCodec(webrtc::VideoCodec* codec);
96
97// Log useful info about each of the simulcast substreams of the
98// codec.
99void LogSimulcastSubstreams(const webrtc::VideoCodec& codec);
100
101// Configure the codec's bitrate and temporal layers so that it's good
102// for a screencast in conference mode. Technically, this shouldn't
103// go in simulcast.cc. But it's closely related.
104void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec);
105
106} // namespace cricket
107
108#endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_