OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void RunUntilIdle() { | 106 void RunUntilIdle() { |
107 DVLOG(3) << __func__; | 107 DVLOG(3) << __func__; |
108 encoder_thread_.task_runner()->PostTask( | 108 encoder_thread_.task_runner()->PostTask( |
109 FROM_HERE, base::Bind(&base::WaitableEvent::Signal, | 109 FROM_HERE, base::Bind(&base::WaitableEvent::Signal, |
110 base::Unretained(&idle_waiter_))); | 110 base::Unretained(&idle_waiter_))); |
111 idle_waiter_.Wait(); | 111 idle_waiter_.Wait(); |
112 } | 112 } |
113 | 113 |
114 void CreateEncoder(webrtc::VideoCodecType codec_type) { | 114 void CreateEncoder(webrtc::VideoCodecType codec_type) { |
115 DVLOG(3) << __func__; | 115 DVLOG(3) << __func__; |
116 media::VideoCodecProfile media_profile; | 116 rtc_encoder_ = base::MakeUnique<RTCVideoEncoder>(codec_type, |
117 switch (codec_type) { | |
118 case webrtc::kVideoCodecVP8: | |
119 media_profile = media::VP8PROFILE_ANY; | |
120 break; | |
121 case webrtc::kVideoCodecH264: | |
122 media_profile = media::H264PROFILE_BASELINE; | |
123 break; | |
124 default: | |
125 ADD_FAILURE() << "Unexpected codec type: " << codec_type; | |
126 media_profile = media::VIDEO_CODEC_PROFILE_UNKNOWN; | |
127 } | |
128 rtc_encoder_ = base::MakeUnique<RTCVideoEncoder>(media_profile, | |
129 mock_gpu_factories_.get()); | 117 mock_gpu_factories_.get()); |
130 } | 118 } |
131 | 119 |
132 // media::VideoEncodeAccelerator implementation. | 120 // media::VideoEncodeAccelerator implementation. |
133 bool Initialize(media::VideoPixelFormat input_format, | 121 bool Initialize(media::VideoPixelFormat input_format, |
134 const gfx::Size& input_visible_size, | 122 const gfx::Size& input_visible_size, |
135 media::VideoCodecProfile output_profile, | 123 media::VideoCodecProfile output_profile, |
136 uint32_t initial_bitrate, | 124 uint32_t initial_bitrate, |
137 media::VideoEncodeAccelerator::Client* client) { | 125 media::VideoEncodeAccelerator::Client* client) { |
138 DVLOG(3) << __func__; | 126 DVLOG(3) << __func__; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 rtc_frame.set_ntp_time_ms(4567891); | 271 rtc_frame.set_ntp_time_ms(4567891); |
284 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 272 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
285 rtc_encoder_->Encode(rtc_frame, nullptr, &frame_types)); | 273 rtc_encoder_->Encode(rtc_frame, nullptr, &frame_types)); |
286 } | 274 } |
287 | 275 |
288 INSTANTIATE_TEST_CASE_P(CodecProfiles, | 276 INSTANTIATE_TEST_CASE_P(CodecProfiles, |
289 RTCVideoEncoderTest, | 277 RTCVideoEncoderTest, |
290 Values(webrtc::kVideoCodecVP8, | 278 Values(webrtc::kVideoCodecVP8, |
291 webrtc::kVideoCodecH264)); | 279 webrtc::kVideoCodecH264)); |
292 } // namespace content | 280 } // namespace content |
OLD | NEW |