 Chromium Code Reviews
 Chromium Code Reviews Issue 1993113003:
  Refactor how padding is calculated.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1993113003:
  Refactor how padding is calculated.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 
| 3 * | 3 * | 
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found | 
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may | 
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. | 
| 9 */ | 9 */ | 
| 10 | 10 | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 public EncodedImageCallback, | 53 public EncodedImageCallback, | 
| 54 public VCMSendStatisticsCallback { | 54 public VCMSendStatisticsCallback { | 
| 55 public: | 55 public: | 
| 56 friend class ViEBitrateObserver; | 56 friend class ViEBitrateObserver; | 
| 57 | 57 | 
| 58 ViEEncoder(uint32_t number_of_cores, | 58 ViEEncoder(uint32_t number_of_cores, | 
| 59 ProcessThread* module_process_thread, | 59 ProcessThread* module_process_thread, | 
| 60 SendStatisticsProxy* stats_proxy, | 60 SendStatisticsProxy* stats_proxy, | 
| 61 OveruseFrameDetector* overuse_detector, | 61 OveruseFrameDetector* overuse_detector, | 
| 62 EncodedImageCallback* sink); | 62 EncodedImageCallback* sink); | 
| 63 | |
| 64 ~ViEEncoder(); | 63 ~ViEEncoder(); | 
| 65 | 64 | 
| 66 vcm::VideoSender* video_sender(); | 65 vcm::VideoSender* video_sender(); | 
| 67 | 66 | 
| 68 // Returns the id of the owning channel. | 67 // Returns the id of the owning channel. | 
| 69 int Owner() const; | 68 int Owner() const; | 
| 70 | 69 | 
| 71 void Start(); | 70 void Start(); | 
| 72 // Drops incoming packets before they get to the encoder. | 71 // Drops incoming packets before they get to the encoder. | 
| 73 void Pause(); | 72 void Pause(); | 
| 74 | 73 | 
| 75 // Codec settings. | 74 // Codec settings. | 
| 76 int32_t RegisterExternalEncoder(VideoEncoder* encoder, | 75 int32_t RegisterExternalEncoder(VideoEncoder* encoder, | 
| 77 uint8_t pl_type, | 76 uint8_t pl_type, | 
| 78 bool internal_source); | 77 bool internal_source); | 
| 79 int32_t DeRegisterExternalEncoder(uint8_t pl_type); | 78 int32_t DeRegisterExternalEncoder(uint8_t pl_type); | 
| 80 void SetEncoder(const VideoCodec& video_codec, | 79 void SetEncoder(const VideoCodec& video_codec, | 
| 81 int min_transmit_bitrate_bps, | |
| 82 size_t max_data_payload_length); | 80 size_t max_data_payload_length); | 
| 83 | 81 | 
| 84 void EncodeVideoFrame(const VideoFrame& video_frame); | 82 void EncodeVideoFrame(const VideoFrame& video_frame); | 
| 85 void SendKeyFrame(); | 83 void SendKeyFrame(); | 
| 86 | 84 | 
| 85 // Checks to see if the encoder has produced anything during the last | |
| 86 // VideoEncoderSink::TimeOutMs period. | |
| 87 // TODO(perkj): CheckForActivity should be moved to VideoSendStream and | |
| 88 // handled internally within VideoSendStream once an internal timer | |
| 
stefan-webrtc
2016/06/10 13:54:13
Two extra spaces on this line.
 
perkj_webrtc
2016/06/14 10:58:02
Acknowledged.
 | |
| 89 // once ViEncoder owns the encoder thread. | |
| 
stefan-webrtc
2016/06/10 13:54:13
And this comment doesnt seem correct...
 
perkj_webrtc
2016/06/14 10:58:02
The whole comment is wrong.. sorry.
I still thin
 | |
| 90 int64_t time_of_last_frame_activity_ms(); | |
| 91 | |
| 87 // Implements VideoEncoderRateObserver. | 92 // Implements VideoEncoderRateObserver. | 
| 88 // TODO(perkj): Refactor VideoEncoderRateObserver. This is only used for | 93 // TODO(perkj): Refactor VideoEncoderRateObserver. This is only used for | 
| 89 // stats. The stats should be set in VideoSendStream instead. | 94 // stats. The stats should be set in VideoSendStream instead. | 
| 90 // |bitrate_bps| is the target bitrate and |framerate| is the input frame | 95 // |bitrate_bps| is the target bitrate and |framerate| is the input frame | 
| 91 // rate so it has nothing to do with the actual encoder. | 96 // rate so it has nothing to do with the actual encoder. | 
| 92 void OnSetRates(uint32_t bitrate_bps, int framerate) override; | 97 void OnSetRates(uint32_t bitrate_bps, int framerate) override; | 
| 93 | 98 | 
| 94 // Implements EncodedImageCallback. | 99 // Implements EncodedImageCallback. | 
| 95 int32_t Encoded(const EncodedImage& encoded_image, | 100 int32_t Encoded(const EncodedImage& encoded_image, | 
| 96 const CodecSpecificInfo* codec_specific_info, | 101 const CodecSpecificInfo* codec_specific_info, | 
| 97 const RTPFragmentationHeader* fragmentation) override; | 102 const RTPFragmentationHeader* fragmentation) override; | 
| 98 | 103 | 
| 99 // Implements VideoSendStatisticsCallback. | 104 // Implements VideoSendStatisticsCallback. | 
| 100 void SendStatistics(uint32_t bit_rate, | 105 void SendStatistics(uint32_t bit_rate, | 
| 101 uint32_t frame_rate, | 106 uint32_t frame_rate, | 
| 102 const std::string& encoder_name) override; | 107 const std::string& encoder_name) override; | 
| 103 | 108 | 
| 104 // virtual to test EncoderStateFeedback with mocks. | 109 // virtual to test EncoderStateFeedback with mocks. | 
| 105 virtual void OnReceivedIntraFrameRequest(size_t stream_index); | 110 virtual void OnReceivedIntraFrameRequest(size_t stream_index); | 
| 106 virtual void OnReceivedSLI(uint8_t picture_id); | 111 virtual void OnReceivedSLI(uint8_t picture_id); | 
| 107 virtual void OnReceivedRPSI(uint64_t picture_id); | 112 virtual void OnReceivedRPSI(uint64_t picture_id); | 
| 108 | 113 | 
| 109 int GetPaddingNeededBps() const; | |
| 110 | |
| 111 void OnBitrateUpdated(uint32_t bitrate_bps, | 114 void OnBitrateUpdated(uint32_t bitrate_bps, | 
| 112 uint8_t fraction_lost, | 115 uint8_t fraction_lost, | 
| 113 int64_t round_trip_time_ms); | 116 int64_t round_trip_time_ms); | 
| 114 | 117 | 
| 115 private: | 118 private: | 
| 116 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 119 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 
| 117 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 120 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 
| 118 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 121 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 
| 119 | 122 | 
| 120 const uint32_t number_of_cores_; | 123 const uint32_t number_of_cores_; | 
| 121 EncodedImageCallback* const sink_; | 124 EncodedImageCallback* const sink_; | 
| 122 | 125 | 
| 123 const std::unique_ptr<VideoProcessing> vp_; | 126 const std::unique_ptr<VideoProcessing> vp_; | 
| 124 vcm::VideoSender video_sender_; | 127 vcm::VideoSender video_sender_; | 
| 125 | 128 | 
| 126 rtc::CriticalSection data_cs_; | 129 rtc::CriticalSection data_cs_; | 
| 127 | 130 | 
| 128 SendStatisticsProxy* const stats_proxy_; | 131 SendStatisticsProxy* const stats_proxy_; | 
| 129 OveruseFrameDetector* const overuse_detector_; | 132 OveruseFrameDetector* const overuse_detector_; | 
| 130 | 133 | 
| 131 // The time we last received an input frame or encoded frame. This is used to | 134 // The time we last received an input frame or encoded frame. This is used to | 
| 132 // track when video is stopped long enough that we also want to stop sending | 135 // track when video is stopped long enough that we also want to stop sending | 
| 133 // padding. | 136 // padding. | 
| 134 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 137 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 
| 135 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 138 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 
| 136 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); | |
| 137 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 139 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 
| 138 bool encoder_paused_ GUARDED_BY(data_cs_); | 140 bool encoder_paused_ GUARDED_BY(data_cs_); | 
| 139 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 141 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 
| 140 | 142 | 
| 141 ProcessThread* module_process_thread_; | 143 ProcessThread* module_process_thread_; | 
| 142 | 144 | 
| 143 bool has_received_sli_ GUARDED_BY(data_cs_); | 145 bool has_received_sli_ GUARDED_BY(data_cs_); | 
| 144 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 146 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 
| 145 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 147 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 
| 146 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 148 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 
| 147 | 149 | 
| 148 bool video_suspended_ GUARDED_BY(data_cs_); | 150 bool video_suspended_ GUARDED_BY(data_cs_); | 
| 149 }; | 151 }; | 
| 150 | 152 | 
| 151 } // namespace webrtc | 153 } // namespace webrtc | 
| 152 | 154 | 
| 153 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 155 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 
| OLD | NEW |