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 | 62 |
63 private: | 63 private: |
64 class Impl; | 64 class Impl; |
65 friend class RTCVideoEncoder::Impl; | 65 friend class RTCVideoEncoder::Impl; |
66 | 66 |
67 void RecordInitEncodeUMA(int32_t init_retval, | 67 void RecordInitEncodeUMA(int32_t init_retval, |
68 media::VideoCodecProfile profile); | 68 media::VideoCodecProfile profile); |
69 | 69 |
70 // The video codec type, as reported to WebRTC. | 70 const media::VideoCodecProfile profile_; |
71 const webrtc::VideoCodecType video_codec_type_; | |
72 | 71 |
73 // Factory for creating VEAs, shared memory buffers, etc. | 72 // Factory for creating VEAs, shared memory buffers, etc. |
74 media::GpuVideoAcceleratorFactories* gpu_factories_; | 73 media::GpuVideoAcceleratorFactories* gpu_factories_; |
75 | 74 |
76 // Task runner that the video accelerator runs on. | 75 // Task runner that the video accelerator runs on. |
77 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; | 76 const scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; |
78 | 77 |
79 // The RTCVideoEncoder::Impl that does all the work. | 78 // The RTCVideoEncoder::Impl that does all the work. |
80 scoped_refptr<Impl> impl_; | 79 scoped_refptr<Impl> impl_; |
81 | 80 |
82 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); | 81 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); |
83 }; | 82 }; |
84 | 83 |
85 } // namespace content | 84 } // namespace content |
86 | 85 |
87 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ | 86 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_ENCODER_H_ |
OLD | NEW |