xbmc
JNIXBMCVideoView.h
1 /*
2  * Copyright (C) 2016 Christian Browet
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/Event.h"
12 #include "utils/Geometry.h"
13 
14 #include <androidjni/Context.h>
15 #include <androidjni/JNIBase.h>
16 #include <androidjni/Rect.h>
17 #include <androidjni/Surface.h>
18 #include <androidjni/SurfaceHolder.h>
19 
20 namespace jni
21 {
22 
23 class CJNIXBMCVideoView : virtual public CJNIBase, public CJNISurfaceHolderCallback, public CJNIInterfaceImplem<CJNIXBMCVideoView>
24 {
25 public:
26  CJNIXBMCVideoView(const jni::jhobject &object);
27  ~CJNIXBMCVideoView() override = default;
28 
29  static void RegisterNatives(JNIEnv* env);
30 
31  static CJNIXBMCVideoView* createVideoView(CJNISurfaceHolderCallback* callback);
32 
33  // CJNISurfaceHolderCallback interface
34  void surfaceChanged(CJNISurfaceHolder holder, int format, int width, int height) override;
35  void surfaceCreated(CJNISurfaceHolder holder) override;
36  void surfaceDestroyed(CJNISurfaceHolder holder) override;
37 
38  static void _surfaceChanged(JNIEnv* env, jobject thiz, jobject holder, jint format, jint width, jint height);
39  static void _surfaceCreated(JNIEnv* env, jobject thiz, jobject holder);
40  static void _surfaceDestroyed(JNIEnv* env, jobject thiz, jobject holder);
41 
42  bool waitForSurface(unsigned int millis);
43  bool isActive() { return m_surfaceCreated.Signaled(); }
44  CJNISurface getSurface();
45  const CRect& getSurfaceRect();
46  void setSurfaceRect(const CRect& rect);
47  void add();
48  void release();
49  int ID() const;
50  bool isCreated() const;
51 
52 protected:
53  CJNISurfaceHolderCallback* m_callback = nullptr;
54  CEvent m_surfaceCreated;
55  CRect m_surfaceRect;
56 
57 private:
58  CJNIXBMCVideoView() = default;
59 };
60 
61 } // namespace jni
bool Signaled()
Returns true if Event has been triggered and not reset, false otherwise.
Definition: Event.h:81
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: JNIXBMCVideoView.h:23
Definition: JNIMainActivity.h:15