blob: 9962fc6124b87017966a516bfa6e4ed049a06c37 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.bluetooth.avrcp;
// Types are intended match how they are defined in the BT AVRCP 1.6.2 spec
// and the 1394-TA AV\C Panel specification.
// Deviations are called out in comments.
/// Status codes for commands sent as the controller.
type ControllerError = strict enum : uint32 {
UNKNOWN_FAILURE = 1;
TIMED_OUT = 2;
REMOTE_NOT_CONNECTED = 3;
COMMAND_NOT_IMPLEMENTED = 4;
COMMAND_REJECTED = 5;
COMMAND_UNEXPECTED = 6;
INVALID_ARGUMENTS = 7;
PACKET_ENCODING = 8;
PROTOCOL_ERROR = 9;
CONNECTION_ERROR = 10;
UNEXPECTED_RESPONSE = 11;
};
/// Status codes for passthrough responses received from the target.
type TargetPassthroughError = strict enum {
COMMAND_NOT_IMPLEMENTED = 1;
COMMAND_REJECTED = 2;
};
/// Status codes for AVRCP specific AV/C commands.
/// Defined in AVRCP 1.6.2 section 6.15.3, Table 6.49.
/// Style note: named exactly as they are in Table 6.49 with the "REJECTED_" prefix.
type TargetAvcError = strict enum : uint32 {
REJECTED_INVALID_COMMAND = 0x00;
REJECTED_INVALID_PARAMETER = 0x01;
REJECTED_PARAMETER_CONTENT_ERROR = 0x02;
REJECTED_INTERNAL_ERROR = 0x03;
REJECTED_UID_CHANGED = 0x05;
REJECTED_INVALID_PLAYER_ID = 0x11;
REJECTED_NO_AVAILABLE_PLAYERS = 0x15;
REJECTED_ADDRESSED_PLAYER_CHANGED = 0x16;
};
/// The `AddressedPlayerId` is a unique identifier, assigned by AVRCP, for a media player.
/// This ID is only used for AVRCP purposes, and should not be interpreted as an
/// identification created, assigned, or used by MediaSession or any other API surfaces.
///
/// Defined in AVRCP 1.6, Section 6.10.2.1.
type AddressedPlayerId = struct {
id uint16;
};
/// The maximum number of Notification Event IDs that can be supported by the TG.
/// 0x0E to 0xFF are reserved for future use.
/// Defined by AVRCP 1.6.2 Appendix H.
const MAX_NOTIFICATIONS uint8 = 255;
/// Defined by AVRCP 1.6.2 section 6.7.2 (RegisterNotification) and Appendix H.
/// Style note: named exactly as they are in the specification with the "EVENT_" prefix.
type NotificationEvent = strict enum : uint8 {
PLAYBACK_STATUS_CHANGED = 0x01;
TRACK_CHANGED = 0x02;
TRACK_REACHED_END = 0x03;
TRACK_REACHED_START = 0x04;
TRACK_POS_CHANGED = 0x05;
BATT_STATUS_CHANGED = 0x06;
SYSTEM_STATUS_CHANGED = 0x07;
PLAYER_APPLICATION_SETTING_CHANGED = 0x08;
NOW_PLAYING_CONTENT_CHANGED = 0x09;
AVAILABLE_PLAYERS_CHANGED = 0x0a;
ADDRESSED_PLAYER_CHANGED = 0x0b;
UIDS_CHANGED = 0x0c;
VOLUME_CHANGED = 0x0d;
};
/// Change notifications that a controller client can register.
type Notifications = strict bits : uint32 {
// AVRCP native notifications
/// AVRCP `EVENT_PLAYBACK_STATUS_CHANGED` Notification
PLAYBACK_STATUS = 0x1;
/// AVRCP `EVENT_TRACK_CHANGED` Notification
TRACK = 0x2;
/// AVRCP `EVENT_TRACK_POS_CHANGED` Notification
TRACK_POS = 0x4;
/// AVRCP `EVENT_BATT_STATUS_CHANGED` Notification
BATT_STATUS = 0x8;
/// AVRCP `EVENT_SYSTEM_STATUS_CHANGED` Notification
SYSTEM_STATUS = 0x10;
/// AVRCP `EVENT_PLAYER_APPLICATION_SETTINGS_CHANGED` Notification
PLAYER_APPLICATION_SETTINGS = 0x20;
/// AVRCP `EVENT_ADDRESSED_PLAYER_CHANGED` Notification
ADDRESSED_PLAYER = 0x40;
/// AVRCP `EVENT_VOLUME_CHANGED` Notification
VOLUME = 0x80;
/// AVRCP `EVENT_AVAILABLE_PLAYERS_CHANGED` Notification
AVAILABLE_PLAYERS = 0x100;
// Internal notifications
/// Internal connection change event.
CONNECTION = 0x10000;
};
/// Event data from incoming target notifications.
/// Defined by AVRCP 1.6.2 Sec 6.7.2.
type Notification = table {
/// `EVENT_PLAYBACK_STATUS_CHANGED` event data
1: status PlaybackStatus;
/// `EVENT_TRACK_CHANGED` event data
2: track_id uint64;
/// `EVENT_TRACK_POS_CHANGED` event data
3: pos uint32;
/// `EVENT_BATT_STATUS_CHANGED` event data
4: battery_status BatteryStatus;
/// `EVENT_SYSTEM_STATUS_CHANGED` event data
5: system_status SystemStatus;
/// `EVENT_PLAYER_APPLICATION_SETTINGS_CHANGED` event data
6: application_settings PlayerApplicationSettings;
/// `EVENT_ADDRESSED_PLAYER_CHANGED` event data
7: player_id uint16;
/// `EVENT_VOLUME_CHANGED` event data
8: volume uint8;
/// `CONNECTION_CHANGE` event data
9: device_connected bool;
/// `AVAILABLE_PLAYERS_CHANGED` event data
10: available_players_changed bool;
/// `ADDRESSED_PLAYER_CHANGED` event data
11: addressed_player uint16;
};
/// Defined by AVRCP 1.6.2 section 6.7.2 (RegisterNotification).
/// Format for `EVENT_SYSTEM_STATUS_CHANGED`.
type SystemStatus = strict enum : uint8 {
POWER_ON = 0x00;
POWER_OFF = 0x01;
UNPLUGGED = 0x02;
};
/// Defined by AVRCP 1.6.2 section 6.7.2 (RegisterNotification).
/// Format for `EVENT_PLAYBACK_STATUS_CHANGED`.
type PlaybackStatus = strict enum : uint8 {
STOPPED = 0x00;
PLAYING = 0x01;
PAUSED = 0x02;
FWD_SEEK = 0x03;
REV_SEEK = 0x04;
ERROR = 0xFF;
};
/// Defined by AVRCP 1.6.2 section 6.7.2 (RegisterNotification).
/// Format for `EVENT_BATT_STATUS_CHANGED`.
/// Same encoding also defined by 6.5.8 (InformBatteryStatusOfCT).
type BatteryStatus = strict enum : uint8 {
NORMAL = 0x00;
WARNING = 0x01;
CRITICAL = 0x02;
EXTERNAL = 0x03;
FULL_CHARGE = 0x04;
RESERVED = 0x05;
};
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type RepeatStatusMode = strict enum : uint8 {
OFF = 0x01;
SINGLE_TRACK_REPEAT = 0x02;
ALL_TRACK_REPEAT = 0x03;
GROUP_REPEAT = 0x04;
};
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type ShuffleMode = strict enum : uint8 {
OFF = 0x01;
ALL_TRACK_SHUFFLE = 0x02;
GROUP_SHUFFLE = 0x03;
};
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type ScanMode = strict enum : uint8 {
OFF = 0x01;
ALL_TRACK_SCAN = 0x02;
GROUP_SCAN = 0x03;
};
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type Equalizer = strict enum : uint8 {
OFF = 0x01;
ON = 0x02;
};
/// The maximum number of custom attributes that can be used.
/// Defined by AVRCP 1.6.2 Appendix F.
const MAX_CUSTOM_ATTRIBUTES uint64 = 127;
/// The maximum number of possible values an attribute can take on.
/// Defined by AVRCP 1.6.2 Sec 6.5.2
const MAX_ATTRIBUTE_VALUES uint64 = 255;
/// The total number of attributes that can be set. The custom attributes + the 4
/// defined attributes, `PlayerApplicationSettingAttributeId`. 4 + 127 = 131.
const MAX_ATTRIBUTES uint64 = 131;
/// 0x80 - 0xFF is reserved for custom player application settings.
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type PlayerApplicationSettingAttributeId = strict enum : uint8 {
EQUALIZER = 0x01;
REPEAT_STATUS_MODE = 0x02;
SHUFFLE_MODE = 0x03;
SCAN_MODE = 0x04;
};
/// The custom attribute value and its description.
type CustomAttributeValue = struct {
description string:255;
value uint8;
};
/// Specification allowed player application settings.
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type CustomPlayerApplicationSetting = table {
/// The attribute id for the custom setting. Must be between 0x80-0xFF, as
/// defined in AVRCP 1.6.2 Appendix F.
1: attribute_id uint8;
/// The string descriptor of the custom attribute.
2: attribute_name string:255;
/// The possible values the custom attribute can take.
3: possible_values vector<CustomAttributeValue>:MAX_ATTRIBUTE_VALUES;
/// The current value that the custom setting is set to.
4: current_value uint8;
};
/// Defined by AVRCP 1.6.2 Appendix F (player application settings).
type PlayerApplicationSettings = table {
/// The equalizer status of the remote target.
1: equalizer Equalizer;
/// The repeat mode status of the remote target.
2: repeat_status_mode RepeatStatusMode;
/// The shuffle mode status of the remote target.
3: shuffle_mode ShuffleMode;
/// The scan mode status of the remote target.
4: scan_mode ScanMode;
/// Custom settings that are specification allowed.
5: custom_settings vector<CustomPlayerApplicationSetting>:MAX_CUSTOM_ATTRIBUTES;
};
/// The maximum length of an attribute value in the media attributes.
/// Defined by AVRCP 1.6.2 Sec 6.6.1.
const MAX_ATTRIBUTE_VALUE_LENGTH uint64 = 65535;
/// Defined by AVRCP 1.6.2 Appendix E (media attributes).
type MediaAttributes = table {
/// The title, song name, or content description.
1: title string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The artist, performer, or group.
2: artist_name string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The title of the source of media.
3: album_name string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The order number of the media on its original recording.
4: track_number string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The total number of tracks in the media.
5: total_number_of_tracks string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The category of composition of the media,
6: genre string:MAX_ATTRIBUTE_VALUE_LENGTH;
/// The length of the media in milliseconds (ms).
7: playing_time string:MAX_ATTRIBUTE_VALUE_LENGTH;
// TODO(https://fxbug.dev/42082325): Add BIP cover art handle.
};
/// Status of currently playing media on the TG.
/// Defined by AVRCP 1.6.2 section 6.7.1, Table 6.29.
type PlayStatus = table {
/// The total length of the currently playing media, in milliseconds.
/// Optional, if the TG does not support song length.
1: song_length uint32;
/// The current position of the playing media, in milliseconds elapsed.
/// Optional, if the TG does not support song position.
2: song_position uint32;
/// The playback status of the currently playing media.
/// Mandatory, the TG must respond with a PlaybackStatus.
3: playback_status PlaybackStatus;
};
/// The maximum number of MediaPlayerItems that can be returned from a call to
/// GetMediaPlayerItems.
/// This value is arbitrary and is meant to limit the number of items that can be returned.
/// AVRCP 1.6.2, Section 6.10.4.2.2 defines the `Number of Items` parameter as a uint16.
const MAX_MEDIA_PLAYER_ITEMS uint16 = 16;
/// The Major Player Type associated with a media player.
/// Defined by AVRCP 1.6.2 section 6.10.2.1.
type MajorPlayerType = strict bits : uint8 {
AUDIO = 0x01;
VIDEO = 0x02;
BROADCASTING_AUDIO = 0x04;
BROADCASTING_VIDEO = 0x08;
// Bits 4 - 7 are reserved.
};
/// The Player Sub Type associated with a media player.
/// Defined by AVRCP 1.6.2 section 6.10.2.1.
type PlayerSubType = strict bits : uint32 {
AUDIO_BOOK = 0x01;
PODCAST = 0x02;
// Bits 2 - 31 are reserved.
};
// Player feature bits associated with feature bits in octets 0-7.
// Defined by AVRCP 1.6.2 section 6.10.2.1.
// Note that the feature bits are represented as big-endian 64 bit integer
// for convenience and the fidl bit value for each feature is set to work with that
// assumption.
type PlayerFeatureBits = strict bits : uint64 {
// Octet 0.
SELECT = 0x0100000000000000;
UP = 0x0200000000000000;
DOWN = 0x0400000000000000;
LEFT = 0x0800000000000000;
RIGHT = 0x1000000000000000;
RIGHT_UP = 0x2000000000000000;
RIGHT_DOWN = 0x4000000000000000;
LEFT_UP = 0x8000000000000000;
// Octet 1.
LEFT_DOWN = 0x0001000000000000;
ROOT_MENU = 0x0002000000000000;
SETUP_MENU = 0x0004000000000000;
CONTENTS_MENU = 0x0008000000000000;
FAVORITE_MENU = 0x0010000000000000;
EXIT = 0x0020000000000000;
// ZERO-NINE are for pass through commands 0-9.
ZERO = 0x0040000000000000;
ONE = 0x0080000000000000;
// Octet 2.
TWO = 0x0000010000000000;
THREE = 0x0000020000000000;
FOUR = 0x0000040000000000;
FIVE = 0x0000080000000000;
SIX = 0x0000100000000000;
SEVEN = 0x0000200000000000;
EIGHT = 0x0000400000000000;
NINE = 0x0000800000000000;
// Octet 3.
DOT = 0x0000000100000000;
ENTER = 0x0000000200000000;
CLEAR = 0x0000000400000000;
CHANNEL_UP = 0x0000000800000000;
CHANNEL_DOWN = 0x0000001000000000;
PREVIOUS_CHANNEL = 0x0000002000000000;
SOUND_SELECT = 0x0000004000000000;
INPUT_SELECT = 0x0000008000000000;
// Octet 4.
DISPLAY_INFORMATION = 0x0000000001000000;
HELP = 0x0000000002000000;
PAGE_UP = 0x0000000004000000;
PAGE_DOWN = 0x0000000008000000;
POWER = 0x0000000010000000;
VOLUME_UP = 0x0000000020000000;
VOLUME_DOWN = 0x0000000040000000;
MUTE = 0x0000000080000000;
// Octet 5.
PLAY = 0x0000000000010000;
STOP = 0x0000000000020000;
PAUSE = 0x0000000000040000;
RECORD = 0x0000000000080000;
REWIND = 0x0000000000100000;
FAST_FORWARD = 0x0000000000200000;
EJECT = 0x0000000000400000;
FORWARD = 0x0000000000800000;
// Octet 6.
BACKWARD = 0x0000000000000100;
ANGLE = 0x0000000000000200;
SUBPICTURE = 0x0000000000000400;
F1 = 0x0000000000000800;
F2 = 0x0000000000001000;
F3 = 0x0000000000002000;
F4 = 0x0000000000004000;
F5 = 0x0000000000008000;
// Octet 7.
VENDOR_UNIQUE = 0x0000000000000001;
BASIC_GROUP_NAVIGATION = 0x0000000000000002;
ADVANCED_CONTROL_PLAYER = 0x0000000000000004;
BROWSING = 0x0000000000000008;
SEARCHING = 0x0000000000000010;
ADD_TO_NOW_PLAYING = 0x0000000000000020;
UIDS_UNIQUE_IN_PLAYER_BROWSE_TREE = 0x0000000000000040;
ONLY_BROWSABLE_WHEN_ADDRESSED = 0x0000000000000080;
};
// Player feature bits associated with feature bits in octets 8-15.
// Defined by AVRCP 1.6.2 section 6.10.2.1.
// Note that the feature bits are represented as big-endian 64 bit integer
// for convenience and the fidl bit value for each feature is set to work with that
// assumption.
type PlayerFeatureBitsExt = strict bits : uint64 {
// Octet 0.
ONLY_SEARCHABLE_WHEN_ADDRESSED = 0x0100000000000000;
NOW_PLAYING = 0x0200000000000000;
UID_PERSISTENCY = 0x0400000000000000;
NUMBER_OF_ITEMS = 0x0800000000000000;
COVER_ART = 0x1000000000000000;
// Octet 0 bits 5 onwards are reserved.
};
/// Response data for the browseable items associated with a media player.
/// Defined by AVRCP 1.6.2 section 6.10.2.1.
type MediaPlayerItem = table {
1: player_id uint16;
2: major_type MajorPlayerType;
3: sub_type PlayerSubType;
4: playback_status PlaybackStatus;
5: displayable_name string:255;
6: feature_bits PlayerFeatureBits;
7: feature_bits_ext PlayerFeatureBitsExt;
};
/// Response data for a browseable media element item.
/// Defined by AVRCP 1.6.2 section 6.10.2.3.
type MediaElementItem = table {
1: media_element_uid uint64;
2: media_type MediaType;
3: displayable_name string:255;
4: attributes MediaAttributes;
};
/// Response data for a browseable folder item.
/// Defined by AVRCP 1.6.2 section 6.10.2.2.
type FolderItem = table {
1: folder_uid uint64;
2: folder_type FolderType;
3: is_playable bool;
4: displayable_name string:255;
};
/// Items returned from GetFolderItems(Filesystem) may be either a folder or media element.
/// Defined by AVRCP 1.6.2 section 6.10.1.2.
/// Only one of `folder` or `media_element` should be set.
type FileSystemItem = strict union {
1: folder FolderItem;
2: media_element MediaElementItem;
};
/// Defined by AV\C Panel specification.
type AvcPanelCommand = strict enum : uint8 {
SELECT = 0x00;
UP = 0x01;
DOWN = 0x02;
LEFT = 0x03;
RIGHT = 0x04;
ROOT_MENU = 0x09;
CONTENTS_MENU = 0x0b;
FAVORITE_MENU = 0x0c;
EXIT = 0x0d;
ON_DEMAND_MENU = 0x0e;
APPS_MENU = 0x0f;
KEY_0 = 0x20;
KEY_1 = 0x21;
KEY_2 = 0x22;
KEY_3 = 0x23;
KEY_4 = 0x24;
KEY_5 = 0x25;
KEY_6 = 0x26;
KEY_7 = 0x27;
KEY_8 = 0x28;
KEY_9 = 0x29;
DOT = 0x2a;
ENTER = 0x2b;
CHANNEL_UP = 0x30;
CHANNEL_DOWN = 0x31;
CHANNEL_PREVIOUS = 0x32;
INPUT_SELECT = 0x34;
INFO = 0x35;
HELP = 0x36;
PAGE_UP = 0x37;
PAGE_DOWN = 0x38;
LOCK = 0x3a;
POWER = 0x40;
VOLUME_UP = 0x41;
VOLUME_DOWN = 0x42;
MUTE = 0x43;
PLAY = 0x44;
STOP = 0x45;
PAUSE = 0x46;
RECORD = 0x47;
REWIND = 0x48;
FAST_FORWARD = 0x49;
EJECT = 0x4a;
FORWARD = 0x4b;
BACKWARD = 0x4c;
LIST = 0x4d;
F1 = 0x71;
F2 = 0x72;
F3 = 0x73;
F4 = 0x74;
F5 = 0x75;
F6 = 0x76;
F7 = 0x77;
F8 = 0x78;
F9 = 0x79;
RED = 0x7a;
GREEN = 0x7b;
BLUE = 0x7c;
YELLOW = 0x7d;
};
/// Errors from AVRCP 1.6.2 Section 6.15.3.
type BrowseControllerError = strict enum : uint32 {
UNKNOWN_FAILURE = 1;
TIMED_OUT = 2;
REMOTE_NOT_CONNECTED = 3;
COMMAND_NOT_IMPLEMENTED = 4;
COMMAND_REJECTED = 5;
COMMAND_UNEXPECTED = 6;
PACKET_ENCODING = 7;
PROTOCOL_ERROR = 8;
CONNECTION_ERROR = 9;
// More specific errors (i.e. derived from response's StatusCode).
UID_CHANGED = 10;
INVALID_DIRECTION = 11;
INVALID_ID = 12;
INVALID_SCOPE = 13;
RANGE_OUT_OF_BOUNDS = 14;
ITEM_NOT_PLAYABLE = 15;
MEDIA_IN_USE = 16;
PLAYER_NOT_BROWSABLE = 17;
PLAYER_NOT_ADDRESSED = 18;
NO_VALID_RESULTS = 19;
NO_AVAILABLE_PLAYERS = 20;
};
/// The maximum number of MediaAttributeId that can be returned from a call to
/// GetFileSystemItems or GetNowPlayingItems.
/// This value based on list of media attributes available as per
/// AVRCP 1.6.2, 26 Appendix E: list of media attributes.
const MAX_NUM_MEDIA_ATTRIBUTES uint8 = 8;
/// Defined by AVRCP 1.6.2 Appendix E (media attributes).
/// 0x9-0xFFFFFFFF reserved for future use.
type MediaAttributeId = strict enum : uint32 {
TITLE = 0x01;
ARTIST_NAME = 0x02;
ALBUM_NAME = 0x03;
TRACK_NUMBER = 0x04;
TOTAL_NUMBER_OF_TRACKS = 0x05;
GENRE = 0x06;
PLAYING_TIME = 0x07;
DEFAULT_COVER_ART = 0x08;
};
/// The folder type associated with a folder item.
/// Defined by AVRCP 1.6.2 section 6.10.2.2.
type FolderType = strict enum : uint8 {
MIXED = 0x00;
TITLES = 0x01;
ALBUMS = 0x02;
ARTISTS = 0x03;
GENRES = 0x04;
PLAYLISTS = 0x05;
YEARS = 0x06;
// Bit 7 is reserved.
};
/// Type of a media element item.
/// Defined by AVRCP 1.6.2 section 6.10.2.3.
type MediaType = strict enum : uint8 {
AUDIO = 0x00;
VIDEO = 0x01;
// Bit 0x02-0xFF is reserved.
};
/// The maximum number of MediaPlayerItems that can be returned from a call to
/// GetFileSystemItems.
/// This value is arbitrary and is meant to limit the number of items that can be returned.
/// AVRCP 1.6.2, Section 6.10.4.2.2 defines the `Number of Items` parameter as a uint16.
const MAX_FILESYSTEM_ITEMS uint16 = 16;
/// The maximum number of MediaPlayerItems that can be returned from a call to
/// GetFileSystemItems.
/// This value is arbitrary and is meant to limit the number of items that can be returned.
/// AVRCP 1.6.2, Section 6.10.4.2.2 defines the `Number of Items` parameter as a uint16.
const MAX_NOW_PLAYING_ITEMS uint16 = 16;
/// Set `get_all` if we want all attributes of a media element item.
/// Set `attribute_list` if we want to get only the specified attributes.
/// If `get_all` is set to false, it will be treated as attribute request
/// with emtpy list of attribute IDs.
type AttributeRequestOption = strict union {
1: get_all bool;
2: attribute_list vector<MediaAttributeId>:MAX_NUM_MEDIA_ATTRIBUTES;
};
/// Relative path from the current directory.
/// As per AVRCP 1.6.2 Section 6.10.4.1.1, it either specifies a parent folder
/// for Folder Up direction or a child folder by its unique ID for Folder
/// Down direction.
type Path = flexible union {
1: parent struct {};
2: child_folder_uid uint64;
};