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

Side by Side Diff: webrtc/test/layer_filtering_transport.cc

Issue 2997393002: Move rtp dump writer from quality test to test transport (Closed)
Patch Set: Dump RTP packets after fake network, not before Created 3 years, 4 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
« no previous file with comments | « webrtc/test/layer_filtering_transport.h ('k') | webrtc/video/screenshare_loopback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <memory> 11 #include <memory>
12 12
13 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 13 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
15 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 15 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
17 #include "webrtc/rtc_base/checks.h" 17 #include "webrtc/rtc_base/checks.h"
18 #include "webrtc/test/layer_filtering_transport.h" 18 #include "webrtc/test/layer_filtering_transport.h"
19 #include "webrtc/test/rtp_file_writer.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 namespace test { 22 namespace test {
22 23
23 LayerFilteringTransport::LayerFilteringTransport( 24 LayerFilteringTransport::LayerFilteringTransport(
24 SingleThreadedTaskQueueForTesting* task_queue, 25 SingleThreadedTaskQueueForTesting* task_queue,
25 const FakeNetworkPipe::Config& config, 26 const FakeNetworkPipe::Config& config,
26 Call* send_call, 27 Call* send_call,
27 uint8_t vp8_video_payload_type, 28 uint8_t vp8_video_payload_type,
28 uint8_t vp9_video_payload_type, 29 uint8_t vp9_video_payload_type,
29 int selected_tl, 30 int selected_tl,
30 int selected_sl, 31 int selected_sl,
31 const std::map<uint8_t, MediaType>& payload_type_map) 32 const std::map<uint8_t, MediaType>& payload_type_map,
33 std::unique_ptr<test::RtpFileWriter> rtp_file_writer)
32 : DirectTransport(task_queue, config, send_call, payload_type_map), 34 : DirectTransport(task_queue, config, send_call, payload_type_map),
33 vp8_video_payload_type_(vp8_video_payload_type), 35 vp8_video_payload_type_(vp8_video_payload_type),
34 vp9_video_payload_type_(vp9_video_payload_type), 36 vp9_video_payload_type_(vp9_video_payload_type),
35 selected_tl_(selected_tl), 37 selected_tl_(selected_tl),
36 selected_sl_(selected_sl), 38 selected_sl_(selected_sl),
37 discarded_last_packet_(false) {} 39 discarded_last_packet_(false),
40 receiver_(nullptr),
41 start_ms_(rtc::TimeMillis()),
42 rtp_file_writer_(std::move(rtp_file_writer)) {
43 DirectTransport::SetReceiver(this);
44 }
38 45
39 bool LayerFilteringTransport::DiscardedLastPacket() const { 46 bool LayerFilteringTransport::DiscardedLastPacket() const {
40 return discarded_last_packet_; 47 return discarded_last_packet_;
41 } 48 }
42 49
43 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, 50 bool LayerFilteringTransport::SendRtp(const uint8_t* packet,
44 size_t length, 51 size_t length,
45 const PacketOptions& options) { 52 const PacketOptions& options) {
53
46 if (selected_tl_ == -1 && selected_sl_ == -1) { 54 if (selected_tl_ == -1 && selected_sl_ == -1) {
47 // Nothing to change, forward the packet immediately. 55 // Nothing to change, forward the packet immediately.
48 return test::DirectTransport::SendRtp(packet, length, options); 56 return test::DirectTransport::SendRtp(packet, length, options);
49 } 57 }
50 58
51 bool set_marker_bit = false; 59 bool set_marker_bit = false;
52 RtpUtility::RtpHeaderParser parser(packet, length); 60 RtpUtility::RtpHeaderParser parser(packet, length);
53 RTPHeader header; 61 RTPHeader header;
54 parser.Parse(&header); 62 parser.Parse(&header);
55
56 RTC_DCHECK_LE(length, IP_PACKET_SIZE); 63 RTC_DCHECK_LE(length, IP_PACKET_SIZE);
57 uint8_t temp_buffer[IP_PACKET_SIZE]; 64 uint8_t temp_buffer[IP_PACKET_SIZE];
58 memcpy(temp_buffer, packet, length); 65 memcpy(temp_buffer, packet, length);
59 66
60 if (header.payloadType == vp8_video_payload_type_ || 67 if (header.payloadType == vp8_video_payload_type_ ||
61 header.payloadType == vp9_video_payload_type_) { 68 header.payloadType == vp9_video_payload_type_) {
62 const uint8_t* payload = packet + header.headerLength; 69 const uint8_t* payload = packet + header.headerLength;
63 RTC_DCHECK_GT(length, header.headerLength); 70 RTC_DCHECK_GT(length, header.headerLength);
64 const size_t payload_length = length - header.headerLength; 71 const size_t payload_length = length - header.headerLength;
65 RTC_DCHECK_GT(payload_length, header.paddingLength); 72 RTC_DCHECK_GT(payload_length, header.paddingLength);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 105
99 // We are discarding some of the packets (specifically, whole layers), so 106 // We are discarding some of the packets (specifically, whole layers), so
100 // make sure the marker bit is set properly, and that sequence numbers are 107 // make sure the marker bit is set properly, and that sequence numbers are
101 // continuous. 108 // continuous.
102 if (set_marker_bit) 109 if (set_marker_bit)
103 temp_buffer[1] |= kRtpMarkerBitMask; 110 temp_buffer[1] |= kRtpMarkerBitMask;
104 111
105 return test::DirectTransport::SendRtp(temp_buffer, length, options); 112 return test::DirectTransport::SendRtp(temp_buffer, length, options);
106 } 113 }
107 114
115 void LayerFilteringTransport::SetReceiver(PacketReceiver* receiver) {
116 receiver_ = receiver;
117 }
118
119 PacketReceiver::DeliveryStatus LayerFilteringTransport::DeliverPacket(
stefan-webrtc 2017/08/24 12:52:18 Maybe we should make this a feature of DirectTrans
120 MediaType media_type,
121 const uint8_t* packet,
122 size_t length,
123 const PacketTime& packet_time) {
124 if (rtp_file_writer_.get()) {
125 RtpPacket rtp_packet;
126 RTC_DCHECK_LE(length, IP_PACKET_SIZE);
127 memcpy(rtp_packet.data, packet, length);
128 rtp_packet.length = length;
129 rtp_packet.original_length = length;
130 rtp_packet.time_ms = rtc::TimeMillis() - start_ms_;
131 rtp_file_writer_->WritePacket(&rtp_packet);
132 }
133
134 if (!receiver_)
135 return PacketReceiver::DELIVERY_PACKET_ERROR;
136 return receiver_->DeliverPacket(media_type, packet, length, packet_time);
137 }
138
108 } // namespace test 139 } // namespace test
109 } // namespace webrtc 140 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/layer_filtering_transport.h ('k') | webrtc/video/screenshare_loopback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698