aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-02-14 17:30:41 -0800
committerJames Dong <jdong@google.com>2010-02-16 11:47:26 -0800
commitbb42f35be4ea2c150e9302f612e3b33fe2ff0e8c (patch)
tree30b03737a4e66233192a88ba020677270f18cc22
parentfe25f0b51b322705a66714fb514d216761d0422b (diff)
downloadopencore-bb42f35be4ea2c150e9302f612e3b33fe2ff0e8c.tar.gz
Switch to use xml configuration for authoring
-rw-r--r--android/author/authordriver.cpp116
-rw-r--r--android/author/authordriver.h3
2 files changed, 13 insertions, 106 deletions
diff --git a/android/author/authordriver.cpp b/android/author/authordriver.cpp
index a7b071b79..fd817666b 100644
--- a/android/author/authordriver.cpp
+++ b/android/author/authordriver.cpp
@@ -20,9 +20,9 @@
#include <unistd.h>
#include <media/thread_init.h>
+#include <media/MediaProfiles.h>
#include <surfaceflinger/ISurface.h>
#include <camera/ICamera.h>
-#include <cutils/properties.h> // for property_get
#include "authordriver.h"
#include "pv_omxcore.h"
#include <sys/prctl.h>
@@ -118,6 +118,7 @@ AuthorDriver::AuthorDriver()
mVideo_bitrate_setting(0),
ifpOutput(NULL)
{
+ mMediaProfiles = MediaProfiles::getInstance();
mSyncSem = new OsclSemaphore();
mSyncSem->Create();
@@ -1140,110 +1141,13 @@ static int setVideoBitrateHeuristically(int videoWidth)
return bitrate_setting;
}
-
-// Returns true on success
-static bool getMinAndMaxValuesOfProperty(const char*propertyKey, int64& minValue, int64& maxValue)
-{
- char value[PROPERTY_VALUE_MAX];
- int rc = property_get(propertyKey, value, 0);
- LOGV("property_get(): rc = %d, value=%s", rc, value);
- if (rc > 0) {
- char* b = strchr(value, ',');
- if (b == 0) { // A pair of values separated by ","?
- return false;
- } else {
- String8 key(value, b - value);
- if (!safe_strtoi64(key.string(), &minValue) || !safe_strtoi64(b + 1, &maxValue)) {
- return false;
- }
- }
- return true;
- }
- return false;
-}
-
-// Maps the given encoder to a system property key
-// Returns true on success
-static bool getPropertyKeyForVideoEncoder(video_encoder encoder, char* name, size_t len)
-{
- switch(encoder) {
- case VIDEO_ENCODER_MPEG_4_SP:
- strncpy(name, "ro.media.enc.vid.m4v.", len);
- return true;
- case VIDEO_ENCODER_H264:
- strncpy(name, "ro.media.enc.vid.h264.", len);
- return true;
- case VIDEO_ENCODER_H263:
- strncpy(name, "ro.media.enc.vid.h263.", len);
- return true;
- default:
- LOGE("Failed to get system property key for video encoder(%d)", encoder);
- return false;
- }
-}
-
-// Retrieves the advertised video property range from system properties for the given encoder.
-// If the encoder is not found, or the video property is not listed as a system property,
-// default hardcoded min and max values will be used.
-static void getSupportedPropertyRange(video_encoder encoder, const char* property, int64& min, int64& max)
-{
- char videoEncoderName[PROPERTY_KEY_MAX];
- bool propertyKeyExists = getPropertyKeyForVideoEncoder(encoder, videoEncoderName, PROPERTY_KEY_MAX - 1);
- if (propertyKeyExists) {
- if ((strlen(videoEncoderName) + strlen(property) + 1) < PROPERTY_KEY_MAX) { // Valid key length
- strcat(videoEncoderName, property);
- } else {
- propertyKeyExists = false;
- }
- }
- if (!propertyKeyExists || !getMinAndMaxValuesOfProperty(videoEncoderName, min, max)) {
- if (strcmp(property, "bps") == 0) {
- min = MIN_VIDEO_BITRATE_SETTING;
- max = MAX_VIDEO_BITRATE_SETTING;
- } else if (strcmp(property, "fps") == 0) {
- min = ANDROID_MIN_FRAME_RATE_FPS;
- max = ANDROID_MAX_FRAME_RATE_FPS;
- } else if (strcmp(property, "width") == 0) {
- min = ANDROID_MIN_ENCODED_FRAME_WIDTH;
- max = ANDROID_MAX_ENCODED_FRAME_WIDTH;
- } else if (strcmp(property, "height") == 0) {
- min = ANDROID_MIN_ENCODED_FRAME_HEIGHT;
- max = ANDROID_MAX_ENCODED_FRAME_HEIGHT;
- } else {
- LOGE("Unknown video property: %s", property);
- min = max = 0;
- }
- LOGW("Use default video %s range [%lld %lld]", property, min, max);
- }
-}
-
-static void getSupportedVideoBitRateRange(video_encoder encoder, int64& minBitRateBps, int64& maxBitRateBps)
-{
- getSupportedPropertyRange(encoder, "bps", minBitRateBps, maxBitRateBps);
-}
-
-static void getSupportedVideoFrameRateRange(video_encoder encoder, int64& minFrameRateFps, int64& maxFrameRateFps)
-{
- getSupportedPropertyRange(encoder, "fps", minFrameRateFps, maxFrameRateFps);
-}
-
-static void getSupportedVideoFrameWidthRange(video_encoder encoder, int64& minWidth, int64& maxWidth)
-{
- getSupportedPropertyRange(encoder, "width", minWidth, maxWidth);
-}
-
-static void getSupportedVideoFrameHeightRange(video_encoder encoder, int64& minHeight, int64& maxHeight)
-{
- getSupportedPropertyRange(encoder, "height", minHeight, maxHeight);
-}
-
// Clips the intented video encoding rate so that it is
// within the advertised support range. Logs a warning if
// the intended bit rate is out of the range.
void AuthorDriver::clipVideoBitrate()
{
- int64 minBitrate, maxBitrate;
- getSupportedVideoBitRateRange(mVideoEncoder, minBitrate, maxBitrate);
+ int minBitrate = mMediaProfiles->getVideoEncoderParamByName("enc.vid.bps.min", mVideoEncoder);
+ int maxBitrate = mMediaProfiles->getVideoEncoderParamByName("enc.vid.bps.max", mVideoEncoder);
if (mVideo_bitrate_setting < minBitrate) {
LOGW("Intended video encoding bit rate (%d bps) is too small and will be set to (%lld bps)", mVideo_bitrate_setting, minBitrate);
mVideo_bitrate_setting = minBitrate;
@@ -1255,8 +1159,8 @@ void AuthorDriver::clipVideoBitrate()
void AuthorDriver::clipVideoFrameRate()
{
- int64 minFrameRate, maxFrameRate;
- getSupportedVideoFrameRateRange(mVideoEncoder, minFrameRate, maxFrameRate);
+ int minFrameRate = mMediaProfiles->getVideoEncoderParamByName("enc.vid.fps.min", mVideoEncoder);
+ int maxFrameRate = mMediaProfiles->getVideoEncoderParamByName("enc.vid.fps.max", mVideoEncoder);
if (mVideoFrameRate < minFrameRate) {
LOGW("Intended video encoding frame rate (%d fps) is too small and will be set to (%lld fps)", mVideoFrameRate, minFrameRate);
mVideoFrameRate = minFrameRate;
@@ -1268,8 +1172,8 @@ void AuthorDriver::clipVideoFrameRate()
void AuthorDriver::clipVideoFrameWidth()
{
- int64 minFrameWidth, maxFrameWidth;
- getSupportedVideoFrameWidthRange(mVideoEncoder, minFrameWidth, maxFrameWidth);
+ int minFrameWidth = mMediaProfiles->getVideoEncoderParamByName("enc.vid.width.min", mVideoEncoder);
+ int maxFrameWidth = mMediaProfiles->getVideoEncoderParamByName("enc.vid.width.max", mVideoEncoder);
if (mVideoWidth < minFrameWidth) {
LOGW("Intended video encoding frame width (%d) is too small and will be set to (%lld)", mVideoWidth, minFrameWidth);
mVideoWidth = minFrameWidth;
@@ -1281,8 +1185,8 @@ void AuthorDriver::clipVideoFrameWidth()
void AuthorDriver::clipVideoFrameHeight()
{
- int64 minFrameHeight, maxFrameHeight;
- getSupportedVideoFrameHeightRange(mVideoEncoder, minFrameHeight, maxFrameHeight);
+ int minFrameHeight = mMediaProfiles->getVideoEncoderParamByName("enc.vid.height.min", mVideoEncoder);
+ int maxFrameHeight = mMediaProfiles->getVideoEncoderParamByName("enc.vid.height.max", mVideoEncoder);
if (mVideoHeight < minFrameHeight) {
LOGW("Intended video encoding frame height (%d) is too small and will be set to (%lld)", mVideoHeight, minFrameHeight);
mVideoHeight = minFrameHeight;
diff --git a/android/author/authordriver.h b/android/author/authordriver.h
index 7b24e42a9..601d824e6 100644
--- a/android/author/authordriver.h
+++ b/android/author/authordriver.h
@@ -236,6 +236,8 @@ private:
set_parameters_command& operator=(const set_parameters_command&);
};
+class MediaProfiles;
+
class AuthorDriver :
public OsclActiveObject,
public PVCommandStatusObserver,
@@ -381,6 +383,7 @@ private:
int32 mVideo_bitrate_setting;
FILE* ifpOutput;
+ MediaProfiles *mMediaProfiles;
};
class AuthorDriverWrapper