OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 TEST_F(TestSimulcastEncoderAdapter, DISABLED_TestRPSIEncoder) { | 105 TEST_F(TestSimulcastEncoderAdapter, DISABLED_TestRPSIEncoder) { |
106 TestVp8Simulcast::TestRPSIEncoder(); | 106 TestVp8Simulcast::TestRPSIEncoder(); |
107 } | 107 } |
108 | 108 |
109 class MockVideoEncoder : public VideoEncoder { | 109 class MockVideoEncoder : public VideoEncoder { |
110 public: | 110 public: |
111 int32_t InitEncode(const VideoCodec* codecSettings, | 111 int32_t InitEncode(const VideoCodec* codecSettings, |
112 int32_t numberOfCores, | 112 int32_t numberOfCores, |
113 size_t maxPayloadSize) { | 113 size_t maxPayloadSize) override { |
114 codec_ = *codecSettings; | 114 codec_ = *codecSettings; |
115 return 0; | 115 return 0; |
116 } | 116 } |
117 | 117 |
118 int32_t Encode(const VideoFrame& inputImage, | 118 int32_t Encode(const VideoFrame& inputImage, |
119 const CodecSpecificInfo* codecSpecificInfo, | 119 const CodecSpecificInfo* codecSpecificInfo, |
120 const std::vector<VideoFrameType>* frame_types) { | 120 const std::vector<VideoFrameType>* frame_types) override { |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 | 123 |
124 int32_t RegisterEncodeCompleteCallback(EncodedImageCallback* callback) { | 124 int32_t RegisterEncodeCompleteCallback( |
| 125 EncodedImageCallback* callback) override { |
125 callback_ = callback; | 126 callback_ = callback; |
126 return 0; | 127 return 0; |
127 } | 128 } |
128 | 129 |
129 int32_t Release() { | 130 int32_t Release() override { |
130 return 0; | 131 return 0; |
131 } | 132 } |
132 | 133 |
133 int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) { | 134 int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) override { |
134 return 0; | 135 return 0; |
135 } | 136 } |
136 | 137 |
137 MOCK_METHOD2(SetChannelParameters, | 138 MOCK_METHOD2(SetChannelParameters, |
138 int32_t(uint32_t packetLoss, int64_t rtt)); | 139 int32_t(uint32_t packetLoss, int64_t rtt)); |
139 | 140 |
| 141 bool SupportsNativeHandle() const override { |
| 142 return supports_native_handle_; |
| 143 } |
| 144 |
140 virtual ~MockVideoEncoder() { | 145 virtual ~MockVideoEncoder() { |
141 } | 146 } |
142 | 147 |
143 const VideoCodec& codec() const { return codec_; } | 148 const VideoCodec& codec() const { return codec_; } |
144 | 149 |
145 void SendEncodedImage(int width, int height) { | 150 void SendEncodedImage(int width, int height) { |
146 // Sends a fake image of the given width/height. | 151 // Sends a fake image of the given width/height. |
147 EncodedImage image; | 152 EncodedImage image; |
148 image._encodedWidth = width; | 153 image._encodedWidth = width; |
149 image._encodedHeight = height; | 154 image._encodedHeight = height; |
150 CodecSpecificInfo codecSpecificInfo; | 155 CodecSpecificInfo codecSpecificInfo; |
151 memset(&codecSpecificInfo, 0, sizeof(codecSpecificInfo)); | 156 memset(&codecSpecificInfo, 0, sizeof(codecSpecificInfo)); |
152 callback_->Encoded(image, &codecSpecificInfo, NULL); | 157 callback_->Encoded(image, &codecSpecificInfo, NULL); |
153 } | 158 } |
154 | 159 |
| 160 void set_supports_native_handle(bool enabled) { |
| 161 supports_native_handle_ = enabled; |
| 162 } |
| 163 |
155 private: | 164 private: |
| 165 bool supports_native_handle_ = false; |
156 VideoCodec codec_; | 166 VideoCodec codec_; |
157 EncodedImageCallback* callback_; | 167 EncodedImageCallback* callback_; |
158 }; | 168 }; |
159 | 169 |
160 class MockVideoEncoderFactory : public VideoEncoderFactory { | 170 class MockVideoEncoderFactory : public VideoEncoderFactory { |
161 public: | 171 public: |
162 VideoEncoder* Create() override { | 172 VideoEncoder* Create() override { |
163 MockVideoEncoder* encoder = new MockVideoEncoder(); | 173 MockVideoEncoder* encoder = new MockVideoEncoder(); |
164 encoders_.push_back(encoder); | 174 encoders_.push_back(encoder); |
165 return encoder; | 175 return encoder; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 EXPECT_EQ(620, height); | 385 EXPECT_EQ(620, height); |
376 EXPECT_EQ(1, simulcast_index); | 386 EXPECT_EQ(1, simulcast_index); |
377 | 387 |
378 helper_->factory()->encoders()[2]->SendEncodedImage(120, 240); | 388 helper_->factory()->encoders()[2]->SendEncodedImage(120, 240); |
379 EXPECT_TRUE(GetLastEncodedImageInfo(&width, &height, &simulcast_index)); | 389 EXPECT_TRUE(GetLastEncodedImageInfo(&width, &height, &simulcast_index)); |
380 EXPECT_EQ(120, width); | 390 EXPECT_EQ(120, width); |
381 EXPECT_EQ(240, height); | 391 EXPECT_EQ(240, height); |
382 EXPECT_EQ(2, simulcast_index); | 392 EXPECT_EQ(2, simulcast_index); |
383 } | 393 } |
384 | 394 |
| 395 TEST_F(TestSimulcastEncoderAdapterFake, SupportsNativeHandleForSingleStreams) { |
| 396 TestVp8Simulcast::DefaultSettings( |
| 397 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); |
| 398 codec_.numberOfSimulcastStreams = 1; |
| 399 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); |
| 400 adapter_->RegisterEncodeCompleteCallback(this); |
| 401 ASSERT_EQ(1u, helper_->factory()->encoders().size()); |
| 402 helper_->factory()->encoders()[0]->set_supports_native_handle(true); |
| 403 EXPECT_TRUE(adapter_->SupportsNativeHandle()); |
| 404 helper_->factory()->encoders()[0]->set_supports_native_handle(false); |
| 405 EXPECT_FALSE(adapter_->SupportsNativeHandle()); |
| 406 } |
| 407 |
| 408 TEST_F(TestSimulcastEncoderAdapterFake, |
| 409 SupportsNativeHandleDisabledForMultipleStreams) { |
| 410 // TODO(pbos): Implement actual test (verify that it works) when implemented |
| 411 // for multiple streams. |
| 412 TestVp8Simulcast::DefaultSettings( |
| 413 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); |
| 414 codec_.numberOfSimulcastStreams = 3; |
| 415 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); |
| 416 adapter_->RegisterEncodeCompleteCallback(this); |
| 417 ASSERT_EQ(3u, helper_->factory()->encoders().size()); |
| 418 for (MockVideoEncoder* encoder : helper_->factory()->encoders()) |
| 419 encoder->set_supports_native_handle(true); |
| 420 EXPECT_FALSE(adapter_->SupportsNativeHandle()); |
| 421 } |
| 422 |
385 } // namespace testing | 423 } // namespace testing |
386 } // namespace webrtc | 424 } // namespace webrtc |
OLD | NEW |