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

Side by Side Diff: webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc

Issue 2523843002: Send audio and video codecs to RTPPayloadRegistry (Closed)
Patch Set: Change strcpy to strncpy Created 4 years 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 transport_->SetSendModule(video_module_, &rtp_payload_registry_, 65 transport_->SetSendModule(video_module_, &rtp_payload_registry_,
66 rtp_receiver_.get(), receive_statistics_.get()); 66 rtp_receiver_.get(), receive_statistics_.get());
67 67
68 VideoCodec video_codec; 68 VideoCodec video_codec;
69 memset(&video_codec, 0, sizeof(video_codec)); 69 memset(&video_codec, 0, sizeof(video_codec));
70 video_codec.plType = 123; 70 video_codec.plType = 123;
71 memcpy(video_codec.plName, "I420", 5); 71 memcpy(video_codec.plName, "I420", 5);
72 72
73 EXPECT_EQ(0, video_module_->RegisterSendPayload(video_codec)); 73 EXPECT_EQ(0, video_module_->RegisterSendPayload(video_codec));
74 EXPECT_EQ(0, rtp_receiver_->RegisterReceivePayload(video_codec.plName, 74 EXPECT_EQ(0, rtp_payload_registry_.RegisterReceivePayload(video_codec));
75 video_codec.plType,
76 90000,
77 0,
78 video_codec.maxBitrate));
79 75
80 payload_data_length_ = sizeof(video_frame_); 76 payload_data_length_ = sizeof(video_frame_);
81 77
82 for (size_t n = 0; n < payload_data_length_; n++) { 78 for (size_t n = 0; n < payload_data_length_; n++) {
83 video_frame_[n] = n%10; 79 video_frame_[n] = n%10;
84 } 80 }
85 } 81 }
86 82
87 size_t BuildRTPheader(uint8_t* dataBuffer, 83 size_t BuildRTPheader(uint8_t* dataBuffer,
88 uint32_t timestamp, 84 uint32_t timestamp,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 150
155 TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) { 151 TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
156 const size_t kPadSize = 255; 152 const size_t kPadSize = 255;
157 uint8_t padding_packet[kPadSize]; 153 uint8_t padding_packet[kPadSize];
158 uint32_t seq_num = 0; 154 uint32_t seq_num = 0;
159 uint32_t timestamp = 3000; 155 uint32_t timestamp = 3000;
160 VideoCodec codec; 156 VideoCodec codec;
161 codec.codecType = kVideoCodecVP8; 157 codec.codecType = kVideoCodecVP8;
162 codec.plType = kPayloadType; 158 codec.plType = kPayloadType;
163 strncpy(codec.plName, "VP8", 4); 159 strncpy(codec.plName, "VP8", 4);
164 EXPECT_EQ(0, rtp_receiver_->RegisterReceivePayload(codec.plName, 160 EXPECT_EQ(0, rtp_payload_registry_.RegisterReceivePayload(codec));
165 codec.plType,
166 90000,
167 0,
168 codec.maxBitrate));
169 for (int frame_idx = 0; frame_idx < 10; ++frame_idx) { 161 for (int frame_idx = 0; frame_idx < 10; ++frame_idx) {
170 for (int packet_idx = 0; packet_idx < 5; ++packet_idx) { 162 for (int packet_idx = 0; packet_idx < 5; ++packet_idx) {
171 size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num, 163 size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
172 kPadSize); 164 kPadSize);
173 ++seq_num; 165 ++seq_num;
174 RTPHeader header; 166 RTPHeader header;
175 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); 167 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
176 EXPECT_TRUE(parser->Parse(padding_packet, packet_size, &header)); 168 EXPECT_TRUE(parser->Parse(padding_packet, packet_size, &header));
177 PayloadUnion payload_specific; 169 PayloadUnion payload_specific;
178 EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType, 170 EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
179 &payload_specific)); 171 &payload_specific));
180 const uint8_t* payload = padding_packet + header.headerLength; 172 const uint8_t* payload = padding_packet + header.headerLength;
181 const size_t payload_length = packet_size - header.headerLength; 173 const size_t payload_length = packet_size - header.headerLength;
182 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, payload, 174 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, payload,
183 payload_length, 175 payload_length,
184 payload_specific, true)); 176 payload_specific, true));
185 EXPECT_EQ(0u, receiver_->payload_size()); 177 EXPECT_EQ(0u, receiver_->payload_size());
186 EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength); 178 EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength);
187 } 179 }
188 timestamp += 3000; 180 timestamp += 3000;
189 fake_clock.AdvanceTimeMilliseconds(33); 181 fake_clock.AdvanceTimeMilliseconds(33);
190 } 182 }
191 } 183 }
192 184
193 } // namespace webrtc 185 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc ('k') | webrtc/video/rtp_stream_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698