OLD | NEW |
1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2013 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 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ | 9 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ |
10 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ | 10 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ |
11 | 11 |
12 #include <list> | 12 #include <list> |
13 | 13 |
14 #include "vpx/vpx_encoder.h" | 14 #include "vpx/vpx_encoder.h" |
15 | 15 |
16 #include "webrtc/base/timeutils.h" | 16 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
18 #include "webrtc/modules/video_coding/utility/frame_dropper.h" | 18 #include "webrtc/modules/video_coding/utility/frame_dropper.h" |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 struct CodecSpecificInfoVP8; | 23 struct CodecSpecificInfoVP8; |
| 24 class Clock; |
24 | 25 |
25 class ScreenshareLayers : public TemporalLayers { | 26 class ScreenshareLayers : public TemporalLayers { |
26 public: | 27 public: |
27 static const double kMaxTL0FpsReduction; | 28 static const double kMaxTL0FpsReduction; |
28 static const double kAcceptableTargetOvershoot; | 29 static const double kAcceptableTargetOvershoot; |
29 static const int kTl0Flags; | 30 static const int kTl0Flags; |
30 static const int kTl1Flags; | 31 static const int kTl1Flags; |
31 static const int kTl1SyncFlags; | 32 static const int kTl1SyncFlags; |
32 | 33 |
33 ScreenshareLayers(int num_temporal_layers, uint8_t initial_tl0_pic_idx); | 34 ScreenshareLayers(int num_temporal_layers, |
34 virtual ~ScreenshareLayers() {} | 35 uint8_t initial_tl0_pic_idx, |
| 36 Clock* clock); |
| 37 virtual ~ScreenshareLayers(); |
35 | 38 |
36 // Returns the recommended VP8 encode flags needed. May refresh the decoder | 39 // Returns the recommended VP8 encode flags needed. May refresh the decoder |
37 // and/or update the reference buffers. | 40 // and/or update the reference buffers. |
38 int EncodeFlags(uint32_t timestamp) override; | 41 int EncodeFlags(uint32_t timestamp) override; |
39 | 42 |
40 bool ConfigureBitrates(int bitrate_kbps, | 43 bool ConfigureBitrates(int bitrate_kbps, |
41 int max_bitrate_kbps, | 44 int max_bitrate_kbps, |
42 int framerate, | 45 int framerate, |
43 vpx_codec_enc_cfg_t* cfg) override; | 46 vpx_codec_enc_cfg_t* cfg) override; |
44 | 47 |
45 void PopulateCodecSpecific(bool base_layer_sync, | 48 void PopulateCodecSpecific(bool base_layer_sync, |
46 CodecSpecificInfoVP8* vp8_info, | 49 CodecSpecificInfoVP8* vp8_info, |
47 uint32_t timestamp) override; | 50 uint32_t timestamp) override; |
48 | 51 |
49 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override; | 52 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override; |
50 | 53 |
51 int CurrentLayerId() const override; | 54 int CurrentLayerId() const override; |
52 | 55 |
53 // Allows the layers adapter to update the encoder configuration prior to a | 56 // Allows the layers adapter to update the encoder configuration prior to a |
54 // frame being encoded. Return true if the configuration should be updated | 57 // frame being encoded. Return true if the configuration should be updated |
55 // and false if now change is needed. | 58 // and false if now change is needed. |
56 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; | 59 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; |
57 | 60 |
58 private: | 61 private: |
59 bool TimeToSync(int64_t timestamp) const; | 62 bool TimeToSync(int64_t timestamp) const; |
60 | 63 |
| 64 Clock* const clock_; |
| 65 |
61 int number_of_temporal_layers_; | 66 int number_of_temporal_layers_; |
62 bool last_base_layer_sync_; | 67 bool last_base_layer_sync_; |
63 uint8_t tl0_pic_idx_; | 68 uint8_t tl0_pic_idx_; |
64 int active_layer_; | 69 int active_layer_; |
65 int64_t last_timestamp_; | 70 int64_t last_timestamp_; |
66 int64_t last_sync_timestamp_; | 71 int64_t last_sync_timestamp_; |
67 rtc::TimestampWrapAroundHandler time_wrap_handler_; | 72 rtc::TimestampWrapAroundHandler time_wrap_handler_; |
68 int min_qp_; | 73 int min_qp_; |
69 int max_qp_; | 74 int max_qp_; |
70 uint32_t max_debt_bytes_; | 75 uint32_t max_debt_bytes_; |
(...skipping 15 matching lines...) Expand all Loading... |
86 kQualityBoost, | 91 kQualityBoost, |
87 } state; | 92 } state; |
88 | 93 |
89 int enhanced_max_qp; | 94 int enhanced_max_qp; |
90 int last_qp; | 95 int last_qp; |
91 uint32_t debt_bytes_; | 96 uint32_t debt_bytes_; |
92 uint32_t target_rate_kbps_; | 97 uint32_t target_rate_kbps_; |
93 | 98 |
94 void UpdateDebt(int64_t delta_ms); | 99 void UpdateDebt(int64_t delta_ms); |
95 } layers_[kMaxNumTemporalLayers]; | 100 } layers_[kMaxNumTemporalLayers]; |
| 101 |
| 102 void UpdateHistograms(); |
| 103 // Data for histogram statistics. |
| 104 struct Stats { |
| 105 int64_t first_framt_time_ms_ = -1; |
| 106 int64_t num_tl0_frames_ = 0; |
| 107 int64_t num_tl1_frames_ = 0; |
| 108 int64_t num_dropped_frames_ = 0; |
| 109 int64_t num_overshoots_ = 0; |
| 110 int64_t tl0_qp_sum_ = 0; |
| 111 int64_t tl1_qp_sum_ = 0; |
| 112 int64_t tl0_target_bitrate_sum_ = 0; |
| 113 int64_t tl1_target_bitrate_sum_ = 0; |
| 114 } stats_; |
96 }; | 115 }; |
97 } // namespace webrtc | 116 } // namespace webrtc |
98 | 117 |
99 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ | 118 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ |
OLD | NEW |