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 rtc::CritScope crit(&timing_params_lock_); |
| 65 timing_frames_thresholds_ = thresholds; |
| 66 } |
| 67 |
51 private: | 68 private: |
| 69 rtc::CriticalSection timing_params_lock_; |
52 bool internal_source_; | 70 bool internal_source_; |
53 EncodedImageCallback* const post_encode_callback_; | 71 EncodedImageCallback* const post_encode_callback_; |
54 media_optimization::MediaOptimization* const media_opt_; | 72 media_optimization::MediaOptimization* const media_opt_; |
| 73 |
| 74 struct TimingFramesLayerInfo { |
| 75 size_t target_bitrate_bytes_per_sec = 0; |
| 76 std::map<int64_t, int64_t> encode_start_time_ms; |
| 77 }; |
| 78 // Separate instance for each simulcast stream or spatial layer. |
| 79 std::vector<TimingFramesLayerInfo> timing_frames_info_ |
| 80 GUARDED_BY(timing_params_lock_); |
| 81 size_t framerate_ GUARDED_BY(timing_params_lock_); |
| 82 int64_t last_timing_frame_time_ms_ GUARDED_BY(timing_params_lock_); |
| 83 VideoCodec::TimingFrameTriggerThresholds timing_frames_thresholds_ |
| 84 GUARDED_BY(timing_params_lock_); |
55 }; | 85 }; |
56 | 86 |
57 class VCMGenericEncoder { | 87 class VCMGenericEncoder { |
58 friend class VCMCodecDataBase; | 88 friend class VCMCodecDataBase; |
59 | 89 |
60 public: | 90 public: |
61 VCMGenericEncoder(VideoEncoder* encoder, | 91 VCMGenericEncoder(VideoEncoder* encoder, |
62 VCMEncodedFrameCallback* encoded_frame_callback, | 92 VCMEncodedFrameCallback* encoded_frame_callback, |
63 bool internal_source); | 93 bool internal_source); |
64 ~VCMGenericEncoder(); | 94 ~VCMGenericEncoder(); |
(...skipping 16 matching lines...) Expand all Loading... |
81 | 111 |
82 private: | 112 private: |
83 rtc::RaceChecker race_checker_; | 113 rtc::RaceChecker race_checker_; |
84 | 114 |
85 VideoEncoder* const encoder_ GUARDED_BY(race_checker_); | 115 VideoEncoder* const encoder_ GUARDED_BY(race_checker_); |
86 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; | 116 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; |
87 const bool internal_source_; | 117 const bool internal_source_; |
88 rtc::CriticalSection params_lock_; | 118 rtc::CriticalSection params_lock_; |
89 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); | 119 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); |
90 bool is_screenshare_; | 120 bool is_screenshare_; |
| 121 size_t streams_or_svc_num_; |
91 }; | 122 }; |
92 | 123 |
93 } // namespace webrtc | 124 } // namespace webrtc |
94 | 125 |
95 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 126 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ |
OLD | NEW |