OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #ifndef TALK_MEDIA_WEBRTC_SIMULCAST_H_ | 28 #ifndef TALK_MEDIA_WEBRTC_SIMULCAST_H_ |
29 #define TALK_MEDIA_WEBRTC_SIMULCAST_H_ | 29 #define TALK_MEDIA_WEBRTC_SIMULCAST_H_ |
30 | 30 |
31 #include <vector> | 31 #include <vector> |
32 | 32 |
33 #include "webrtc/base/basictypes.h" | 33 #include "webrtc/base/basictypes.h" |
34 #include "webrtc/config.h" | 34 #include "webrtc/config.h" |
35 | 35 |
36 namespace webrtc { | |
37 struct VideoCodec; | |
38 } | |
39 | |
40 namespace cricket { | 36 namespace cricket { |
41 struct VideoOptions; | |
42 struct StreamParams; | 37 struct StreamParams; |
43 | 38 |
44 enum SimulcastBitrateMode { | |
45 SBM_NORMAL = 0, | |
46 SBM_HIGH, | |
47 SBM_VERY_HIGH, | |
48 SBM_COUNT | |
49 }; | |
50 | |
51 // Config for use with screen cast when temporal layers are enabled. | 39 // Config for use with screen cast when temporal layers are enabled. |
52 struct ScreenshareLayerConfig { | 40 struct ScreenshareLayerConfig { |
53 public: | 41 public: |
54 ScreenshareLayerConfig(int tl0_bitrate, int tl1_bitrate); | 42 ScreenshareLayerConfig(int tl0_bitrate, int tl1_bitrate); |
55 | 43 |
56 // Bitrates, for temporal layers 0 and 1. | 44 // Bitrates, for temporal layers 0 and 1. |
57 int tl0_bitrate_kbps; | 45 int tl0_bitrate_kbps; |
58 int tl1_bitrate_kbps; | 46 int tl1_bitrate_kbps; |
59 | 47 |
60 static ScreenshareLayerConfig GetDefault(); | 48 static ScreenshareLayerConfig GetDefault(); |
61 | 49 |
62 // Parse bitrate from group name on format "(tl0_bitrate)-(tl1_bitrate)", | 50 // Parse bitrate from group name on format "(tl0_bitrate)-(tl1_bitrate)", |
63 // eg. "100-1000" for the default rates. | 51 // eg. "100-1000" for the default rates. |
64 static bool FromFieldTrialGroup(const std::string& group, | 52 static bool FromFieldTrialGroup(const std::string& group, |
65 ScreenshareLayerConfig* config); | 53 ScreenshareLayerConfig* config); |
66 }; | 54 }; |
67 | 55 |
68 // TODO(pthatcher): Write unit tests just for these functions, | 56 // TODO(pthatcher): Write unit tests just for these functions, |
69 // independent of WebrtcVideoEngine. | 57 // independent of WebrtcVideoEngine. |
70 | 58 |
71 // Get the simulcast bitrate mode to use based on | 59 int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& streams); |
72 // options.video_highest_bitrate. | |
73 SimulcastBitrateMode GetSimulcastBitrateMode( | |
74 const VideoOptions& options); | |
75 | 60 |
76 // Get the ssrcs of the SIM group from the stream params. | 61 // Get the ssrcs of the SIM group from the stream params. |
77 void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs); | 62 void GetSimulcastSsrcs(const StreamParams& sp, std::vector<uint32_t>* ssrcs); |
78 | 63 |
79 // Get simulcast settings. | 64 // Get simulcast settings. |
80 std::vector<webrtc::VideoStream> GetSimulcastConfig( | 65 std::vector<webrtc::VideoStream> GetSimulcastConfig(size_t max_streams, |
81 size_t max_streams, | 66 int width, |
82 SimulcastBitrateMode bitrate_mode, | 67 int height, |
83 int width, | 68 int max_bitrate_bps, |
84 int height, | 69 int max_qp, |
85 int max_bitrate_bps, | 70 int max_framerate); |
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. | |
91 bool 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. | |
99 bool 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. | |
108 void ConfigureSimulcastTemporalLayers( | |
109 int num_temporal_layers, webrtc::VideoCodec* codec); | |
110 | |
111 // Turn off all simulcasting for the given codec. | |
112 void DisableSimulcastCodec(webrtc::VideoCodec* codec); | |
113 | |
114 // Log useful info about each of the simulcast substreams of the | |
115 // codec. | |
116 void 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. | |
121 void ConfigureConferenceModeScreencastCodec(webrtc::VideoCodec* codec); | |
122 | 71 |
123 } // namespace cricket | 72 } // namespace cricket |
124 | 73 |
125 #endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_ | 74 #endif // TALK_MEDIA_WEBRTC_SIMULCAST_H_ |
OLD | NEW |