Andrew Top | 193dc3d | 2019-01-23 09:57:23 -0800 | [diff] [blame] | 1 | // 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 Shi | 6c3b32a | 2020-09-21 12:36:58 -0700 | [diff] [blame] | 21 | #include "starboard/android/shared/video_decoder.h" |
Xiaoming Shi | e65d165 | 2020-02-19 13:24:00 -0800 | [diff] [blame] | 22 | #include "starboard/shared/starboard/player/filter/video_render_algorithm.h" |
Andrew Top | 193dc3d | 2019-01-23 09:57:23 -0800 | [diff] [blame] | 23 | |
| 24 | namespace starboard { |
| 25 | namespace android { |
| 26 | namespace shared { |
| 27 | |
| 28 | class VideoRenderAlgorithm : public ::starboard::shared::starboard::player:: |
| 29 | filter::VideoRenderAlgorithm { |
| 30 | public: |
Xiaoming Shi | 6c3b32a | 2020-09-21 12:36:58 -0700 | [diff] [blame] | 31 | explicit VideoRenderAlgorithm(VideoDecoder* video_decoder); |
| 32 | |
Andrew Top | 193dc3d | 2019-01-23 09:57:23 -0800 | [diff] [blame] | 33 | void Render(MediaTimeProvider* media_time_provider, |
| 34 | std::list<scoped_refptr<VideoFrame>>* frames, |
| 35 | VideoRendererSink::DrawFrameCB draw_frame_cb) override; |
Kaido Kert | b685599 | 2020-06-22 16:39:13 -0700 | [diff] [blame] | 36 | void Seek(SbTime seek_to_time) override {} |
Andrew Top | 193dc3d | 2019-01-23 09:57:23 -0800 | [diff] [blame] | 37 | 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 Shi | 6c3b32a | 2020-09-21 12:36:58 -0700 | [diff] [blame] | 51 | VideoDecoder* video_decoder_ = nullptr; |
| 52 | double playback_rate_ = 1.0; |
Andrew Top | 193dc3d | 2019-01-23 09:57:23 -0800 | [diff] [blame] | 53 | 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_ |