video_render_frames.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2012 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. #ifndef COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
  11. #define COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <list>
  15. #include "absl/types/optional.h"
  16. #include "api/video/video_frame.h"
  17. namespace webrtc {
  18. // Class definitions
  19. class VideoRenderFrames {
  20. public:
  21. explicit VideoRenderFrames(uint32_t render_delay_ms);
  22. VideoRenderFrames(const VideoRenderFrames&) = delete;
  23. ~VideoRenderFrames();
  24. // Add a frame to the render queue
  25. int32_t AddFrame(VideoFrame&& new_frame);
  26. // Get a frame for rendering, or false if it's not time to render.
  27. absl::optional<VideoFrame> FrameToRender();
  28. // Returns the number of ms to next frame to render
  29. uint32_t TimeToNextFrameRelease();
  30. bool HasPendingFrames() const;
  31. private:
  32. // Sorted list with framed to be rendered, oldest first.
  33. std::list<VideoFrame> incoming_frames_;
  34. // Estimated delay from a frame is released until it's rendered.
  35. const uint32_t render_delay_ms_;
  36. int64_t last_render_time_ms_ = 0;
  37. size_t frames_dropped_ = 0;
  38. };
  39. } // namespace webrtc
  40. #endif // COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_