Methods Summary |
---|
public int | addOrUpdateStream(int deviceId, android.view.Surface surface, android.media.tv.TvStreamConfig streamConfig)
synchronized (mLock) {
if (mPtr == 0) {
return ERROR_NO_INIT;
}
int generation = mStreamConfigGenerations.get(deviceId, 0);
if (generation != streamConfig.getGeneration()) {
return ERROR_STALE_CONFIG;
}
if (nativeAddOrUpdateStream(mPtr, deviceId, streamConfig.getStreamId(), surface) == 0) {
return SUCCESS;
} else {
return ERROR_UNKNOWN;
}
}
|
public void | close()
synchronized (mLock) {
if (mPtr != 0l) {
nativeClose(mPtr);
}
}
|
private void | deviceAvailableFromNative(android.media.tv.TvInputHardwareInfo info)
if (DEBUG) {
Slog.d(TAG, "deviceAvailableFromNative: info = " + info);
}
mHandler.obtainMessage(EVENT_DEVICE_AVAILABLE, info).sendToTarget();
|
private void | deviceUnavailableFromNative(int deviceId)
mHandler.obtainMessage(EVENT_DEVICE_UNAVAILABLE, deviceId, 0).sendToTarget();
|
private void | firstFrameCapturedFromNative(int deviceId, int streamId)
mHandler.sendMessage(
mHandler.obtainMessage(EVENT_STREAM_CONFIGURATION_CHANGED, deviceId, streamId));
|
public boolean | handleMessage(android.os.Message msg)
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE: {
TvStreamConfig[] configs;
TvInputHardwareInfo info = (TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
retrieveStreamConfigsLocked(info.getDeviceId());
if (DEBUG) {
Slog.d(TAG, "EVENT_DEVICE_AVAILABLE: info = " + info);
}
configs = mStreamConfigs.get(info.getDeviceId());
}
mCallback.onDeviceAvailable(info, configs);
break;
}
case EVENT_DEVICE_UNAVAILABLE: {
int deviceId = msg.arg1;
if (DEBUG) {
Slog.d(TAG, "EVENT_DEVICE_UNAVAILABLE: deviceId = " + deviceId);
}
mCallback.onDeviceUnavailable(deviceId);
break;
}
case EVENT_STREAM_CONFIGURATION_CHANGED: {
TvStreamConfig[] configs;
int deviceId = msg.arg1;
synchronized (mLock) {
if (DEBUG) {
Slog.d(TAG, "EVENT_STREAM_CONFIGURATION_CHANGED: deviceId = " + deviceId);
}
retrieveStreamConfigsLocked(deviceId);
configs = mStreamConfigs.get(deviceId);
}
mCallback.onStreamConfigurationChanged(deviceId, configs);
break;
}
case EVENT_FIRST_FRAME_CAPTURED: {
int deviceId = msg.arg1;
int streamId = msg.arg2;
mCallback.onFirstFrameCaptured(deviceId, streamId);
break;
}
default:
Slog.e(TAG, "Unknown event: " + msg);
return false;
}
return true;
|
public void | init()
synchronized (mLock) {
mPtr = nativeOpen(mHandler.getLooper().getQueue());
}
|
private static native int | nativeAddOrUpdateStream(long ptr, int deviceId, int streamId, android.view.Surface surface)
|
private static native void | nativeClose(long ptr)
|
private static native android.media.tv.TvStreamConfig[] | nativeGetStreamConfigs(long ptr, int deviceId, int generation)
|
private native long | nativeOpen(android.os.MessageQueue queue)
|
private static native int | nativeRemoveStream(long ptr, int deviceId, int streamId)
|
public int | removeStream(int deviceId, android.media.tv.TvStreamConfig streamConfig)
synchronized (mLock) {
if (mPtr == 0) {
return ERROR_NO_INIT;
}
int generation = mStreamConfigGenerations.get(deviceId, 0);
if (generation != streamConfig.getGeneration()) {
return ERROR_STALE_CONFIG;
}
if (nativeRemoveStream(mPtr, deviceId, streamConfig.getStreamId()) == 0) {
return SUCCESS;
} else {
return ERROR_UNKNOWN;
}
}
|
private void | retrieveStreamConfigsLocked(int deviceId)
int generation = mStreamConfigGenerations.get(deviceId, 0) + 1;
mStreamConfigs.put(deviceId, nativeGetStreamConfigs(mPtr, deviceId, generation));
mStreamConfigGenerations.put(deviceId, generation);
|
private void | streamConfigsChangedFromNative(int deviceId)
mHandler.obtainMessage(EVENT_STREAM_CONFIGURATION_CHANGED, deviceId, 0).sendToTarget();
|