Chromium Code Reviews| 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 |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ |
| 13 | 13 |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 #include <map> | |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 18 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 19 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 19 | 20 |
| 20 #include "webrtc/base/criticalsection.h" | 21 #include "webrtc/base/criticalsection.h" |
| 21 #include "webrtc/base/race_checker.h" | 22 #include "webrtc/base/race_checker.h" |
| 22 | 23 |
| 23 namespace webrtc { | 24 namespace webrtc { |
| 24 | 25 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 37 public: | 38 public: |
| 38 VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback, | 39 VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback, |
| 39 media_optimization::MediaOptimization* media_opt); | 40 media_optimization::MediaOptimization* media_opt); |
| 40 virtual ~VCMEncodedFrameCallback(); | 41 virtual ~VCMEncodedFrameCallback(); |
| 41 | 42 |
| 42 // Implements EncodedImageCallback. | 43 // Implements EncodedImageCallback. |
| 43 EncodedImageCallback::Result OnEncodedImage( | 44 EncodedImageCallback::Result OnEncodedImage( |
| 44 const EncodedImage& encoded_image, | 45 const EncodedImage& encoded_image, |
| 45 const CodecSpecificInfo* codec_specific_info, | 46 const CodecSpecificInfo* codec_specific_info, |
| 46 const RTPFragmentationHeader* fragmentation) override; | 47 const RTPFragmentationHeader* fragmentation) override; |
| 48 | |
| 47 void SetInternalSource(bool internal_source) { | 49 void SetInternalSource(bool internal_source) { |
| 48 internal_source_ = internal_source; | 50 internal_source_ = internal_source; |
| 49 } | 51 } |
| 50 | 52 |
| 53 // Timing frames configuration methods. These 4 should be called before | |
| 54 // |OnEncodedImage| at least once. | |
| 55 void OnTargetBitrateChanged(size_t bitrate_bytes_per_sec, | |
| 56 size_t simulcast_svc_idx); | |
| 57 | |
| 58 void OnFrameRateChanged(size_t framerate); | |
| 59 | |
| 60 void OnEncodeStarted(int64_t capture_time_ms, size_t simulcast_svc_idx); | |
| 61 | |
| 62 void SetTimingFramesThresholds( | |
| 63 const VideoCodec::TimingFrameTriggerThresholds& thresholds) { | |
| 64 timing_frames_thresholds_ = thresholds; | |
| 65 } | |
| 66 | |
| 51 private: | 67 private: |
| 52 bool internal_source_; | 68 bool internal_source_; |
| 53 EncodedImageCallback* const post_encode_callback_; | 69 EncodedImageCallback* const post_encode_callback_; |
| 54 media_optimization::MediaOptimization* const media_opt_; | 70 media_optimization::MediaOptimization* const media_opt_; |
| 71 | |
| 72 struct TimingFramesLayerInfo { | |
| 73 size_t target_bitrate_bytes_per_sec = 0; | |
| 74 std::map<int64_t, int64_t> encode_start_time_ms; | |
| 75 }; | |
| 76 // Separate instance for each simulcast stream or spatial layer. | |
| 77 std::vector<TimingFramesLayerInfo> timing_frames_info_; | |
| 78 size_t framerate_; | |
| 79 int64_t last_timing_frame_time_ms_; | |
| 80 VideoCodec::TimingFrameTriggerThresholds timing_frames_thresholds_; | |
|
sprang_webrtc
2017/06/09 11:02:01
Looks like there are potential raciness here, as r
ilnik
2017/06/09 12:06:05
I think, there's no raciness here, as most methods
sprang_webrtc
2017/06/12 07:10:10
OnEncodedImage() is called by the encoder, but the
ilnik
2017/06/12 09:06:24
Ok, Added protection using critical section.
| |
| 55 }; | 81 }; |
|
sprang_webrtc
2017/06/09 11:02:01
This logic definitely warrants units tests as well
ilnik
2017/06/09 12:06:06
I am writing a second CL with tests in parallel. G
sprang_webrtc
2017/06/12 07:10:10
I'd actually prefer they are in the same one. If i
ilnik
2017/06/12 09:06:24
Working on it.
ilnik
2017/06/12 10:08:50
Added generic_encoder_unittests and also another t
| |
| 56 | 82 |
| 57 class VCMGenericEncoder { | 83 class VCMGenericEncoder { |
| 58 friend class VCMCodecDataBase; | 84 friend class VCMCodecDataBase; |
| 59 | 85 |
| 60 public: | 86 public: |
| 61 VCMGenericEncoder(VideoEncoder* encoder, | 87 VCMGenericEncoder(VideoEncoder* encoder, |
| 62 VCMEncodedFrameCallback* encoded_frame_callback, | 88 VCMEncodedFrameCallback* encoded_frame_callback, |
| 63 bool internal_source); | 89 bool internal_source); |
| 64 ~VCMGenericEncoder(); | 90 ~VCMGenericEncoder(); |
| 65 int32_t Release(); | 91 int32_t Release(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 81 | 107 |
| 82 private: | 108 private: |
| 83 rtc::RaceChecker race_checker_; | 109 rtc::RaceChecker race_checker_; |
| 84 | 110 |
| 85 VideoEncoder* const encoder_ GUARDED_BY(race_checker_); | 111 VideoEncoder* const encoder_ GUARDED_BY(race_checker_); |
| 86 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; | 112 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; |
| 87 const bool internal_source_; | 113 const bool internal_source_; |
| 88 rtc::CriticalSection params_lock_; | 114 rtc::CriticalSection params_lock_; |
| 89 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); | 115 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); |
| 90 bool is_screenshare_; | 116 bool is_screenshare_; |
| 117 size_t streams_or_svc_num_; | |
| 91 }; | 118 }; |
| 92 | 119 |
| 93 } // namespace webrtc | 120 } // namespace webrtc |
| 94 | 121 |
| 95 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 122 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ |
| OLD | NEW |