Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: webrtc/video/video_decoder_unittest.cc

Issue 1406903002: Expose codec implementation names in stats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: report what we fell back from Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 int32_t Release() override { 46 int32_t Release() override {
47 ++release_count_; 47 ++release_count_;
48 return WEBRTC_VIDEO_CODEC_OK; 48 return WEBRTC_VIDEO_CODEC_OK;
49 } 49 }
50 50
51 int32_t Reset() override { 51 int32_t Reset() override {
52 ++reset_count_; 52 ++reset_count_;
53 return WEBRTC_VIDEO_CODEC_OK; 53 return WEBRTC_VIDEO_CODEC_OK;
54 } 54 }
55
56 const char* ImplementationName() const override {
57 return "fake-decoder";
58 }
59
55 int init_decode_count_ = 0; 60 int init_decode_count_ = 0;
56 int decode_count_ = 0; 61 int decode_count_ = 0;
57 int32_t decode_return_code_ = WEBRTC_VIDEO_CODEC_OK; 62 int32_t decode_return_code_ = WEBRTC_VIDEO_CODEC_OK;
58 DecodedImageCallback* decode_complete_callback_ = nullptr; 63 DecodedImageCallback* decode_complete_callback_ = nullptr;
59 int release_count_ = 0; 64 int release_count_ = 0;
60 int reset_count_ = 0; 65 int reset_count_ = 0;
61 }; 66 };
62 CountingFakeDecoder fake_decoder_; 67 CountingFakeDecoder fake_decoder_;
63 VideoDecoderSoftwareFallbackWrapper fallback_wrapper_; 68 VideoDecoderSoftwareFallbackWrapper fallback_wrapper_;
64 }; 69 };
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 141
137 fake_decoder_.decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; 142 fake_decoder_.decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
138 EncodedImage encoded_image; 143 EncodedImage encoded_image;
139 fallback_wrapper_.Decode(encoded_image, false, nullptr, nullptr, -1); 144 fallback_wrapper_.Decode(encoded_image, false, nullptr, nullptr, -1);
140 fallback_wrapper_.Reset(); 145 fallback_wrapper_.Reset();
141 EXPECT_EQ(2, fake_decoder_.reset_count_) 146 EXPECT_EQ(2, fake_decoder_.reset_count_)
142 << "Reset not forwarded during fallback."; 147 << "Reset not forwarded during fallback.";
143 } 148 }
144 149
145 // TODO(pbos): Fake a VP8 frame well enough to actually receive a callback from 150 // TODO(pbos): Fake a VP8 frame well enough to actually receive a callback from
146 // the software encoder. 151 // the software decoder.
147 TEST_F(VideoDecoderSoftwareFallbackWrapperTest, 152 TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
148 ForwardsRegisterDecodeCompleteCallback) { 153 ForwardsRegisterDecodeCompleteCallback) {
149 class FakeDecodedImageCallback : public DecodedImageCallback { 154 class FakeDecodedImageCallback : public DecodedImageCallback {
150 int32_t Decoded(VideoFrame& decodedImage) override { return 0; } 155 int32_t Decoded(VideoFrame& decodedImage) override { return 0; }
151 } callback, callback2; 156 } callback, callback2;
152 157
153 VideoCodec codec = {}; 158 VideoCodec codec = {};
154 fallback_wrapper_.InitDecode(&codec, 2); 159 fallback_wrapper_.InitDecode(&codec, 2);
155 fallback_wrapper_.RegisterDecodeCompleteCallback(&callback); 160 fallback_wrapper_.RegisterDecodeCompleteCallback(&callback);
156 EXPECT_EQ(&callback, fake_decoder_.decode_complete_callback_); 161 EXPECT_EQ(&callback, fake_decoder_.decode_complete_callback_);
157 162
158 fake_decoder_.decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; 163 fake_decoder_.decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
159 EncodedImage encoded_image; 164 EncodedImage encoded_image;
160 fallback_wrapper_.Decode(encoded_image, false, nullptr, nullptr, -1); 165 fallback_wrapper_.Decode(encoded_image, false, nullptr, nullptr, -1);
161 fallback_wrapper_.RegisterDecodeCompleteCallback(&callback2); 166 fallback_wrapper_.RegisterDecodeCompleteCallback(&callback2);
162 EXPECT_EQ(&callback2, fake_decoder_.decode_complete_callback_); 167 EXPECT_EQ(&callback2, fake_decoder_.decode_complete_callback_);
163 } 168 }
164 169
170 TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
171 ReportsFallbackImplementationName) {
172 VideoCodec codec = {};
173 fallback_wrapper_.InitDecode(&codec, 2);
174
175 fake_decoder_.decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
176 EncodedImage encoded_image;
177 fallback_wrapper_.Decode(encoded_image, false, nullptr, nullptr, -1);
178 // Hard coded expected value since libvpx is the software implementation name
179 // for VP8. Change accordingly if the underlying implementation does.
180 EXPECT_STREQ("libvpx (fallback from: fake-decoder)",
181 fallback_wrapper_.ImplementationName());
182 fallback_wrapper_.Release();
183 }
184
165 } // namespace webrtc 185 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698