Home | History | Annotate | Download | only in avrcp
      1 /*
      2  * Copyright (C) 2015 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 package com.android.bluetooth.avrcp;
     18 
     19 import android.util.Log;
     20 
     21 import com.android.bluetooth.Utils;
     22 
     23 import java.nio.ByteBuffer;
     24 import java.nio.charset.Charset;
     25 import java.util.ArrayList;
     26 import java.util.Arrays;
     27 import java.util.HashMap;
     28 import java.util.List;
     29 
     30 /**
     31  * Provides Bluetooth AVRCP Controller profile, as a service in the Bluetooth application.
     32  * TODO(sanketa): Rip out this feature as this is part of 1.6.
     33  * @hide
     34  */
     35 public class RemoteMediaPlayers {
     36     private static final boolean DBG = true;
     37     private static final String TAG = "RemoteMediaPlayers";
     38 
     39     RemoteDevice mDevice;
     40     private PlayerInfo mAddressedPlayer;
     41     private PlayerInfo mBrowsedPlayer;
     42     ArrayList<PlayerInfo> mMediaPlayerList;
     43 
     44     public RemoteMediaPlayers (RemoteDevice mRemoteDevice) {
     45         mDevice = mRemoteDevice;
     46         mAddressedPlayer = null;
     47         mBrowsedPlayer = null;
     48         mMediaPlayerList = new ArrayList<PlayerInfo>();
     49     }
     50 
     51     public void cleanup() {
     52         mDevice = null;
     53         mAddressedPlayer = null;
     54         mBrowsedPlayer = null;
     55         if(mMediaPlayerList != null)
     56             mMediaPlayerList.clear();
     57     }
     58     /*
     59      * add a Player
     60      */
     61     public void addPlayer (PlayerInfo mPlayer) {
     62         if(mMediaPlayerList != null)
     63             mMediaPlayerList.add(mPlayer);
     64     }
     65     /*
     66      * add players and Set AddressedPlayer and BrowsePlayer
     67      */
     68     public void setAddressedPlayer(PlayerInfo mPlayer) {
     69         mAddressedPlayer = mPlayer;
     70     }
     71 
     72     public void setBrowsedPlayer(PlayerInfo mPlayer) {
     73         mBrowsedPlayer = mPlayer;
     74     }
     75     /*
     76      * Returns the currently addressed, browsed player
     77      */
     78     public PlayerInfo getAddressedPlayer() {
     79         return mAddressedPlayer;
     80     }
     81 
     82     /*
     83      * getPlayStatus of addressed player
     84      */
     85     public byte getPlayStatus() {
     86         if(getAddressedPlayer() != null)
     87             return getAddressedPlayer().mPlayStatus;
     88         else
     89             return AvrcpControllerConstants.PLAY_STATUS_STOPPED;
     90     }
     91 
     92     /*
     93      * getPlayStatus of addressed player
     94      */
     95     public long getPlayPosition() {
     96         if(getAddressedPlayer() != null)
     97             return getAddressedPlayer().mPlayTime;
     98         else
     99             return AvrcpControllerConstants.PLAYING_TIME_INVALID;
    100     }
    101 
    102 }
    103