1/* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
2*
3*  Use of this source code is governed by a BSD-style license
4*  that can be found in the LICENSE file in the root of the source
5*  tree. An additional intellectual property rights grant can be found
6*  in the file PATENTS.  All contributing project authors may
7*  be found in the AUTHORS file in the root of the source tree.
8*/
9/*
10* This file defines the interface for doing temporal layers with VP8.
11*/
12#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_
13#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_
14
15#include "webrtc/common_video/interface/video_image.h"
16#include "webrtc/typedefs.h"
17
18// libvpx forward declaration.
19typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t;
20
21namespace webrtc {
22
23struct CodecSpecificInfoVP8;
24
25class TemporalLayers {
26 public:
27  // Factory for TemporalLayer strategy. Default behaviour is a fixed pattern
28  // of temporal layers. See default_temporal_layers.cc
29  struct Factory {
30    Factory() {}
31    virtual ~Factory() {}
32    virtual TemporalLayers* Create(int temporal_layers,
33                                   uint8_t initial_tl0_pic_idx) const;
34  };
35
36  virtual ~TemporalLayers() {}
37
38  // Returns the recommended VP8 encode flags needed. May refresh the decoder
39  // and/or update the reference buffers.
40  virtual int EncodeFlags(uint32_t timestamp) = 0;
41
42  virtual bool ConfigureBitrates(int bitrate_kbit,
43                                 int max_bitrate_kbit,
44                                 int framerate,
45                                 vpx_codec_enc_cfg_t* cfg) = 0;
46
47  virtual void PopulateCodecSpecific(bool base_layer_sync,
48                                     CodecSpecificInfoVP8* vp8_info,
49                                     uint32_t timestamp) = 0;
50
51  virtual void FrameEncoded(unsigned int size, uint32_t timestamp) = 0;
52
53  virtual int CurrentLayerId() const = 0;
54};
55
56// Factory for a temporal layers strategy that adaptively changes the number of
57// layers based on input framerate so that the base layer has an acceptable
58// framerate. See realtime_temporal_layers.cc
59struct RealTimeTemporalLayersFactory : TemporalLayers::Factory {
60  virtual ~RealTimeTemporalLayersFactory() {}
61  virtual TemporalLayers* Create(int num_temporal_layers,
62                                 uint8_t initial_tl0_pic_idx) const;
63};
64
65}  // namespace webrtc
66#endif  // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_
67