| // 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 { |
| UNKOWN_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; |
| |
| // 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; |
| }; |
| |
| /// 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(fxbug.dev/1322): 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. |
| }; |
| |
| /// 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; |
| }; |
| |
| /// 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; |
| }; |