| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Instantiate. | 42 // Instantiate. |
| 43 // Call SetSink. | 43 // Call SetSink. |
| 44 // Call SetSource. | 44 // Call SetSource. |
| 45 // Call ConfigureEncoder with the codec settings. | 45 // Call ConfigureEncoder with the codec settings. |
| 46 // Call Stop() when done. | 46 // Call Stop() when done. |
| 47 class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, | 47 class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| 48 public EncodedImageCallback, | 48 public EncodedImageCallback, |
| 49 public VCMSendStatisticsCallback, | 49 public VCMSendStatisticsCallback, |
| 50 public CpuOveruseObserver { | 50 public CpuOveruseObserver { |
| 51 public: | 51 public: |
| 52 // Interface for receiving encoded video frames and notifications about |
| 53 // configuration changes. |
| 54 class EncoderSink : public EncodedImageCallback { |
| 55 public: |
| 56 virtual void OnEncoderConfigurationChanged( |
| 57 std::vector<VideoStream> streams, |
| 58 int min_transmit_bitrate_bps) = 0; |
| 59 }; |
| 60 |
| 52 ViEEncoder(uint32_t number_of_cores, | 61 ViEEncoder(uint32_t number_of_cores, |
| 53 SendStatisticsProxy* stats_proxy, | 62 SendStatisticsProxy* stats_proxy, |
| 54 const webrtc::VideoSendStream::Config::EncoderSettings& settings, | 63 const webrtc::VideoSendStream::Config::EncoderSettings& settings, |
| 55 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 64 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
| 56 LoadObserver* overuse_callback, | 65 LoadObserver* overuse_callback, |
| 57 EncodedFrameObserver* encoder_timing); | 66 EncodedFrameObserver* encoder_timing); |
| 58 ~ViEEncoder(); | 67 ~ViEEncoder(); |
| 59 // RegisterProcessThread register |module_process_thread| with those objects | 68 // RegisterProcessThread register |module_process_thread| with those objects |
| 60 // that use it. Registration has to happen on the thread where | 69 // that use it. Registration has to happen on the thread where |
| 61 // |module_process_thread| was created (libjingle's worker thread). | 70 // |module_process_thread| was created (libjingle's worker thread). |
| 62 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. | 71 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. |
| 63 void RegisterProcessThread(ProcessThread* module_process_thread); | 72 void RegisterProcessThread(ProcessThread* module_process_thread); |
| 64 void DeRegisterProcessThread(); | 73 void DeRegisterProcessThread(); |
| 65 | 74 |
| 66 void SetSource(rtc::VideoSourceInterface<VideoFrame>* source); | 75 void SetSource(rtc::VideoSourceInterface<VideoFrame>* source); |
| 67 void SetSink(EncodedImageCallback* sink); | 76 void SetSink(EncoderSink* sink); |
| 68 | 77 |
| 69 // TODO(perkj): Can we remove VideoCodec.startBitrate ? | 78 // TODO(perkj): Can we remove VideoCodec.startBitrate ? |
| 70 void SetStartBitrate(int start_bitrate_bps); | 79 void SetStartBitrate(int start_bitrate_bps); |
| 71 | 80 |
| 72 void ConfigureEncoder(const VideoEncoderConfig& config, | 81 void ConfigureEncoder(VideoEncoderConfig config, |
| 73 size_t max_data_payload_length); | 82 size_t max_data_payload_length); |
| 74 | 83 |
| 75 // Permanently stop encoding. After this method has returned, it is | 84 // Permanently stop encoding. After this method has returned, it is |
| 76 // guaranteed that no encoded frames will be delivered to the sink. | 85 // guaranteed that no encoded frames will be delivered to the sink. |
| 77 void Stop(); | 86 void Stop(); |
| 78 | 87 |
| 79 void SendKeyFrame(); | 88 void SendKeyFrame(); |
| 80 | 89 |
| 81 // virtual to test EncoderStateFeedback with mocks. | 90 // virtual to test EncoderStateFeedback with mocks. |
| 82 virtual void OnReceivedIntraFrameRequest(size_t stream_index); | 91 virtual void OnReceivedIntraFrameRequest(size_t stream_index); |
| 83 virtual void OnReceivedSLI(uint8_t picture_id); | 92 virtual void OnReceivedSLI(uint8_t picture_id); |
| 84 virtual void OnReceivedRPSI(uint64_t picture_id); | 93 virtual void OnReceivedRPSI(uint64_t picture_id); |
| 85 | 94 |
| 86 void OnBitrateUpdated(uint32_t bitrate_bps, | 95 void OnBitrateUpdated(uint32_t bitrate_bps, |
| 87 uint8_t fraction_lost, | 96 uint8_t fraction_lost, |
| 88 int64_t round_trip_time_ms); | 97 int64_t round_trip_time_ms); |
| 89 | 98 |
| 90 private: | 99 private: |
| 91 class EncodeTask; | 100 class EncodeTask; |
| 92 class VideoSourceProxy; | 101 class VideoSourceProxy; |
| 93 | 102 |
| 94 void ConfigureEncoderInternal(const VideoCodec& video_codec, | 103 void ConfigureEncoderInternal(const VideoCodec& video_codec, |
| 95 size_t max_data_payload_length); | 104 size_t max_data_payload_length, |
| 105 std::vector<VideoStream> stream, |
| 106 int min_transmit_bitrate); |
| 96 | 107 |
| 97 // Implements VideoSinkInterface. | 108 // Implements VideoSinkInterface. |
| 98 void OnFrame(const VideoFrame& video_frame) override; | 109 void OnFrame(const VideoFrame& video_frame) override; |
| 99 | 110 |
| 100 // Implements VideoSendStatisticsCallback. | 111 // Implements VideoSendStatisticsCallback. |
| 101 void SendStatistics(uint32_t bit_rate, | 112 void SendStatistics(uint32_t bit_rate, |
| 102 uint32_t frame_rate) override; | 113 uint32_t frame_rate) override; |
| 103 | 114 |
| 104 void EncodeVideoFrame(const VideoFrame& frame, | 115 void EncodeVideoFrame(const VideoFrame& frame, |
| 105 int64_t time_when_posted_in_ms); | 116 int64_t time_when_posted_in_ms); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 116 | 127 |
| 117 bool EncoderPaused() const; | 128 bool EncoderPaused() const; |
| 118 void TraceFrameDropStart(); | 129 void TraceFrameDropStart(); |
| 119 void TraceFrameDropEnd(); | 130 void TraceFrameDropEnd(); |
| 120 | 131 |
| 121 rtc::Event shutdown_event_; | 132 rtc::Event shutdown_event_; |
| 122 | 133 |
| 123 const uint32_t number_of_cores_; | 134 const uint32_t number_of_cores_; |
| 124 | 135 |
| 125 const std::unique_ptr<VideoSourceProxy> source_proxy_; | 136 const std::unique_ptr<VideoSourceProxy> source_proxy_; |
| 126 EncodedImageCallback* sink_; | 137 EncoderSink* sink_; |
| 127 const VideoSendStream::Config::EncoderSettings settings_; | 138 const VideoSendStream::Config::EncoderSettings settings_; |
| 128 | 139 |
| 129 const std::unique_ptr<VideoProcessing> vp_; | 140 const std::unique_ptr<VideoProcessing> vp_; |
| 130 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); | 141 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
| 131 | 142 |
| 132 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); | 143 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); |
| 133 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); | 144 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); |
| 134 | 145 |
| 135 SendStatisticsProxy* const stats_proxy_; | 146 SendStatisticsProxy* const stats_proxy_; |
| 136 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 147 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 165 // All public methods are proxied to |encoder_queue_|. It must must be | 176 // All public methods are proxied to |encoder_queue_|. It must must be |
| 166 // destroyed first to make sure no tasks are run that use other members. | 177 // destroyed first to make sure no tasks are run that use other members. |
| 167 rtc::TaskQueue encoder_queue_; | 178 rtc::TaskQueue encoder_queue_; |
| 168 | 179 |
| 169 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 180 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
| 170 }; | 181 }; |
| 171 | 182 |
| 172 } // namespace webrtc | 183 } // namespace webrtc |
| 173 | 184 |
| 174 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 185 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
| OLD | NEW |