OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ | |
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/threading/thread_checker.h" | |
14 #include "content/common/content_export.h" | |
15 #include "media/base/video_decoder_config.h" | |
16 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i nterface.h" | |
17 #include "ui/gfx/size.h" | |
18 | |
19 namespace base { | |
20 | |
21 class MessageLoopProxy; | |
22 | |
23 } // namespace base | |
24 | |
25 namespace content { | |
26 | |
27 class RendererGpuVideoAcceleratorFactories; | |
28 | |
29 // This class uses a media::VideoEncodeAccelerator to implement a | |
30 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are | |
31 // trampolined to a private RTCVideoEncoder::Impl instance. The class runs on | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
"The class" is ambiguous in this sentence.
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
Now that I understand that you're using Impl as a
sheu
2013/08/06 06:16:36
Done.
sheu
2013/08/06 06:16:36
TBH that sounds a little excessive? I haven't see
| |
32 // the |impl_message_loop_proxy_|, which is queried from the |gpu_factories_| | |
33 // and is presently the media thread. VEA::Client callbacks are posted back to | |
34 // the thread that the RTCVideoEncoder constructor is called on. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
Comment could be clearer about the fact that RTCVE
sheu
2013/08/06 06:16:36
Done.
| |
35 class CONTENT_EXPORT RTCVideoEncoder | |
36 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { | |
37 public: | |
38 RTCVideoEncoder( | |
39 media::VideoCodecProfile profile, | |
40 const scoped_refptr<RendererGpuVideoAcceleratorFactories>& gpu_factories); | |
41 virtual ~RTCVideoEncoder(); | |
42 | |
43 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the | |
44 // appropriate VEA methods. | |
45 virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, | |
46 int32_t number_of_cores, | |
47 uint32_t max_payload_size) OVERRIDE; | |
48 virtual int32_t Encode( | |
49 const webrtc::I420VideoFrame& input_image, | |
50 const webrtc::CodecSpecificInfo* codec_specific_info, | |
51 const std::vector<webrtc::VideoFrameType>* frame_types) OVERRIDE; | |
52 virtual int32_t RegisterEncodeCompleteCallback( | |
53 webrtc::EncodedImageCallback* callback) OVERRIDE; | |
54 virtual int32_t Release() OVERRIDE; | |
55 virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; | |
56 virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) OVERRIDE; | |
57 | |
58 private: | |
59 class Impl; | |
60 friend class RTCVideoEncoder::Impl; | |
61 | |
62 // Return an encoded output buffer to WebRTC. | |
63 void ReturnEncodedImage(const scoped_refptr<Impl>& impl, | |
64 scoped_ptr<webrtc::EncodedImage> image, | |
65 int32 bitstream_buffer_id); | |
66 void NotifyError(const scoped_refptr<Impl>& impl, int32_t error); | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
newline
sheu
2013/08/06 06:16:36
Done.
| |
67 | |
68 base::ThreadChecker thread_checker_; | |
69 | |
70 // The video codec profile we were created with. | |
71 media::VideoCodecProfile video_codec_profile_; | |
72 | |
73 // Factory for creating VEAs, shared memory buffers, etc. | |
74 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories_; | |
75 | |
76 // Message loop that |impl_| runs on; queried from |gpu_factories_|. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
given this is always equal to gpu_factories_->GetM
sheu
2013/08/06 06:16:36
To save some typing and ref/unrefs?
I guess I can
| |
77 const scoped_refptr<base::MessageLoopProxy> impl_message_loop_proxy_; | |
78 | |
79 // Weak pointer and factory for posting back VEA::Client notifications to | |
80 // RTCVideoEncoder. | |
81 base::WeakPtrFactory<RTCVideoEncoder> weak_this_factory_; | |
82 base::WeakPtr<RTCVideoEncoder> weak_this_; | |
83 | |
84 // webrtc::VideoEncoder encode complete callback. | |
85 webrtc::EncodedImageCallback* encoded_image_callback_; | |
86 | |
87 // The RTCVideoEncoder::Impl that does all the work. | |
88 scoped_refptr<Impl> impl_; | |
89 | |
90 // We cannot immediately return error conditions to the WebRTC user of this | |
91 // class, as there is no error callback in the webrtc::VideoEncoder interface. | |
92 // Instead, we cache an error status here and return it the next time an | |
93 // interface entry point is called. | |
94 int32_t impl_status_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); | |
97 }; | |
98 | |
99 } // namespace content | |
100 | |
101 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ | |
OLD | NEW |