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_GPU_RTC_VIDEO_ENCODER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ |
6 #define CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ | 6 #define CONTENT_RENDERER_MEDIA_GPU_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 23 matching lines...) Expand all Loading... |
34 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a | 34 // RTCVideoEncoder uses a media::VideoEncodeAccelerator to implement a |
35 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are | 35 // webrtc::VideoEncoder class for WebRTC. Internally, VEA methods are |
36 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs | 36 // trampolined to a private RTCVideoEncoder::Impl instance. The Impl class runs |
37 // on the worker thread queried from the |gpu_factories_|, which is presently | 37 // on the worker thread queried from the |gpu_factories_|, which is presently |
38 // the media thread. RTCVideoEncoder is sychronized by webrtc::VideoSender. | 38 // the media thread. RTCVideoEncoder is sychronized by webrtc::VideoSender. |
39 // webrtc::VideoEncoder methods do not run concurrently. RtcVideoEncoder needs | 39 // webrtc::VideoEncoder methods do not run concurrently. RtcVideoEncoder needs |
40 // to synchronize RegisterEncodeCompleteCallback and encode complete callback. | 40 // to synchronize RegisterEncodeCompleteCallback and encode complete callback. |
41 class CONTENT_EXPORT RTCVideoEncoder | 41 class CONTENT_EXPORT RTCVideoEncoder |
42 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { | 42 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { |
43 public: | 43 public: |
44 RTCVideoEncoder(webrtc::VideoCodecType type, | 44 RTCVideoEncoder(media::VideoCodecProfile profile, |
45 media::GpuVideoAcceleratorFactories* gpu_factories); | 45 media::GpuVideoAcceleratorFactories* gpu_factories); |
46 ~RTCVideoEncoder() override; | 46 ~RTCVideoEncoder() override; |
47 | 47 |
48 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the | 48 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the |
49 // appropriate VEA methods. | 49 // appropriate VEA methods. |
50 int32_t InitEncode(const webrtc::VideoCodec* codec_settings, | 50 int32_t InitEncode(const webrtc::VideoCodec* codec_settings, |
51 int32_t number_of_cores, | 51 int32_t number_of_cores, |
52 size_t max_payload_size) override; | 52 size_t max_payload_size) override; |
53 int32_t Encode( | 53 int32_t Encode( |
54 const webrtc::VideoFrame& input_image, | 54 const webrtc::VideoFrame& input_image, |
55 const webrtc::CodecSpecificInfo* codec_specific_info, | 55 const webrtc::CodecSpecificInfo* codec_specific_info, |
56 const std::vector<webrtc::FrameType>* frame_types) override; | 56 const std::vector<webrtc::FrameType>* frame_types) override; |
57 int32_t RegisterEncodeCompleteCallback( | 57 int32_t RegisterEncodeCompleteCallback( |
58 webrtc::EncodedImageCallback* callback) override; | 58 webrtc::EncodedImageCallback* callback) override; |
59 int32_t Release() override; | 59 int32_t Release() override; |
60 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; | 60 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; | 61 int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; |
62 bool SupportsNativeHandle() const override; | 62 bool SupportsNativeHandle() const override; |
63 | 63 |
64 private: | 64 private: |
65 class Impl; | 65 class Impl; |
66 friend class RTCVideoEncoder::Impl; | 66 friend class RTCVideoEncoder::Impl; |
67 | 67 |
68 void RecordInitEncodeUMA(int32_t init_retval, | 68 void RecordInitEncodeUMA(int32_t init_retval, |
69 media::VideoCodecProfile profile); | 69 media::VideoCodecProfile profile); |
70 | 70 |
71 // The video codec type, as reported to WebRTC. | 71 const media::VideoCodecProfile profile_; |
72 const webrtc::VideoCodecType video_codec_type_; | |
73 | 72 |
74 // Factory for creating VEAs, shared memory buffers, etc. | 73 // Factory for creating VEAs, shared memory buffers, etc. |
75 media::GpuVideoAcceleratorFactories* gpu_factories_; | 74 media::GpuVideoAcceleratorFactories* gpu_factories_; |
76 | 75 |
77 // Task runner that the video accelerator runs on. | 76 // Task runner that the video accelerator runs on. |
78 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; | 77 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; |
79 | 78 |
80 // The RTCVideoEncoder::Impl that does all the work. | 79 // The RTCVideoEncoder::Impl that does all the work. |
81 scoped_refptr<Impl> impl_; | 80 scoped_refptr<Impl> impl_; |
82 | 81 |
83 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); | 82 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); |
84 }; | 83 }; |
85 | 84 |
86 } // namespace content | 85 } // namespace content |
87 | 86 |
88 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ | 87 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ |
OLD | NEW |