File indexing completed on 2025-01-19 03:57:02
0001 /********************************************************* 0002 * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> * 0003 * * 0004 * This file is part of QtAVPlayer. * 0005 * Free Qt Media Player based on FFmpeg. * 0006 *********************************************************/ 0007 0008 #include "qavandroidsurfacetexture_p.h" 0009 #include <QtCore/qmutex.h> 0010 #include <QtCore/qcoreapplication.h> 0011 0012 QT_BEGIN_NAMESPACE 0013 0014 QAVAndroidSurfaceTexture::QAVAndroidSurfaceTexture(quint32 texName) 0015 { 0016 Q_STATIC_ASSERT(sizeof (jlong) >= sizeof (void *)); 0017 m_surfaceTexture = JniObject("android/graphics/SurfaceTexture", "(I)V", jint(texName)); 0018 } 0019 0020 QAVAndroidSurfaceTexture::~QAVAndroidSurfaceTexture() 0021 { 0022 if (m_surface.isValid()) 0023 m_surface.callMethod<void>("release"); 0024 0025 if (m_surfaceTexture.isValid()) 0026 release(); 0027 } 0028 0029 void QAVAndroidSurfaceTexture::release() 0030 { 0031 m_surfaceTexture.callMethod<void>("release"); 0032 } 0033 0034 void QAVAndroidSurfaceTexture::updateTexImage() 0035 { 0036 if (!m_surfaceTexture.isValid()) 0037 return; 0038 0039 m_surfaceTexture.callMethod<void>("updateTexImage"); 0040 } 0041 0042 jobject QAVAndroidSurfaceTexture::surfaceTexture() 0043 { 0044 return m_surfaceTexture.object(); 0045 } 0046 0047 jobject QAVAndroidSurfaceTexture::surface() 0048 { 0049 if (!m_surface.isValid()) { 0050 m_surface = JniObject("android/view/Surface", 0051 "(Landroid/graphics/SurfaceTexture;)V", 0052 m_surfaceTexture.object()); 0053 } 0054 0055 return m_surface.object(); 0056 } 0057 0058 void QAVAndroidSurfaceTexture::attachToGLContext(quint32 texName) 0059 { 0060 if (!m_surfaceTexture.isValid()) 0061 return; 0062 0063 m_surfaceTexture.callMethod<void>("attachToGLContext", "(I)V", texName); 0064 } 0065 0066 void QAVAndroidSurfaceTexture::detachFromGLContext() 0067 { 0068 if (!m_surfaceTexture.isValid()) 0069 return; 0070 0071 m_surfaceTexture.callMethod<void>("detachFromGLContext"); 0072 } 0073 0074 QT_END_NAMESPACE