blob: fa2582fa2764c2c9e0ff3261b1f65516015bee67 [file] [log] [blame]
Erik Språng08127a92016-11-16 16:41:30 +01001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_
12#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_
Erik Språng08127a92016-11-16 16:41:30 +010013
14#include <memory>
15#include <string>
16#include <vector>
17
Niels Möller259a4972018-04-05 15:36:51 +020018#include "call/video_config.h"
Erik Språng08127a92016-11-16 16:41:30 +010019
20namespace webrtc {
21
Erik Språng08127a92016-11-16 16:41:30 +010022class VideoBitrateAllocator;
23class VideoCodec;
24class VideoEncoderConfig;
25
26class VideoCodecInitializer {
27 public:
Niels Möllerb46d1b82018-04-06 13:07:01 +020028 // Takes a VideoEncoderConfig and the VideoStream configuration and
29 // translates them into the old school VideoCodec type.
Erik Språng08127a92016-11-16 16:41:30 +010030 // 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ång08127a92016-11-16 16:41:30 +010036 const std::vector<VideoStream>& streams,
37 VideoCodec* codec,
38 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator);
39
Niels Möllerf1338562018-04-26 09:51:47 +020040 // TODO(nisse): Deprecated, delete as soon as downstream projects are
41 // updated.
42 static bool SetupCodec(
43 const VideoEncoderConfig& config,
44 const std::vector<VideoStream>& streams,
45 bool /* nack_enabled */,
46 VideoCodec* codec,
47 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
48 return SetupCodec(config, streams, codec, bitrate_allocator);
49 }
50
Niels Möller24697ab2018-04-09 10:54:50 +020051 // Create a bitrate allocator for the specified codec.
Erik Språng08127a92016-11-16 16:41:30 +010052 static std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
Erik Språng82fad3d2018-03-21 09:57:23 +010053 const VideoCodec& codec);
Erik Språng08127a92016-11-16 16:41:30 +010054
55 private:
56 static VideoCodec VideoEncoderConfigToVideoCodec(
57 const VideoEncoderConfig& config,
Niels Möllerf1338562018-04-26 09:51:47 +020058 const std::vector<VideoStream>& streams);
Erik Språng08127a92016-11-16 16:41:30 +010059};
60
61} // namespace webrtc
62
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020063#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_