tor-browser

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

frame_generator_interface.h (2184B)


      1 /*
      2 *  Copyright (c) 2019 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 
     11 #ifndef API_TEST_FRAME_GENERATOR_INTERFACE_H_
     12 #define API_TEST_FRAME_GENERATOR_INTERFACE_H_
     13 
     14 #include <cstddef>
     15 #include <optional>
     16 #include <utility>
     17 
     18 #include "api/scoped_refptr.h"
     19 #include "api/video/video_frame.h"
     20 #include "api/video/video_frame_buffer.h"
     21 
     22 namespace webrtc {
     23 namespace test {
     24 
     25 class FrameGeneratorInterface {
     26 public:
     27  struct Resolution {
     28    size_t width;
     29    size_t height;
     30  };
     31  struct VideoFrameData {
     32    VideoFrameData(scoped_refptr<VideoFrameBuffer> buffer,
     33                   std::optional<VideoFrame::UpdateRect> update_rect)
     34        : buffer(std::move(buffer)), update_rect(update_rect) {}
     35 
     36    scoped_refptr<VideoFrameBuffer> buffer;
     37    std::optional<VideoFrame::UpdateRect> update_rect;
     38  };
     39 
     40  enum class OutputType { kI420, kI420A, kI010, kNV12 };
     41  static const char* OutputTypeToString(OutputType type);
     42 
     43  virtual ~FrameGeneratorInterface() = default;
     44 
     45  // Returns VideoFrameBuffer and area where most of update was done to set them
     46  // on the VideoFrame object.
     47  virtual VideoFrameData NextFrame() = 0;
     48  // Skips the next frame in case it doesn't need to be encoded.
     49  // Default implementation is to call NextFrame and ignore the returned value.
     50  virtual void SkipNextFrame() { NextFrame(); }
     51 
     52  // Change the capture resolution.
     53  virtual void ChangeResolution(size_t width, size_t height) = 0;
     54 
     55  virtual Resolution GetResolution() const = 0;
     56 
     57  // Returns the frames per second this generator is supposed to provide
     58  // according to its data source. Not all frame generators know the frames per
     59  // second of the data source, in such case this method returns std::nullopt.
     60  virtual std::optional<int> fps() const = 0;
     61 };
     62 
     63 }  // namespace test
     64 }  // namespace webrtc
     65 
     66 #endif  // API_TEST_FRAME_GENERATOR_INTERFACE_H_