henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "talk/media/base/testutils.h" |
| 29 | |
buildbot@webrtc.org | 72e4485 | 2014-09-03 00:43:48 +0000 | [diff] [blame] | 30 | #if defined(OSX) && defined(FLUTE_IN_CHROME_BUILD) |
| 31 | #include <mach-o/dyld.h> // For NSGetExecutablePath. |
| 32 | #endif |
| 33 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | #include <math.h> |
| 35 | |
thorcarpenter@google.com | a3344cf | 2014-09-05 16:34:13 +0000 | [diff] [blame^] | 36 | #include "talk/media/base/executablehelpers.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 37 | #include "talk/media/base/rtpdump.h" |
| 38 | #include "talk/media/base/videocapturer.h" |
| 39 | #include "talk/media/base/videoframe.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 40 | #include "webrtc/base/bytebuffer.h" |
| 41 | #include "webrtc/base/fileutils.h" |
| 42 | #include "webrtc/base/gunit.h" |
| 43 | #include "webrtc/base/pathutils.h" |
| 44 | #include "webrtc/base/stream.h" |
| 45 | #include "webrtc/base/stringutils.h" |
| 46 | #include "webrtc/base/testutils.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | |
| 48 | namespace cricket { |
| 49 | |
| 50 | ///////////////////////////////////////////////////////////////////////// |
| 51 | // Implementation of RawRtpPacket |
| 52 | ///////////////////////////////////////////////////////////////////////// |
| 53 | void RawRtpPacket::WriteToByteBuffer( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 54 | uint32 in_ssrc, rtc::ByteBuffer *buf) const { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | if (!buf) return; |
| 56 | |
| 57 | buf->WriteUInt8(ver_to_cc); |
| 58 | buf->WriteUInt8(m_to_pt); |
| 59 | buf->WriteUInt16(sequence_number); |
| 60 | buf->WriteUInt32(timestamp); |
| 61 | buf->WriteUInt32(in_ssrc); |
| 62 | buf->WriteBytes(payload, sizeof(payload)); |
| 63 | } |
| 64 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 65 | bool RawRtpPacket::ReadFromByteBuffer(rtc::ByteBuffer* buf) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | if (!buf) return false; |
| 67 | |
| 68 | bool ret = true; |
| 69 | ret &= buf->ReadUInt8(&ver_to_cc); |
| 70 | ret &= buf->ReadUInt8(&m_to_pt); |
| 71 | ret &= buf->ReadUInt16(&sequence_number); |
| 72 | ret &= buf->ReadUInt32(×tamp); |
| 73 | ret &= buf->ReadUInt32(&ssrc); |
| 74 | ret &= buf->ReadBytes(payload, sizeof(payload)); |
| 75 | return ret; |
| 76 | } |
| 77 | |
| 78 | bool RawRtpPacket::SameExceptSeqNumTimestampSsrc( |
| 79 | const RawRtpPacket& packet, uint16 seq, uint32 ts, uint32 ssc) const { |
| 80 | return sequence_number == seq && |
| 81 | timestamp == ts && |
| 82 | ver_to_cc == packet.ver_to_cc && |
| 83 | m_to_pt == packet.m_to_pt && |
| 84 | ssrc == ssc && |
| 85 | 0 == memcmp(payload, packet.payload, sizeof(payload)); |
| 86 | } |
| 87 | |
| 88 | ///////////////////////////////////////////////////////////////////////// |
| 89 | // Implementation of RawRtcpPacket |
| 90 | ///////////////////////////////////////////////////////////////////////// |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 91 | void RawRtcpPacket::WriteToByteBuffer(rtc::ByteBuffer *buf) const { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 92 | if (!buf) return; |
| 93 | |
| 94 | buf->WriteUInt8(ver_to_count); |
| 95 | buf->WriteUInt8(type); |
| 96 | buf->WriteUInt16(length); |
| 97 | buf->WriteBytes(payload, sizeof(payload)); |
| 98 | } |
| 99 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 100 | bool RawRtcpPacket::ReadFromByteBuffer(rtc::ByteBuffer* buf) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | if (!buf) return false; |
| 102 | |
| 103 | bool ret = true; |
| 104 | ret &= buf->ReadUInt8(&ver_to_count); |
| 105 | ret &= buf->ReadUInt8(&type); |
| 106 | ret &= buf->ReadUInt16(&length); |
| 107 | ret &= buf->ReadBytes(payload, sizeof(payload)); |
| 108 | return ret; |
| 109 | } |
| 110 | |
| 111 | bool RawRtcpPacket::EqualsTo(const RawRtcpPacket& packet) const { |
| 112 | return ver_to_count == packet.ver_to_count && |
| 113 | type == packet.type && |
| 114 | length == packet.length && |
| 115 | 0 == memcmp(payload, packet.payload, sizeof(payload)); |
| 116 | } |
| 117 | |
| 118 | ///////////////////////////////////////////////////////////////////////// |
| 119 | // Implementation of class RtpTestUtility |
| 120 | ///////////////////////////////////////////////////////////////////////// |
| 121 | const RawRtpPacket RtpTestUtility::kTestRawRtpPackets[] = { |
| 122 | {0x80, 0, 0, 0, RtpTestUtility::kDefaultSsrc, "RTP frame 0"}, |
| 123 | {0x80, 0, 1, 30, RtpTestUtility::kDefaultSsrc, "RTP frame 1"}, |
| 124 | {0x80, 0, 2, 30, RtpTestUtility::kDefaultSsrc, "RTP frame 1"}, |
| 125 | {0x80, 0, 3, 60, RtpTestUtility::kDefaultSsrc, "RTP frame 2"} |
| 126 | }; |
| 127 | const RawRtcpPacket RtpTestUtility::kTestRawRtcpPackets[] = { |
| 128 | // The Version is 2, the Length is 2, and the payload has 8 bytes. |
| 129 | {0x80, 0, 2, "RTCP0000"}, |
| 130 | {0x80, 0, 2, "RTCP0001"}, |
| 131 | {0x80, 0, 2, "RTCP0002"}, |
| 132 | {0x80, 0, 2, "RTCP0003"}, |
| 133 | }; |
| 134 | |
| 135 | size_t RtpTestUtility::GetTestPacketCount() { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 136 | return rtc::_min( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 137 | ARRAY_SIZE(kTestRawRtpPackets), |
| 138 | ARRAY_SIZE(kTestRawRtcpPackets)); |
| 139 | } |
| 140 | |
| 141 | bool RtpTestUtility::WriteTestPackets( |
| 142 | size_t count, bool rtcp, uint32 rtp_ssrc, RtpDumpWriter* writer) { |
| 143 | if (!writer || count > GetTestPacketCount()) return false; |
| 144 | |
| 145 | bool result = true; |
| 146 | uint32 elapsed_time_ms = 0; |
| 147 | for (size_t i = 0; i < count && result; ++i) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 148 | rtc::ByteBuffer buf; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 149 | if (rtcp) { |
| 150 | kTestRawRtcpPackets[i].WriteToByteBuffer(&buf); |
| 151 | } else { |
| 152 | kTestRawRtpPackets[i].WriteToByteBuffer(rtp_ssrc, &buf); |
| 153 | } |
| 154 | |
| 155 | RtpDumpPacket dump_packet(buf.Data(), buf.Length(), elapsed_time_ms, rtcp); |
| 156 | elapsed_time_ms += kElapsedTimeInterval; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 157 | result &= (rtc::SR_SUCCESS == writer->WritePacket(dump_packet)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 158 | } |
| 159 | return result; |
| 160 | } |
| 161 | |
| 162 | bool RtpTestUtility::VerifyTestPacketsFromStream( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 163 | size_t count, rtc::StreamInterface* stream, uint32 ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 164 | if (!stream) return false; |
| 165 | |
| 166 | uint32 prev_elapsed_time = 0; |
| 167 | bool result = true; |
| 168 | stream->Rewind(); |
| 169 | RtpDumpLoopReader reader(stream); |
| 170 | for (size_t i = 0; i < count && result; ++i) { |
| 171 | // Which loop and which index in the loop are we reading now. |
| 172 | size_t loop = i / GetTestPacketCount(); |
| 173 | size_t index = i % GetTestPacketCount(); |
| 174 | |
| 175 | RtpDumpPacket packet; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 176 | result &= (rtc::SR_SUCCESS == reader.ReadPacket(&packet)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 177 | // Check the elapsed time of the dump packet. |
| 178 | result &= (packet.elapsed_time >= prev_elapsed_time); |
| 179 | prev_elapsed_time = packet.elapsed_time; |
| 180 | |
| 181 | // Check the RTP or RTCP packet. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 182 | rtc::ByteBuffer buf(reinterpret_cast<const char*>(&packet.data[0]), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 183 | packet.data.size()); |
| 184 | if (packet.is_rtcp()) { |
| 185 | // RTCP packet. |
| 186 | RawRtcpPacket rtcp_packet; |
| 187 | result &= rtcp_packet.ReadFromByteBuffer(&buf); |
| 188 | result &= rtcp_packet.EqualsTo(kTestRawRtcpPackets[index]); |
| 189 | } else { |
| 190 | // RTP packet. |
| 191 | RawRtpPacket rtp_packet; |
| 192 | result &= rtp_packet.ReadFromByteBuffer(&buf); |
| 193 | result &= rtp_packet.SameExceptSeqNumTimestampSsrc( |
| 194 | kTestRawRtpPackets[index], |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 195 | static_cast<uint16>(kTestRawRtpPackets[index].sequence_number + |
| 196 | loop * GetTestPacketCount()), |
| 197 | static_cast<uint32>(kTestRawRtpPackets[index].timestamp + |
| 198 | loop * kRtpTimestampIncrease), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 199 | ssrc); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | stream->Rewind(); |
| 204 | return result; |
| 205 | } |
| 206 | |
| 207 | bool RtpTestUtility::VerifyPacket(const RtpDumpPacket* dump, |
| 208 | const RawRtpPacket* raw, |
| 209 | bool header_only) { |
| 210 | if (!dump || !raw) return false; |
| 211 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 212 | rtc::ByteBuffer buf; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 213 | raw->WriteToByteBuffer(RtpTestUtility::kDefaultSsrc, &buf); |
| 214 | |
| 215 | if (header_only) { |
| 216 | size_t header_len = 0; |
| 217 | dump->GetRtpHeaderLen(&header_len); |
| 218 | return header_len == dump->data.size() && |
| 219 | buf.Length() > dump->data.size() && |
| 220 | 0 == memcmp(buf.Data(), &dump->data[0], dump->data.size()); |
| 221 | } else { |
| 222 | return buf.Length() == dump->data.size() && |
| 223 | 0 == memcmp(buf.Data(), &dump->data[0], dump->data.size()); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Implementation of VideoCaptureListener. |
| 228 | VideoCapturerListener::VideoCapturerListener(VideoCapturer* capturer) |
| 229 | : last_capture_state_(CS_STARTING), |
| 230 | frame_count_(0), |
| 231 | frame_fourcc_(0), |
| 232 | frame_width_(0), |
| 233 | frame_height_(0), |
| 234 | frame_size_(0), |
| 235 | resolution_changed_(false) { |
| 236 | capturer->SignalStateChange.connect(this, |
| 237 | &VideoCapturerListener::OnStateChange); |
| 238 | capturer->SignalFrameCaptured.connect(this, |
| 239 | &VideoCapturerListener::OnFrameCaptured); |
| 240 | } |
| 241 | |
| 242 | void VideoCapturerListener::OnStateChange(VideoCapturer* capturer, |
| 243 | CaptureState result) { |
| 244 | last_capture_state_ = result; |
| 245 | } |
| 246 | |
| 247 | void VideoCapturerListener::OnFrameCaptured(VideoCapturer* capturer, |
| 248 | const CapturedFrame* frame) { |
| 249 | ++frame_count_; |
| 250 | if (1 == frame_count_) { |
| 251 | frame_fourcc_ = frame->fourcc; |
| 252 | frame_width_ = frame->width; |
| 253 | frame_height_ = frame->height; |
| 254 | frame_size_ = frame->data_size; |
| 255 | } else if (frame_width_ != frame->width || frame_height_ != frame->height) { |
| 256 | resolution_changed_ = true; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // Returns the absolute path to a file in the testdata/ directory. |
| 261 | std::string GetTestFilePath(const std::string& filename) { |
| 262 | // Locate test data directory. |
thorcarpenter@google.com | a3344cf | 2014-09-05 16:34:13 +0000 | [diff] [blame^] | 263 | #ifdef ENABLE_WEBRTC |
| 264 | rtc::Pathname path = rtc::GetExecutablePath(); |
buildbot@webrtc.org | 72e4485 | 2014-09-03 00:43:48 +0000 | [diff] [blame] | 265 | EXPECT_FALSE(path.empty()); |
thorcarpenter@google.com | a3344cf | 2014-09-05 16:34:13 +0000 | [diff] [blame^] | 266 | path.AppendPathname("../../talk/"); |
buildbot@webrtc.org | 72e4485 | 2014-09-03 00:43:48 +0000 | [diff] [blame] | 267 | #else |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 268 | rtc::Pathname path = testing::GetTalkDirectory(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 269 | EXPECT_FALSE(path.empty()); // must be run from inside "talk" |
buildbot@webrtc.org | 72e4485 | 2014-09-03 00:43:48 +0000 | [diff] [blame] | 270 | #endif |
thorcarpenter@google.com | a3344cf | 2014-09-05 16:34:13 +0000 | [diff] [blame^] | 271 | path.AppendFolder("media/testdata/"); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 272 | path.SetFilename(filename); |
| 273 | return path.pathname(); |
| 274 | } |
| 275 | |
| 276 | // Loads the image with the specified prefix and size into |out|. |
| 277 | bool LoadPlanarYuvTestImage(const std::string& prefix, |
| 278 | int width, int height, uint8* out) { |
| 279 | std::stringstream ss; |
| 280 | ss << prefix << "." << width << "x" << height << "_P420.yuv"; |
| 281 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 282 | rtc::scoped_ptr<rtc::FileStream> stream( |
| 283 | rtc::Filesystem::OpenFile(rtc::Pathname( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 284 | GetTestFilePath(ss.str())), "rb")); |
| 285 | if (!stream) { |
| 286 | return false; |
| 287 | } |
| 288 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 289 | rtc::StreamResult res = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 290 | stream->ReadAll(out, I420_SIZE(width, height), NULL, NULL); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 291 | return (res == rtc::SR_SUCCESS); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | // Dumps the YUV image out to a file, for visual inspection. |
| 295 | // PYUV tool can be used to view dump files. |
| 296 | void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img, |
| 297 | int w, int h) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 298 | rtc::FileStream fs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 299 | char filename[256]; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 300 | rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_P420.yuv", |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | prefix.c_str(), w, h); |
| 302 | fs.Open(filename, "wb", NULL); |
| 303 | fs.Write(img, I420_SIZE(w, h), NULL, NULL); |
| 304 | } |
| 305 | |
| 306 | // Dumps the ARGB image out to a file, for visual inspection. |
| 307 | // ffplay tool can be used to view dump files. |
| 308 | void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img, |
| 309 | int w, int h) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 310 | rtc::FileStream fs; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 311 | char filename[256]; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 312 | rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_ARGB.raw", |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 313 | prefix.c_str(), w, h); |
| 314 | fs.Open(filename, "wb", NULL); |
| 315 | fs.Write(img, ARGB_SIZE(w, h), NULL, NULL); |
| 316 | } |
| 317 | |
| 318 | bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1) { |
| 319 | const uint8* y0 = frame0->GetYPlane(); |
| 320 | const uint8* u0 = frame0->GetUPlane(); |
| 321 | const uint8* v0 = frame0->GetVPlane(); |
| 322 | const uint8* y1 = frame1->GetYPlane(); |
| 323 | const uint8* u1 = frame1->GetUPlane(); |
| 324 | const uint8* v1 = frame1->GetVPlane(); |
| 325 | |
| 326 | for (size_t i = 0; i < frame0->GetHeight(); ++i) { |
| 327 | if (0 != memcmp(y0, y1, frame0->GetWidth())) { |
| 328 | return false; |
| 329 | } |
| 330 | y0 += frame0->GetYPitch(); |
| 331 | y1 += frame1->GetYPitch(); |
| 332 | } |
| 333 | |
| 334 | for (size_t i = 0; i < frame0->GetChromaHeight(); ++i) { |
| 335 | if (0 != memcmp(u0, u1, frame0->GetChromaWidth())) { |
| 336 | return false; |
| 337 | } |
| 338 | if (0 != memcmp(v0, v1, frame0->GetChromaWidth())) { |
| 339 | return false; |
| 340 | } |
| 341 | u0 += frame0->GetUPitch(); |
| 342 | v0 += frame0->GetVPitch(); |
| 343 | u1 += frame1->GetUPitch(); |
| 344 | v1 += frame1->GetVPitch(); |
| 345 | } |
| 346 | |
| 347 | return true; |
| 348 | } |
| 349 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 350 | cricket::StreamParams CreateSimStreamParams( |
| 351 | const std::string& cname, const std::vector<uint32>& ssrcs) { |
| 352 | cricket::StreamParams sp; |
| 353 | cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, ssrcs); |
| 354 | sp.ssrcs = ssrcs; |
| 355 | sp.ssrc_groups.push_back(sg); |
| 356 | sp.cname = cname; |
| 357 | return sp; |
| 358 | } |
| 359 | |
| 360 | // There should be an rtx_ssrc per ssrc. |
| 361 | cricket::StreamParams CreateSimWithRtxStreamParams( |
| 362 | const std::string& cname, const std::vector<uint32>& ssrcs, |
| 363 | const std::vector<uint32>& rtx_ssrcs) { |
| 364 | cricket::StreamParams sp = CreateSimStreamParams(cname, ssrcs); |
| 365 | for (size_t i = 0; i < ssrcs.size(); ++i) { |
| 366 | sp.ssrcs.push_back(rtx_ssrcs[i]); |
| 367 | std::vector<uint32> fid_ssrcs; |
| 368 | fid_ssrcs.push_back(ssrcs[i]); |
| 369 | fid_ssrcs.push_back(rtx_ssrcs[i]); |
| 370 | cricket::SsrcGroup fid_group(cricket::kFidSsrcGroupSemantics, fid_ssrcs); |
| 371 | sp.ssrc_groups.push_back(fid_group); |
| 372 | } |
| 373 | return sp; |
| 374 | } |
| 375 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 376 | } // namespace cricket |