| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 VideoMediaChannel::Error error() const { return error_; } | 160 VideoMediaChannel::Error error() const { return error_; } |
| 161 void OnError(uint32_t ssrc, VideoMediaChannel::Error error) { | 161 void OnError(uint32_t ssrc, VideoMediaChannel::Error error) { |
| 162 ssrc_ = ssrc; | 162 ssrc_ = ssrc; |
| 163 error_ = error; | 163 error_ = error; |
| 164 } | 164 } |
| 165 private: | 165 private: |
| 166 uint32_t ssrc_; | 166 uint32_t ssrc_; |
| 167 VideoMediaChannel::Error error_; | 167 VideoMediaChannel::Error error_; |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 // Returns the absolute path to a file in the testdata/ directory. | |
| 171 std::string GetTestFilePath(const std::string& filename); | |
| 172 | |
| 173 // PSNR formula: psnr = 10 * log10 (Peak Signal^2 / mse) | |
| 174 // sse is set to a small number for identical frames or sse == 0 | |
| 175 static inline double ComputePSNR(double sse, double count) { | |
| 176 return libyuv::SumSquareErrorToPsnr(static_cast<uint64_t>(sse), | |
| 177 static_cast<uint64_t>(count)); | |
| 178 } | |
| 179 | |
| 180 static inline double ComputeSumSquareError(const uint8_t* org, | |
| 181 const uint8_t* rec, | |
| 182 int size) { | |
| 183 return static_cast<double>(libyuv::ComputeSumSquareError(org, rec, size)); | |
| 184 } | |
| 185 | |
| 186 // Loads the image with the specified prefix and size into |out|. | |
| 187 bool LoadPlanarYuvTestImage(const std::string& prefix, | |
| 188 int width, | |
| 189 int height, | |
| 190 uint8_t* out); | |
| 191 | |
| 192 // Dumps the YUV image out to a file, for visual inspection. | |
| 193 // PYUV tool can be used to view dump files. | |
| 194 void DumpPlanarYuvTestImage(const std::string& prefix, | |
| 195 const uint8_t* img, | |
| 196 int w, | |
| 197 int h); | |
| 198 | |
| 199 // Dumps the ARGB image out to a file, for visual inspection. | |
| 200 // ffplay tool can be used to view dump files. | |
| 201 void DumpPlanarArgbTestImage(const std::string& prefix, | |
| 202 const uint8_t* img, | |
| 203 int w, | |
| 204 int h); | |
| 205 | |
| 206 // Checks whether |codecs| contains |codec|; checks using Codec::Matches(). | 170 // Checks whether |codecs| contains |codec|; checks using Codec::Matches(). |
| 207 template <class C> | 171 template <class C> |
| 208 bool ContainsMatchingCodec(const std::vector<C>& codecs, const C& codec) { | 172 bool ContainsMatchingCodec(const std::vector<C>& codecs, const C& codec) { |
| 209 typename std::vector<C>::const_iterator it; | 173 typename std::vector<C>::const_iterator it; |
| 210 for (it = codecs.begin(); it != codecs.end(); ++it) { | 174 for (it = codecs.begin(); it != codecs.end(); ++it) { |
| 211 if (it->Matches(codec)) { | 175 if (it->Matches(codec)) { |
| 212 return true; | 176 return true; |
| 213 } | 177 } |
| 214 } | 178 } |
| 215 return false; | 179 return false; |
| 216 } | 180 } |
| 217 | 181 |
| 218 // Create Simulcast StreamParams with given |ssrcs| and |cname|. | 182 // Create Simulcast StreamParams with given |ssrcs| and |cname|. |
| 219 cricket::StreamParams CreateSimStreamParams(const std::string& cname, | 183 cricket::StreamParams CreateSimStreamParams(const std::string& cname, |
| 220 const std::vector<uint32_t>& ssrcs); | 184 const std::vector<uint32_t>& ssrcs); |
| 221 // Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|. | 185 // Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|. |
| 222 // The number of |rtx_ssrcs| must match number of |ssrcs|. | 186 // The number of |rtx_ssrcs| must match number of |ssrcs|. |
| 223 cricket::StreamParams CreateSimWithRtxStreamParams( | 187 cricket::StreamParams CreateSimWithRtxStreamParams( |
| 224 const std::string& cname, | 188 const std::string& cname, |
| 225 const std::vector<uint32_t>& ssrcs, | 189 const std::vector<uint32_t>& ssrcs, |
| 226 const std::vector<uint32_t>& rtx_ssrcs); | 190 const std::vector<uint32_t>& rtx_ssrcs); |
| 227 | 191 |
| 228 } // namespace cricket | 192 } // namespace cricket |
| 229 | 193 |
| 230 #endif // WEBRTC_MEDIA_BASE_TESTUTILS_H_ | 194 #endif // WEBRTC_MEDIA_BASE_TESTUTILS_H_ |
| OLD | NEW |