Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_ |
| 12 | #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_ |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 16 | #include <utility> |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 19 | #include "call/video_config.h" |
Niels Moller | 92be1ca | 2018-03-21 13:53:41 +0000 | [diff] [blame] | 20 | #include "call/video_send_stream.h" |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 24 | class VideoBitrateAllocator; |
| 25 | class VideoCodec; |
| 26 | class VideoEncoderConfig; |
| 27 | |
| 28 | class VideoCodecInitializer { |
| 29 | public: |
| 30 | // Takes an EncoderSettings, a VideoEncoderConfig and the VideoStream |
| 31 | // configuration and translated them into the old school VideoCodec type. |
| 32 | // It also creates a VideoBitrateAllocator instance, suitable for the codec |
| 33 | // type used. For instance, VP8 will create an allocator than can handle |
| 34 | // simulcast and temporal layering. |
| 35 | // GetBitrateAllocator is called implicitly from here, no need to call again. |
| 36 | static bool SetupCodec( |
| 37 | const VideoEncoderConfig& config, |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 38 | const std::vector<VideoStream>& streams, |
asapersson | 5f7226f | 2016-11-25 04:37:00 -0800 | [diff] [blame] | 39 | bool nack_enabled, |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 40 | VideoCodec* codec, |
| 41 | std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator); |
| 42 | |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 43 | // TODO(nisse): Deprecated version, with an additional ignored argument. |
| 44 | // Delete as soon as downstream users are updated, together with above |
| 45 | // includes of "call/video_send_stream.h" and <utility>. |
| 46 | static bool SetupCodec( |
| 47 | const VideoEncoderConfig& config, |
| 48 | const VideoSendStream::Config::EncoderSettings /* settings */, |
| 49 | const std::vector<VideoStream>& streams, |
| 50 | bool nack_enabled, |
| 51 | VideoCodec* codec, |
| 52 | std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { |
| 53 | return SetupCodec(config, streams, nack_enabled, codec, |
| 54 | std::move(bitrate_allocator)); |
| 55 | } |
| 56 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 57 | // Create a bitrate allocator for the specified codec. |tl_factory| is |
| 58 | // optional, if it is populated, ownership of that instance will be |
| 59 | // transferred to the VideoBitrateAllocator instance. |
| 60 | static std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator( |
Erik Språng | 82fad3d | 2018-03-21 09:57:23 +0100 | [diff] [blame] | 61 | const VideoCodec& codec); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | static VideoCodec VideoEncoderConfigToVideoCodec( |
| 65 | const VideoEncoderConfig& config, |
| 66 | const std::vector<VideoStream>& streams, |
asapersson | 5f7226f | 2016-11-25 04:37:00 -0800 | [diff] [blame] | 67 | bool nack_enabled); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace webrtc |
| 71 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 72 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_ |