Home | History | Annotate | Download | only in mediaplayer2
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_MEDIAPLAYER2_TYPES_H
     18 #define ANDROID_MEDIAPLAYER2_TYPES_H
     19 
     20 #include <media/mediaplayer_common.h>
     21 
     22 #include <media/MediaSource.h>
     23 
     24 namespace android {
     25 
     26 typedef MediaSource::ReadOptions::SeekMode MediaPlayer2SeekMode;
     27 
     28 enum media2_event_type {
     29     MEDIA2_NOP               = 0, // interface test message
     30     MEDIA2_PREPARED          = 1,
     31     MEDIA2_PLAYBACK_COMPLETE = 2,
     32     MEDIA2_BUFFERING_UPDATE  = 3,
     33     MEDIA2_SEEK_COMPLETE     = 4,
     34     MEDIA2_SET_VIDEO_SIZE    = 5,
     35     MEDIA2_STARTED           = 6,
     36     MEDIA2_PAUSED            = 7,
     37     MEDIA2_SKIPPED           = 8,
     38     MEDIA2_NOTIFY_TIME       = 98,
     39     MEDIA2_TIMED_TEXT        = 99,
     40     MEDIA2_ERROR             = 100,
     41     MEDIA2_INFO              = 200,
     42     MEDIA2_SUBTITLE_DATA     = 201,
     43     MEDIA2_META_DATA         = 202,
     44     MEDIA2_DRM_INFO          = 210,
     45 };
     46 
     47 // Generic error codes for the media player framework.  Errors are fatal, the
     48 // playback must abort.
     49 //
     50 // Errors are communicated back to the client using the
     51 // MediaPlayer2Listener::notify method defined below.
     52 // In this situation, 'notify' is invoked with the following:
     53 //   'msg' is set to MEDIA_ERROR.
     54 //   'ext1' should be a value from the enum media2_error_type.
     55 //   'ext2' contains an implementation dependant error code to provide
     56 //          more details. Should default to 0 when not used.
     57 //
     58 // The codes are distributed as follow:
     59 //   0xx: Reserved
     60 //   1xx: Android Player errors. Something went wrong inside the MediaPlayer2.
     61 //   2xx: Media errors (e.g Codec not supported). There is a problem with the
     62 //        media itself.
     63 //   3xx: Runtime errors. Some extraordinary condition arose making the playback
     64 //        impossible.
     65 //
     66 enum media2_error_type {
     67     // 0xx
     68     MEDIA2_ERROR_UNKNOWN = 1,
     69     // 1xx
     70     // MEDIA2_ERROR_SERVER_DIED = 100,
     71     // 2xx
     72     MEDIA2_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200,
     73     // 3xx
     74     MEDIA2_ERROR_FAILED_TO_SET_DATA_SOURCE = 300,
     75 };
     76 
     77 
     78 // Info and warning codes for the media player framework.  These are non fatal,
     79 // the playback is going on but there might be some user visible issues.
     80 //
     81 // Info and warning messages are communicated back to the client using the
     82 // MediaPlayer2Listener::notify method defined below.  In this situation,
     83 // 'notify' is invoked with the following:
     84 //   'msg' is set to MEDIA_INFO.
     85 //   'ext1' should be a value from the enum media2_info_type.
     86 //   'ext2' contains an implementation dependant info code to provide
     87 //          more details. Should default to 0 when not used.
     88 //
     89 // The codes are distributed as follow:
     90 //   0xx: Reserved
     91 //   7xx: Android Player info/warning (e.g player lagging behind.)
     92 //   8xx: Media info/warning (e.g media badly interleaved.)
     93 //
     94 enum media2_info_type {
     95     // 0xx
     96     MEDIA2_INFO_UNKNOWN = 1,
     97     // The player just started the playback of this data source.
     98     MEDIA2_INFO_DATA_SOURCE_START = 2,
     99     // The player just pushed the very first video frame for rendering
    100     MEDIA2_INFO_VIDEO_RENDERING_START = 3,
    101     // The player just pushed the very first audio frame for rendering
    102     MEDIA2_INFO_AUDIO_RENDERING_START = 4,
    103     // The player just completed the playback of this data source
    104     MEDIA2_INFO_DATA_SOURCE_END = 5,
    105     // The player just completed the playback of all data sources.
    106     // But this is not visible in native code. Just keep this entry for completeness.
    107     MEDIA2_INFO_DATA_SOURCE_LIST_END = 6,
    108     // The player just completed an iteration of playback loop. This event is sent only when
    109     // looping is enabled.
    110     MEDIA2_INFO_DATA_SOURCE_REPEAT = 7,
    111 
    112     //1xx
    113     // The player just prepared a data source.
    114     MEDIA2_INFO_PREPARED = 100,
    115     // The player just completed a call play().
    116     MEDIA2_INFO_COMPLETE_CALL_PLAY = 101,
    117     // The player just completed a call pause().
    118     MEDIA2_INFO_COMPLETE_CALL_PAUSE = 102,
    119     // The player just completed a call seekTo.
    120     MEDIA2_INFO_COMPLETE_CALL_SEEK = 103,
    121 
    122     // 7xx
    123     // The video is too complex for the decoder: it can't decode frames fast
    124     // enough. Possibly only the audio plays fine at this stage.
    125     MEDIA2_INFO_VIDEO_TRACK_LAGGING = 700,
    126     // MediaPlayer2 is temporarily pausing playback internally in order to
    127     // buffer more data.
    128     MEDIA2_INFO_BUFFERING_START = 701,
    129     // MediaPlayer2 is resuming playback after filling buffers.
    130     MEDIA2_INFO_BUFFERING_END = 702,
    131     // Bandwidth in recent past
    132     MEDIA2_INFO_NETWORK_BANDWIDTH = 703,
    133 
    134     // 8xx
    135     // Bad interleaving means that a media has been improperly interleaved or not
    136     // interleaved at all, e.g has all the video samples first then all the audio
    137     // ones. Video is playing but a lot of disk seek may be happening.
    138     MEDIA2_INFO_BAD_INTERLEAVING = 800,
    139     // The media is not seekable (e.g live stream).
    140     MEDIA2_INFO_NOT_SEEKABLE = 801,
    141     // New media metadata is available.
    142     MEDIA2_INFO_METADATA_UPDATE = 802,
    143     // Audio can not be played.
    144     MEDIA2_INFO_PLAY_AUDIO_ERROR = 804,
    145     // Video can not be played.
    146     MEDIA2_INFO_PLAY_VIDEO_ERROR = 805,
    147 
    148     //9xx
    149     MEDIA2_INFO_TIMED_TEXT_ERROR = 900,
    150 };
    151 
    152 // Do not change these values without updating their counterparts in MediaPlayer2.java
    153 enum mediaplayer2_states {
    154     MEDIAPLAYER2_STATE_IDLE         = 1001,
    155     MEDIAPLAYER2_STATE_PREPARED     = 1002,
    156     MEDIAPLAYER2_STATE_PAUSED       = 1003,
    157     MEDIAPLAYER2_STATE_PLAYING      = 1004,
    158     MEDIAPLAYER2_STATE_ERROR        = 1005,
    159 };
    160 
    161 enum media_player2_internal_states {
    162     MEDIA_PLAYER2_STATE_ERROR        = 0,
    163     MEDIA_PLAYER2_IDLE               = 1 << 0,
    164     MEDIA_PLAYER2_INITIALIZED        = 1 << 1,
    165     MEDIA_PLAYER2_PREPARING          = 1 << 2,
    166     MEDIA_PLAYER2_PREPARED           = 1 << 3,
    167     MEDIA_PLAYER2_STARTED            = 1 << 4,
    168     MEDIA_PLAYER2_PAUSED             = 1 << 5,
    169     MEDIA_PLAYER2_PLAYBACK_COMPLETE  = 1 << 6
    170 };
    171 
    172 // Keep KEY_PARAMETER_* in sync with MediaPlayer2.java.
    173 // The same enum space is used for both set and get, in case there are future keys that
    174 // can be both set and get.  But as of now, all parameters are either set only or get only.
    175 enum media2_parameter_keys {
    176     // Streaming/buffering parameters
    177     MEDIA2_KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100,            // set only
    178 
    179     // Return a Parcel containing a single int, which is the channel count of the
    180     // audio track, or zero for error (e.g. no audio track) or unknown.
    181     MEDIA2_KEY_PARAMETER_AUDIO_CHANNEL_COUNT = 1200,                   // get only
    182 
    183     // Playback rate expressed in permille (1000 is normal speed), saved as int32_t, with negative
    184     // values used for rewinding or reverse playback.
    185     MEDIA2_KEY_PARAMETER_PLAYBACK_RATE_PERMILLE = 1300,                // set only
    186 
    187     // Set a Parcel containing the value of a parcelled Java AudioAttribute instance
    188     MEDIA2_KEY_PARAMETER_AUDIO_ATTRIBUTES = 1400                       // set only
    189 };
    190 
    191 // Keep INVOKE_ID_* in sync with MediaPlayer2.java.
    192 enum media_player2_invoke_ids {
    193     MEDIA_PLAYER2_INVOKE_ID_GET_TRACK_INFO = 1,
    194     MEDIA_PLAYER2_INVOKE_ID_ADD_EXTERNAL_SOURCE = 2,
    195     MEDIA_PLAYER2_INVOKE_ID_ADD_EXTERNAL_SOURCE_FD = 3,
    196     MEDIA_PLAYER2_INVOKE_ID_SELECT_TRACK = 4,
    197     MEDIA_PLAYER2_INVOKE_ID_UNSELECT_TRACK = 5,
    198     MEDIA_PLAYER2_INVOKE_ID_SET_VIDEO_SCALING_MODE = 6,
    199     MEDIA_PLAYER2_INVOKE_ID_GET_SELECTED_TRACK = 7
    200 };
    201 
    202 }; // namespace android
    203 
    204 #endif // ANDROID_MEDIAPLAYER2_TYPES_H
    205