OLD | NEW |
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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
17 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i
nterface.h" | 17 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i
nterface.h" |
18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 class MessageLoopProxy; | 22 class MessageLoopProxy; |
23 | 23 |
24 } // namespace base | 24 } // namespace base |
25 | 25 |
26 namespace media { | 26 namespace content { |
27 | 27 |
28 class GpuVideoAcceleratorFactories; | 28 class RendererGpuVideoAcceleratorFactories; |
29 | |
30 } // namespace media | |
31 | |
32 namespace content { | |
33 | 29 |
34 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a | 30 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a |
35 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are | 31 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are |
36 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs | 32 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs |
37 // 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 |
38 // the media thread. RTCVideoEncoder itself is run and destroyed on the thread | 34 // the media thread. RTCVideoEncoder itself is run and destroyed on the thread |
39 // it is constructed on, which is presently the libjingle worker thread. | 35 // it is constructed on, which is presently the libjingle worker thread. |
40 // Callbacks from the Impl due to its VEA::Client notifications are also posted | 36 // Callbacks from the Impl due to its VEA::Client notifications are also posted |
41 // back to RTCVideoEncoder on this thread. | 37 // back to RTCVideoEncoder on this thread. |
42 class CONTENT_EXPORT RTCVideoEncoder | 38 class CONTENT_EXPORT RTCVideoEncoder |
43 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { | 39 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { |
44 public: | 40 public: |
45 RTCVideoEncoder( | 41 RTCVideoEncoder( |
46 webrtc::VideoCodecType type, | 42 webrtc::VideoCodecType type, |
47 media::VideoCodecProfile profile, | 43 media::VideoCodecProfile profile, |
48 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories); | 44 const scoped_refptr<RendererGpuVideoAcceleratorFactories>& gpu_factories); |
49 virtual ~RTCVideoEncoder(); | 45 virtual ~RTCVideoEncoder(); |
50 | 46 |
51 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the | 47 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the |
52 // appropriate VEA methods. | 48 // appropriate VEA methods. |
53 virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, | 49 virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, |
54 int32_t number_of_cores, | 50 int32_t number_of_cores, |
55 uint32_t max_payload_size) OVERRIDE; | 51 uint32_t max_payload_size) OVERRIDE; |
56 virtual int32_t Encode( | 52 virtual int32_t Encode( |
57 const webrtc::I420VideoFrame& input_image, | 53 const webrtc::I420VideoFrame& input_image, |
58 const webrtc::CodecSpecificInfo* codec_specific_info, | 54 const webrtc::CodecSpecificInfo* codec_specific_info, |
(...skipping 18 matching lines...) Expand all Loading... |
77 | 73 |
78 base::ThreadChecker thread_checker_; | 74 base::ThreadChecker thread_checker_; |
79 | 75 |
80 // The video codec type, as reported to WebRTC. | 76 // The video codec type, as reported to WebRTC. |
81 const webrtc::VideoCodecType video_codec_type_; | 77 const webrtc::VideoCodecType video_codec_type_; |
82 | 78 |
83 // The video codec profile, to configure the encoder to encode to. | 79 // The video codec profile, to configure the encoder to encode to. |
84 const media::VideoCodecProfile video_codec_profile_; | 80 const media::VideoCodecProfile video_codec_profile_; |
85 | 81 |
86 // Factory for creating VEAs, shared memory buffers, etc. | 82 // Factory for creating VEAs, shared memory buffers, etc. |
87 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; | 83 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories_; |
88 | 84 |
89 // webrtc::VideoEncoder encode complete callback. | 85 // webrtc::VideoEncoder encode complete callback. |
90 webrtc::EncodedImageCallback* encoded_image_callback_; | 86 webrtc::EncodedImageCallback* encoded_image_callback_; |
91 | 87 |
92 // The RTCVideoEncoder::Impl that does all the work. | 88 // The RTCVideoEncoder::Impl that does all the work. |
93 scoped_refptr<Impl> impl_; | 89 scoped_refptr<Impl> impl_; |
94 | 90 |
95 // We cannot immediately return error conditions to the WebRTC user of this | 91 // We cannot immediately return error conditions to the WebRTC user of this |
96 // class, as there is no error callback in the webrtc::VideoEncoder interface. | 92 // class, as there is no error callback in the webrtc::VideoEncoder interface. |
97 // Instead, we cache an error status here and return it the next time an | 93 // Instead, we cache an error status here and return it the next time an |
98 // interface entry point is called. | 94 // interface entry point is called. |
99 int32_t impl_status_; | 95 int32_t impl_status_; |
100 | 96 |
101 // Weak pointer factory for posting back VEA::Client notifications to | 97 // Weak pointer factory for posting back VEA::Client notifications to |
102 // RTCVideoEncoder. | 98 // RTCVideoEncoder. |
103 base::WeakPtrFactory<RTCVideoEncoder> weak_this_factory_; | 99 base::WeakPtrFactory<RTCVideoEncoder> weak_this_factory_; |
104 | 100 |
105 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); | 101 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); |
106 }; | 102 }; |
107 | 103 |
108 } // namespace content | 104 } // namespace content |
109 | 105 |
110 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ | 106 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ |
OLD | NEW |