HdmiCecMessageBuilderpublic class HdmiCecMessageBuilder extends Object A helper class to build {@link HdmiCecMessage} from various cec commands. |
Fields Summary |
---|
private static final int | OSD_NAME_MAX_LENGTH |
Constructors Summary |
---|
private HdmiCecMessageBuilder()
|
Methods Summary |
---|
static HdmiCecMessage | buildActiveSource(int src, int physicalAddress)Build <Active Source> command.
return buildCommand(src, Constants.ADDR_BROADCAST, Constants.MESSAGE_ACTIVE_SOURCE,
physicalAddressToParam(physicalAddress));
| static HdmiCecMessage | buildCecVersion(int src, int dest, int version)Build <Device Vendor Id> command. It has one byte cec version as parameter.
byte[] params = new byte[] {
(byte) (version & 0xFF)
};
return buildCommand(src, dest, Constants.MESSAGE_CEC_VERSION, params);
| static HdmiCecMessage | buildClearAnalogueTimer(int src, int dest, byte[] params)Build <Clear Analog Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_CLEAR_ANALOG_TIMER, params);
| static HdmiCecMessage | buildClearDigitalTimer(int src, int dest, byte[] params)Build <Clear Digital Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_CLEAR_DIGITAL_TIMER, params);
| static HdmiCecMessage | buildClearExternalTimer(int src, int dest, byte[] params)Build <Clear Digital Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_CLEAR_EXTERNAL_TIMER, params);
| private static HdmiCecMessage | buildCommand(int src, int dest, int opcode)Build a {@link HdmiCecMessage} without extra parameter.
return new HdmiCecMessage(src, dest, opcode, HdmiCecMessage.EMPTY_PARAM);
| private static HdmiCecMessage | buildCommand(int src, int dest, int opcode, byte[] params)Build a {@link HdmiCecMessage} with given values.
return new HdmiCecMessage(src, dest, opcode, params);
| static HdmiCecMessage | buildDeviceVendorIdCommand(int src, int vendorId)Build <Device Vendor Id> command. It has three bytes vendor id as
parameter.
This is a broadcast message sent to all devices on the bus.
byte[] params = new byte[] {
(byte) ((vendorId >> 16) & 0xFF),
(byte) ((vendorId >> 8) & 0xFF),
(byte) (vendorId & 0xFF)
};
// <Device Vendor Id> is broadcast message.
return buildCommand(src, Constants.ADDR_BROADCAST,
Constants.MESSAGE_DEVICE_VENDOR_ID, params);
| static HdmiCecMessage | buildFeatureAbortCommand(int src, int dest, int originalOpcode, int reason)Build <Feature Abort> command. <Feature Abort> consists of
1 byte original opcode and 1 byte reason fields with basic fields.
byte[] params = new byte[] {
(byte) (originalOpcode & 0xFF),
(byte) (reason & 0xFF),
};
return buildCommand(src, dest, Constants.MESSAGE_FEATURE_ABORT, params);
| static HdmiCecMessage | buildGiveAudioStatus(int src, int dest)Build <Give Audio Status> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_AUDIO_STATUS);
| static HdmiCecMessage | buildGiveDevicePowerStatus(int src, int dest)Build <Give Device Power Status> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_DEVICE_POWER_STATUS);
| static HdmiCecMessage | buildGiveDeviceVendorIdCommand(int src, int dest)Build <Give Vendor Id Command> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_DEVICE_VENDOR_ID);
| static HdmiCecMessage | buildGiveOsdNameCommand(int src, int dest)Build <Give Osd Name> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_OSD_NAME);
| static HdmiCecMessage | buildGivePhysicalAddress(int src, int dest)Build <Give Physical Address> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_PHYSICAL_ADDRESS);
| static HdmiCecMessage | buildGiveSystemAudioModeStatus(int src, int dest)Build <Give System Audio Mode Status> command.
return buildCommand(src, dest, Constants.MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS);
| static HdmiCecMessage | buildInactiveSource(int src, int physicalAddress)Build <Inactive Source> command.
return buildCommand(src, Constants.ADDR_TV,
Constants.MESSAGE_INACTIVE_SOURCE, physicalAddressToParam(physicalAddress));
| static HdmiCecMessage | buildRecordOff(int src, int dest)Build <Record Off> command.
return buildCommand(src, dest, Constants.MESSAGE_RECORD_OFF);
| static HdmiCecMessage | buildRecordOn(int src, int dest, byte[] params)Build <Record On> command.
return buildCommand(src, dest, Constants.MESSAGE_RECORD_ON, params);
| static HdmiCecMessage | buildReportArcInitiated(int src, int dest)Build <Report Arc Initiated>
return buildCommand(src, dest, Constants.MESSAGE_REPORT_ARC_INITIATED);
| static HdmiCecMessage | buildReportArcTerminated(int src, int dest)Build <Report Arc Terminated>
return buildCommand(src, dest, Constants.MESSAGE_REPORT_ARC_TERMINATED);
| static HdmiCecMessage | buildReportMenuStatus(int src, int dest, int menuStatus)Build <Report Menu Status> command.
byte[] param = new byte[] {
(byte) (menuStatus & 0xFF)
};
return buildCommand(src, dest, Constants.MESSAGE_MENU_STATUS, param);
| static HdmiCecMessage | buildReportPhysicalAddressCommand(int src, int address, int deviceType)Build <Report Physical Address> command. It has two bytes physical
address and one byte device type as parameter.
This is a broadcast message sent to all devices on the bus.
byte[] params = new byte[] {
// Two bytes for physical address
(byte) ((address >> 8) & 0xFF),
(byte) (address & 0xFF),
// One byte device type
(byte) (deviceType & 0xFF)
};
// <Report Physical Address> is broadcast message.
return buildCommand(src, Constants.ADDR_BROADCAST,
Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS, params);
| static HdmiCecMessage | buildReportPowerStatus(int src, int dest, int powerStatus)Build <Report Power Status> command.
byte[] param = new byte[] {
(byte) (powerStatus & 0xFF)
};
return buildCommand(src, dest, Constants.MESSAGE_REPORT_POWER_STATUS, param);
| static HdmiCecMessage | buildRequestArcInitiation(int src, int dest)Build <Request Arc Initiation>
return buildCommand(src, dest, Constants.MESSAGE_REQUEST_ARC_INITIATION);
| static HdmiCecMessage | buildRequestArcTermination(int src, int dest)Build <Request Arc Termination>
return buildCommand(src, dest, Constants.MESSAGE_REQUEST_ARC_TERMINATION);
| static HdmiCecMessage | buildRoutingChange(int src, int oldPath, int newPath)Build <Routing Change> command.
This is a broadcast message sent to all devices on the bus.
byte[] param = new byte[] {
(byte) ((oldPath >> 8) & 0xFF), (byte) (oldPath & 0xFF),
(byte) ((newPath >> 8) & 0xFF), (byte) (newPath & 0xFF)
};
return buildCommand(src, Constants.ADDR_BROADCAST, Constants.MESSAGE_ROUTING_CHANGE,
param);
| static HdmiCecMessage | buildSetAnalogueTimer(int src, int dest, byte[] params)Build <Set Analogue Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_SET_ANALOG_TIMER, params);
| static HdmiCecMessage | buildSetDigitalTimer(int src, int dest, byte[] params)Build <Set Digital Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_SET_DIGITAL_TIMER, params);
| static HdmiCecMessage | buildSetExternalTimer(int src, int dest, byte[] params)Build <Set External Timer> command.
return buildCommand(src, dest, Constants.MESSAGE_SET_EXTERNAL_TIMER, params);
| static HdmiCecMessage | buildSetMenuLanguageCommand(int src, java.lang.String language)Build <Set Menu Language > command.
This is a broadcast message sent to all devices on the bus.
if (language.length() != 3) {
return null;
}
// Hdmi CEC uses lower-cased ISO 639-2 (3 letters code).
String normalized = language.toLowerCase();
byte[] params = new byte[] {
(byte) (normalized.charAt(0) & 0xFF),
(byte) (normalized.charAt(1) & 0xFF),
(byte) (normalized.charAt(2) & 0xFF),
};
// <Set Menu Language> is broadcast message.
return buildCommand(src, Constants.ADDR_BROADCAST,
Constants.MESSAGE_SET_MENU_LANGUAGE, params);
| static HdmiCecMessage | buildSetOsdNameCommand(int src, int dest, java.lang.String name)Build <Set Osd Name > command.
int length = Math.min(name.length(), OSD_NAME_MAX_LENGTH);
byte[] params;
try {
params = name.substring(0, length).getBytes("US-ASCII");
} catch (UnsupportedEncodingException e) {
return null;
}
return buildCommand(src, dest, Constants.MESSAGE_SET_OSD_NAME, params);
| static HdmiCecMessage | buildSetStreamPath(int src, int streamPath)Build <Set Stream Path> command.
This is a broadcast message sent to all devices on the bus.
return buildCommand(src, Constants.ADDR_BROADCAST,
Constants.MESSAGE_SET_STREAM_PATH, physicalAddressToParam(streamPath));
| public static HdmiCecMessage | buildStandby(int src, int dest)Build <Standby> command.
return buildCommand(src, dest, Constants.MESSAGE_STANDBY);
| static HdmiCecMessage | buildSystemAudioModeRequest(int src, int avr, int avrPhysicalAddress, boolean enableSystemAudio)Build <System Audio Mode Request> command.
if (enableSystemAudio) {
return buildCommand(src, avr, Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST,
physicalAddressToParam(avrPhysicalAddress));
} else {
return buildCommand(src, avr, Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST);
}
| static HdmiCecMessage | buildTextViewOn(int src, int dest)Build <Text View On> command.
return buildCommand(src, dest, Constants.MESSAGE_TEXT_VIEW_ON);
| static HdmiCecMessage | buildUserControlPressed(int src, int dest, int uiCommand)Build <User Control Pressed> command.
return buildUserControlPressed(src, dest, new byte[] { (byte) (uiCommand & 0xFF) });
| static HdmiCecMessage | buildUserControlPressed(int src, int dest, byte[] commandParam)Build <User Control Pressed> command.
return buildCommand(src, dest, Constants.MESSAGE_USER_CONTROL_PRESSED, commandParam);
| static HdmiCecMessage | buildUserControlReleased(int src, int dest)Build <User Control Released> command.
return buildCommand(src, dest, Constants.MESSAGE_USER_CONTROL_RELEASED);
| static HdmiCecMessage | buildVendorCommand(int src, int dest, byte[] params)Build <Vendor Command> command.
return buildCommand(src, dest, Constants.MESSAGE_VENDOR_COMMAND, params);
| static HdmiCecMessage | buildVendorCommandWithId(int src, int dest, int vendorId, byte[] operands)Build <Vendor Command With ID> command.
byte[] params = new byte[operands.length + 3]; // parameter plus len(vendorId)
params[0] = (byte) ((vendorId >> 16) & 0xFF);
params[1] = (byte) ((vendorId >> 8) & 0xFF);
params[2] = (byte) (vendorId & 0xFF);
System.arraycopy(operands, 0, params, 3, operands.length);
return buildCommand(src, dest, Constants.MESSAGE_VENDOR_COMMAND_WITH_ID, params);
| static HdmiCecMessage | of(int src, int dest, byte[] body)Build {@link HdmiCecMessage} from raw data.
byte opcode = body[0];
byte params[] = Arrays.copyOfRange(body, 1, body.length);
return new HdmiCecMessage(src, dest, opcode, params);
| private static byte[] | physicalAddressToParam(int physicalAddress)
return new byte[] {
(byte) ((physicalAddress >> 8) & 0xFF),
(byte) (physicalAddress & 0xFF)
};
|
|