MEDIA_PLAYER_PLAYBACK_COMPLETE = 1 << 7
};
-enum media_set_parameter_keys {
- KEY_PARAMETER_TIMED_TEXT_TRACK_INDEX = 1000,
- KEY_PARAMETER_TIMED_TEXT_ADD_OUT_OF_BAND_SOURCE = 1001,
+// Keep KEY_PARAMETER_* in sync with MediaPlayer.java.
+// The same enum space is used for both set and get, in case there are future keys that
+// can be both set and get. But as of now, all parameters are either set only or get only.
+enum media_parameter_keys {
+ KEY_PARAMETER_TIMED_TEXT_TRACK_INDEX = 1000, // set only
+ KEY_PARAMETER_TIMED_TEXT_ADD_OUT_OF_BAND_SOURCE = 1001, // set only
// Streaming/buffering parameters
- KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100,
+ KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100, // set only
+
+ // Return a Parcel containing a single int, which is the channel count of the
+ // audio track, or zero for error (e.g. no audio track) or unknown.
+ KEY_PARAMETER_AUDIO_CHANNEL_COUNT = 1200, // get only
+
};
+
// ----------------------------------------------------------------------------
// ref-counted object for callbacks
class MediaPlayerListener: virtual public RefBase
*/
private static final int KEY_PARAMETER_TIMED_TEXT_ADD_OUT_OF_BAND_SOURCE = 1001;
+ // There are currently no defined keys usable from Java with get*Parameter.
+ // But if any keys are defined, the order must be kept in sync with include/media/mediaplayer.h.
+ // private static final int KEY_PARAMETER_... = ...;
+
/**
* Sets the parameter indicated by key.
* @param key key indicates the parameter to be set.
public boolean setParameter(int key, String value) {
Parcel p = Parcel.obtain();
p.writeString(value);
- return setParameter(key, p);
+ boolean ret = setParameter(key, p);
+ p.recycle();
+ return ret;
}
/**
public boolean setParameter(int key, int value) {
Parcel p = Parcel.obtain();
p.writeInt(value);
- return setParameter(key, p);
+ boolean ret = setParameter(key, p);
+ p.recycle();
+ return ret;
}
/**
/**
* Gets the value of the parameter indicated by key.
+ * The caller is responsible for recycling the returned parcel.
* @param key key indicates the parameter to get.
* @return value of the parameter.
* {@hide}
public String getStringParameter(int key) {
Parcel p = Parcel.obtain();
getParameter(key, p);
- return p.readString();
+ String ret = p.readString();
+ p.recycle();
+ return ret;
}
/**
public int getIntParameter(int key) {
Parcel p = Parcel.obtain();
getParameter(key, p);
- return p.readInt();
+ int ret = p.readInt();
+ p.recycle();
+ return ret;
}
/**
}
status_t AwesomePlayer::getParameter(int key, Parcel *reply) {
- return OK;
+ switch (key) {
+ case KEY_PARAMETER_AUDIO_CHANNEL_COUNT:
+ {
+ int32_t channelCount;
+ if (mAudioTrack == 0 ||
+ !mAudioTrack->getFormat()->findInt32(kKeyChannelCount, &channelCount)) {
+ channelCount = 0;
+ }
+ reply->writeInt32(channelCount);
+ }
+ return OK;
+ default:
+ {
+ return ERROR_UNSUPPORTED;
+ }
+ }
}
bool AwesomePlayer::isStreamingHTTP() const {