public abstract class TcrRenderView
extends FrameLayout
Modifier and Type | Class and Description |
---|---|
static class |
TcrRenderView.InputDeviceType
An enumeration that defines the input device type.
|
static interface |
TcrRenderView.Observer
This interface represents the observer of TcrRenderView.
|
static class |
TcrRenderView.ScaleType
An enumeration that defines the video scaling type.
|
static class |
TcrRenderView.TcrRenderViewType
An enumeration that defines the types of the rendering view.
|
static class |
TcrRenderView.VideoRotation
An enumeration that defines the video rotation angle.
|
Modifier and Type | Field and Description |
---|---|
protected TcrRenderView.Observer |
mObserver |
protected View |
mRenderView |
protected TcrRenderView.TcrRenderViewType |
mTcrRenderViewType |
Modifier | Constructor and Description |
---|---|
protected |
TcrRenderView(Context context,
TcrRenderView.TcrRenderViewType type,
TcrSession session)
The constructor
|
Modifier and Type | Method and Description |
---|---|
protected abstract View |
createRenderView(TcrRenderView.TcrRenderViewType type)
创建渲染视图
|
boolean |
dispatchGenericMotionEvent(MotionEvent event) |
boolean |
dispatchKeyEvent(KeyEvent event) |
java.util.Map |
getKeyCodeMapping(TcrRenderView.InputDeviceType inputDeviceType)
Returns a mapping table, based on which TcrRenderView maps local peripheral input events to cloud input events.
|
void |
handleMotion(MotionEvent event)
Handle touch event.
|
boolean |
onCapturedPointerEvent(MotionEvent event) |
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom) |
abstract void |
release()
Release the underlying resources of this view.
You need to call this API to release the underlying resources if it is no longer needed, for example, when the Activity is to be destroyed. |
abstract void |
setDisplayDebugView(boolean displayDebugView)
Set whether to display the debug view.
|
void |
setEnableInputDeviceHandle(boolean enableInputDeviceHandler)
Set whether to enable TcrRenderView to process the peripheral input events.
|
abstract void |
setEnableSuperResolution(boolean enableSuperResolution)
Set whether the video super-resolution capability should be enabled.
|
void |
setObserver(TcrRenderView.Observer observer)
Set the observer of this TcrRenderView instance.
|
void |
setOnTouchListener(View.OnTouchListener listener)
Set the listener for the touch events of the view.
|
abstract void |
setVideoRotation(TcrRenderView.VideoRotation rotation)
Set the rotation angle of the rendered video.
|
abstract void |
setVideoScaleType(TcrRenderView.ScaleType type)
Set the scaling type of the rendered video.
|
protected final View mRenderView
protected final TcrRenderView.TcrRenderViewType mTcrRenderViewType
protected TcrRenderView.Observer mObserver
protected TcrRenderView(Context context, TcrRenderView.TcrRenderViewType type, TcrSession session)
context
- The context of this view.type
- The type of this view.protected abstract View createRenderView(TcrRenderView.TcrRenderViewType type)
type
- 渲染视图的类型protected void onLayout(boolean changed, int left, int top, int right, int bottom)
public void setOnTouchListener(View.OnTouchListener listener)
PcTouchListener
: Convert local screen touch events to mouse events on the cloud machine.MobileTouchListener
: Map local screen touch events to touch events on the cloud machine.public abstract void release()
Activity
is to be destroyed.public void handleMotion(MotionEvent event)
This method will be useful in scenarios like the following: a virtual keyboard view is placed on top of the
rendering view, and it is hoped that the buttons on the virtual keyboard view can be clicked while touching the
rendering view, such as controlling a character to attack while moving in a mobile game. You can achieve this
interactive effect like this:
1. Place the virtual keyboard view above the level of the rendering view, with the same size.
2. In the virtual keyboard view, at the same level as the button, create an empty view, named
delegateView
for example, that fills the virtual keyboard view in the layout.
3. Listen to the OnTouchListener
of delegateView, call this in onTouch() callback, and return true.
For example:
delegateView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
tcrRenderView.handleMotion(event);
return true;
}
});
event
- The motion event.public abstract void setVideoRotation(TcrRenderView.VideoRotation rotation)
rotation
- The rotation anglepublic abstract void setVideoScaleType(TcrRenderView.ScaleType type)
If not set, the default scaling type is TcrRenderView.ScaleType.SCALE_ASPECT_FIT
.
type
- The scaling typepublic abstract void setEnableSuperResolution(boolean enableSuperResolution)
If enabled, the rendering quality will be improved, but the GPU and power consumption will increase, and the frame rate may decrease.
Note that this method only works in api level 21 or above.
enableSuperResolution
- true
to enable SuperResolution, false
otherwise.public abstract void setDisplayDebugView(boolean displayDebugView)
The debug view shows the information such as performance data, version information, encoding type, key and touch information, etc.
displayDebugView
- true
to display the debug view, false
otherwise.public java.util.Map getKeyCodeMapping(TcrRenderView.InputDeviceType inputDeviceType)
If the input device type is TcrRenderView.InputDeviceType.MOUSE
, the returned map is of type HashMap<Integer,
KeyType>. The key of the returned map refers to the keycodes defined in KeyEvent
, and the value of
the returned map refers to the enums defined in Mouse.KeyType
.
If the input device type is TcrRenderView.InputDeviceType.GAMEPAD
or TcrRenderView.InputDeviceType.KEYBOARD
, the returned
map is of type HashMap<Integer, Integer>. The key of the returned map refers to the keycodes defined in
KeyEvent
, and the value of the returned map refers to the keycodes defined in
WindowsKeyEvent
.
You can modify the returned map to customize the mapping.
inputDeviceType
- The input device type.public void setEnableInputDeviceHandle(boolean enableInputDeviceHandler)
Setting this to true tells the TcrRenderView to process input device events automatically. This is the default behavior of TcrRenderView.
enableInputDeviceHandler
- true to enable, false to disable.public boolean dispatchKeyEvent(KeyEvent event)
public boolean dispatchGenericMotionEvent(MotionEvent event)
public boolean onCapturedPointerEvent(MotionEvent event)
public void setObserver(TcrRenderView.Observer observer)
observer
- The observer to be set.