blob: 498cb3db9081fe18cf0ed4eeb4c82359c9548fd3 [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>
Niels Möller04dd1762018-03-23 16:05:22 +010016#include <utility>
Erik Språng08127a92016-11-16 16:41:30 +010017#include <vector>
18
Niels Möller04dd1762018-03-23 16:05:22 +010019#include "call/video_config.h"
Niels Moller92be1ca2018-03-21 13:53:41 +000020#include "call/video_send_stream.h"
Erik Språng08127a92016-11-16 16:41:30 +010021
22namespace webrtc {
23
Erik Språng08127a92016-11-16 16:41:30 +010024class VideoBitrateAllocator;
25class VideoCodec;
26class VideoEncoderConfig;
27
28class 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ång08127a92016-11-16 16:41:30 +010038 const std::vector<VideoStream>& streams,
asapersson5f7226f2016-11-25 04:37:00 -080039 bool nack_enabled,
Erik Språng08127a92016-11-16 16:41:30 +010040 VideoCodec* codec,
41 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator);
42
Niels Möller04dd1762018-03-23 16:05:22 +010043 // 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ång08127a92016-11-16 16:41:30 +010057 // 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ång82fad3d2018-03-21 09:57:23 +010061 const VideoCodec& codec);
Erik Språng08127a92016-11-16 16:41:30 +010062
63 private:
64 static VideoCodec VideoEncoderConfigToVideoCodec(
65 const VideoEncoderConfig& config,
66 const std::vector<VideoStream>& streams,
asapersson5f7226f2016-11-25 04:37:00 -080067 bool nack_enabled);
Erik Språng08127a92016-11-16 16:41:30 +010068};
69
70} // namespace webrtc
71
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020072#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INITIALIZER_H_