Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1545)

Side by Side Diff: content/renderer/media/rtc_video_encoder.h

Issue 1845563006: Make RTCVideoEncoder usable from non-postable thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address all review comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/rtc_video_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 14 matching lines...) Expand all
25 class GpuVideoAcceleratorFactories; 25 class GpuVideoAcceleratorFactories;
26 } // namespace media 26 } // namespace media
27 27
28 namespace content { 28 namespace content {
29 29
30 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a 30 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a
31 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are 31 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are
32 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs 32 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs
33 // on the worker thread queried from the |gpu_factories_|, which is presently 33 // on the worker thread queried from the |gpu_factories_|, which is presently
34 // the media thread. RTCVideoEncoder is sychronized by webrtc::VideoSender. 34 // the media thread. RTCVideoEncoder is sychronized by webrtc::VideoSender.
35 // webrtc::VideoEncoder methods do not run concurrently. RTCVideoEncoder is run 35 // webrtc::VideoEncoder methods do not run concurrently. RtcVideoEncoder needs
36 // and destroyed on the thread it is constructed on, which is presently the 36 // to synchronize RegisterEncodeCompleteCallback and encode complete callback.
37 // libjingle worker thread. Encode is run on ViECaptureThread. SetRates and
38 // SetChannelParameters are run on ProcessThread or the libjingle worker thread.
39 // Callbacks from the Impl due to its VEA::Client notifications are posted back
40 // to RTCVideoEncoder on the libjingle worker thread.
41 class CONTENT_EXPORT RTCVideoEncoder 37 class CONTENT_EXPORT RTCVideoEncoder
42 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { 38 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) {
43 public: 39 public:
44 RTCVideoEncoder(webrtc::VideoCodecType type, 40 RTCVideoEncoder(webrtc::VideoCodecType type,
45 media::GpuVideoAcceleratorFactories* gpu_factories); 41 media::GpuVideoAcceleratorFactories* gpu_factories);
46 ~RTCVideoEncoder() override; 42 ~RTCVideoEncoder() override;
47 43
48 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the 44 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the
49 // appropriate VEA methods. 45 // appropriate VEA methods.
50 int32_t InitEncode(const webrtc::VideoCodec* codec_settings, 46 int32_t InitEncode(const webrtc::VideoCodec* codec_settings,
51 int32_t number_of_cores, 47 int32_t number_of_cores,
52 size_t max_payload_size) override; 48 size_t max_payload_size) override;
53 int32_t Encode( 49 int32_t Encode(
54 const webrtc::VideoFrame& input_image, 50 const webrtc::VideoFrame& input_image,
55 const webrtc::CodecSpecificInfo* codec_specific_info, 51 const webrtc::CodecSpecificInfo* codec_specific_info,
56 const std::vector<webrtc::FrameType>* frame_types) override; 52 const std::vector<webrtc::FrameType>* frame_types) override;
57 int32_t RegisterEncodeCompleteCallback( 53 int32_t RegisterEncodeCompleteCallback(
58 webrtc::EncodedImageCallback* callback) override; 54 webrtc::EncodedImageCallback* callback) override;
59 int32_t Release() override; 55 int32_t Release() override;
60 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; 56 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
61 int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; 57 int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override;
62 58
63 private: 59 private:
64 class Impl; 60 class Impl;
65 friend class RTCVideoEncoder::Impl; 61 friend class RTCVideoEncoder::Impl;
66 62
67 // Return an encoded output buffer to WebRTC.
68 void ReturnEncodedImage(std::unique_ptr<webrtc::EncodedImage> image,
69 int32_t bitstream_buffer_id,
70 uint16_t picture_id);
71
72 void NotifyError(int32_t error);
73
74 void RecordInitEncodeUMA(int32_t init_retval, 63 void RecordInitEncodeUMA(int32_t init_retval,
75 media::VideoCodecProfile profile); 64 media::VideoCodecProfile profile);
76 65
77 base::ThreadChecker thread_checker_;
78
79 // The video codec type, as reported to WebRTC.
80 const webrtc::VideoCodecType video_codec_type_;
81
82 // Factory for creating VEAs, shared memory buffers, etc. 66 // Factory for creating VEAs, shared memory buffers, etc.
83 media::GpuVideoAcceleratorFactories* gpu_factories_; 67 media::GpuVideoAcceleratorFactories* gpu_factories_;
84 68
85 // Task runner that the video accelerator runs on. 69 // Task runner that the video accelerator runs on.
86 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; 70 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
87 71
88 // webrtc::VideoEncoder encode complete callback.
89 webrtc::EncodedImageCallback* encoded_image_callback_;
90
91 // The RTCVideoEncoder::Impl that does all the work. 72 // The RTCVideoEncoder::Impl that does all the work.
92 scoped_refptr<Impl> impl_; 73 scoped_refptr<Impl> impl_;
93 74
94 // We cannot immediately return error conditions to the WebRTC user of this
95 // class, as there is no error callback in the webrtc::VideoEncoder interface.
96 // Instead, we cache an error status here and return it the next time an
97 // interface entry point is called.
98 int32_t impl_status_;
99
100 // Weak pointer factory for posting back VEA::Client notifications to
101 // RTCVideoEncoder.
102 // NOTE: Weak pointers must be invalidated before all other member variables.
103 base::WeakPtrFactory<RTCVideoEncoder> weak_factory_;
104
105 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); 75 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder);
106 }; 76 };
107 77
108 } // namespace content 78 } // namespace content
109 79
110 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ 80 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/rtc_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698