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> |
| 16 | #include <vector> |
| 17 | |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 18 | #include "call/video_config.h" |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 22 | class VideoBitrateAllocator; |
| 23 | class VideoCodec; |
| 24 | class VideoEncoderConfig; |
| 25 | |
| 26 | class VideoCodecInitializer { |
| 27 | public: |
Niels Möller | b46d1b8 | 2018-04-06 13:07:01 +0200 | [diff] [blame] | 28 | // Takes a VideoEncoderConfig and the VideoStream configuration and |
| 29 | // translates them into the old school VideoCodec type. |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 30 | // It also creates a VideoBitrateAllocator instance, suitable for the codec |
| 31 | // type used. For instance, VP8 will create an allocator than can handle |
| 32 | // simulcast and temporal layering. |
| 33 | // GetBitrateAllocator is called implicitly from here, no need to call again. |
| 34 | static bool SetupCodec( |
| 35 | const VideoEncoderConfig& config, |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 36 | const std::vector<VideoStream>& streams, |
asapersson | 5f7226f | 2016-11-25 04:37:00 -0800 | [diff] [blame] | 37 | bool nack_enabled, |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 38 | VideoCodec* codec, |
| 39 | std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator); |
| 40 | |
| 41 | // Create a bitrate allocator for the specified codec. |tl_factory| is |
| 42 | // optional, if it is populated, ownership of that instance will be |
| 43 | // transferred to the VideoBitrateAllocator instance. |
| 44 | static std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator( |
Erik Språng | 82fad3d | 2018-03-21 09:57:23 +0100 | [diff] [blame] | 45 | const VideoCodec& codec); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 46 | |
| 47 | private: |
| 48 | static VideoCodec VideoEncoderConfigToVideoCodec( |
| 49 | const VideoEncoderConfig& config, |
| 50 | const std::vector<VideoStream>& streams, |
asapersson | 5f7226f | 2016-11-25 04:37:00 -0800 | [diff] [blame] | 51 | bool nack_enabled); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace webrtc |
| 55 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 56 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_ |