tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_video_track_source.cc (1863B)


      1 /*
      2 *  Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
      3 *
      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
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 #include "api/test/video/test_video_track_source.h"
     11 
     12 #include <optional>
     13 #include <string>
     14 #include <utility>
     15 
     16 #include "api/media_stream_interface.h"
     17 #include "api/sequence_checker.h"
     18 #include "api/video/video_frame.h"
     19 #include "api/video/video_sink_interface.h"
     20 #include "api/video/video_source_interface.h"
     21 #include "rtc_base/checks.h"
     22 
     23 namespace webrtc {
     24 namespace test {
     25 
     26 TestVideoTrackSource::TestVideoTrackSource(
     27    bool remote,
     28    std::optional<std::string> stream_label)
     29    : stream_label_(std::move(stream_label)),
     30      state_(kInitializing),
     31      remote_(remote) {
     32  worker_thread_checker_.Detach();
     33  signaling_thread_checker_.Detach();
     34 }
     35 
     36 VideoTrackSourceInterface::SourceState TestVideoTrackSource::state() const {
     37  RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
     38  return state_;
     39 }
     40 
     41 void TestVideoTrackSource::SetState(SourceState new_state) {
     42  RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
     43  if (state_ != new_state) {
     44    state_ = new_state;
     45    FireOnChanged();
     46  }
     47 }
     48 
     49 void TestVideoTrackSource::AddOrUpdateSink(VideoSinkInterface<VideoFrame>* sink,
     50                                           const VideoSinkWants& wants) {
     51  RTC_DCHECK(worker_thread_checker_.IsCurrent());
     52  source()->AddOrUpdateSink(sink, wants);
     53 }
     54 
     55 void TestVideoTrackSource::RemoveSink(VideoSinkInterface<VideoFrame>* sink) {
     56  RTC_DCHECK(worker_thread_checker_.IsCurrent());
     57  source()->RemoveSink(sink);
     58 }
     59 
     60 }  // namespace test
     61 }  // namespace webrtc