summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSurajit Podder <spodder@codeaurora.org>2013-10-11 16:54:29 +0530
committerShalaj Jain <shalajj@codeaurora.org>2013-11-12 14:42:51 -0800
commit5e24aa425878cca53f46f2973831712d6016c0c1 (patch)
tree939e643f6c525ff9b1e47a1d11b72a1005756978
parente84b6d339d97d364747be110016516990a736eb0 (diff)
downloadandroid_hardware_qcom_media-5e24aa425878cca53f46f2973831712d6016c0c1.tar.gz
android_hardware_qcom_media-5e24aa425878cca53f46f2973831712d6016c0c1.tar.bz2
android_hardware_qcom_media-5e24aa425878cca53f46f2973831712d6016c0c1.zip
dashplayer: Add support for invoke
Added suport for invoke() in dashplayer and QCMediaPLayer. Change-Id: Ie5fa1ebe464d025bdaa08712e2a5b80ac15926b3
-rw-r--r--[-rwxr-xr-x]QCMediaPlayer/Android.mk9
-rw-r--r--QCMediaPlayer/NonJB/com/qualcomm/qcmedia/QCMediaPlayer.java330
-rw-r--r--dashplayer/DashPlayer.cpp2
-rw-r--r--dashplayer/DashPlayer.h3
-rw-r--r--dashplayer/DashPlayerDriver.cpp41
5 files changed, 382 insertions, 3 deletions
diff --git a/QCMediaPlayer/Android.mk b/QCMediaPlayer/Android.mk
index 973a40e7..ec52901d 100755..100644
--- a/QCMediaPlayer/Android.mk
+++ b/QCMediaPlayer/Android.mk
@@ -8,7 +8,14 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
+#LOCAL_SRC_FILES := $(call all-subdir-java-files)
+ifeq ($(PLATFORM_VERSION),4.3)
+LOCAL_SRC_FILES :=com/qualcomm/qcmedia/QCMediaPlayer.java
+else
+LOCAL_SRC_FILES :=NonJB/com/qualcomm/qcmedia/QCMediaPlayer.java
+endif
+
+LOCAL_SRC_FILES += com/qualcomm/qcmedia/QCTimedText.java
LOCAL_MODULE := qcmediaplayer
LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)
diff --git a/QCMediaPlayer/NonJB/com/qualcomm/qcmedia/QCMediaPlayer.java b/QCMediaPlayer/NonJB/com/qualcomm/qcmedia/QCMediaPlayer.java
new file mode 100644
index 00000000..66ac6ffe
--- /dev/null
+++ b/QCMediaPlayer/NonJB/com/qualcomm/qcmedia/QCMediaPlayer.java
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * File: QCMediaPlayer.java
+ * Description: Snapdragon SDK for Android support class.
+ *
+ *
+ * Not a Contribution, Apache license notifications and license are retained
+ * for attribution purposes only.
+ *
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.qualcomm.qcmedia;
+
+import android.media.MediaPlayer;
+import android.util.Log;
+import android.media.TimedText;
+import java.lang.ref.WeakReference;
+import com.qualcomm.qcmedia.QCTimedText;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Parcel;
+
+/**
+* QCMediaPlayer extends MediaPlayer from package android.media and provides
+* extended APIs and interfaces to get and set MPD attributes for DASH protocol
+* in compatible Snapdragon builds.
+*{@hide}
+*/
+
+public class QCMediaPlayer extends MediaPlayer
+{
+ private final static String TAG = "QCMediaPlayer";
+ private QCMediaEventHandler mEventHandler;
+
+ public QCMediaPlayer()
+ {
+ super();
+ Looper looper;
+ if ((looper = Looper.myLooper()) != null)
+ {
+ mEventHandler = new QCMediaEventHandler(this, looper);
+ }
+ else if ((looper = Looper.getMainLooper()) != null)
+ {
+ mEventHandler = new QCMediaEventHandler(this, looper);
+ }
+ else
+ {
+ mEventHandler = null;
+ }
+ Log.d(TAG, "QCMediaPlayer::QCMediaPlayer");
+ }
+
+ private void callOnPreparedListener()
+ {
+ Log.d(TAG, "callOnPreparedListener");
+ if (mQCOnPreparedListener != null)
+ mQCOnPreparedListener.onPrepared(this);
+ }
+
+ private void callOnMPDAttributeListener()
+ {
+ Log.d(TAG, "callOnMPDAttributeListener");
+ String mpdAttributes = QCgetStringParameter(OnMPDAttributeListener.INVOKE_ID_GET_ATTRIBUTES_TYPE_MPD);
+ if (mOnMPDAttributeListener != null)
+ mOnMPDAttributeListener.onMPDAttribute(OnMPDAttributeListener.INVOKE_ID_SET_ATTRIBUTES_TYPE_MPD, mpdAttributes, this);
+ }
+ private void callQCTimedTextListener(QCTimedText text)
+ {
+ if(mOnQCTimedTextListener != null)
+ {
+ mOnQCTimedTextListener.onQCTimedText(this, text);
+ }
+ }
+
+ /**
+ * Additional propreitary interface definition of a callback to be invoked
+ * when a Qtimed text is available for display.
+ * {@hide}
+ */
+ public interface OnQCTimedTextListener
+ {
+ /**
+ * Called to indicate an avaliable timed text
+ *
+ * @param mp the QCMediaPlayer associated with this
+ * callback
+ * @param text the Qtimed text sample which contains the text
+ * needed to be displayed and the display format.
+ * {@hide}
+ */
+ public void onQCTimedText(QCMediaPlayer mp, QCTimedText text);
+ }
+
+ /**
+ * Register a callback to be invoked when a Qtimed text is available
+ * for display.
+ *
+ * @param listener the callback that will be run
+ * {@hide}
+ */
+ public void setOnQCTimedTextListener(OnQCTimedTextListener listener)
+ {
+ mOnQCTimedTextListener = listener;
+ }
+ private OnQCTimedTextListener mOnQCTimedTextListener;
+
+ /**
+ * Register a callback to be invoked when the media source is ready
+ * for playback.
+ *
+ * @param listener the callback that will be run
+ */
+ public void setOnPreparedListener(OnPreparedListener listener)
+ {
+ mQCOnPreparedListener = listener;
+ Log.d(TAG, "QCMediaPlayer::setOnPreparedListener");
+ }
+ private OnPreparedListener mQCOnPreparedListener;
+
+ /**
+ * Interface definition for a callback to be invoked when the media
+ * source is ready for MPD attribute retrieval
+ */
+ public interface OnMPDAttributeListener
+ {
+ /**
+ * Key to identify type of MPD attributes
+ */
+ public static final int ATTRIBUTES_TYPE_MPD = 8002;
+ /**
+ * Key to be used to retrieve complete MPD.
+ */
+ public static final int ATTRIBUTES_WHOLE_MPD = 8003;
+ /**
+ * Key to Get MPD attributes
+ */
+ public static final int INVOKE_ID_GET_ATTRIBUTES_TYPE_MPD = 8004;
+
+ /**
+ * Key to Set MPD attributes
+ */
+ public static final int INVOKE_ID_SET_ATTRIBUTES_TYPE_MPD = 8005;
+ /**
+ * Called when attributes are available.
+ *
+ * @param attributekey the key identifying the type of attributes available
+ * @param value the value for the attribute
+ * @param mp the MediaPlayer to which MPD attribute is applicable
+ *
+ */
+ public void onMPDAttribute(int attributekey, String value, QCMediaPlayer mp);
+ }
+
+ /**
+ * Register a callback to be invoked when MPD attributes are avaialble
+ *
+ * @param listener the callback that will be run
+ */
+ public void setOnMPDAttributeListener(OnMPDAttributeListener listener)
+ {
+ mOnMPDAttributeListener = listener;
+ }
+
+ private OnMPDAttributeListener mOnMPDAttributeListener;
+
+ /**
+ * Process the parameter indicated by key.
+ * @param key the key idicated the parameter to be processed
+ * @param value the value for the parameter identified by key
+ * @return true if successful in processing the parameter else returns false
+ * @see OnMPDAttributeListener the interface for valid keys to be used
+ *
+ */
+ public boolean processMPDAttribute(int key, String value)
+ {
+ return QCsetStringParameter(key, value);
+ }
+ public String QCGetParameter(int key)
+ {
+ return QCgetStringParameter(key);
+ }
+ public boolean QCSetParameter(int key, int value)
+ {
+ Log.d(TAG, "QCMediaPlayer : QCSetParameter");
+ return QCsetParameter(key, value);
+ }
+ /* Do not change these values without updating their counterparts
+ * in include/media/mediaplayer.h!
+ */
+ private static final int MEDIA_NOP = 0; // interface test message
+ private static final int MEDIA_PREPARED = 1;
+ private static final int MEDIA_PLAYBACK_COMPLETE = 2;
+ private static final int MEDIA_BUFFERING_UPDATE = 3;
+ private static final int MEDIA_SEEK_COMPLETE = 4;
+ private static final int MEDIA_SET_VIDEO_SIZE = 5;
+ private static final int MEDIA_TIMED_TEXT = 99;
+ private static final int MEDIA_ERROR = 100;
+ private static final int MEDIA_INFO = 200;
+
+ private class QCMediaEventHandler extends Handler
+ {
+ private QCMediaPlayer mQCMediaPlayer;
+
+ public QCMediaEventHandler(QCMediaPlayer mp, Looper looper){
+ super(looper);
+ Log.d(TAG, "QCMediaEventHandler calling mp.mEventHandler.sendMessage()m");
+ mQCMediaPlayer = mp;
+ }
+
+ public void handleMessage(Message msg)
+ {
+ Log.d(TAG, "QCMediaPlayer::QCMediaEventHandler::handleMessage");
+ switch(msg.what)
+ {
+ case MEDIA_PREPARED:
+ Log.d(TAG, "QCMediaEventHandler::handleMessage::MEDIA_PREPARED calling callOnMPDAttributeListener");
+ callOnMPDAttributeListener();
+ Log.d(TAG, "QCMediaEventHandler::handleMessage::MEDIA_PREPARED calling callOnPreparedListener");
+ callOnPreparedListener();
+ return;
+
+ case MEDIA_TIMED_TEXT:
+ Log.d(TAG, "QCMediaEventHandler::handleMessage::MEDIA_TIMED_TEXT");
+ if(mOnQCTimedTextListener != null)
+ {
+ if (msg.obj instanceof Parcel) {
+ Parcel parcel = (Parcel)msg.obj;
+ QCTimedText text = new QCTimedText(parcel);
+ callQCTimedTextListener(text);
+ }
+ }
+ return;
+
+ default:
+ Log.d(TAG, "Unknown message type " + msg.what);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Called from native code when an interesting event happens. This method
+ * just uses the EventHandler system to post the event back to the main app thread.
+ * We use a weak reference to the original QCMediaPlayer object so that the native
+ * code is safe from the object disappearing from underneath it. (This is
+ * the cookie passed to native_setup().)
+ */
+ private static void QCMediaPlayerNativeEventHandler(Object mediaplayer_ref,
+ int what, int arg1, int arg2, Object obj)
+ {
+ Log.d(TAG, "QCMediaPlayerNativeEventHandler");
+ QCMediaPlayer mp = (QCMediaPlayer)((WeakReference)mediaplayer_ref).get();
+ if (mp == null)
+ {
+ Log.d(TAG, "QCMediaPlayerNativeEventHandler mp == null");
+ return;
+ }
+ if (mp.mEventHandler != null)
+ {
+ Message m = mp.mEventHandler.obtainMessage(what, arg1, arg2, obj);
+ Log.d(TAG, "QCMediaPlayerNativeEventHandler calling mp.mEventHandler.sendMessage()");
+ mp.mEventHandler.sendMessage(m);
+ }
+ }
+
+ private String QCgetStringParameter(int key)
+ {
+ Parcel request = newRequest();
+ Parcel reply = Parcel.obtain();
+ reply.setDataPosition(0);
+ request.writeInt(key);
+ invoke(request, reply);
+ String ret = reply.readString();
+ request.recycle();
+ reply.recycle();
+ return ret;
+ }
+
+ public boolean QCsetStringParameter(int key, String value) {
+ boolean retval = false;
+ Parcel request = newRequest();
+ Parcel reply = Parcel.obtain();
+ request.writeInt(key);
+ request.writeString(value);
+ invoke(request, reply);
+ retval = reply.readInt() > 0 ? true : false;
+ request.recycle();
+ reply.recycle();
+ return retval;
+ }
+
+ public boolean QCsetParameter(int key, int value) {
+ boolean retval = false;
+ Parcel request = newRequest();
+ Parcel reply = Parcel.obtain();
+ request.writeInt(key);
+ request.writeInt(value);
+ invoke(request, reply);
+ retval = reply.readInt() > 0 ? true : false;
+ request.recycle();
+ reply.recycle();
+ return retval;
+ }
+
+ public Parcel QCgetParcelParameter(int key) {
+ boolean retval = false;
+ Parcel request = newRequest();
+ Parcel reply = Parcel.obtain();
+ request.writeInt(key);
+ invoke(request, reply);
+ request.recycle();
+ return reply;
+ }
+}
diff --git a/dashplayer/DashPlayer.cpp b/dashplayer/DashPlayer.cpp
index 64b04299..618e6b04 100644
--- a/dashplayer/DashPlayer.cpp
+++ b/dashplayer/DashPlayer.cpp
@@ -1689,7 +1689,7 @@ status_t DashPlayer::getParameter(int key, Parcel *reply)
status_t DashPlayer::setParameter(int key, const Parcel &request)
{
status_t err = OK;
- if (key == 8002) {
+ if (key == 8002 || key == 8006){
size_t len = 0;
const char16_t* str = request.readString16Inplace(&len);
diff --git a/dashplayer/DashPlayer.h b/dashplayer/DashPlayer.h
index ee6f94f0..2d10f2df 100644
--- a/dashplayer/DashPlayer.h
+++ b/dashplayer/DashPlayer.h
@@ -23,10 +23,13 @@
#include <media/stagefright/NativeWindowWrapper.h>
#include "DashPlayerStats.h"
#include <media/stagefright/foundation/ABuffer.h>
+#include <cutils/properties.h>
+// used for Get Adaptionset property (NonJB)and for both Get and set for JB
#define KEY_DASH_ADAPTION_PROPERTIES 8002
#define KEY_DASH_MPD_QUERY 8003
#define KEY_DASH_QOE_EVENT 8004
#define KEY_DASH_QOE_PERIODIC_EVENT 8008
+#define KEY_DASH_SET_ADAPTION_PROPERTIES 8006 // used for Set Adaptionset property (NonJB)
namespace android {
diff --git a/dashplayer/DashPlayerDriver.cpp b/dashplayer/DashPlayerDriver.cpp
index 02a9d148..4441a97e 100644
--- a/dashplayer/DashPlayerDriver.cpp
+++ b/dashplayer/DashPlayerDriver.cpp
@@ -280,7 +280,46 @@ player_type DashPlayerDriver::playerType() {
}
status_t DashPlayerDriver::invoke(const Parcel &request, Parcel *reply) {
- return INVALID_OPERATION;
+ status_t ret = INVALID_OPERATION;
+#ifndef ANDROID_JB_MR2
+ if (reply == NULL) {
+ ALOGE("reply is a NULL pointer");
+ return BAD_VALUE;
+ }
+
+ int32_t methodId;
+ ret = request.readInt32(&methodId);
+ if (ret != OK) {
+ ALOGE("Failed to retrieve the requested method to invoke");
+ return ret;
+ }
+
+ switch (methodId) {
+ case KEY_DASH_ADAPTION_PROPERTIES:
+ {
+ ALOGE("calling KEY_DASH_ADAPTION_PROPERTIES");
+ ret = getParameter(methodId,reply);
+ break;
+ }
+ case KEY_DASH_SET_ADAPTION_PROPERTIES:
+ {
+ ALOGE("calling KEY_DASH_SET_ADAPTION_PROPERTIES");
+ int32_t val = 0;
+ ret = setParameter(methodId,request);
+ val = (ret == OK)? 1:0;
+ reply->setDataPosition(0);
+ reply->writeInt32(val);
+ break;
+ }
+ default:
+ {
+ ALOGE("Invoke:unHandled requested method%d",methodId);
+ ret = OK;
+ break;
+ }
+ }
+#endif
+ return ret;
}
void DashPlayerDriver::setAudioSink(const sp<AudioSink> &audioSink) {