blob: 132e8714ab06de68d549f43034b1e931d3a205a3 [file] [log] [blame]
Andrew Top193dc3d2019-01-23 09:57:23 -08001// Copyright 2017 The Cobalt Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef STARBOARD_ANDROID_SHARED_VIDEO_RENDER_ALGORITHM_H_
16#define STARBOARD_ANDROID_SHARED_VIDEO_RENDER_ALGORITHM_H_
17
18#include <list>
19
20#include "starboard/android/shared/jni_env_ext.h"
Xiaoming Shi6c3b32a2020-09-21 12:36:58 -070021#include "starboard/android/shared/video_decoder.h"
Xiaoming Shie65d1652020-02-19 13:24:00 -080022#include "starboard/shared/starboard/player/filter/video_render_algorithm.h"
Andrew Top193dc3d2019-01-23 09:57:23 -080023
24namespace starboard {
25namespace android {
26namespace shared {
27
28class VideoRenderAlgorithm : public ::starboard::shared::starboard::player::
29 filter::VideoRenderAlgorithm {
30 public:
Xiaoming Shi6c3b32a2020-09-21 12:36:58 -070031 explicit VideoRenderAlgorithm(VideoDecoder* video_decoder);
32
Andrew Top193dc3d2019-01-23 09:57:23 -080033 void Render(MediaTimeProvider* media_time_provider,
34 std::list<scoped_refptr<VideoFrame>>* frames,
35 VideoRendererSink::DrawFrameCB draw_frame_cb) override;
Kaido Kertb6855992020-06-22 16:39:13 -070036 void Seek(SbTime seek_to_time) override {}
Andrew Top193dc3d2019-01-23 09:57:23 -080037 int GetDroppedFrames() override { return dropped_frames_; }
38
39 private:
40 class VideoFrameReleaseTimeHelper {
41 public:
42 VideoFrameReleaseTimeHelper();
43 ~VideoFrameReleaseTimeHelper();
44 jlong AdjustReleaseTime(jlong frame_presentation_time_us,
45 jlong unadjusted_release_time_ns);
46
47 private:
48 jobject j_video_frame_release_time_helper_ = nullptr;
49 };
50
Xiaoming Shi6c3b32a2020-09-21 12:36:58 -070051 VideoDecoder* video_decoder_ = nullptr;
52 double playback_rate_ = 1.0;
Andrew Top193dc3d2019-01-23 09:57:23 -080053 VideoFrameReleaseTimeHelper video_frame_release_time_helper_;
54 int dropped_frames_ = 0;
55};
56
57} // namespace shared
58} // namespace android
59} // namespace starboard
60
61#endif // STARBOARD_ANDROID_SHARED_VIDEO_RENDER_ALGORITHM_H_