Android のみを対象とする C++Builder 10.2 Tokyo の FMX プロジェクトがあります。Camera2 APIを利用しようとしています。Java2Pasツールを使用して、必要な Delphi インターフェイスとクラスを作成し、それらを 1 つの Pascal ファイルにまとめて、C++ プロジェクトに追加しました。
このパスカル ファイルの一部は次のようになります。
JTextureView_SurfaceTextureListenerClass = interface(JObjectClass)
['{106DB13E-C1B4-4898-B906-0143D97C0075}']
function onSurfaceTextureDestroyed(JSurfaceTextureparam0 : JSurfaceTexture) : boolean; cdecl;// (Landroid/graphics/SurfaceTexture;)Z A: $401
procedure onSurfaceTextureAvailable(JSurfaceTextureparam0 : JSurfaceTexture; Integerparam1 : Integer; Integerparam2 : Integer) ; cdecl;// (Landroid/graphics/SurfaceTexture;II)V A: $401
procedure onSurfaceTextureSizeChanged(JSurfaceTextureparam0 : JSurfaceTexture; Integerparam1 : Integer; Integerparam2 : Integer) ; cdecl;// (Landroid/graphics/SurfaceTexture;II)V A: $401
procedure onSurfaceTextureUpdated(JSurfaceTextureparam0 : JSurfaceTexture) ; cdecl;// (Landroid/graphics/SurfaceTexture;)V A: $401
end;
[JavaSignature('android/view/TextureView_SurfaceTextureListener')]
JTextureView_SurfaceTextureListener = interface(JObject)
['{58A7FBD1-27B9-44AC-B013-F077E1BF5975}']
function onSurfaceTextureDestroyed(JSurfaceTextureparam0 : JSurfaceTexture) : boolean; cdecl;// (Landroid/graphics/SurfaceTexture;)Z A: $401
procedure onSurfaceTextureAvailable(JSurfaceTextureparam0 : JSurfaceTexture; Integerparam1 : Integer; Integerparam2 : Integer) ; cdecl;// (Landroid/graphics/SurfaceTexture;II)V A: $401
procedure onSurfaceTextureSizeChanged(JSurfaceTextureparam0 : JSurfaceTexture; Integerparam1 : Integer; Integerparam2 : Integer) ; cdecl;// (Landroid/graphics/SurfaceTexture;II)V A: $401
procedure onSurfaceTextureUpdated(JSurfaceTextureparam0 : JSurfaceTexture) ; cdecl;// (Landroid/graphics/SurfaceTexture;)V A: $401
end;
TJTextureView_SurfaceTextureListener = class(TJavaGenericImport<JTextureView_SurfaceTextureListenerClass, JTextureView_SurfaceTextureListener>)
end;
インターフェイスはTJTextureView_SurfaceTextureListener
コールバック オブジェクトとして使用する必要があるため、いくつかのイベント ハンドラーを追加し、次のように変更しました。
TOnSurfaceTextureDestroyed = function(aSurface: JSurfaceTexture): Boolean of object;
TOnSurfaceTextureUpdated = procedure(aSurface: JSurfaceTexture) of object;
TOnSurfaceTextureSize = procedure(aSurface: JSurfaceTexture; aWidth:Integer; aHeight: Integer) of object;
TJTextureView_SurfaceTextureListener = class(TJavaGenericImport<JTextureView_SurfaceTextureListenerClass, JTextureView_SurfaceTextureListener>)
protected
FOnTextureDestroyed: TOnSurfaceTextureDestroyed;
FOnTextureUpdated: TOnSurfaceTextureUpdated;
FOnTextureAvailable: TOnSurfaceTextureSize;
FOnTextureSizeChanged: TOnSurfaceTextureSize;
public
function onSurfaceTextureDestroyed(aSurface : JSurfaceTexture) : boolean; cdecl;
procedure onSurfaceTextureAvailable(aSurface : JSurfaceTexture; aWidth : Integer; aHeight : Integer) ; cdecl;
procedure onSurfaceTextureSizeChanged(aSurface : JSurfaceTexture; aWidth : Integer; aHeight : Integer) ; cdecl;
procedure onSurfaceTextureUpdated(aSurface : JSurfaceTexture) ; cdecl;
property OnTextureDestroyed: TOnSurfaceTextureDestroyed read FOnTextureDestroyed write FOnTextureDestroyed;
property OnTextureUpdated: TOnSurfaceTextureUpdated read FOnTextureUpdated write FOnTextureUpdated;
property OnTextureAvailable: TOnSurfaceTextureSize read FOnTextureAvailable write FOnTextureAvailable;
property OnTextureSizeChanged: TOnSurfaceTextureSize read FOnTextureSizeChanged write FOnTextureSizeChanged;
end;
implementation
{ TJTextureView_SurfaceTextureListener }
procedure TJTextureView_SurfaceTextureListener.onSurfaceTextureAvailable(aSurface: JSurfaceTexture; aWidth, aHeight: Integer);
begin
if Assigned(FOnTextureAvailable) then
FOnTextureAvailable(aSurface, aWidth, aHeight);
end;
function TJTextureView_SurfaceTextureListener.onSurfaceTextureDestroyed(aSurface: JSurfaceTexture): boolean;
begin
if Assigned(FOnTextureDestroyed) then
Result := FOnTextureDestroyed(aSurface)
else
Result := False;
end;
procedure TJTextureView_SurfaceTextureListener.onSurfaceTextureSizeChanged(aSurface: JSurfaceTexture; aWidth, aHeight: Integer);
begin
if Assigned(FOnTextureSizeChanged) then
FOnTextureSizeChanged(aSurface, aWidth, aHeight);
end;
procedure TJTextureView_SurfaceTextureListener.onSurfaceTextureUpdated(aSurface: JSurfaceTexture);
begin
if Assigned(FOnTextureUpdated) then
FOnTextureUpdated(aSurface);
end;
IDE は、次のようなヘッダー ファイルを作成しました。
__interface JTextureView_SurfaceTextureListenerClass;
typedef System::DelphiInterface<JTextureView_SurfaceTextureListenerClass> _di_JTextureView_SurfaceTextureListenerClass;
__interface JTextureView_SurfaceTextureListener;
typedef System::DelphiInterface<JTextureView_SurfaceTextureListener> _di_JTextureView_SurfaceTextureListener;
class DELPHICLASS TJTextureView_SurfaceTextureListener;
__interface INTERFACE_UUID("{106DB13E-C1B4-4898-B906-0143D97C0075}") JTextureView_SurfaceTextureListenerClass : public Androidapi::Jni::Javatypes::JObjectClass
{
virtual bool __cdecl onSurfaceTextureDestroyed(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0) = 0 ;
virtual void __cdecl onSurfaceTextureAvailable(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0, int Integerparam1, int Integerparam2) = 0 ;
virtual void __cdecl onSurfaceTextureSizeChanged(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0, int Integerparam1, int Integerparam2) = 0 ;
virtual void __cdecl onSurfaceTextureUpdated(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0) = 0 ;
};
__interface INTERFACE_UUID("{58A7FBD1-27B9-44AC-B013-F077E1BF5975}") JTextureView_SurfaceTextureListener : public Androidapi::Jni::Javatypes::JObject
{
virtual bool __cdecl onSurfaceTextureDestroyed(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0) = 0 ;
virtual void __cdecl onSurfaceTextureAvailable(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0, int Integerparam1, int Integerparam2) = 0 ;
virtual void __cdecl onSurfaceTextureSizeChanged(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0, int Integerparam1, int Integerparam2) = 0 ;
virtual void __cdecl onSurfaceTextureUpdated(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture JSurfaceTextureparam0) = 0 ;
};
typedef bool __fastcall (__closure *TOnSurfaceTextureDestroyed)(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface);
typedef void __fastcall (__closure *TOnSurfaceTextureUpdated)(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface);
typedef void __fastcall (__closure *TOnSurfaceTextureSize)(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface, int aWidth, int aHeight);
class PASCALIMPLEMENTATION TJTextureView_SurfaceTextureListener : public Androidapi::Jnibridge::TJavaGenericImport__2<_di_JTextureView_SurfaceTextureListenerClass,_di_JTextureView_SurfaceTextureListener>
{
typedef Androidapi::Jnibridge::TJavaGenericImport__2<_di_JTextureView_SurfaceTextureListenerClass,_di_JTextureView_SurfaceTextureListener> inherited;
protected:
TOnSurfaceTextureDestroyed FOnTextureDestroyed;
TOnSurfaceTextureUpdated FOnTextureUpdated;
TOnSurfaceTextureSize FOnTextureAvailable;
TOnSurfaceTextureSize FOnTextureSizeChanged;
public:
bool __cdecl onSurfaceTextureDestroyed(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface);
void __cdecl onSurfaceTextureAvailable(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface, int aWidth, int aHeight);
void __cdecl onSurfaceTextureSizeChanged(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface, int aWidth, int aHeight);
void __cdecl onSurfaceTextureUpdated(Androidapi::Jni::Graphicscontentviewtext::_di_JSurfaceTexture aSurface);
__property TOnSurfaceTextureDestroyed OnTextureDestroyed = {read=FOnTextureDestroyed, write=FOnTextureDestroyed};
__property TOnSurfaceTextureUpdated OnTextureUpdated = {read=FOnTextureUpdated, write=FOnTextureUpdated};
__property TOnSurfaceTextureSize OnTextureAvailable = {read=FOnTextureAvailable, write=FOnTextureAvailable};
__property TOnSurfaceTextureSize OnTextureSizeChanged = {read=FOnTextureSizeChanged, write=FOnTextureSizeChanged};
public:
/* TObject.Create */ inline __fastcall TJTextureView_SurfaceTextureListener(void) : Androidapi::Jnibridge::TJavaGenericImport__2<_di_JTextureView_SurfaceTextureListenerClass,_di_JTextureView_SurfaceTextureListener> () { }
/* TObject.Destroy */ inline __fastcall virtual ~TJTextureView_SurfaceTextureListener(void) { }
};
私のC++コード内では、次のように使用しようとしています:
_di_JTextureView_SurfaceTextureListener = TJTextureView_SurfaceTextureListener::JavaClass->init();
SurfaceTextureListener->OnTextureAvailable = SetupCamera;
しかし、コンパイラは私にエラーを与えます:
「Androidcamera2::JTextureView_SurfaceTextureListener」に「OnTextureAvailable」という名前のメンバーがありません
ここで私が間違っていることを誰かに教えてもらえますか?