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

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

Issue 1353263005: Adding support for simulcast and spatial layers into VideoQualityTest (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase master, includes the perf regression fix Created 5 years, 2 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/full_stack.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 "webrtc/base/checks.h" 11 #include "webrtc/base/checks.h"
12 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" 12 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
13 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" 13 #include "webrtc/modules/rtp_rtcp/interface/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/test/layer_filtering_transport.h" 17 #include "webrtc/test/layer_filtering_transport.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 namespace test { 20 namespace test {
21 21
22 LayerFilteringTransport::LayerFilteringTransport( 22 LayerFilteringTransport::LayerFilteringTransport(
23 const FakeNetworkPipe::Config& config, 23 const FakeNetworkPipe::Config& config,
24 uint8_t vp8_video_payload_type, 24 uint8_t vp8_video_payload_type,
25 uint8_t vp9_video_payload_type, 25 uint8_t vp9_video_payload_type,
26 uint8_t tl_discard_threshold, 26 int selected_tl,
27 uint8_t sl_discard_threshold) 27 int selected_sl)
28 : test::DirectTransport(config), 28 : test::DirectTransport(config),
29 vp8_video_payload_type_(vp8_video_payload_type), 29 vp8_video_payload_type_(vp8_video_payload_type),
30 vp9_video_payload_type_(vp9_video_payload_type), 30 vp9_video_payload_type_(vp9_video_payload_type),
31 tl_discard_threshold_(tl_discard_threshold), 31 selected_tl_(selected_tl),
32 sl_discard_threshold_(sl_discard_threshold) { 32 selected_sl_(selected_sl),
33 discarded_last_packet_(false) {
34 }
35
36 bool LayerFilteringTransport::DiscardedLastPacket() const {
37 return discarded_last_packet_;
33 } 38 }
34 39
35 uint16_t LayerFilteringTransport::NextSequenceNumber(uint32_t ssrc) { 40 uint16_t LayerFilteringTransport::NextSequenceNumber(uint32_t ssrc) {
36 auto it = current_seq_nums_.find(ssrc); 41 auto it = current_seq_nums_.find(ssrc);
37 if (it == current_seq_nums_.end()) 42 if (it == current_seq_nums_.end())
38 return current_seq_nums_[ssrc] = 10000; 43 return current_seq_nums_[ssrc] = 10000;
39 return ++it->second; 44 return ++it->second;
40 } 45 }
41 46
42 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, 47 bool LayerFilteringTransport::SendRtp(const uint8_t* packet,
43 size_t length, 48 size_t length,
44 const PacketOptions& options) { 49 const PacketOptions& options) {
45 if (tl_discard_threshold_ == 0 && sl_discard_threshold_ == 0) { 50 if (selected_tl_ == -1 && selected_sl_ == -1) {
46 // Nothing to change, forward the packet immediately. 51 // Nothing to change, forward the packet immediately.
47 return test::DirectTransport::SendRtp(packet, length, options); 52 return test::DirectTransport::SendRtp(packet, length, options);
48 } 53 }
49 54
50 bool set_marker_bit = false; 55 bool set_marker_bit = false;
51 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); 56 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
52 RTPHeader header; 57 RTPHeader header;
53 parser->Parse(packet, length, &header); 58 parser->Parse(packet, length, &header);
54 59
55 if (header.payloadType == vp8_video_payload_type_ || 60 if (header.payloadType == vp8_video_payload_type_ ||
56 header.payloadType == vp9_video_payload_type_) { 61 header.payloadType == vp9_video_payload_type_) {
57 const uint8_t* payload = packet + header.headerLength; 62 const uint8_t* payload = packet + header.headerLength;
58 RTC_DCHECK_GT(length, header.headerLength); 63 RTC_DCHECK_GT(length, header.headerLength);
59 const size_t payload_length = length - header.headerLength; 64 const size_t payload_length = length - header.headerLength;
60 RTC_DCHECK_GT(payload_length, header.paddingLength); 65 RTC_DCHECK_GT(payload_length, header.paddingLength);
61 const size_t payload_data_length = payload_length - header.paddingLength; 66 const size_t payload_data_length = payload_length - header.paddingLength;
62 67
63 const bool is_vp8 = header.payloadType == vp8_video_payload_type_; 68 const bool is_vp8 = header.payloadType == vp8_video_payload_type_;
64 rtc::scoped_ptr<RtpDepacketizer> depacketizer( 69 rtc::scoped_ptr<RtpDepacketizer> depacketizer(
65 RtpDepacketizer::Create(is_vp8 ? kRtpVideoVp8 : kRtpVideoVp9)); 70 RtpDepacketizer::Create(is_vp8 ? kRtpVideoVp8 : kRtpVideoVp9));
66 RtpDepacketizer::ParsedPayload parsed_payload; 71 RtpDepacketizer::ParsedPayload parsed_payload;
67 if (depacketizer->Parse(&parsed_payload, payload, payload_data_length)) { 72 if (depacketizer->Parse(&parsed_payload, payload, payload_data_length)) {
68 const uint8_t temporalIdx = 73 const int temporal_idx = static_cast<int>(
69 is_vp8 ? parsed_payload.type.Video.codecHeader.VP8.temporalIdx 74 is_vp8 ? parsed_payload.type.Video.codecHeader.VP8.temporalIdx
70 : parsed_payload.type.Video.codecHeader.VP9.temporal_idx; 75 : parsed_payload.type.Video.codecHeader.VP9.temporal_idx);
71 const uint8_t spatialIdx = 76 const int spatial_idx = static_cast<int>(
72 is_vp8 ? kNoSpatialIdx 77 is_vp8 ? kNoSpatialIdx
73 : parsed_payload.type.Video.codecHeader.VP9.spatial_idx; 78 : parsed_payload.type.Video.codecHeader.VP9.spatial_idx);
74 if (sl_discard_threshold_ > 0 && 79 if (selected_sl_ >= 0 &&
75 spatialIdx == sl_discard_threshold_ - 1 && 80 spatial_idx == selected_sl_ &&
76 parsed_payload.type.Video.codecHeader.VP9.end_of_frame) { 81 parsed_payload.type.Video.codecHeader.VP9.end_of_frame) {
77 // This layer is now the last in the superframe. 82 // This layer is now the last in the superframe.
78 set_marker_bit = true; 83 set_marker_bit = true;
79 } 84 }
80 if ((tl_discard_threshold_ > 0 && temporalIdx != kNoTemporalIdx && 85 if ((selected_tl_ >= 0 && temporal_idx != kNoTemporalIdx &&
81 temporalIdx >= tl_discard_threshold_) || 86 temporal_idx > selected_tl_) ||
82 (sl_discard_threshold_ > 0 && spatialIdx != kNoSpatialIdx && 87 (selected_sl_ >= 0 && spatial_idx != kNoSpatialIdx &&
83 spatialIdx >= sl_discard_threshold_)) { 88 spatial_idx > selected_sl_)) {
84 return true; // Discard the packet. 89 discarded_last_packet_ = true;
90 return true;
85 } 91 }
86 } else { 92 } else {
87 RTC_NOTREACHED() << "Parse error"; 93 RTC_NOTREACHED() << "Parse error";
88 } 94 }
89 } 95 }
90 96
91 uint8_t temp_buffer[IP_PACKET_SIZE]; 97 uint8_t temp_buffer[IP_PACKET_SIZE];
92 memcpy(temp_buffer, packet, length); 98 memcpy(temp_buffer, packet, length);
93 99
94 // We are discarding some of the packets (specifically, whole layers), so 100 // We are discarding some of the packets (specifically, whole layers), so
95 // make sure the marker bit is set properly, and that sequence numbers are 101 // make sure the marker bit is set properly, and that sequence numbers are
96 // continuous. 102 // continuous.
97 if (set_marker_bit) 103 if (set_marker_bit)
98 temp_buffer[1] |= kRtpMarkerBitMask; 104 temp_buffer[1] |= kRtpMarkerBitMask;
99 105
100 uint16_t seq_num = NextSequenceNumber(header.ssrc); 106 uint16_t seq_num = NextSequenceNumber(header.ssrc);
101 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], seq_num); 107 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], seq_num);
102 return test::DirectTransport::SendRtp(temp_buffer, length, options); 108 return test::DirectTransport::SendRtp(temp_buffer, length, options);
103 } 109 }
104 110
105 } // namespace test 111 } // namespace test
106 } // namespace webrtc 112 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/layer_filtering_transport.h ('k') | webrtc/video/full_stack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698