kodi
JNIXBMCMainView.h
1 /*
2  * Copyright (C) 2017 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/Surface.h>
17 #include <androidjni/SurfaceHolder.h>
18 
19 namespace jni
20 {
21 
22 class CJNIXBMCMainView : virtual public CJNIBase, public CJNISurfaceHolderCallback, public CJNIInterfaceImplem<CJNIXBMCMainView>
23 {
24 public:
25  CJNIXBMCMainView(CJNISurfaceHolderCallback* callback);
26  ~CJNIXBMCMainView() override = default;
27 
28  static void RegisterNatives(JNIEnv* env);
29 
30  // CJNISurfaceHolderCallback interface
31  void surfaceChanged(CJNISurfaceHolder holder, int format, int width, int height) override;
32  void surfaceCreated(CJNISurfaceHolder holder) override;
33  void surfaceDestroyed(CJNISurfaceHolder holder) override;
34 
35  void attach(const jobject& thiz);
36  bool waitForSurface(unsigned int millis);
37  bool isActive() { return m_surfaceCreated.Signaled(); }
38  CJNISurface getSurface();
39  bool isCreated() const;
40 
41 protected:
42  static CJNIXBMCMainView* m_instance;
43  CJNISurfaceHolderCallback* m_callback;
44  static CEvent m_surfaceCreated;
45 
46  static void _attach(JNIEnv* env, jobject thiz);
47  static void _surfaceChanged(JNIEnv* env, jobject thiz, jobject holder, jint format, jint width, jint height);
48  static void _surfaceCreated(JNIEnv* env, jobject thiz, jobject holder);
49  static void _surfaceDestroyed(JNIEnv* env, jobject thiz, jobject holder);
50 };
51 
52 } // 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: JNIMainActivity.h:15
Definition: JNIXBMCMainView.h:22