1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2012 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #include "pc/test/integration_test_helpers.h" 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 14*d9f75844SAndroid Build Coastguard Worker IceRestartOfferAnswerOptions()15*d9f75844SAndroid Build Coastguard WorkerPeerConnectionInterface::RTCOfferAnswerOptions IceRestartOfferAnswerOptions() { 16*d9f75844SAndroid Build Coastguard Worker PeerConnectionInterface::RTCOfferAnswerOptions options; 17*d9f75844SAndroid Build Coastguard Worker options.ice_restart = true; 18*d9f75844SAndroid Build Coastguard Worker return options; 19*d9f75844SAndroid Build Coastguard Worker } 20*d9f75844SAndroid Build Coastguard Worker RemoveSsrcsAndMsids(cricket::SessionDescription * desc)21*d9f75844SAndroid Build Coastguard Workervoid RemoveSsrcsAndMsids(cricket::SessionDescription* desc) { 22*d9f75844SAndroid Build Coastguard Worker for (ContentInfo& content : desc->contents()) { 23*d9f75844SAndroid Build Coastguard Worker content.media_description()->mutable_streams().clear(); 24*d9f75844SAndroid Build Coastguard Worker } 25*d9f75844SAndroid Build Coastguard Worker desc->set_msid_supported(false); 26*d9f75844SAndroid Build Coastguard Worker desc->set_msid_signaling(0); 27*d9f75844SAndroid Build Coastguard Worker } 28*d9f75844SAndroid Build Coastguard Worker RemoveSsrcsAndKeepMsids(cricket::SessionDescription * desc)29*d9f75844SAndroid Build Coastguard Workervoid RemoveSsrcsAndKeepMsids(cricket::SessionDescription* desc) { 30*d9f75844SAndroid Build Coastguard Worker for (ContentInfo& content : desc->contents()) { 31*d9f75844SAndroid Build Coastguard Worker std::string track_id; 32*d9f75844SAndroid Build Coastguard Worker std::vector<std::string> stream_ids; 33*d9f75844SAndroid Build Coastguard Worker if (!content.media_description()->streams().empty()) { 34*d9f75844SAndroid Build Coastguard Worker const StreamParams& first_stream = 35*d9f75844SAndroid Build Coastguard Worker content.media_description()->streams()[0]; 36*d9f75844SAndroid Build Coastguard Worker track_id = first_stream.id; 37*d9f75844SAndroid Build Coastguard Worker stream_ids = first_stream.stream_ids(); 38*d9f75844SAndroid Build Coastguard Worker } 39*d9f75844SAndroid Build Coastguard Worker content.media_description()->mutable_streams().clear(); 40*d9f75844SAndroid Build Coastguard Worker StreamParams new_stream; 41*d9f75844SAndroid Build Coastguard Worker new_stream.id = track_id; 42*d9f75844SAndroid Build Coastguard Worker new_stream.set_stream_ids(stream_ids); 43*d9f75844SAndroid Build Coastguard Worker content.media_description()->AddStream(new_stream); 44*d9f75844SAndroid Build Coastguard Worker } 45*d9f75844SAndroid Build Coastguard Worker } 46*d9f75844SAndroid Build Coastguard Worker FindFirstMediaStatsIndexByKind(const std::string & kind,const std::vector<const webrtc::DEPRECATED_RTCMediaStreamTrackStats * > & media_stats_vec)47*d9f75844SAndroid Build Coastguard Workerint FindFirstMediaStatsIndexByKind( 48*d9f75844SAndroid Build Coastguard Worker const std::string& kind, 49*d9f75844SAndroid Build Coastguard Worker const std::vector<const webrtc::DEPRECATED_RTCMediaStreamTrackStats*>& 50*d9f75844SAndroid Build Coastguard Worker media_stats_vec) { 51*d9f75844SAndroid Build Coastguard Worker for (size_t i = 0; i < media_stats_vec.size(); i++) { 52*d9f75844SAndroid Build Coastguard Worker if (media_stats_vec[i]->kind.ValueToString() == kind) { 53*d9f75844SAndroid Build Coastguard Worker return i; 54*d9f75844SAndroid Build Coastguard Worker } 55*d9f75844SAndroid Build Coastguard Worker } 56*d9f75844SAndroid Build Coastguard Worker return -1; 57*d9f75844SAndroid Build Coastguard Worker } 58*d9f75844SAndroid Build Coastguard Worker TaskQueueMetronome(TimeDelta tick_period)59*d9f75844SAndroid Build Coastguard WorkerTaskQueueMetronome::TaskQueueMetronome(TimeDelta tick_period) 60*d9f75844SAndroid Build Coastguard Worker : tick_period_(tick_period) { 61*d9f75844SAndroid Build Coastguard Worker sequence_checker_.Detach(); 62*d9f75844SAndroid Build Coastguard Worker } 63*d9f75844SAndroid Build Coastguard Worker ~TaskQueueMetronome()64*d9f75844SAndroid Build Coastguard WorkerTaskQueueMetronome::~TaskQueueMetronome() { 65*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&sequence_checker_); 66*d9f75844SAndroid Build Coastguard Worker } RequestCallOnNextTick(absl::AnyInvocable<void ()&&> callback)67*d9f75844SAndroid Build Coastguard Workervoid TaskQueueMetronome::RequestCallOnNextTick( 68*d9f75844SAndroid Build Coastguard Worker absl::AnyInvocable<void() &&> callback) { 69*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&sequence_checker_); 70*d9f75844SAndroid Build Coastguard Worker callbacks_.push_back(std::move(callback)); 71*d9f75844SAndroid Build Coastguard Worker // Only schedule a tick callback for the first `callback` addition. 72*d9f75844SAndroid Build Coastguard Worker // Schedule on the current task queue to comply with RequestCallOnNextTick 73*d9f75844SAndroid Build Coastguard Worker // requirements. 74*d9f75844SAndroid Build Coastguard Worker if (callbacks_.size() == 1) { 75*d9f75844SAndroid Build Coastguard Worker TaskQueueBase::Current()->PostDelayedTask( 76*d9f75844SAndroid Build Coastguard Worker SafeTask(safety_.flag(), 77*d9f75844SAndroid Build Coastguard Worker [this] { 78*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&sequence_checker_); 79*d9f75844SAndroid Build Coastguard Worker std::vector<absl::AnyInvocable<void() &&>> callbacks; 80*d9f75844SAndroid Build Coastguard Worker callbacks_.swap(callbacks); 81*d9f75844SAndroid Build Coastguard Worker for (auto& callback : callbacks) 82*d9f75844SAndroid Build Coastguard Worker std::move(callback)(); 83*d9f75844SAndroid Build Coastguard Worker }), 84*d9f75844SAndroid Build Coastguard Worker tick_period_); 85*d9f75844SAndroid Build Coastguard Worker } 86*d9f75844SAndroid Build Coastguard Worker } 87*d9f75844SAndroid Build Coastguard Worker TickPeriod() const88*d9f75844SAndroid Build Coastguard WorkerTimeDelta TaskQueueMetronome::TickPeriod() const { 89*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_RUN_ON(&sequence_checker_); 90*d9f75844SAndroid Build Coastguard Worker return tick_period_; 91*d9f75844SAndroid Build Coastguard Worker } 92*d9f75844SAndroid Build Coastguard Worker 93*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 94