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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // and destroyed on the thread it is constructed on, which is presently the | 40 // and destroyed on the thread it is constructed on, which is presently the |
41 // libjingle worker thread. Encode is run on ViECaptureThread. SetRates and | 41 // libjingle worker thread. Encode is run on ViECaptureThread. SetRates and |
42 // SetChannelParameters are run on ProcessThread or the libjingle worker thread. | 42 // SetChannelParameters are run on ProcessThread or the libjingle worker thread. |
43 // Callbacks from the Impl due to its VEA::Client notifications are posted back | 43 // Callbacks from the Impl due to its VEA::Client notifications are posted back |
44 // to RTCVideoEncoder on the libjingle worker thread. | 44 // to RTCVideoEncoder on the libjingle worker thread. |
45 class CONTENT_EXPORT RTCVideoEncoder | 45 class CONTENT_EXPORT RTCVideoEncoder |
46 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { | 46 : NON_EXPORTED_BASE(public webrtc::VideoEncoder) { |
47 public: | 47 public: |
48 RTCVideoEncoder( | 48 RTCVideoEncoder( |
49 webrtc::VideoCodecType type, | 49 webrtc::VideoCodecType type, |
50 media::VideoCodecProfile profile, | |
51 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories); | 50 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories); |
52 virtual ~RTCVideoEncoder(); | 51 virtual ~RTCVideoEncoder(); |
53 | 52 |
54 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the | 53 // webrtc::VideoEncoder implementation. Tasks are posted to |impl_| using the |
55 // appropriate VEA methods. | 54 // appropriate VEA methods. |
56 virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, | 55 virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, |
57 int32_t number_of_cores, | 56 int32_t number_of_cores, |
58 uint32_t max_payload_size) override; | 57 uint32_t max_payload_size) override; |
59 virtual int32_t Encode( | 58 virtual int32_t Encode( |
60 const webrtc::I420VideoFrame& input_image, | 59 const webrtc::I420VideoFrame& input_image, |
61 const webrtc::CodecSpecificInfo* codec_specific_info, | 60 const webrtc::CodecSpecificInfo* codec_specific_info, |
62 const std::vector<webrtc::VideoFrameType>* frame_types) override; | 61 const std::vector<webrtc::VideoFrameType>* frame_types) override; |
63 virtual int32_t RegisterEncodeCompleteCallback( | 62 virtual int32_t RegisterEncodeCompleteCallback( |
64 webrtc::EncodedImageCallback* callback) override; | 63 webrtc::EncodedImageCallback* callback) override; |
65 virtual int32_t Release() override; | 64 virtual int32_t Release() override; |
66 virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) override; | 65 virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) override; |
67 virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; | 66 virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) override; |
68 | 67 |
69 private: | 68 private: |
70 class Impl; | 69 class Impl; |
71 friend class RTCVideoEncoder::Impl; | 70 friend class RTCVideoEncoder::Impl; |
72 | 71 |
73 // Return an encoded output buffer to WebRTC. | 72 // Return an encoded output buffer to WebRTC. |
74 void ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image, | 73 void ReturnEncodedImage(scoped_ptr<webrtc::EncodedImage> image, |
75 int32 bitstream_buffer_id, | 74 int32 bitstream_buffer_id, |
76 uint16 picture_id); | 75 uint16 picture_id); |
77 | 76 |
78 void NotifyError(int32_t error); | 77 void NotifyError(int32_t error); |
79 | 78 |
80 void RecordInitEncodeUMA(int32_t init_retval); | 79 void RecordInitEncodeUMA(int32_t init_retval, |
| 80 media::VideoCodecProfile profile); |
81 | 81 |
82 base::ThreadChecker thread_checker_; | 82 base::ThreadChecker thread_checker_; |
83 | 83 |
84 // The video codec type, as reported to WebRTC. | 84 // The video codec type, as reported to WebRTC. |
85 const webrtc::VideoCodecType video_codec_type_; | 85 const webrtc::VideoCodecType video_codec_type_; |
86 | 86 |
87 // The video codec profile, to configure the encoder to encode to. | |
88 const media::VideoCodecProfile video_codec_profile_; | |
89 | |
90 // Factory for creating VEAs, shared memory buffers, etc. | 87 // Factory for creating VEAs, shared memory buffers, etc. |
91 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; | 88 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; |
92 | 89 |
93 // webrtc::VideoEncoder encode complete callback. | 90 // webrtc::VideoEncoder encode complete callback. |
94 webrtc::EncodedImageCallback* encoded_image_callback_; | 91 webrtc::EncodedImageCallback* encoded_image_callback_; |
95 | 92 |
96 // The RTCVideoEncoder::Impl that does all the work. | 93 // The RTCVideoEncoder::Impl that does all the work. |
97 scoped_refptr<Impl> impl_; | 94 scoped_refptr<Impl> impl_; |
98 | 95 |
99 // We cannot immediately return error conditions to the WebRTC user of this | 96 // We cannot immediately return error conditions to the WebRTC user of this |
100 // class, as there is no error callback in the webrtc::VideoEncoder interface. | 97 // class, as there is no error callback in the webrtc::VideoEncoder interface. |
101 // Instead, we cache an error status here and return it the next time an | 98 // Instead, we cache an error status here and return it the next time an |
102 // interface entry point is called. | 99 // interface entry point is called. |
103 int32_t impl_status_; | 100 int32_t impl_status_; |
104 | 101 |
105 // Weak pointer factory for posting back VEA::Client notifications to | 102 // Weak pointer factory for posting back VEA::Client notifications to |
106 // RTCVideoEncoder. | 103 // RTCVideoEncoder. |
107 // NOTE: Weak pointers must be invalidated before all other member variables. | 104 // NOTE: Weak pointers must be invalidated before all other member variables. |
108 base::WeakPtrFactory<RTCVideoEncoder> weak_factory_; | 105 base::WeakPtrFactory<RTCVideoEncoder> weak_factory_; |
109 | 106 |
110 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); | 107 DISALLOW_COPY_AND_ASSIGN(RTCVideoEncoder); |
111 }; | 108 }; |
112 | 109 |
113 } // namespace content | 110 } // namespace content |
114 | 111 |
115 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ | 112 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_ENCODER_H_ |
OLD | NEW |