Merge change I11438c37 into eclair-mr2
* changes:
Implement the full screen WebView plugin.
diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java
index a52b86a..b74564a 100644
--- a/core/java/android/provider/Calendar.java
+++ b/core/java/android/provider/Calendar.java
@@ -16,6 +16,7 @@
package android.provider;
+import android.accounts.Account;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
@@ -30,6 +31,7 @@
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.net.Uri;
+import android.os.RemoteException;
import android.pim.ICalendar;
import android.pim.RecurrenceSet;
import android.text.TextUtils;
@@ -37,8 +39,6 @@
import android.text.format.Time;
import android.util.Config;
import android.util.Log;
-import android.accounts.Account;
-import android.os.RemoteException;
/**
* The Calendar provider contains all calendar events.
@@ -1223,7 +1223,7 @@
/**
* The default sort order for this table
*/
- public static final String DEFAULT_SORT_ORDER = "alarmTime ASC,begin ASC,title ASC";
+ public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC";
}
public static final class CalendarAlerts implements BaseColumns,
@@ -1240,6 +1240,8 @@
public static final Uri CONTENT_URI_BY_INSTANCE =
Uri.parse("content://calendar/calendar_alerts/by_instance");
+ private static final boolean DEBUG = true;
+
public static final Uri insert(ContentResolver cr, long eventId,
long begin, long end, long alarmTime, int minutes) {
ContentValues values = new ContentValues();
@@ -1257,9 +1259,9 @@
}
public static final Cursor query(ContentResolver cr, String[] projection,
- String selection, String[] selectionArgs) {
+ String selection, String[] selectionArgs, String sortOrder) {
return cr.query(CONTENT_URI, projection, selection, selectionArgs,
- DEFAULT_SORT_ORDER);
+ sortOrder);
}
/**
@@ -1276,7 +1278,7 @@
// TODO: construct an explicit SQL query so that we can add
// "LIMIT 1" to the end and get just one result.
String[] projection = new String[] { ALARM_TIME };
- Cursor cursor = query(cr, projection, selection, null);
+ Cursor cursor = query(cr, projection, selection, null, ALARM_TIME + " ASC");
long alarmTime = -1;
try {
if (cursor != null && cursor.moveToFirst()) {
@@ -1305,46 +1307,61 @@
// Get all the alerts that have been scheduled but have not fired
// and should have fired by now and are not too old.
long now = System.currentTimeMillis();
- long ancient = now - 24 * DateUtils.HOUR_IN_MILLIS;
+ long ancient = now - DateUtils.DAY_IN_MILLIS;
String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.SCHEDULED
+ " AND " + CalendarAlerts.ALARM_TIME + "<" + now
+ " AND " + CalendarAlerts.ALARM_TIME + ">" + ancient
+ " AND " + CalendarAlerts.END + ">=" + now;
String[] projection = new String[] {
- _ID,
- BEGIN,
- END,
ALARM_TIME,
};
- Cursor cursor = CalendarAlerts.query(cr, projection, selection, null);
+
+ // TODO: construct an explicit SQL query so that we can add
+ // "GROUPBY" instead of doing a sort and de-dup
+ Cursor cursor = CalendarAlerts.query(cr, projection, selection, null, "alarmTime ASC");
if (cursor == null) {
return;
}
- if (Log.isLoggable(TAG, Log.DEBUG)) {
+
+ if (DEBUG) {
Log.d(TAG, "missed alarms found: " + cursor.getCount());
}
try {
+ long alarmTime = -1;
+
while (cursor.moveToNext()) {
- long id = cursor.getLong(0);
- long begin = cursor.getLong(1);
- long end = cursor.getLong(2);
- long alarmTime = cursor.getLong(3);
- Uri uri = ContentUris.withAppendedId(CONTENT_URI, id);
- Intent intent = new Intent(android.provider.Calendar.EVENT_REMINDER_ACTION);
- intent.setData(uri);
- intent.putExtra(android.provider.Calendar.EVENT_BEGIN_TIME, begin);
- intent.putExtra(android.provider.Calendar.EVENT_END_TIME, end);
- PendingIntent sender = PendingIntent.getBroadcast(context,
- 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
- Log.w(TAG, "rescheduling missed alarm, id: " + id + " begin: " + begin
- + " end: " + end + " alarmTime: " + alarmTime);
- manager.set(AlarmManager.RTC_WAKEUP, alarmTime, sender);
+ long newAlarmTime = cursor.getLong(0);
+ if (alarmTime != newAlarmTime) {
+ if (DEBUG) {
+ Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime);
+ }
+ scheduleAlarm(context, manager, newAlarmTime);
+ alarmTime = newAlarmTime;
+ }
}
} finally {
cursor.close();
}
+ }
+ public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) {
+ if (DEBUG) {
+ Time time = new Time();
+ time.set(alarmTime);
+ String schedTime = time.format(" %a, %b %d, %Y %I:%M%P");
+ Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime);
+ }
+
+ if (manager == null) {
+ manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+ }
+
+ Intent intent = new Intent(android.provider.Calendar.EVENT_REMINDER_ACTION);
+ intent.putExtra(android.provider.Calendar.CalendarAlerts.ALARM_TIME, alarmTime);
+ PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ manager.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}
/**
@@ -1367,7 +1384,7 @@
// TODO: construct an explicit SQL query so that we can add
// "LIMIT 1" to the end and get just one result.
String[] projection = new String[] { CalendarAlerts.ALARM_TIME };
- Cursor cursor = query(cr, projection, selection, null);
+ Cursor cursor = query(cr, projection, selection, null, null);
boolean found = false;
try {
if (cursor != null && cursor.getCount() > 0) {
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index b5c9900..e98d8ee 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -376,6 +376,124 @@
}
/**
+ * Constants for various styles of combining given name, family name etc into
+ * a full name. For example, the western tradition follows the pattern
+ * 'given name' 'middle name' 'family name' with the alternative pattern being
+ * 'family name', 'given name' 'middle name'. The CJK tradition is
+ * 'family name' 'middle name' 'given name', with Japanese favoring a space between
+ * the names and Chinese omitting the space.
+ * @hide
+ */
+ public interface FullNameStyle {
+ public static final int UNDEFINED = 0;
+ public static final int WESTERN = 1;
+
+ /**
+ * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
+ * which specific language it belongs to: Chinese, Japanese or Korean.
+ */
+ public static final int CJK = 2;
+
+ public static final int CHINESE = 3;
+ public static final int JAPANESE = 4;
+ public static final int KOREAN = 5;
+ }
+
+ /**
+ * Constants for various styles of capturing the pronunciation of a person's name.
+ * @hide
+ */
+ public interface PhoneticNameStyle {
+ public static final int UNDEFINED = 0;
+
+ /**
+ * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
+ * shown in UIs, but used for searches and sorting.
+ */
+ public static final int PINYIN = 3;
+
+ /**
+ * Hiragana and Katakana are two common styles of writing out the pronunciation
+ * of a Japanese names.
+ */
+ public static final int JAPANESE = 4;
+
+ /**
+ * Hangul is the Korean phonetic alphabet.
+ */
+ public static final int KOREAN = 5;
+ }
+
+ /**
+ * Types of data used to produce the display name for a contact. Listed in the order
+ * of increasing priority.
+ *
+ * @hide
+ */
+ public interface DisplayNameSources {
+ public static final int UNDEFINED = 0;
+ public static final int EMAIL = 10;
+ public static final int PHONE = 20;
+ public static final int ORGANIZATION = 30;
+ public static final int NICKNAME = 35;
+ public static final int STRUCTURED_NAME = 40;
+ }
+
+ /**
+ * @see Contacts
+ * @see RawContacts
+ * @hide
+ */
+ protected interface ContactNameColumns {
+
+ /**
+ * The kind of data that is used as the display name for the contact, see
+ * DisplayNameSources.
+ */
+ public static final String DISPLAY_NAME_SOURCE = "display_name_source";
+
+ /**
+ * The default text shown as the contact's display name. It is based on
+ * available data, see {@link #DISPLAY_NAME_SOURCE}.
+ */
+ public static final String DISPLAY_NAME = "display_name";
+
+ /**
+ * Alternative representation of the display name. If display name is
+ * based on the structured name and the structured name follows
+ * the Western full name style, then this field contains the "family name first"
+ * version of the full name. Otherwise, it is the same as {@link #DISPLAY_NAME}.
+ */
+ public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
+
+ /**
+ * The type of alphabet used to capture the phonetic name. See
+ * PhoneticNameStyle.
+ */
+ public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
+
+ /**
+ * Pronunciation of the full name. See PhoneticNameStyle.
+ */
+ public static final String PHONETIC_NAME = "phonetic_name";
+
+ /**
+ * Sort key that takes into account locale-based traditions for sorting
+ * names in address books. More specifically, for Chinese names
+ * the sort key is the name's Pinyin spelling; for Japanese names
+ * it is the Hiragana version of the phonetic name.
+ */
+ public static final String SORT_KEY = "sort_key";
+
+ /**
+ * Sort key based on the alternative representation of the full name,
+ * specifically the one using the 'family name first' format for
+ * Western names.
+ */
+ public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
+ }
+
+ /**
* Constants for the contacts table, which contains a record per aggregate
* of raw contacts representing the same person.
* <h3>Operations</h3>
@@ -1234,7 +1352,7 @@
* </table>
*/
public static final class RawContacts implements BaseColumns, RawContactsColumns,
- ContactOptionsColumns, SyncColumns {
+ ContactOptionsColumns, ContactNameColumns, SyncColumns {
/**
* This utility class cannot be instantiated
*/
@@ -2889,6 +3007,21 @@
* <P>Type: TEXT</P>
*/
public static final String PHONETIC_FAMILY_NAME = DATA9;
+
+ /**
+ * The style used for combining given/middle/family name into a full name.
+ * See {@link ContactsContract.FullNameStyle}.
+ *
+ * @hide
+ */
+ public static final String FULL_NAME_STYLE = DATA10;
+
+ /**
+ * The alphabet used for capturing the phonetic name.
+ * See {@link ContactsContract.PhoneticNameStyle}.
+ * @hide
+ */
+ public static final String PHONETIC_NAME_STYLE = DATA11;
}
/**
diff --git a/core/res/res/values-en-rUS/donottranslate-names.xml b/core/res/res/values-en-rUS/donottranslate-names.xml
index ae38ddf..f8ec765 100644
--- a/core/res/res/values-en-rUS/donottranslate-names.xml
+++ b/core/res/res/values-en-rUS/donottranslate-names.xml
@@ -156,8 +156,8 @@
MRS, MS, PASTOR, PROF, REP, REVEREND, REV, SEN, ST
</string>
<string name="common_name_suffixes">
- B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR, M.A., M.D, MA,
- MD, MS, PH.D., PHD, SR, V, VI, VII, VIII, X
+ B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR., M.A., M.D., MA,
+ MD, MS, PH.D., PHD, SR., V, VI, VII, VIII, X
</string>
<string name="common_last_name_prefixes">
D\', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON
diff --git a/include/media/stagefright/OMXPluginBase.h b/include/media/stagefright/OMXPluginBase.h
index 61cc50a..2fd8e12 100644
--- a/include/media/stagefright/OMXPluginBase.h
+++ b/include/media/stagefright/OMXPluginBase.h
@@ -22,6 +22,9 @@
#include <OMX_Component.h>
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
namespace android {
struct OMXComponentBase;
@@ -44,6 +47,10 @@
size_t size,
OMX_U32 index) = 0;
+ virtual OMX_ERRORTYPE getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles) = 0;
+
private:
OMXPluginBase(const OMXPluginBase &);
OMXPluginBase &operator=(const OMXPluginBase &);
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5a89b73..99c39f8 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -55,15 +55,68 @@
const char *codec;
};
+#if BUILD_WITH_FULL_STAGEFRIGHT
+#define OPTIONAL(x,y) { x, y },
+
+#define FACTORY_CREATE(name) \
+static sp<MediaSource> Make##name(const sp<MediaSource> &source) { \
+ return new name(source); \
+}
+
+#define FACTORY_REF(name) { #name, Make##name },
+
+FACTORY_CREATE(MP3Decoder)
+FACTORY_CREATE(AMRNBDecoder)
+FACTORY_CREATE(AMRWBDecoder)
+FACTORY_CREATE(AACDecoder)
+FACTORY_CREATE(AVCDecoder)
+FACTORY_CREATE(AMRNBEncoder)
+
+static sp<MediaSource> InstantiateSoftwareCodec(
+ const char *name, const sp<MediaSource> &source) {
+ struct FactoryInfo {
+ const char *name;
+ sp<MediaSource> (*CreateFunc)(const sp<MediaSource> &);
+ };
+
+ static const FactoryInfo kFactoryInfo[] = {
+ FACTORY_REF(MP3Decoder)
+ FACTORY_REF(AMRNBDecoder)
+ FACTORY_REF(AMRWBDecoder)
+ FACTORY_REF(AACDecoder)
+ FACTORY_REF(AVCDecoder)
+ FACTORY_REF(AMRNBEncoder)
+ };
+ for (size_t i = 0;
+ i < sizeof(kFactoryInfo) / sizeof(kFactoryInfo[0]); ++i) {
+ if (!strcmp(name, kFactoryInfo[i].name)) {
+ return (*kFactoryInfo[i].CreateFunc)(source);
+ }
+ }
+
+ return NULL;
+}
+
+#undef FACTORY_REF
+#undef FACTORY_CREATE
+
+#else
+#define OPTIONAL(x,y)
+#endif
+
static const CodecInfo kDecoderInfo[] = {
{ MEDIA_MIMETYPE_IMAGE_JPEG, "OMX.TI.JPEG.decode" },
{ MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.TI.MP3.decode" },
+ OPTIONAL(MEDIA_MIMETYPE_AUDIO_MPEG, "MP3Decoder")
{ MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.PV.mp3dec" },
{ MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.TI.AMR.decode" },
+ OPTIONAL(MEDIA_MIMETYPE_AUDIO_AMR_NB, "AMRNBDecoder")
{ MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.PV.amrdec" },
{ MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.TI.WBAMR.decode" },
+ OPTIONAL(MEDIA_MIMETYPE_AUDIO_AMR_WB, "AMRWBDecoder")
{ MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.PV.amrdec" },
{ MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.decode" },
+ OPTIONAL(MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder")
{ MEDIA_MIMETYPE_AUDIO_AAC, "OMX.PV.aacdec" },
{ MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.video.decoder.mpeg4" },
{ MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.Decoder" },
@@ -73,11 +126,13 @@
{ MEDIA_MIMETYPE_VIDEO_H263, "OMX.PV.h263dec" },
{ MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.video.decoder.avc" },
{ MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.Decoder" },
+ OPTIONAL(MEDIA_MIMETYPE_VIDEO_AVC, "AVCDecoder")
{ MEDIA_MIMETYPE_VIDEO_AVC, "OMX.PV.avcdec" },
};
static const CodecInfo kEncoderInfo[] = {
{ MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.TI.AMR.encode" },
+ OPTIONAL(MEDIA_MIMETYPE_AUDIO_AMR_NB, "AMRNBEncoder")
{ MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.PV.amrencnb" },
{ MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.TI.WBAMR.encode" },
{ MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.encode" },
@@ -92,6 +147,8 @@
{ MEDIA_MIMETYPE_VIDEO_AVC, "OMX.PV.avcenc" },
};
+#undef OPTIONAL
+
#define CODEC_LOGI(x, ...) LOGI("[%s] "x, mComponentName, ##__VA_ARGS__)
#define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
@@ -188,8 +245,22 @@
return false;
}
+// A sort order in which non-OMX components are first,
+// followed by software codecs, i.e. OMX.PV.*, followed
+// by all the others.
static int CompareSoftwareCodecsFirst(
const String8 *elem1, const String8 *elem2) {
+ bool isNotOMX1 = strncmp(elem1->string(), "OMX.", 4);
+ bool isNotOMX2 = strncmp(elem2->string(), "OMX.", 4);
+
+ if (isNotOMX1) {
+ if (isNotOMX2) { return 0; }
+ return -1;
+ }
+ if (isNotOMX2) {
+ return 1;
+ }
+
bool isSoftwareCodec1 = IsSoftwareCodec(elem1->string());
bool isSoftwareCodec2 = IsSoftwareCodec(elem2->string());
@@ -293,27 +364,6 @@
bool success = meta->findCString(kKeyMIMEType, &mime);
CHECK(success);
-#if BUILD_WITH_FULL_STAGEFRIGHT
- if (!createEncoder) {
- if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
- return new AACDecoder(source);
- } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
- return new AMRNBDecoder(source);
- } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) {
- return new AMRWBDecoder(source);
- } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
- return new MP3Decoder(source);
- } else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
- && (flags & kPreferSoftwareCodecs)) {
- return new AVCDecoder(source);
- }
- } else {
- if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
- return new AMRNBEncoder(source);
- }
- }
-#endif
-
Vector<String8> matchingCodecs;
findMatchingCodecs(
mime, createEncoder, matchComponentName, flags, &matchingCodecs);
@@ -330,6 +380,17 @@
for (size_t i = 0; i < matchingCodecs.size(); ++i) {
componentName = matchingCodecs[i].string();
+#if BUILD_WITH_FULL_STAGEFRIGHT
+ sp<MediaSource> softwareCodec =
+ InstantiateSoftwareCodec(componentName, source);
+
+ if (softwareCodec != NULL) {
+ LOGV("Successfully allocated software codec '%s'", componentName);
+
+ return softwareCodec;
+ }
+#endif
+
LOGV("Attempting to allocate OMX node '%s'", componentName);
status_t err = omx->allocateNode(componentName, observer, &node);
diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk
index 965852b..4f88d99 100644
--- a/media/libstagefright/omx/Android.mk
+++ b/media/libstagefright/omx/Android.mk
@@ -12,8 +12,7 @@
OMX.cpp \
OMXComponentBase.cpp \
OMXNodeInstance.cpp \
- OMXMaster.cpp \
- OMXSoftwareCodecsPlugin.cpp \
+ OMXMaster.cpp
ifneq ($(BUILD_WITHOUT_PV),true)
LOCAL_SRC_FILES += \
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 61be8f7..94dbb6d 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -208,6 +208,29 @@
instance->onObserverDied(mMaster);
}
+#if 0
+static void dumpRoles(OMXMaster *master, const char *name) {
+ Vector<String8> roles;
+ OMX_ERRORTYPE err = master->getRolesOfComponent(name, &roles);
+
+ if (err != OMX_ErrorNone) {
+ LOGE("Could not get roles for component '%s'.", name);
+ return;
+ }
+
+ if (roles.isEmpty()) {
+ LOGE("Component '%s' has NO roles!", name);
+ return;
+ }
+
+ LOGI("Component '%s' has the following roles:", name);
+
+ for (size_t i = 0; i < roles.size(); ++i) {
+ LOGI("%d) %s", i + 1, roles[i].string());
+ }
+}
+#endif
+
status_t OMX::listNodes(List<String8> *list) {
list->clear();
@@ -217,6 +240,8 @@
componentName, sizeof(componentName), index) == OMX_ErrorNone) {
list->push_back(String8(componentName));
+ // dumpRoles(mMaster, componentName);
+
++index;
}
diff --git a/media/libstagefright/omx/OMXMaster.cpp b/media/libstagefright/omx/OMXMaster.cpp
index 12302f3..9a45bea 100644
--- a/media/libstagefright/omx/OMXMaster.cpp
+++ b/media/libstagefright/omx/OMXMaster.cpp
@@ -24,14 +24,10 @@
#include "OMXPVCodecsPlugin.h"
#endif
-#include "OMXSoftwareCodecsPlugin.h"
-
namespace android {
OMXMaster::OMXMaster()
: mVendorLibHandle(NULL) {
- addPlugin(new OMXSoftwareCodecsPlugin);
-
addVendorPlugin();
#ifndef NO_OPENCORE
@@ -168,4 +164,21 @@
return OMX_ErrorNone;
}
+OMX_ERRORTYPE OMXMaster::getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles) {
+ Mutex::Autolock autoLock(mLock);
+
+ roles->clear();
+
+ ssize_t index = mPluginByComponentName.indexOfKey(String8(name));
+
+ if (index < 0) {
+ return OMX_ErrorInvalidComponentName;
+ }
+
+ OMXPluginBase *plugin = mPluginByComponentName.valueAt(index);
+ return plugin->getRolesOfComponent(name, roles);
+}
+
} // namespace android
diff --git a/media/libstagefright/omx/OMXMaster.h b/media/libstagefright/omx/OMXMaster.h
index e944c4a..7ba8d18 100644
--- a/media/libstagefright/omx/OMXMaster.h
+++ b/media/libstagefright/omx/OMXMaster.h
@@ -45,6 +45,10 @@
size_t size,
OMX_U32 index);
+ virtual OMX_ERRORTYPE getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles);
+
private:
Mutex mLock;
List<OMXPluginBase *> mPlugins;
diff --git a/media/libstagefright/omx/OMXPVCodecsPlugin.cpp b/media/libstagefright/omx/OMXPVCodecsPlugin.cpp
index 2bd8094..d1f5be3 100644
--- a/media/libstagefright/omx/OMXPVCodecsPlugin.cpp
+++ b/media/libstagefright/omx/OMXPVCodecsPlugin.cpp
@@ -54,4 +54,48 @@
return OMX_MasterComponentNameEnum(name, size, index);
}
+OMX_ERRORTYPE OMXPVCodecsPlugin::getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles) {
+ roles->clear();
+
+ OMX_U32 numRoles;
+ OMX_ERRORTYPE err =
+ OMX_MasterGetRolesOfComponent(
+ const_cast<char *>(name),
+ &numRoles,
+ NULL);
+
+ if (err != OMX_ErrorNone) {
+ return err;
+ }
+
+ if (numRoles > 0) {
+ OMX_U8 **array = new OMX_U8 *[numRoles];
+ for (OMX_U32 i = 0; i < numRoles; ++i) {
+ array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE];
+ }
+
+ OMX_U32 numRoles2;
+ err = OMX_MasterGetRolesOfComponent(
+ const_cast<char *>(name), &numRoles2, array);
+
+ CHECK_EQ(err, OMX_ErrorNone);
+ CHECK_EQ(numRoles, numRoles2);
+
+ for (OMX_U32 i = 0; i < numRoles; ++i) {
+ String8 s((const char *)array[i]);
+ roles->push(s);
+
+ delete[] array[i];
+ array[i] = NULL;
+ }
+
+ delete[] array;
+ array = NULL;
+ }
+
+ return OMX_ErrorNone;
+}
+
} // namespace android
diff --git a/media/libstagefright/omx/OMXPVCodecsPlugin.h b/media/libstagefright/omx/OMXPVCodecsPlugin.h
index f32eede..c133232 100644
--- a/media/libstagefright/omx/OMXPVCodecsPlugin.h
+++ b/media/libstagefright/omx/OMXPVCodecsPlugin.h
@@ -40,6 +40,10 @@
size_t size,
OMX_U32 index);
+ virtual OMX_ERRORTYPE getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles);
+
private:
OMXPVCodecsPlugin(const OMXPVCodecsPlugin &);
OMXPVCodecsPlugin &operator=(const OMXPVCodecsPlugin &);
diff --git a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp b/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp
deleted file mode 100644
index 51c7029..0000000
--- a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "OMXSoftwareCodecsPlugin.h"
-
-#include <string.h>
-
-namespace android {
-
-typedef OMX_ERRORTYPE (*ComponentFactory)(
- const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData,
- OMX_COMPONENTTYPE **component);
-
-static const struct ComponentInfo {
- const char *mName;
- ComponentFactory mFactory;
-} kComponentInfos[] = {
-};
-
-OMXSoftwareCodecsPlugin::OMXSoftwareCodecsPlugin() {
-}
-
-OMX_ERRORTYPE OMXSoftwareCodecsPlugin::makeComponentInstance(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component) {
- *component = NULL;
-
- const size_t kNumComponentInfos =
- sizeof(kComponentInfos) / sizeof(kComponentInfos[0]);
-
- for (size_t i = 0; i < kNumComponentInfos; ++i) {
- if (!strcmp(kComponentInfos[i].mName, name)) {
- return (*kComponentInfos[i].mFactory)(
- callbacks, appData, component);
- }
- }
-
- return OMX_ErrorInvalidComponentName;
-}
-
-OMX_ERRORTYPE OMXSoftwareCodecsPlugin::destroyComponentInstance(
- OMX_COMPONENTTYPE *component) {
- return (*component->ComponentDeInit)(component);
-}
-
-OMX_ERRORTYPE OMXSoftwareCodecsPlugin::enumerateComponents(
- OMX_STRING name,
- size_t size,
- OMX_U32 index) {
- const size_t kNumComponentInfos =
- sizeof(kComponentInfos) / sizeof(kComponentInfos[0]);
-
- if (index >= kNumComponentInfos) {
- return OMX_ErrorNoMore;
- }
-
- strncpy(name, kComponentInfos[index].mName, size - 1);
- name[size - 1] = '\0';
-
- return OMX_ErrorNone;
-}
-
-} // namespace android
diff --git a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h b/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h
deleted file mode 100644
index 5beeb26..0000000
--- a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef OMX_SOFTWARE_CODECS_PLUGIN_H_
-
-#define OMX_SOFTWARE_CODECS_PLUGIN_H_
-
-#include <media/stagefright/OMXPluginBase.h>
-
-namespace android {
-
-struct OMXSoftwareCodecsPlugin : public OMXPluginBase {
- OMXSoftwareCodecsPlugin();
-
- virtual OMX_ERRORTYPE makeComponentInstance(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component);
-
- virtual OMX_ERRORTYPE destroyComponentInstance(
- OMX_COMPONENTTYPE *component);
-
- virtual OMX_ERRORTYPE enumerateComponents(
- OMX_STRING name,
- size_t size,
- OMX_U32 index);
-
-private:
- OMXSoftwareCodecsPlugin(const OMXSoftwareCodecsPlugin &);
- OMXSoftwareCodecsPlugin &operator=(const OMXSoftwareCodecsPlugin &);
-};
-
-} // namespace android
-
-#endif // OMX_SOFTWARE_CODECS_PLUGIN_H_
-