| OLD | NEW | 
|---|
| 1 /* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 
| 2 * | 2 * | 
| 3 *  Use of this source code is governed by a BSD-style license | 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 | 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 | 5 *  tree. An additional intellectual property rights grant can be found | 
| 6 *  in the file PATENTS.  All contributing project authors may | 6 *  in the file PATENTS.  All contributing project authors may | 
| 7 *  be found in the AUTHORS file in the root of the source tree. | 7 *  be found in the AUTHORS file in the root of the source tree. | 
| 8 */ | 8 */ | 
| 9 /* | 9 /* | 
| 10 * This file defines the interface for doing temporal layers with VP8. | 10 * This file defines the interface for doing temporal layers with VP8. | 
| 11 */ | 11 */ | 
| 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 
| 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 
| 14 | 14 | 
| 15 #include "vpx/vpx_encoder.h" | 15 #include <vector> | 
| 16 | 16 | 
| 17 #include "webrtc/common_video/include/video_image.h" | 17 #include "webrtc/common_video/include/video_image.h" | 
| 18 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" | 
| 19 | 19 | 
|  | 20 struct vpx_codec_enc_cfg; | 
|  | 21 typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t; | 
|  | 22 | 
| 20 namespace webrtc { | 23 namespace webrtc { | 
| 21 | 24 | 
| 22 struct CodecSpecificInfoVP8; | 25 struct CodecSpecificInfoVP8; | 
| 23 | 26 | 
| 24 class TemporalLayers { | 27 class TemporalLayers { | 
| 25  public: | 28  public: | 
| 26   // Factory for TemporalLayer strategy. Default behaviour is a fixed pattern | 29   // Factory for TemporalLayer strategy. Default behavior is a fixed pattern | 
| 27   // of temporal layers. See default_temporal_layers.cc | 30   // of temporal layers. See default_temporal_layers.cc | 
| 28   virtual ~TemporalLayers() {} | 31   virtual ~TemporalLayers() {} | 
| 29 | 32 | 
| 30   // Returns the recommended VP8 encode flags needed. May refresh the decoder | 33   // Returns the recommended VP8 encode flags needed. May refresh the decoder | 
| 31   // and/or update the reference buffers. | 34   // and/or update the reference buffers. | 
| 32   virtual int EncodeFlags(uint32_t timestamp) = 0; | 35   virtual int EncodeFlags(uint32_t timestamp) = 0; | 
| 33 | 36 | 
| 34   virtual bool ConfigureBitrates(int bitrate_kbit, | 37   // Update state based on new bitrate target and incoming framerate. | 
| 35                                  int max_bitrate_kbit, | 38   // Returns the bitrate allocation for the active temporal layers. | 
| 36                                  int framerate, | 39   virtual std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, | 
| 37                                  vpx_codec_enc_cfg_t* cfg) = 0; | 40                                                int max_bitrate_kbps, | 
|  | 41                                                int framerate) = 0; | 
|  | 42 | 
|  | 43   // Update the encoder configuration with target bitrates or other parameters. | 
|  | 44   // Returns true iff the configuration was actually modified. | 
|  | 45   virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; | 
| 38 | 46 | 
| 39   virtual void PopulateCodecSpecific(bool base_layer_sync, | 47   virtual void PopulateCodecSpecific(bool base_layer_sync, | 
| 40                                      CodecSpecificInfoVP8* vp8_info, | 48                                      CodecSpecificInfoVP8* vp8_info, | 
| 41                                      uint32_t timestamp) = 0; | 49                                      uint32_t timestamp) = 0; | 
| 42 | 50 | 
| 43   virtual void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) = 0; | 51   virtual void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) = 0; | 
| 44 | 52 | 
| 45   virtual int CurrentLayerId() const = 0; | 53   virtual int CurrentLayerId() const = 0; | 
| 46 |  | 
| 47   virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; |  | 
| 48 }; | 54 }; | 
| 49 | 55 | 
|  | 56 class TemporalLayersListener; | 
| 50 class TemporalLayersFactory { | 57 class TemporalLayersFactory { | 
| 51  public: | 58  public: | 
|  | 59   TemporalLayersFactory() : listener_(nullptr) {} | 
| 52   virtual ~TemporalLayersFactory() {} | 60   virtual ~TemporalLayersFactory() {} | 
| 53   virtual TemporalLayers* Create(int temporal_layers, | 61   virtual TemporalLayers* Create(int simulcast_id, | 
|  | 62                                  int temporal_layers, | 
| 54                                  uint8_t initial_tl0_pic_idx) const; | 63                                  uint8_t initial_tl0_pic_idx) const; | 
|  | 64   void SetListener(TemporalLayersListener* listener); | 
|  | 65 | 
|  | 66  protected: | 
|  | 67   TemporalLayersListener* listener_; | 
|  | 68 }; | 
|  | 69 | 
|  | 70 class ScreenshareTemporalLayersFactory : public webrtc::TemporalLayersFactory { | 
|  | 71  public: | 
|  | 72   ScreenshareTemporalLayersFactory() {} | 
|  | 73   virtual ~ScreenshareTemporalLayersFactory() {} | 
|  | 74 | 
|  | 75   webrtc::TemporalLayers* Create(int simulcast_id, | 
|  | 76                                  int num_temporal_layers, | 
|  | 77                                  uint8_t initial_tl0_pic_idx) const override; | 
| 55 }; | 78 }; | 
| 56 | 79 | 
| 57 // Factory for a temporal layers strategy that adaptively changes the number of | 80 // Factory for a temporal layers strategy that adaptively changes the number of | 
| 58 // layers based on input framerate so that the base layer has an acceptable | 81 // layers based on input frame rate so that the base layer has an acceptable | 
| 59 // framerate. See realtime_temporal_layers.cc | 82 // frame rate. See realtime_temporal_layers.cc | 
| 60 class RealTimeTemporalLayersFactory : public TemporalLayersFactory { | 83 class RealTimeTemporalLayersFactory : public TemporalLayersFactory { | 
| 61  public: | 84  public: | 
|  | 85   RealTimeTemporalLayersFactory() {} | 
| 62   ~RealTimeTemporalLayersFactory() override {} | 86   ~RealTimeTemporalLayersFactory() override {} | 
| 63   TemporalLayers* Create(int num_temporal_layers, | 87   TemporalLayers* Create(int simulcast_id, | 
|  | 88                          int num_temporal_layers, | 
| 64                          uint8_t initial_tl0_pic_idx) const override; | 89                          uint8_t initial_tl0_pic_idx) const override; | 
| 65 }; | 90 }; | 
| 66 | 91 | 
|  | 92 class TemporalLayersListener { | 
|  | 93  public: | 
|  | 94   TemporalLayersListener() {} | 
|  | 95   virtual ~TemporalLayersListener() {} | 
|  | 96 | 
|  | 97   virtual void OnTemporalLayersCreated(int simulcast_id, | 
|  | 98                                        TemporalLayers* layers) = 0; | 
|  | 99 }; | 
|  | 100 | 
| 67 }  // namespace webrtc | 101 }  // namespace webrtc | 
| 68 #endif  // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 102 #endif  // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 
| OLD | NEW | 
|---|