OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 EncodedImageCallback::Result | 30 EncodedImageCallback::Result |
31 VideoCodecTest::FakeEncodeCompleteCallback::OnEncodedImage( | 31 VideoCodecTest::FakeEncodeCompleteCallback::OnEncodedImage( |
32 const EncodedImage& frame, | 32 const EncodedImage& frame, |
33 const CodecSpecificInfo* codec_specific_info, | 33 const CodecSpecificInfo* codec_specific_info, |
34 const RTPFragmentationHeader* fragmentation) { | 34 const RTPFragmentationHeader* fragmentation) { |
35 rtc::CritScope lock(&test_->encoded_frame_section_); | 35 rtc::CritScope lock(&test_->encoded_frame_section_); |
36 test_->encoded_frame_.emplace(frame); | 36 test_->encoded_frame_.emplace(frame); |
| 37 RTC_DCHECK(codec_specific_info); |
| 38 test_->codec_specific_info_.codecType = codec_specific_info->codecType; |
| 39 // Skip |codec_name|, to avoid allocating. |
| 40 test_->codec_specific_info_.codecSpecific = |
| 41 codec_specific_info->codecSpecific; |
37 test_->encoded_frame_event_.Set(); | 42 test_->encoded_frame_event_.Set(); |
38 return Result(Result::OK); | 43 return Result(Result::OK); |
39 } | 44 } |
40 | 45 |
41 void VideoCodecTest::FakeDecodeCompleteCallback::Decoded( | 46 void VideoCodecTest::FakeDecodeCompleteCallback::Decoded( |
42 VideoFrame& frame, | 47 VideoFrame& frame, |
43 rtc::Optional<int32_t> decode_time_ms, | 48 rtc::Optional<int32_t> decode_time_ms, |
44 rtc::Optional<uint8_t> qp) { | 49 rtc::Optional<uint8_t> qp) { |
45 rtc::CritScope lock(&test_->decoded_frame_section_); | 50 rtc::CritScope lock(&test_->decoded_frame_section_); |
46 test_->decoded_frame_.emplace(frame); | 51 test_->decoded_frame_.emplace(frame); |
(...skipping 12 matching lines...) Expand all Loading... |
59 fclose(source_file_); | 64 fclose(source_file_); |
60 | 65 |
61 encoder_.reset(CreateEncoder()); | 66 encoder_.reset(CreateEncoder()); |
62 decoder_.reset(CreateDecoder()); | 67 decoder_.reset(CreateDecoder()); |
63 encoder_->RegisterEncodeCompleteCallback(&encode_complete_callback_); | 68 encoder_->RegisterEncodeCompleteCallback(&encode_complete_callback_); |
64 decoder_->RegisterDecodeCompleteCallback(&decode_complete_callback_); | 69 decoder_->RegisterDecodeCompleteCallback(&decode_complete_callback_); |
65 | 70 |
66 InitCodecs(); | 71 InitCodecs(); |
67 } | 72 } |
68 | 73 |
69 bool VideoCodecTest::WaitForEncodedFrame(EncodedImage* frame) { | 74 bool VideoCodecTest::WaitForEncodedFrame( |
| 75 EncodedImage* frame, |
| 76 CodecSpecificInfo* codec_specific_info) { |
70 bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs); | 77 bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs); |
71 EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame."; | 78 EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame."; |
72 // This becomes unsafe if there are multiple threads waiting for frames. | 79 // This becomes unsafe if there are multiple threads waiting for frames. |
73 rtc::CritScope lock(&encoded_frame_section_); | 80 rtc::CritScope lock(&encoded_frame_section_); |
74 EXPECT_TRUE(encoded_frame_); | 81 EXPECT_TRUE(encoded_frame_); |
75 if (encoded_frame_) { | 82 if (encoded_frame_) { |
76 *frame = std::move(*encoded_frame_); | 83 *frame = std::move(*encoded_frame_); |
77 encoded_frame_.reset(); | 84 encoded_frame_.reset(); |
| 85 RTC_DCHECK(codec_specific_info); |
| 86 codec_specific_info->codecType = codec_specific_info_.codecType; |
| 87 codec_specific_info->codecSpecific = codec_specific_info_.codecSpecific; |
78 return true; | 88 return true; |
79 } else { | 89 } else { |
80 return false; | 90 return false; |
81 } | 91 } |
82 } | 92 } |
83 | 93 |
84 bool VideoCodecTest::WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame, | 94 bool VideoCodecTest::WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame, |
85 rtc::Optional<uint8_t>* qp) { | 95 rtc::Optional<uint8_t>* qp) { |
86 bool ret = decoded_frame_event_.Wait(kDecodeTimeoutMs); | 96 bool ret = decoded_frame_event_.Wait(kDecodeTimeoutMs); |
87 EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame."; | 97 EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame."; |
88 // This becomes unsafe if there are multiple threads waiting for frames. | 98 // This becomes unsafe if there are multiple threads waiting for frames. |
89 rtc::CritScope lock(&decoded_frame_section_); | 99 rtc::CritScope lock(&decoded_frame_section_); |
90 EXPECT_TRUE(decoded_frame_); | 100 EXPECT_TRUE(decoded_frame_); |
91 if (decoded_frame_) { | 101 if (decoded_frame_) { |
92 frame->reset(new VideoFrame(std::move(*decoded_frame_))); | 102 frame->reset(new VideoFrame(std::move(*decoded_frame_))); |
93 *qp = decoded_qp_; | 103 *qp = decoded_qp_; |
94 decoded_frame_.reset(); | 104 decoded_frame_.reset(); |
95 return true; | 105 return true; |
96 } else { | 106 } else { |
97 return false; | 107 return false; |
98 } | 108 } |
99 } | 109 } |
100 | 110 |
101 void VideoCodecTest::InitCodecs() { | 111 void VideoCodecTest::InitCodecs() { |
102 VideoCodec codec_inst = codec_settings(); | 112 codec_settings_ = codec_settings(); |
103 codec_inst.startBitrate = kStartBitrate; | 113 codec_settings_.startBitrate = kStartBitrate; |
104 codec_inst.targetBitrate = kTargetBitrate; | 114 codec_settings_.targetBitrate = kTargetBitrate; |
105 codec_inst.maxBitrate = kMaxBitrate; | 115 codec_settings_.maxBitrate = kMaxBitrate; |
106 codec_inst.maxFramerate = kMaxFramerate; | 116 codec_settings_.maxFramerate = kMaxFramerate; |
107 codec_inst.width = kWidth; | 117 codec_settings_.width = kWidth; |
108 codec_inst.height = kHeight; | 118 codec_settings_.height = kHeight; |
109 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 119 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
110 encoder_->InitEncode(&codec_inst, 1 /* number of cores */, | 120 encoder_->InitEncode(&codec_settings_, 1 /* number of cores */, |
111 0 /* max payload size (unused) */)); | 121 0 /* max payload size (unused) */)); |
112 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 122 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
113 decoder_->InitDecode(&codec_inst, 1 /* number of cores */)); | 123 decoder_->InitDecode(&codec_settings_, 1 /* number of cores */)); |
114 } | 124 } |
115 | 125 |
116 } // namespace webrtc | 126 } // namespace webrtc |
OLD | NEW |