Merge "media.bufferpool@1.0 implementation"
diff --git a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2AudioOutput.h b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2AudioOutput.h
index ad4937a..5d5b8e4 100644
--- a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2AudioOutput.h
+++ b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2AudioOutput.h
@@ -87,7 +87,6 @@
static bool isOnEmulator();
static int getMinBufferCount();
- void setNextOutput(const sp<MediaPlayer2AudioOutput>& nextOutput);
virtual bool needsTrailingPadding() {
return true;
// TODO: return correct value.
diff --git a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h
index 96aea7f..02bf891 100644
--- a/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h
+++ b/media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h
@@ -200,9 +200,9 @@
return OK;
}
virtual status_t seekTo(
- int msec, MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC) = 0;
- virtual status_t getCurrentPosition(int *msec) = 0;
- virtual status_t getDuration(int *msec) = 0;
+ int64_t msec, MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC) = 0;
+ virtual status_t getCurrentPosition(int64_t *msec) = 0;
+ virtual status_t getDuration(int64_t *msec) = 0;
virtual status_t reset() = 0;
virtual status_t notifyAt(int64_t /* mediaTimeUs */) {
return INVALID_OPERATION;
diff --git a/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h b/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
index 11e4f42..3433cb1 100644
--- a/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
+++ b/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
@@ -77,11 +77,11 @@
status_t getVideoWidth(int *w);
status_t getVideoHeight(int *h);
status_t seekTo(
- int msec,
+ int64_t msec,
MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC);
status_t notifyAt(int64_t mediaTimeUs);
- status_t getCurrentPosition(int *msec);
- status_t getDuration(int *msec);
+ status_t getCurrentPosition(int64_t *msec);
+ status_t getDuration(int64_t *msec);
status_t reset();
status_t setAudioStreamType(audio_stream_type_t type);
status_t getAudioStreamType(audio_stream_type_t *type);
@@ -99,7 +99,6 @@
status_t attachAuxEffect(int effectId);
status_t setParameter(int key, const Parcel& request);
status_t getParameter(int key, Parcel* reply);
- status_t setNextMediaPlayer(const sp<MediaPlayer2>& player);
// Modular DRM
status_t prepareDrm(const uint8_t uuid[16], const Vector<uint8_t>& drmSessionId);
@@ -131,9 +130,9 @@
status_t setAudioAttributes_l(const Parcel &request);
void clear_l();
- status_t seekTo_l(int msec, MediaPlayer2SeekMode mode);
+ status_t seekTo_l(int64_t msec, MediaPlayer2SeekMode mode);
status_t prepareAsync_l();
- status_t getDuration_l(int *msec);
+ status_t getDuration_l(int64_t *msec);
status_t reset_l();
status_t checkStateForKeySet_l(int key);
@@ -147,9 +146,9 @@
Mutex mNotifyLock;
sp<MediaPlayer2Listener> mListener;
media_player2_states mCurrentState;
- int mCurrentPosition;
+ int64_t mCurrentPosition;
MediaPlayer2SeekMode mCurrentSeekMode;
- int mSeekPosition;
+ int64_t mSeekPosition;
MediaPlayer2SeekMode mSeekMode;
audio_stream_type_t mStreamType;
Parcel* mAudioAttributesParcel;
diff --git a/media/libmediaplayer2/mediaplayer2.cpp b/media/libmediaplayer2/mediaplayer2.cpp
index b401ee8..c465caa 100644
--- a/media/libmediaplayer2/mediaplayer2.cpp
+++ b/media/libmediaplayer2/mediaplayer2.cpp
@@ -936,27 +936,27 @@
return NO_ERROR;
}
-status_t MediaPlayer2::getCurrentPosition(int *msec) {
+status_t MediaPlayer2::getCurrentPosition(int64_t *msec) {
ALOGV("getCurrentPosition");
Mutex::Autolock _l(mLock);
if (mPlayer == 0) {
return INVALID_OPERATION;
}
if (mCurrentPosition >= 0) {
- ALOGV("Using cached seek position: %d", mCurrentPosition);
+ ALOGV("Using cached seek position: %lld", (long long)mCurrentPosition);
*msec = mCurrentPosition;
return NO_ERROR;
}
status_t ret = mPlayer->getCurrentPosition(msec);
if (ret == NO_ERROR) {
- ALOGV("getCurrentPosition = %d", *msec);
+ ALOGV("getCurrentPosition = %lld", (long long)*msec);
} else {
ALOGE("getCurrentPosition returned %d", ret);
}
return ret;
}
-status_t MediaPlayer2::getDuration(int *msec) {
+status_t MediaPlayer2::getDuration(int64_t *msec) {
Mutex::Autolock _l(mLock);
ALOGV("getDuration_l");
bool isValidState = (mCurrentState & (MEDIA_PLAYER2_PREPARED | MEDIA_PLAYER2_STARTED |
@@ -966,11 +966,11 @@
mPlayer.get(), mCurrentState);
return INVALID_OPERATION;
}
- int durationMs;
+ int64_t durationMs;
status_t ret = mPlayer->getDuration(&durationMs);
if (ret == NO_ERROR) {
- ALOGV("getDuration = %d", durationMs);
+ ALOGV("getDuration = %lld", (long long)durationMs);
} else {
ALOGE("getDuration returned %d", ret);
// Do not enter error state just because no duration was available.
@@ -983,50 +983,47 @@
return OK;
}
-status_t MediaPlayer2::seekTo_l(int msec, MediaPlayer2SeekMode mode) {
- ALOGV("seekTo (%d, %d)", msec, mode);
- if ((mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER2_STARTED | MEDIA_PLAYER2_PREPARED |
- MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_PLAYBACK_COMPLETE) ) ) {
- if (msec < 0) {
- ALOGW("Attempt to seek to invalid position: %d", msec);
- msec = 0;
- }
-
- int durationMs;
- status_t err = mPlayer->getDuration(&durationMs);
-
- if (err != OK) {
- ALOGW("Stream has no duration and is therefore not seekable.");
- return err;
- }
-
- if (msec > durationMs) {
- ALOGW("Attempt to seek to past end of file: request = %d, "
- "durationMs = %d",
- msec,
- durationMs);
-
- msec = durationMs;
- }
-
- // cache duration
- mCurrentPosition = msec;
- mCurrentSeekMode = mode;
- if (mSeekPosition < 0) {
- mSeekPosition = msec;
- mSeekMode = mode;
- return mPlayer->seekTo(msec, mode);
- } else {
- ALOGV("Seek in progress - queue up seekTo[%d, %d]", msec, mode);
- return NO_ERROR;
- }
+status_t MediaPlayer2::seekTo_l(int64_t msec, MediaPlayer2SeekMode mode) {
+ ALOGV("seekTo (%lld, %d)", (long long)msec, mode);
+ if ((mPlayer == 0) || !(mCurrentState & (MEDIA_PLAYER2_STARTED | MEDIA_PLAYER2_PREPARED |
+ MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_PLAYBACK_COMPLETE))) {
+ ALOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u",
+ mPlayer.get(), mCurrentState);
+ return INVALID_OPERATION;
}
- ALOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u", mPlayer.get(),
- mCurrentState);
- return INVALID_OPERATION;
+ if (msec < 0) {
+ ALOGW("Attempt to seek to invalid position: %lld", (long long)msec);
+ msec = 0;
+ }
+
+ int64_t durationMs;
+ status_t err = mPlayer->getDuration(&durationMs);
+
+ if (err != OK) {
+ ALOGW("Stream has no duration and is therefore not seekable.");
+ return err;
+ }
+
+ if (msec > durationMs) {
+ ALOGW("Attempt to seek to past end of file: request = %lld, durationMs = %lld",
+ (long long)msec, (long long)durationMs);
+
+ msec = durationMs;
+ }
+
+ // cache duration
+ mCurrentPosition = msec;
+ mCurrentSeekMode = mode;
+ if (mSeekPosition < 0) {
+ mSeekPosition = msec;
+ mSeekMode = mode;
+ return mPlayer->seekTo(msec, mode);
+ }
+ ALOGV("Seek in progress - queue up seekTo[%lld, %d]", (long long)msec, mode);
+ return NO_ERROR;
}
-status_t MediaPlayer2::seekTo(int msec, MediaPlayer2SeekMode mode) {
+status_t MediaPlayer2::seekTo(int64_t msec, MediaPlayer2SeekMode mode) {
mLockThreadId = getThreadId();
Mutex::Autolock _l(mLock);
status_t result = seekTo_l(msec, mode);
@@ -1228,6 +1225,16 @@
status_t MediaPlayer2::getParameter(int key, Parcel *reply) {
ALOGV("MediaPlayer2::getParameter(%d)", key);
Mutex::Autolock _l(mLock);
+ if (key == MEDIA2_KEY_PARAMETER_AUDIO_ATTRIBUTES) {
+ if (reply == NULL) {
+ return BAD_VALUE;
+ }
+ if (mAudioAttributesParcel != NULL) {
+ reply->appendFrom(mAudioAttributesParcel, 0, mAudioAttributesParcel->dataSize());
+ }
+ return OK;
+ }
+
if (mPlayer == NULL) {
ALOGV("getParameter: no active player");
return INVALID_OPERATION;
@@ -1339,7 +1346,8 @@
case MEDIA2_SEEK_COMPLETE:
ALOGV("Received seek complete");
if (mSeekPosition != mCurrentPosition || (mSeekMode != mCurrentSeekMode)) {
- ALOGV("Executing queued seekTo(%d, %d)", mCurrentPosition, mCurrentSeekMode);
+ ALOGV("Executing queued seekTo(%lld, %d)",
+ (long long)mCurrentPosition, mCurrentSeekMode);
mSeekPosition = -1;
mSeekMode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC;
seekTo_l(mCurrentPosition, mCurrentSeekMode);
@@ -1387,10 +1395,6 @@
}
}
-status_t MediaPlayer2::setNextMediaPlayer(const sp<MediaPlayer2>& /* next */) {
- return INVALID_OPERATION;
-}
-
// Modular DRM
status_t MediaPlayer2::prepareDrm(const uint8_t uuid[16], const Vector<uint8_t>& drmSessionId) {
// TODO change to ALOGV
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
index 38d107d..5971a8b 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2.cpp
@@ -2765,10 +2765,10 @@
break;
}
- int posMs;
+ int64_t posMs;
int64_t timeUs, posUs;
driver->getCurrentPosition(&posMs);
- posUs = (int64_t) posMs * 1000ll;
+ posUs = posMs * 1000ll;
CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
if (posUs < timeUs) {
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
index ca08e79..03d17a5 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp
@@ -354,7 +354,7 @@
// down for audio offload mode. If that happens, the NuPlayerRenderer will no longer know the
// current position. So similar to seekTo, update |mPositionUs| to the pause position by calling
// getCurrentPosition here.
- int unused;
+ int64_t unused;
getCurrentPosition(&unused);
Mutex::Autolock autoLock(mLock);
@@ -384,7 +384,7 @@
status_t err = mPlayer->setPlaybackSettings(rate);
if (err == OK) {
// try to update position
- int unused;
+ int64_t unused;
getCurrentPosition(&unused);
Mutex::Autolock autoLock(mLock);
if (rate.mSpeed == 0.f && mState == STATE_RUNNING) {
@@ -411,8 +411,8 @@
return mPlayer->getSyncSettings(sync, videoFps);
}
-status_t NuPlayer2Driver::seekTo(int msec, MediaPlayer2SeekMode mode) {
- ALOGD("seekTo(%p) (%d ms, %d) at state %d", this, msec, mode, mState);
+status_t NuPlayer2Driver::seekTo(int64_t msec, MediaPlayer2SeekMode mode) {
+ ALOGD("seekTo(%p) (%lld ms, %d) at state %d", this, (long long)msec, mode, mState);
Mutex::Autolock autoLock(mLock);
int64_t seekTimeUs = msec * 1000ll;
@@ -437,13 +437,13 @@
return OK;
}
-status_t NuPlayer2Driver::getCurrentPosition(int *msec) {
+status_t NuPlayer2Driver::getCurrentPosition(int64_t *msec) {
int64_t tempUs = 0;
{
Mutex::Autolock autoLock(mLock);
if (mSeekInProgress || (mState == STATE_PAUSED && !mAtEOS)) {
tempUs = (mPositionUs <= 0) ? 0 : mPositionUs;
- *msec = (int)divRound(tempUs, (int64_t)(1000));
+ *msec = divRound(tempUs, (int64_t)(1000));
return OK;
}
}
@@ -459,11 +459,11 @@
} else {
mPositionUs = tempUs;
}
- *msec = (int)divRound(tempUs, (int64_t)(1000));
+ *msec = divRound(tempUs, (int64_t)(1000));
return OK;
}
-status_t NuPlayer2Driver::getDuration(int *msec) {
+status_t NuPlayer2Driver::getDuration(int64_t *msec) {
Mutex::Autolock autoLock(mLock);
if (mDurationUs < 0) {
@@ -529,7 +529,7 @@
// always provide duration and playing time, even if they have 0/unknown values.
// getDuration() uses mLock for mutex -- careful where we use it.
- int duration_ms = -1;
+ int64_t duration_ms = -1;
getDuration(&duration_ms);
mAnalyticsItem->setInt64(kPlayerDuration, duration_ms);
@@ -661,7 +661,7 @@
case MEDIA_PLAYER2_INVOKE_ID_SELECT_TRACK:
{
int trackIndex = request.readInt32();
- int msec = 0;
+ int64_t msec = 0;
// getCurrentPosition should always return OK
getCurrentPosition(&msec);
return mPlayer->selectTrack(trackIndex, true /* select */, msec * 1000ll);
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.h b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.h
index 502a2cc..4da2566 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.h
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.h
@@ -50,9 +50,9 @@
virtual status_t setSyncSettings(const AVSyncSettings &sync, float videoFpsHint);
virtual status_t getSyncSettings(AVSyncSettings *sync, float *videoFps);
virtual status_t seekTo(
- int msec, MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC);
- virtual status_t getCurrentPosition(int *msec);
- virtual status_t getDuration(int *msec);
+ int64_t msec, MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC);
+ virtual status_t getCurrentPosition(int64_t *msec);
+ virtual status_t getDuration(int64_t *msec);
virtual status_t reset();
virtual status_t notifyAt(int64_t mediaTimeUs) override;
virtual status_t setLooping(int loop);
diff --git a/media/libstagefright/C2OMXNode.cpp b/media/libstagefright/C2OMXNode.cpp
index e6f81af..04faa28 100644
--- a/media/libstagefright/C2OMXNode.cpp
+++ b/media/libstagefright/C2OMXNode.cpp
@@ -234,7 +234,7 @@
std::shared_ptr<C2Buffer> c2Buffer(
// TODO: fence
new Buffer2D(block->share(
- C2Rect(block->width(), block->height()), ::android::C2Fence())),
+ C2Rect(block->width(), block->height()), ::C2Fence())),
[handle, buffer, source = getSource()](C2Buffer *ptr) {
delete ptr;
native_handle_delete(handle);
diff --git a/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp b/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
index 08b5d65..693eeea 100644
--- a/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
+++ b/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
@@ -123,7 +123,7 @@
std::shared_ptr<C2Buffer> c2Buffer(
// TODO: fence
new Buffer2D(block->share(
- C2Rect(block->width(), block->height()), ::android::C2Fence())),
+ C2Rect(block->width(), block->height()), ::C2Fence())),
[handle, bufferId, src = mSource](C2Buffer *ptr) {
delete ptr;
native_handle_delete(handle);
diff --git a/media/libstagefright/codec2/SimpleC2Component.cpp b/media/libstagefright/codec2/SimpleC2Component.cpp
index aaefd31..c345783 100644
--- a/media/libstagefright/codec2/SimpleC2Component.cpp
+++ b/media/libstagefright/codec2/SimpleC2Component.cpp
@@ -373,7 +373,7 @@
std::shared_ptr<C2Buffer> SimpleC2Component::createLinearBuffer(
const std::shared_ptr<C2LinearBlock> &block, size_t offset, size_t size) {
- return C2Buffer::CreateLinearBuffer(block->share(offset, size, ::android::C2Fence()));
+ return C2Buffer::CreateLinearBuffer(block->share(offset, size, ::C2Fence()));
}
std::shared_ptr<C2Buffer> SimpleC2Component::createGraphicBuffer(
@@ -383,7 +383,7 @@
std::shared_ptr<C2Buffer> SimpleC2Component::createGraphicBuffer(
const std::shared_ptr<C2GraphicBlock> &block, const C2Rect &crop) {
- return C2Buffer::CreateGraphicBuffer(block->share(crop, ::android::C2Fence()));
+ return C2Buffer::CreateGraphicBuffer(block->share(crop, ::C2Fence()));
}
} // namespace android
diff --git a/media/libstagefright/codec2/include/C2.h b/media/libstagefright/codec2/include/C2.h
index 508f9ae..e90fe42 100644
--- a/media/libstagefright/codec2/include/C2.h
+++ b/media/libstagefright/codec2/include/C2.h
@@ -141,9 +141,13 @@
/// \defgroup utils Utilities
/// @{
-#define C2_DO_NOT_COPY(type, args...) \
- type args& operator=(const type args&) = delete; \
- type(const type args&) = delete; \
+#define C2_DO_NOT_COPY(type) \
+ type& operator=(const type &) = delete; \
+ type(const type &) = delete; \
+
+#define C2_DEFAULT_MOVE(type) \
+ type& operator=(type &&) = default; \
+ type(type &&) = default; \
#define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer")))
#define C2_CONST __attribute__((const))
@@ -274,7 +278,7 @@
/**
* Convert to a smaller counter type. This is always safe.
*/
- template<typename U, typename E=typename std::enable_if<sizeof(U) < sizeof(T)>::type>
+ template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type>
inline operator c2_cntr_t<U>() {
return c2_cntr_t<U>(mValue);
}
@@ -295,7 +299,7 @@
return c2_cntr_t<T>(mValue op compat::get(value)); \
} \
\
- template<typename U, typename E=typename std::enable_if<sizeof(U) < sizeof(T)>::type> \
+ template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type> \
attrib inline constexpr c2_cntr_t<U> operator op(const c2_cntr_t<U> &value) const { \
return c2_cntr_t<U>(U(mValue) op value.peeku()); \
}
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index e49f82b..4bdd20f 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -746,19 +746,19 @@
/**
* Maps a portion of an allocation starting from |offset| with |size| into local process memory.
* Stores the starting address into |addr|, or NULL if the operation was unsuccessful.
- * |fenceFd| is a file descriptor referring to an acquire sync fence object. If it is already
- * safe to access the buffer contents, then -1.
+ * |fence| will contain an acquire sync fence object. If it is already
+ * safe to access the buffer contents, then it will contain an empty (already fired) fence.
*
- * \param offset starting position of the portion to be mapped (this does not have to
+ * \param offset starting position of the portion to be mapped (this does not have to
* be page aligned)
- * \param size size of the portion to be mapped (this does not have to be page
+ * \param size size of the portion to be mapped (this does not have to be page
* aligned)
- * \param usage the desired usage. \todo this must be kSoftwareRead and/or
+ * \param usage the desired usage. \todo this must be kSoftwareRead and/or
* kSoftwareWrite.
- * \param fenceFd a pointer to a file descriptor if an async mapping is requested. If
- * not-null, and acquire fence FD will be stored here on success, or -1
- * on failure. If null, the mapping will be synchronous.
- * \param addr a pointer to where the starting address of the mapped portion will be
+ * \param fence a pointer to a fence object if an async mapping is requested. If
+ * not-null, and acquire fence will be stored here on success, or empty
+ * fence on failure. If null, the mapping will be synchronous.
+ * \param addr a pointer to where the starting address of the mapped portion will be
* stored. On failure, nullptr will be stored here.
*
* \todo Only one portion can be mapped at the same time - this is true for gralloc, but there
@@ -775,19 +775,19 @@
* \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
*/
virtual c2_status_t map(
- size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd /* nullable */,
+ size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence /* nullable */,
void **addr /* nonnull */) = 0;
/**
* Unmaps a portion of an allocation at |addr| with |size|. These must be parameters previously
- * passed to |map|; otherwise, this operation is a no-op.
+ * passed to and returned by |map|; otherwise, this operation is a no-op.
*
- * \param addr starting address of the mapped region
- * \param size size of the mapped region
- * \param fenceFd a pointer to a file descriptor if an async unmapping is requested. If
- * not-null, a release fence FD will be stored here on success, or -1
+ * \param addr starting address of the mapped region
+ * \param size size of the mapped region
+ * \param fence a pointer to a fence object if an async unmapping is requested. If
+ * not-null, a release fence will be stored here on success, or empty fence
* on failure. This fence signals when the original allocation contains
- * any changes that happened to the mapped region. If null, the unmapping
+ * all changes that happened to the mapped region. If null, the unmapping
* will be synchronous.
*
* \retval C2_OK the operation was successful
@@ -798,7 +798,7 @@
* \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
* \retval C2_REFUSED no permission to unmap the portion (unexpected - system)
*/
- virtual c2_status_t unmap(void *addr, size_t size, int *fenceFd /* nullable */) = 0;
+ virtual c2_status_t unmap(void *addr, size_t size, C2Fence *fence /* nullable */) = 0;
/**
* Returns the allocator ID for this allocation. This is useful to put the handle into context.
@@ -1339,6 +1339,9 @@
uint32_t width;
uint32_t height;
+ constexpr inline C2Rect()
+ : C2Rect(0, 0, 0, 0) { }
+
constexpr inline C2Rect(uint32_t width_, uint32_t height_)
: C2Rect(width_, height_, 0, 0) { }
@@ -1507,6 +1510,15 @@
BIG_END, // BIG_ENDIAN is a reserved macro
} endianness; ///< endianness of the samples
+ /**
+ * The following two fields define the relation between multiple planes. If multiple planes are
+ * interleaved, they share a root plane (whichever plane's start address is the lowest), and
+ * |offset| is the offset of this plane inside the root plane (in bytes). |rootIx| is the index
+ * of the root plane. If a plane is independent, rootIx is its index and offset is 0.
+ */
+ uint32_t rootIx; ///< index of the root plane
+ uint32_t offset; ///< offset of this plane inside of the root plane
+
inline constexpr ssize_t minOffset(uint32_t width, uint32_t height) const {
ssize_t offs = 0;
if (width > 0 && colInc < 0) {
@@ -1541,7 +1553,8 @@
};
type_t type; // image type
- uint32_t numPlanes; // number of planes
+ uint32_t numPlanes; // number of component planes
+ uint32_t rootPlanes; // number of layout planes (root planes)
enum plane_index_t : uint32_t {
PLANE_Y = 0,
@@ -1693,22 +1706,19 @@
* Maps a rectangular section (as defined by |rect|) of a 2D allocation into local process
* memory for flexible access. On success, it fills out |layout| with the plane specifications
* and fills the |addr| array with pointers to the first byte of the top-left pixel of each
- * plane used. Otherwise, it leaves |layout| and |addr| untouched. |fenceFd| is a file
- * descriptor referring to an acquire sync fence object. If it is already safe to access the
- * buffer contents, then -1.
+ * plane used. Otherwise, it leaves |layout| and |addr| untouched. |fence| will contain
+ * an acquire sync fence object. If it is already safe to access the
+ * buffer contents, then it will be an empty (already fired) fence.
*
- * Safe regions for the pointer addresses returned can be gotten via C2LayoutInfo.minOffse()/
+ * Safe regions for the pointer addresses returned can be gotten via C2LayoutInfo.minOffset()/
* maxOffset().
*
- * \note Only one portion of the graphic allocation can be mapped at the same time. (This is
- * from gralloc1 limitation.)
- *
* \param rect section to be mapped (this does not have to be aligned)
* \param usage the desired usage. \todo this must be kSoftwareRead and/or
* kSoftwareWrite.
- * \param fenceFd a pointer to a file descriptor if an async mapping is requested. If
- * not-null, and acquire fence FD will be stored here on success, or -1
- * on failure. If null, the mapping will be synchronous.
+ * \param fence a pointer to a fence object if an async mapping is requested. If
+ * not-null, and acquire fence will be stored here on success, or empty
+ * fence on failure. If null, the mapping will be synchronous.
* \param layout a pointer to where the mapped planes' descriptors will be
* stored. On failure, nullptr will be stored here.
* \param addr pointer to an array with at least C2PlanarLayout::MAX_NUM_PLANES
@@ -1716,7 +1726,8 @@
*
* \retval C2_OK the operation was successful
* \retval C2_REFUSED no permission to map the section
- * \retval C2_DUPLICATE there is already a mapped region (caller error)
+ * \retval C2_DUPLICATE there is already a mapped region and this allocation cannot support
+ * multi-mapping (caller error)
* \retval C2_TIMED_OUT the operation timed out
* \retval C2_NO_MEMORY not enough memory to complete the operation
* \retval C2_BAD_VALUE the parameters (rect) are invalid or outside the allocation, or the
@@ -1725,25 +1736,30 @@
*/
virtual c2_status_t map(
- C2Rect rect, C2MemoryUsage usage, int *fenceFd,
+ C2Rect rect, C2MemoryUsage usage, C2Fence *fence,
C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) = 0;
/**
- * Unmaps the last mapped rectangular section.
+ * Unmaps a section of an allocation at |addr| with |rect|. These must be parameters previously
+ * passed to and returned by |map|; otherwise, this operation is a no-op.
*
- * \param fenceFd a pointer to a file descriptor if an async unmapping is requested. If
- * not-null, a release fence FD will be stored here on success, or -1
+ * \param addr pointer to an array with at least C2PlanarLayout::MAX_NUM_PLANES
+ * elements containing the starting addresses of the mapped layers
+ * \param rect boundaries of the mapped section
+ * \param fence a pointer to a fence object if an async unmapping is requested. If
+ * not-null, a release fence will be stored here on success, or empty fence
* on failure. This fence signals when the original allocation contains
- * any changes that happened to the mapped section. If null, the unmapping
+ * all changes that happened to the mapped section. If null, the unmapping
* will be synchronous.
*
* \retval C2_OK the operation was successful
* \retval C2_TIMED_OUT the operation timed out
- * \retval C2_NOT_FOUND there is no mapped region (caller error)
+ * \retval C2_NOT_FOUND there is no such mapped region (caller error)
* \retval C2_CORRUPTED some unknown error prevented the operation from completing (unexpected)
* \retval C2_REFUSED no permission to unmap the section (unexpected - system)
*/
- virtual c2_status_t unmap(C2Fence *fenceFd /* nullable */) = 0;
+ virtual c2_status_t unmap(
+ uint8_t **addr /* nonnull */, C2Rect rect, C2Fence *fence /* nullable */) = 0;
/**
* Returns the allocator ID for this allocation. This is useful to put the handle into context.
@@ -2262,10 +2278,4 @@
/// @}
-// expose some objects in android namespace
-namespace android {
- /// \deprecated
- typedef ::C2Fence C2Fence;
-}
-
#endif // C2BUFFER_H_
diff --git a/media/libstagefright/codec2/include/C2Component.h b/media/libstagefright/codec2/include/C2Component.h
index 64bd1cb..61fcfc0 100644
--- a/media/libstagefright/codec2/include/C2Component.h
+++ b/media/libstagefright/codec2/include/C2Component.h
@@ -38,23 +38,29 @@
CURRENT, ///< query currently possible values given dependent settings
};
- const C2ParamField field;
- const type_t type;
+private:
+ C2ParamField _mField;
+ type_t _mType;
+public:
c2_status_t status;
C2FieldSupportedValues values;
C2FieldSupportedValuesQuery(const C2ParamField &field_, type_t type_)
- : field(field_), type(type_), status(C2_NO_INIT) { }
+ : _mField(field_), _mType(type_), status(C2_NO_INIT) { }
- static C2FieldSupportedValuesQuery&&
+ static C2FieldSupportedValuesQuery
Current(const C2ParamField &field_) {
- return std::move(C2FieldSupportedValuesQuery(field_, CURRENT));
+ return C2FieldSupportedValuesQuery(field_, CURRENT);
}
- static C2FieldSupportedValuesQuery&&
+ static C2FieldSupportedValuesQuery
Possible(const C2ParamField &field_) {
- return std::move(C2FieldSupportedValuesQuery(field_, POSSIBLE));
+ return C2FieldSupportedValuesQuery(field_, POSSIBLE);
}
+
+ inline C2ParamField field() const { return _mField; };
+
+ inline type_t type() const { return _mType; }
};
/**
@@ -943,11 +949,4 @@
/// @}
-namespace android {
- /// \deprecated
- typedef ::C2Component C2Component;
- /// \deprecated
- typedef ::C2ComponentInterface C2ComponentInterface;
-}
-
#endif // C2COMPONENT_H_
diff --git a/media/libstagefright/codec2/include/C2Param.h b/media/libstagefright/codec2/include/C2Param.h
index 181697d..e0a743c 100644
--- a/media/libstagefright/codec2/include/C2Param.h
+++ b/media/libstagefright/codec2/include/C2Param.h
@@ -299,7 +299,7 @@
DEFINE_FIELD_BASED_COMPARISON_OPERATORS(Index, mIndex)
private:
- friend struct C2Param; // for setStream, makeStreamId, isValid
+ friend struct C2Param; // for setStream, MakeStreamId, isValid
friend struct _C2ParamInspector; // for testing
/**
@@ -320,7 +320,7 @@
/// returns the streamId bitfield for a given |stream|. If stream is invalid,
/// returns an invalid bitfield.
- inline static uint32_t makeStreamId(unsigned stream) {
+ inline static uint32_t MakeStreamId(unsigned stream) {
// saturate stream ID (max value is invalid)
if (stream > MAX_STREAM_ID) {
stream = MAX_STREAM_ID;
@@ -334,7 +334,7 @@
*/
inline bool setStream(unsigned stream) {
if (forStream()) {
- mIndex = (mIndex & ~STREAM_ID_MASK) | makeStreamId(stream);
+ mIndex = (mIndex & ~STREAM_ID_MASK) | MakeStreamId(stream);
return this->stream() < MAX_STREAM_ID;
}
return false;
@@ -455,7 +455,7 @@
// allow undefined or different direction (e.g. as constructed from C2PortParam() vs.
// C2PortParam::input), but still require equivalent type (stream, port or global); otherwise,
// return null.
- inline static const C2Param* ifSuitable(
+ inline static const C2Param* IfSuitable(
const C2Param* o, size_t size, Type type, size_t flexSize = 0, bool checkDir = true) {
if (o == nullptr || o->_mSize < size || (flexSize && ((o->_mSize - size) % flexSize))) {
return nullptr;
@@ -480,7 +480,7 @@
/// base constructor with stream set
inline C2Param(uint32_t paramSize, Index paramIndex, unsigned stream)
: _mSize(paramSize),
- _mIndex(paramIndex | Index::makeStreamId(stream)) {
+ _mIndex(paramIndex | Index::MakeStreamId(stream)) {
if (paramSize > sizeof(C2Param)) {
memset(this + 1, 0, paramSize - sizeof(C2Param));
}
@@ -664,7 +664,7 @@
template<typename S, typename T>
inline C2ParamField(S* param, T* offset)
: _mIndex(param->index()),
- _mFieldId(offset) {}
+ _mFieldId((T*)((uintptr_t)offset - (uintptr_t)param)) {}
/**
* Create a field identifier using a configuration parameter (variable),
@@ -698,7 +698,7 @@
*/
template<typename S>
inline C2ParamField(S* param)
- : _mIndex(param->index()), _mFieldId(0u, param->size()) {}
+ : _mIndex(param->index()), _mFieldId(0u, param->size()) { }
/**
* Equality operator.
@@ -735,27 +735,27 @@
public:
/// A union of supported primitive types.
union Primitive {
- int32_t i32; ///< int32_t value
- uint32_t u32; ///< uint32_t value
- c2_cntr32_t c32; ///< c2_cntr32_t value
- int64_t i64; ///< int64_t value
+ // first member is always zero initialized so it must be the largest
uint64_t u64; ///< uint64_t value
+ int64_t i64; ///< int64_t value
c2_cntr64_t c64; ///< c2_cntr64_t value
+ uint32_t u32; ///< uint32_t value
+ int32_t i32; ///< int32_t value
+ c2_cntr32_t c32; ///< c2_cntr32_t value
float fp; ///< float value
// constructors - implicit
- Primitive(int32_t value) : i32(value) { }
- Primitive(uint32_t value) : u32(value) { }
- Primitive(c2_cntr32_t value) : c32(value) { }
- Primitive(int64_t value) : i64(value) { }
Primitive(uint64_t value) : u64(value) { }
+ Primitive(int64_t value) : i64(value) { }
Primitive(c2_cntr64_t value) : c64(value) { }
+ Primitive(uint32_t value) : u32(value) { }
+ Primitive(int32_t value) : i32(value) { }
+ Primitive(c2_cntr32_t value) : c32(value) { }
Primitive(float value) : fp(value) { }
Primitive() : u64(0) { }
- private:
- friend class C2Value;
+ /** gets value out of the union */
template<typename T> const T &ref() const;
};
@@ -842,9 +842,9 @@
STRUCT_FLAG = 0x20000, ///< structs. Marked with this flag in addition to their coreIndex.
};
- typedef std::pair<C2String, C2Value::Primitive> named_value_type;
- typedef std::vector<const named_value_type> named_values_type;
- //typedef std::pair<std::vector<C2String>, std::vector<C2Value::Primitive>> named_values_type;
+ typedef std::pair<C2String, C2Value::Primitive> NamedValueType;
+ typedef std::vector<const NamedValueType> NamedValuesType;
+ //typedef std::pair<std::vector<C2String>, std::vector<C2Value::Primitive>> NamedValuesType;
/**
* Template specialization that returns the named values for a type.
@@ -854,15 +854,15 @@
* \return a vector of name-value pairs.
*/
template<typename B>
- static named_values_type namedValuesFor(const B &);
+ static NamedValuesType namedValuesFor(const B &);
- inline C2FieldDescriptor(uint32_t type, uint32_t length, C2StringLiteral name, size_t offset, size_t size)
- : _mType((type_t)type), _mLength(length), _mName(name), _mFieldId(offset, size) { }
+ inline C2FieldDescriptor(uint32_t type, uint32_t extent, C2StringLiteral name, size_t offset, size_t size)
+ : _mType((type_t)type), _mExtent(extent), _mName(name), _mFieldId(offset, size) { }
template<typename T, class B=typename std::remove_extent<T>::type>
inline C2FieldDescriptor(const T* offset, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mNamedValues(namedValuesFor(*(B*)0)),
_mFieldId(offset) {}
@@ -870,8 +870,8 @@
/*
template<typename T, typename B=typename std::remove_extent<T>::type>
inline C2FieldDescriptor<T, B, false>(T* offset, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mFieldId(offset) {}
*/
@@ -879,8 +879,8 @@
/// \deprecated
template<typename T, typename S, class B=typename std::remove_extent<T>::type>
constexpr inline C2FieldDescriptor(S*, T S::* field, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mFieldId(&(((S*)0)->*field)) {}
@@ -888,11 +888,11 @@
inline type_t type() const { return _mType; }
/// returns the length of the field in case it is an array. Returns 0 for
/// T[] arrays, returns 1 for T[1] arrays as well as if the field is not an array.
- inline size_t length() const { return _mLength; }
+ inline size_t extent() const { return _mExtent; }
/// returns the name of the field
inline C2StringLiteral name() const { return _mName; }
- const named_values_type &namedValues() const { return _mNamedValues; }
+ const NamedValuesType &namedValues() const { return _mNamedValues; }
#if defined(FRIEND_TEST)
friend void PrintTo(const C2FieldDescriptor &, ::std::ostream*);
@@ -901,49 +901,51 @@
#endif
private:
- const type_t _mType;
- const uint32_t _mLength; // the last member can be arbitrary length if it is T[] array,
+ type_t _mType;
+ uint32_t _mExtent; // the last member can be arbitrary length if it is T[] array,
// extending to the end of the parameter (this is marked with
// 0). T[0]-s are not fields.
- const C2StringLiteral _mName;
- const named_values_type _mNamedValues;
+ C2StringLiteral _mName;
+ NamedValuesType _mNamedValues;
- const _C2FieldId _mFieldId; // field identifier (offset and size)
+ _C2FieldId _mFieldId; // field identifier (offset and size)
// NOTE: We do not capture default value(s) here as that may depend on the component.
// NOTE: We also do not capture bestEffort, as 1) this should be true for most fields,
// 2) this is at parameter granularity.
// type resolution
- inline static type_t getType(int32_t*) { return INT32; }
- inline static type_t getType(uint32_t*) { return UINT32; }
- inline static type_t getType(c2_cntr32_t*) { return CNTR32; }
- inline static type_t getType(int64_t*) { return INT64; }
- inline static type_t getType(uint64_t*) { return UINT64; }
- inline static type_t getType(c2_cntr64_t*) { return CNTR64; }
- inline static type_t getType(float*) { return FLOAT; }
- inline static type_t getType(char*) { return STRING; }
- inline static type_t getType(uint8_t*) { return BLOB; }
+ inline static type_t GetType(int32_t*) { return INT32; }
+ inline static type_t GetType(uint32_t*) { return UINT32; }
+ inline static type_t GetType(c2_cntr32_t*) { return CNTR32; }
+ inline static type_t GetType(int64_t*) { return INT64; }
+ inline static type_t GetType(uint64_t*) { return UINT64; }
+ inline static type_t GetType(c2_cntr64_t*) { return CNTR64; }
+ inline static type_t GetType(float*) { return FLOAT; }
+ inline static type_t GetType(char*) { return STRING; }
+ inline static type_t GetType(uint8_t*) { return BLOB; }
template<typename T,
class=typename std::enable_if<std::is_enum<T>::value>::type>
- inline static type_t getType(T*) {
+ inline static type_t GetType(T*) {
typename std::underlying_type<T>::type underlying(0);
- return getType(&underlying);
+ return GetType(&underlying);
}
// verify C2Struct by having a FIELD_LIST and a CORE_INDEX.
template<typename T,
class=decltype(T::CORE_INDEX + 1), class=decltype(T::FIELD_LIST)>
- inline static type_t getType(T*) {
+ inline static type_t GetType(T*) {
static_assert(!std::is_base_of<C2Param, T>::value, "cannot use C2Params as fields");
return (type_t)(T::CORE_INDEX | STRUCT_FLAG);
}
+
+ friend struct _C2ParamInspector;
};
#define DEFINE_NO_NAMED_VALUES_FOR(type) \
-template<> inline C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const type &) { \
- return named_values_type(); \
+template<> inline C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const type &) { \
+ return NamedValuesType(); \
}
// We cannot subtype constructor for enumerated types so insted define no named values for
@@ -1016,6 +1018,14 @@
*/
inline bool isPersistent() const { return _mAttrib & IS_PERSISTENT; }
+ inline bool isStrict() const { return _mAttrib & IS_STRICT; }
+
+ inline bool isReadOnly() const { return _mAttrib & IS_READ_ONLY; }
+
+ inline bool isVisible() const { return !(_mAttrib & IS_HIDDEN); }
+
+ inline bool isPublic() const { return !(_mAttrib & IS_INTERNAL); }
+
/// Returns the name of this param.
/// This defaults to the underlying C2Struct's name, but could be altered for a component.
inline C2String name() const { return _mName; }
@@ -1024,31 +1034,52 @@
inline C2Param::Index index() const { return _mIndex; }
/// Returns the indices of parameters that this parameter has a dependency on
- inline const std::vector<C2Param::Index> &dependencies() const { return mDependencies; }
+ inline const std::vector<C2Param::Index> &dependencies() const { return _mDependencies; }
- // TODO: add more constructors that allow setting dependencies and attributes
-
+ /// \deprecated
template<typename T>
inline C2ParamDescriptor(bool isRequired, C2StringLiteral name, const T*)
: _mIndex(T::PARAM_TYPE),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
+ /// \deprecated
inline C2ParamDescriptor(
bool isRequired, C2StringLiteral name, C2Param::Index index)
: _mIndex(index),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
-private:
enum attrib_t : uint32_t {
- IS_REQUIRED = 1u << 0,
- IS_PERSISTENT = 1u << 1,
+ // flags that default on
+ IS_REQUIRED = 1u << 0, ///< parameter is required to be specified
+ IS_PERSISTENT = 1u << 1, ///< parameter retains its value
+ // flags that default off
+ IS_STRICT = 1u << 2, ///< parameter is strict
+ IS_READ_ONLY = 1u << 3, ///< parameter is publicly read-only
+ IS_HIDDEN = 1u << 4, ///< parameter shall not be visible to clients
+ IS_INTERNAL = 1u << 5, ///< parameter shall not be used by framework (other than testing)
};
+
+ inline C2ParamDescriptor(
+ C2Param::Index index, attrib_t attrib, C2StringLiteral name)
+ : _mIndex(index),
+ _mAttrib(attrib),
+ _mName(name) { }
+
+ inline C2ParamDescriptor(
+ C2Param::Index index, attrib_t attrib, C2String &&name,
+ std::vector<C2Param::Index> &&dependencies)
+ : _mIndex(index),
+ _mAttrib(attrib),
+ _mName(name),
+ _mDependencies(std::move(dependencies)) { }
+
+private:
const C2Param::Index _mIndex;
const uint32_t _mAttrib;
const C2String _mName;
- std::vector<C2Param::Index> mDependencies;
+ std::vector<C2Param::Index> _mDependencies;
friend struct _C2ParamInspector;
};
@@ -1138,7 +1169,7 @@
* private:
* // may have private constructors taking number of widths as the first argument
* // This is used by the C2Param factory methods, e.g.
- * // C2VideoFlexWidthsGlobalParam::alloc_unique(size_t, int32_t);
+ * // C2VideoFlexWidthsGlobalParam::AllocUnique(size_t, int32_t);
* C2VideoFlexWidthsStruct(size_t flexCount, int32_t value) {
* for (size_t i = 0; i < flexCount; ++i) {
* widths[i] = value;
@@ -1148,7 +1179,7 @@
* // If the last argument is T[N] or std::initializer_list<T>, the flexCount will
* // be automatically calculated and passed by the C2Param factory methods, e.g.
* // int widths[] = { 1, 2, 3 };
- * // C2VideoFlexWidthsGlobalParam::alloc_unique(widths);
+ * // C2VideoFlexWidthsGlobalParam::AllocUnique(widths);
* template<unsigned N>
* C2VideoFlexWidthsStruct(size_t flexCount, const int32_t(&init)[N]) {
* for (size_t i = 0; i < flexCount; ++i) {
@@ -1261,7 +1292,7 @@
* descriptions, but we want to conserve memory if client only wants the description
* of a few indices.
*/
- virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) = 0;
+ virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) const = 0;
protected:
virtual ~C2ParamReflector() = default;
@@ -1270,9 +1301,9 @@
/**
* Generic supported values for a field.
*
- * This can be either a range or a set of values. The range can be linear or geometric with a
- * clear minimum and maximum value, and can have an optional step size or geometric ratio. Values
- * can optionally represent flags.
+ * This can be either a range or a set of values. The range can be a simple range, an arithmetic,
+ * geometric or multiply-accumulate series with a clear minimum and maximum value. Values can
+ * be discrete values, or can optionally represent flags to be or-ed.
*
* \note Do not use flags to represent bitfields. Use individual values or separate fields instead.
*/
@@ -1285,17 +1316,47 @@
FLAGS ///< a list of flags that can be OR-ed
};
- type_t type;
+ type_t type; /** Type of values for this field. */
typedef C2Value::Primitive Primitive;
+ /**
+ * Range specifier for supported value. Used if type is RANGE.
+ *
+ * If step is 0 and num and denom are both 1, the supported values are any value, for which
+ * min <= value <= max.
+ *
+ * Otherwise, the range represents a geometric/arithmetic/multiply-accumulate series, where
+ * successive supported values can be derived from previous values (starting at min), using the
+ * following formula:
+ * v[0] = min
+ * v[i] = v[i-1] * num / denom + step for i >= 1, while min < v[i] <= max.
+ */
struct {
+ /** Lower end of the range (inclusive). */
Primitive min;
+ /** Upper end of the range (inclusive if permitted by series). */
Primitive max;
+ /** Step between supported values. */
Primitive step;
+ /** Numerator of a geometric series. */
Primitive num;
+ /** Denominator of a geometric series. */
Primitive denom;
} range;
+
+ /**
+ * List of values. Used if type is VALUES or FLAGS.
+ *
+ * If type is VALUES, this is the list of supported values in decreasing preference.
+ *
+ * If type is FLAGS, this vector contains { min-mask, flag1, flag2... }. Basically, the first
+ * value is the required set of flags to be set, and the rest of the values are flags that can
+ * be set independently. FLAGS is only supported for integral types. Supported flags should
+ * not overlap, as it can make validation non-deterministic. The standard validation method
+ * is that starting from the original value, if each flag is removed when fully present (the
+ * min-mask must be fully present), we shall arrive at 0.
+ */
std::vector<Primitive> values;
C2FieldSupportedValues()
@@ -1313,14 +1374,21 @@
range{min, max, (T)0, num, den} { }
template<typename T>
+ C2FieldSupportedValues(T min, T max, T step, T num, T den)
+ : type(RANGE),
+ range{min, max, step, num, den} { }
+
+ /// \deprecated
+ template<typename T>
C2FieldSupportedValues(bool flags, std::initializer_list<T> list)
: type(flags ? FLAGS : VALUES),
range{(T)0, (T)0, (T)0, (T)0, (T)0} {
- for(T value : list) {
+ for (T value : list) {
values.emplace_back(value);
}
}
+ /// \deprecated
template<typename T>
C2FieldSupportedValues(bool flags, const std::vector<T>& list)
: type(flags ? FLAGS : VALUES),
@@ -1332,20 +1400,23 @@
/// \internal
/// \todo: create separate values vs. flags initializer as for flags we want
- /// to list both allowed and disallowed flags
+ /// to list both allowed and required flags
template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)0))>
C2FieldSupportedValues(bool flags, const T*)
: type(flags ? FLAGS : VALUES),
range{(T)0, (T)0, (T)0, (T)0, (T)0} {
- C2FieldDescriptor::named_values_type named = C2FieldDescriptor::namedValuesFor(*(T*)0);
- for (const C2FieldDescriptor::named_value_type &item : named) {
+ C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)0);
+ if (flags) {
+ values.emplace_back(0); // min-mask defaults to 0
+ }
+ for (const C2FieldDescriptor::NamedValueType &item : named){
values.emplace_back(item.second);
}
}
};
/**
- * Spported values for a specific field.
+ * Supported values for a specific field.
*
* This is a pair of the field specifier together with an optional supported values object.
* This structure is used when reporting parameter configuration failures and conflicts.
@@ -1357,6 +1428,41 @@
/// blobs) describe the supported values for each element (character for string, and bytes for
/// blobs). It is optional for read-only strings and blobs.
std::unique_ptr<C2FieldSupportedValues> values;
+
+ // This struct is meant to be move constructed.
+ C2_DEFAULT_MOVE(C2ParamFieldValues);
+
+ // Copy constructor/assignment is also provided as this object may get copied.
+ C2ParamFieldValues(const C2ParamFieldValues &other)
+ : paramOrField(other.paramOrField),
+ values(other.values ? std::make_unique<C2FieldSupportedValues>(*other.values) : nullptr) { }
+
+ C2ParamFieldValues& operator=(const C2ParamFieldValues &other) {
+ paramOrField = other.paramOrField;
+ values = other.values ? std::make_unique<C2FieldSupportedValues>(*other.values) : nullptr;
+ return *this;
+ }
+
+
+ /**
+ * Construct with no values.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_)
+ : paramOrField(paramOrField_) { }
+
+ /**
+ * Construct with values.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_, const C2FieldSupportedValues &values_)
+ : paramOrField(paramOrField_),
+ values(std::make_unique<C2FieldSupportedValues>(values_)) { }
+
+ /**
+ * Construct from fields.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_, std::unique_ptr<C2FieldSupportedValues> &&values_)
+ : paramOrField(paramOrField_),
+ values(std::move(values_)) { }
};
/// @}
diff --git a/media/libstagefright/codec2/include/C2ParamDef.h b/media/libstagefright/codec2/include/C2ParamDef.h
index f0b6223..86c6833 100644
--- a/media/libstagefright/codec2/include/C2ParamDef.h
+++ b/media/libstagefright/codec2/include/C2ParamDef.h
@@ -36,14 +36,14 @@
struct C2_HIDE _C2Comparable_impl
{
template<typename S, typename=decltype(S() == S())>
- static std::true_type __testEQ(int);
+ static std::true_type TestEqual(int);
template<typename>
- static std::false_type __testEQ(...);
+ static std::false_type TestEqual(...);
template<typename S, typename=decltype(S() != S())>
- static std::true_type __testNE(int);
+ static std::true_type TestNotEqual(int);
template<typename>
- static std::false_type __testNE(...);
+ static std::false_type TestNotEqual(...);
};
/**
@@ -53,30 +53,30 @@
*/
template<typename S>
struct C2_HIDE _C2Comparable
- : public std::integral_constant<bool, decltype(_C2Comparable_impl::__testEQ<S>(0))::value
- || decltype(_C2Comparable_impl::__testNE<S>(0))::value> {
+ : public std::integral_constant<bool, decltype(_C2Comparable_impl::TestEqual<S>(0))::value
+ || decltype(_C2Comparable_impl::TestNotEqual<S>(0))::value> {
};
/// Helper class that checks if a type has a CORE_INDEX constant.
struct C2_HIDE _C2CoreIndexHelper_impl
{
template<typename S, int=S::CORE_INDEX>
- static std::true_type __testCoreIndex(int);
+ static std::true_type TestCoreIndex(int);
template<typename>
- static std::false_type __testCoreIndex(...);
+ static std::false_type TestCoreIndex(...);
};
/// Helper template that verifies a type's CORE_INDEX and creates it if the type does not have one.
template<typename S, int CoreIndex,
- bool HasBase=decltype(_C2CoreIndexHelper_impl::__testCoreIndex<S>(0))::value>
-struct C2_HIDE C2CoreIndexOverride {
+ bool HasBase=decltype(_C2CoreIndexHelper_impl::TestCoreIndex<S>(0))::value>
+struct C2_HIDE _C2CoreIndexOverride {
// TODO: what if we allow structs without CORE_INDEX?
static_assert(CoreIndex == S::CORE_INDEX, "CORE_INDEX differs from structure");
};
/// Specialization for types without a CORE_INDEX.
template<typename S, int CoreIndex>
-struct C2_HIDE C2CoreIndexOverride<S, CoreIndex, false> {
+struct C2_HIDE _C2CoreIndexOverride<S, CoreIndex, false> {
public:
enum : uint32_t {
CORE_INDEX = CoreIndex, ///< CORE_INDEX override.
@@ -85,7 +85,7 @@
/// Helper template that adds a CORE_INDEX to a type if it does not have one.
template<typename S, int CoreIndex>
-struct C2_HIDE C2AddCoreIndex : public S, public C2CoreIndexOverride<S, CoreIndex> {};
+struct C2_HIDE _C2AddCoreIndex : public S, public _C2CoreIndexOverride<S, CoreIndex> {};
/**
* \brief Helper class to check struct requirements for parameters.
@@ -95,7 +95,7 @@
* - expose PARAM_TYPE, and non-flex FLEX_SIZE.
*/
template<typename S, int CoreIndex, unsigned TypeFlags>
-struct C2_HIDE C2StructCheck {
+struct C2_HIDE _C2StructCheck {
static_assert(
std::is_default_constructible<S>::value, "C2 structure must have default constructor");
static_assert(!std::is_polymorphic<S>::value, "C2 structure must not have virtual methods");
@@ -116,15 +116,15 @@
struct C2_HIDE _C2Flexible_impl {
/// specialization for types that have a FLEX_SIZE member
template<typename S, unsigned=S::FLEX_SIZE>
- static std::true_type __testFlexSize(int);
+ static std::true_type TestFlexSize(int);
template<typename>
- static std::false_type __testFlexSize(...);
+ static std::false_type TestFlexSize(...);
};
/// Helper template that returns if a type has an integer FLEX_SIZE member.
template<typename S>
struct C2_HIDE _C2Flexible
- : public std::integral_constant<bool, decltype(_C2Flexible_impl::__testFlexSize<S>(0))::value> {
+ : public std::integral_constant<bool, decltype(_C2Flexible_impl::TestFlexSize<S>(0))::value> {
};
/// Macro to test if a type is flexible (has a FLEX_SIZE member).
@@ -165,9 +165,9 @@
* flexible struct, so may not be needed here)
*/
template<typename S, int ParamIndex, unsigned TypeFlags>
-struct C2_HIDE C2FlexStructCheck :
-// add flexible flag as C2StructCheck defines PARAM_TYPE
- public C2StructCheck<S, ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, TypeFlags> {
+struct C2_HIDE _C2FlexStructCheck :
+// add flexible flag as _C2StructCheck defines PARAM_TYPE
+ public _C2StructCheck<S, ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, TypeFlags> {
public:
enum : uint32_t {
/// \hideinitializer
@@ -177,12 +177,12 @@
const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST; // TODO assign here
// default constructor needed because of the disabled copy constructor
- inline C2FlexStructCheck() = default;
+ inline _C2FlexStructCheck() = default;
protected:
// cannot copy flexible params
- C2FlexStructCheck(const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
- C2FlexStructCheck& operator= (const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
+ _C2FlexStructCheck(const _C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
+ _C2FlexStructCheck& operator= (const _C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
// constants used for helper methods
enum : uint32_t {
@@ -195,7 +195,7 @@
};
/// returns the allocated size of this param with flexCount, or 0 if it would overflow.
- inline static size_t calcSize(size_t flexCount, size_t size = BASE_SIZE) {
+ inline static size_t CalcSize(size_t flexCount, size_t size = BASE_SIZE) {
if (flexCount <= (MAX_SIZE - size) / S::FLEX_SIZE) {
return size + S::FLEX_SIZE * flexCount;
}
@@ -205,7 +205,7 @@
/// dynamic new operator usable for params of type S
inline void* operator new(size_t size, size_t flexCount) noexcept {
// TODO: assert(size == BASE_SIZE);
- size = calcSize(flexCount, size);
+ size = CalcSize(flexCount, size);
if (size > 0) {
return ::operator new(size);
}
@@ -217,12 +217,12 @@
/// Expose FIELD_LIST from subClass;
template<typename S, int ParamIndex, unsigned TypeFlags>
const std::initializer_list<const C2FieldDescriptor>
-C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
+_C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
/// Define From() cast operators for params.
#define DEFINE_CAST_OPERATORS(_Type) \
inline static _Type* From(C2Param *other) { \
- return (_Type*)C2Param::ifSuitable( \
+ return (_Type*)C2Param::IfSuitable( \
other, sizeof(_Type), _Type::PARAM_TYPE, _Type::FLEX_SIZE, \
(_Type::PARAM_TYPE & T::Index::DIR_UNDEFINED) != T::Index::DIR_UNDEFINED); \
} \
@@ -232,40 +232,40 @@
inline static _Type* From(std::nullptr_t) { return nullptr; } \
/**
- * Define flexible allocators (alloc_shared or alloc_unique) for flexible params.
- * - P::alloc_xyz(flexCount, args...): allocate for given flex-count.
- * - P::alloc_xyz(args..., T[]): allocate for size of (and with) init array.
- * - P::alloc_xyz(T[]): allocate for size of (and with) init array with no other args.
- * - P::alloc_xyz(args..., std::initializer_list<T>): allocate for size of (and with) initializer
+ * Define flexible allocators (AllocShared or AllocUnique) for flexible params.
+ * - P::AllocXyz(flexCount, args...): allocate for given flex-count.
+ * - P::AllocXyz(args..., T[]): allocate for size of (and with) init array.
+ * - P::AllocXyz(T[]): allocate for size of (and with) init array with no other args.
+ * - P::AllocXyz(args..., std::initializer_list<T>): allocate for size of (and with) initializer
* list.
*/
-#define DEFINE_FLEXIBLE_ALLOC(_Type, S, ptr) \
+#define DEFINE_FLEXIBLE_ALLOC(_Type, S, ptr, Ptr) \
template<typename ...Args> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(size_t flexCount, const Args(&... args)) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(size_t flexCount, const Args(&... args)) { \
return std::ptr##_ptr<_Type>(new(flexCount) _Type(flexCount, args...)); \
} \
/* NOTE: unfortunately this is not supported by clang yet */ \
template<typename ...Args, typename U=typename S::FlexType, unsigned N> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(const Args(&... args), const U(&init)[N]) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(const Args(&... args), const U(&init)[N]) { \
return std::ptr##_ptr<_Type>(new(N) _Type(N, args..., init)); \
} \
/* so for now, specialize for no args */ \
template<typename U=typename S::FlexType, unsigned N> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(const U(&init)[N]) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(const U(&init)[N]) { \
return std::ptr##_ptr<_Type>(new(N) _Type(N, init)); \
} \
template<typename ...Args, typename U=typename S::FlexType> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr( \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr( \
const Args(&... args), const std::initializer_list<U> &init) { \
return std::ptr##_ptr<_Type>(new(init.size()) _Type(init.size(), args..., init)); \
} \
/**
- * Define flexible methods alloc_shared, alloc_unique and flexCount.
+ * Define flexible methods AllocShared, AllocUnique and flexCount.
*/
#define DEFINE_FLEXIBLE_METHODS(_Type, S) \
- DEFINE_FLEXIBLE_ALLOC(_Type, S, shared) \
- DEFINE_FLEXIBLE_ALLOC(_Type, S, unique) \
+ DEFINE_FLEXIBLE_ALLOC(_Type, S, shared, Shared) \
+ DEFINE_FLEXIBLE_ALLOC(_Type, S, unique, Unique) \
inline size_t flexCount() const { \
static_assert(sizeof(_Type) == _Type::BASE_SIZE, "incorrect BASE_SIZE"); \
size_t sz = this->size(); \
@@ -312,8 +312,8 @@
* structures.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2GlobalParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
+struct C2_HIDE C2GlobalParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
private:
typedef C2GlobalParam<T, S, ParamIndex> _Type;
@@ -342,14 +342,14 @@
*/
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2GlobalParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
- : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
+ : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
private:
typedef C2GlobalParam<T, S, ParamIndex> _Type;
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline C2GlobalParam(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -378,8 +378,8 @@
* unspecified port expose a setPort method, and add an initial port parameter to the constructor.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2PortParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- private C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_UNDEFINED> {
+struct C2_HIDE C2PortParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ private _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_UNDEFINED> {
private:
typedef C2PortParam<T, S, ParamIndex> _Type;
@@ -396,8 +396,8 @@
DEFINE_CAST_OPERATORS(_Type)
/// Specialization for an input port parameter.
- struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
+ struct input : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline input(const Args(&... args)) : T(sizeof(_Type), input::PARAM_TYPE), S(args...) { }
@@ -407,8 +407,8 @@
};
/// Specialization for an output port parameter.
- struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
+ struct output : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline output(const Args(&... args)) : T(sizeof(_Type), output::PARAM_TYPE), S(args...) { }
@@ -438,16 +438,16 @@
*/
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2PortParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
- : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_UNDEFINED> {
+ : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_UNDEFINED> {
private:
typedef C2PortParam<T, S, ParamIndex> _Type;
/// Default constructor for basic allocation: new(flexCount) P.
- inline C2PortParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE) { }
+ inline C2PortParam(size_t flexCount) : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE) { }
template<typename ...Args>
/// Wrapper around base structure's constructor while also specifying port/direction.
inline C2PortParam(size_t flexCount, bool _output, const Args(&... args))
- : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE),
+ : T(_Type::CalcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE),
m(flexCount, args...) { }
public:
@@ -461,12 +461,12 @@
/// Specialization for an input port parameter.
struct input : public T,
- public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
+ public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
private:
/// Wrapper around base structure's constructor while also specifying port/direction.
template<typename ...Args>
inline input(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), input::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), input::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -477,12 +477,12 @@
/// Specialization for an output port parameter.
struct output : public T,
- public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
+ public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
private:
/// Wrapper around base structure's constructor while also specifying port/direction.
template<typename ...Args>
inline output(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), output::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), output::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -514,8 +514,8 @@
* parameter to the constructor.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2StreamParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- private C2StructCheck<S, ParamIndex,
+struct C2_HIDE C2StreamParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ private _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
private:
typedef C2StreamParam<T, S, ParamIndex> _Type;
@@ -537,8 +537,8 @@
DEFINE_CAST_OPERATORS(_Type)
/// Specialization for an input stream parameter.
- struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex,
+ struct input : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
/// Default constructor. Stream-ID is undefined.
inline input() : T(sizeof(_Type), input::PARAM_TYPE) { }
@@ -553,8 +553,8 @@
};
/// Specialization for an output stream parameter.
- struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex,
+ struct output : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
/// Default constructor. Stream-ID is undefined.
inline output() : T(sizeof(_Type), output::PARAM_TYPE) { }
@@ -593,17 +593,17 @@
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2StreamParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
: public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
private:
typedef C2StreamParam<T, S, ParamIndex> _Type;
/// Default constructor. Port/direction and stream-ID is undefined.
- inline C2StreamParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE, 0u) { }
+ inline C2StreamParam(size_t flexCount) : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE, 0u) { }
/// Wrapper around base structure's constructor while also specifying port/direction and
/// stream-ID.
template<typename ...Args>
inline C2StreamParam(size_t flexCount, bool _output, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
+ : T(_Type::CalcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
m(flexCount, args...) { }
public:
@@ -619,15 +619,15 @@
/// Specialization for an input stream parameter.
struct input : public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
private:
/// Default constructor. Stream-ID is undefined.
- inline input(size_t flexCount) : T(_Type::calcSize(flexCount), input::PARAM_TYPE) { }
+ inline input(size_t flexCount) : T(_Type::CalcSize(flexCount), input::PARAM_TYPE) { }
/// Wrapper around base structure's constructor while also specifying stream-ID.
template<typename ...Args>
inline input(size_t flexCount, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), input::PARAM_TYPE, stream), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), input::PARAM_TYPE, stream), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -641,15 +641,15 @@
/// Specialization for an output stream parameter.
struct output : public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
private:
/// Default constructor. Stream-ID is undefined.
- inline output(size_t flexCount) : T(_Type::calcSize(flexCount), output::PARAM_TYPE) { }
+ inline output(size_t flexCount) : T(_Type::CalcSize(flexCount), output::PARAM_TYPE) { }
/// Wrapper around base structure's constructor while also specifying stream-ID.
template<typename ...Args>
inline output(size_t flexCount, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), output::PARAM_TYPE, stream), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), output::PARAM_TYPE, stream), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -818,19 +818,19 @@
private:
/// Construct from a C2MemoryBlock.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
inline C2SimpleArrayStruct(size_t flexCount, const C2MemoryBlock<T> &block) {
_C2ValueArrayHelper::init(values, flexCount, block);
}
/// Construct from an initializer list.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
inline C2SimpleArrayStruct(size_t flexCount, const std::initializer_list<T> &init) {
_C2ValueArrayHelper::init(values, flexCount, init);
}
/// Construct from another flexible array.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
template<unsigned N>
inline C2SimpleArrayStruct(size_t flexCount, const T(&init)[N]) {
_C2ValueArrayHelper::init(values, flexCount, init);
diff --git a/media/libstagefright/codec2/include/C2Work.h b/media/libstagefright/codec2/include/C2Work.h
index a2f02e5..1a35519 100644
--- a/media/libstagefright/codec2/include/C2Work.h
+++ b/media/libstagefright/codec2/include/C2Work.h
@@ -37,17 +37,20 @@
*/
struct C2SettingResult {
enum Failure : uint32_t {
- READ_ONLY, ///< parameter is read-only and cannot be set
- MISMATCH, ///< parameter mismatches input data
- BAD_VALUE, ///< parameter does not accept value
+ /* parameter failures below */
BAD_TYPE, ///< parameter is not supported
BAD_PORT, ///< parameter is not supported on the specific port
BAD_INDEX, ///< parameter is not supported on the specific stream
- CONFLICT, ///< parameter is in conflict with an/other setting(s)
- /// parameter is out of range due to other settings (this failure mode
- /// can only be used for strict parameters)
- UNSUPPORTED,
+ READ_ONLY, ///< parameter is read-only and cannot be set
+ MISMATCH, ///< parameter mismatches input data
+ /* field failures below */
+ BAD_VALUE, ///< parameter does not accept value for the field at all
+ CONFLICT, ///< parameter field value is in conflict with an/other setting(s)
+
+ /// parameter field is out of range due to other settings (this failure mode
+ /// can only be used for strict calculated parameters)
+ UNSUPPORTED,
/// requested parameter value is in conflict with an/other setting(s)
/// and has been corrected to the closest supported value. This failure
@@ -58,14 +61,15 @@
Failure failure; ///< failure code
- /// Failing (or corrected) field. Currently supported values for the field. This is set if
+ /// Failing (or corrected) field or parameterand optionally, currently supported values for the
+ /// field. Values must only be set for field failures other than BAD_VALUE, and only if they are
/// different from the globally supported values (e.g. due to restrictions by another param or
- /// input data)
- /// \todo need to define suggestions for masks to be set and unset.
+ /// input data).
C2ParamFieldValues field;
/// Conflicting parameters or fields with optional suggestions with (optional) suggested values
- /// for any conflicting fields to avoid the conflict.
+ /// for any conflicting fields to avoid the conflict. Must only be set for CONFLICT, UNSUPPORTED
+ /// and INFO_CONFLICT failure codes.
std::vector<C2ParamFieldValues> conflicts;
};
diff --git a/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h b/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
index e46d03c..b011a06 100644
--- a/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
+++ b/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
@@ -48,7 +48,7 @@
// Methods from IInputSurface
sp<InputSurfaceConnection> connectToComponent(
- const std::shared_ptr<::android::C2Component> &comp);
+ const std::shared_ptr<::C2Component> &comp);
// TODO: intf()
static sp<InputSurface> Create();
diff --git a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
index 7da824b..e555e8c 100644
--- a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
+++ b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
@@ -37,7 +37,7 @@
template <class T> std::unique_ptr<T> alloc_unique_cstr(const char *cstr) {
size_t len = strlen(cstr);
- std::unique_ptr<T> ptr = T::alloc_unique(len);
+ std::unique_ptr<T> ptr = T::AllocUnique(len);
memcpy(ptr->m.value, cstr, len);
return ptr;
}
@@ -182,7 +182,7 @@
template <> std::unique_ptr<C2PortMimeConfig::input> makeParam() {
// TODO(hiroh): Set more precise length.
- return C2PortMimeConfig::input::alloc_unique(100);
+ return C2PortMimeConfig::input::AllocUnique(100);
}
#define TRACED_FAILURE(func) \
diff --git a/media/libstagefright/codec2/tests/C2Param_test.cpp b/media/libstagefright/codec2/tests/C2Param_test.cpp
index 168b889..fcfbafd 100644
--- a/media/libstagefright/codec2/tests/C2Param_test.cpp
+++ b/media/libstagefright/codec2/tests/C2Param_test.cpp
@@ -45,14 +45,14 @@
}
}
*os << " " << fd.name();
- if (fd.length() > 1) {
- *os << "[" << fd.length() << "]";
- } else if (fd.length() == 0) {
+ if (fd.extent() > 1) {
+ *os << "[" << fd.extent() << "]";
+ } else if (fd.extent() == 0) {
*os << "[]";
}
*os << " (";
PrintTo(fd._mFieldId, os);
- *os << "*" << fd.length() << ")";
+ *os << "*" << fd.extent() << ")";
}
enum C2ParamIndexType : C2Param::type_index_t {
@@ -102,7 +102,7 @@
bool operator==(const C2FieldDescriptor &a, const C2FieldDescriptor &b) {
return a.type() == b.type()
- && a.length() == b.length()
+ && a.extent() == b.extent()
&& strcmp(a.name(), b.name()) == 0
&& a._mFieldId == b._mFieldId;
}
@@ -140,7 +140,7 @@
// verify first field descriptor
EXPECT_EQ(FD::INT32, fields[0].type());
EXPECT_STREQ("s32", fields[0].name());
- EXPECT_EQ(1u, fields[0].length());
+ EXPECT_EQ(1u, fields[0].extent());
EXPECT_EQ(_C2FieldId(0, 4), fields[0]._mFieldId);
EXPECT_EQ(expected[0], fields[0]);
@@ -736,7 +736,7 @@
s.value = 11;
s = 12;
(void)C2NumberConfig3::FIELD_LIST;
- std::shared_ptr<C2VideoNameConfig> n = C2VideoNameConfig::alloc_shared(25);
+ std::shared_ptr<C2VideoNameConfig> n = C2VideoNameConfig::AllocShared(25);
strcpy(n->m.value, "lajos");
C2NumberConfig4 t(false, 0, 11);
t.value = 15;
@@ -764,10 +764,10 @@
std::list<const C2FieldDescriptor> myList = C2NumberConfig::FIELD_LIST;
- std::unique_ptr<android::C2ParamDescriptor> __test_describe(uint32_t paramType) {
+ std::unique_ptr<C2ParamDescriptor> __test_describe(uint32_t paramType) {
std::list<const C2FieldDescriptor> fields = describeC2Params<C2NumberConfig>();
- auto widths = C2NumbersInfo::alloc_shared(5);
+ auto widths = C2NumbersInfo::AllocShared(5);
widths->flexCount();
widths->m.mNumbers[4] = 1;
@@ -1110,7 +1110,7 @@
{
C2NumberInfo inf(100);
- std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
+ std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::AllocUnique(1);
EXPECT_EQ(tun.coreIndex(), inf.coreIndex());
EXPECT_NE(tun.coreIndex(), tun_->coreIndex());
@@ -1661,8 +1661,8 @@
void StaticTestAddCoreIndex() {
struct nobase {};
struct base { enum : uint32_t { CORE_INDEX = 1 }; };
- static_assert(C2AddCoreIndex<nobase, 2>::CORE_INDEX == 2, "should be 2");
- static_assert(C2AddCoreIndex<base, 1>::CORE_INDEX == 1, "should be 1");
+ static_assert(_C2AddCoreIndex<nobase, 2>::CORE_INDEX == 2, "should be 2");
+ static_assert(_C2AddCoreIndex<base, 1>::CORE_INDEX == 1, "should be 1");
}
class TestFlexHelper {
@@ -1709,10 +1709,10 @@
EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
}
- std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
+ std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::AllocUnique(1);
tun_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersTuning> tun = std::move(tun_);
- std::shared_ptr<C2NumbersTuning> btun = C2NumbersTuning::alloc_shared(1);
+ std::shared_ptr<C2NumbersTuning> btun = C2NumbersTuning::AllocShared(1);
{
// flags & invariables
@@ -1774,24 +1774,24 @@
EXPECT_EQ(*(C2Param::Copy(*tun)), *tun);
}
- std::unique_ptr<C2NumbersPortTuning> outp1_(C2NumbersPortTuning::alloc_unique(1, true)),
- inp1_ = C2NumbersPortTuning::alloc_unique(1, false);
+ std::unique_ptr<C2NumbersPortTuning> outp1_(C2NumbersPortTuning::AllocUnique(1, true)),
+ inp1_ = C2NumbersPortTuning::AllocUnique(1, false);
outp1_->m.mNumbers[0] = 100;
inp1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning> outp1 = std::move(outp1_);
std::unique_ptr<const C2NumbersPortTuning> inp1 = std::move(inp1_);
- std::shared_ptr<C2NumbersPortTuning> boutp1(C2NumbersPortTuning::alloc_shared(1)),
- binp1 = C2NumbersPortTuning::alloc_shared(1),
- binp3 = C2NumbersPortTuning::alloc_shared(1, false);
+ std::shared_ptr<C2NumbersPortTuning> boutp1(C2NumbersPortTuning::AllocShared(1)),
+ binp1 = C2NumbersPortTuning::AllocShared(1),
+ binp3 = C2NumbersPortTuning::AllocShared(1, false);
binp3->m.mNumbers[0] = 100;
- std::unique_ptr<C2NumbersPortTuning::input> inp2_(C2NumbersPortTuning::input::alloc_unique(1));
+ std::unique_ptr<C2NumbersPortTuning::input> inp2_(C2NumbersPortTuning::input::AllocUnique(1));
inp2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning::input> inp2 = std::move(inp2_);
- std::shared_ptr<C2NumbersPortTuning::input> binp2(C2NumbersPortTuning::input::alloc_shared(1));
- std::unique_ptr<C2NumbersPortTuning::output> outp2_(C2NumbersPortTuning::output::alloc_unique(1));
+ std::shared_ptr<C2NumbersPortTuning::input> binp2(C2NumbersPortTuning::input::AllocShared(1));
+ std::unique_ptr<C2NumbersPortTuning::output> outp2_(C2NumbersPortTuning::output::AllocUnique(1));
outp2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning::output> outp2 = std::move(outp2_);
- std::shared_ptr<C2NumbersPortTuning::output> boutp2(C2NumbersPortTuning::output::alloc_shared(1));
+ std::shared_ptr<C2NumbersPortTuning::output> boutp2(C2NumbersPortTuning::output::AllocShared(1));
{
static_assert(canCallSetPort(*binp3), "should be able to");
@@ -1999,24 +1999,24 @@
EXPECT_EQ(*(C2Param::Copy(*outp2)), *outp2);
}
- std::unique_ptr<C2NumbersStreamTuning> outs1_(C2NumbersStreamTuning::alloc_unique(1, true, 1u));
+ std::unique_ptr<C2NumbersStreamTuning> outs1_(C2NumbersStreamTuning::AllocUnique(1, true, 1u));
outs1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning> outs1 = std::move(outs1_);
- std::unique_ptr<C2NumbersStreamTuning> ins1_(C2NumbersStreamTuning::alloc_unique(1, false, 1u));
+ std::unique_ptr<C2NumbersStreamTuning> ins1_(C2NumbersStreamTuning::AllocUnique(1, false, 1u));
ins1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning> ins1 = std::move(ins1_);
- std::shared_ptr<C2NumbersStreamTuning> bouts1(C2NumbersStreamTuning::alloc_shared(1));
- std::shared_ptr<C2NumbersStreamTuning> bins1(C2NumbersStreamTuning::alloc_shared(1));
- std::shared_ptr<C2NumbersStreamTuning> bins3(C2NumbersStreamTuning::alloc_shared(1, false, 1u));
+ std::shared_ptr<C2NumbersStreamTuning> bouts1(C2NumbersStreamTuning::AllocShared(1));
+ std::shared_ptr<C2NumbersStreamTuning> bins1(C2NumbersStreamTuning::AllocShared(1));
+ std::shared_ptr<C2NumbersStreamTuning> bins3(C2NumbersStreamTuning::AllocShared(1, false, 1u));
bins3->m.mNumbers[0] = 100;
- std::unique_ptr<C2NumbersStreamTuning::input> ins2_(C2NumbersStreamTuning::input::alloc_unique(1, 1u));
+ std::unique_ptr<C2NumbersStreamTuning::input> ins2_(C2NumbersStreamTuning::input::AllocUnique(1, 1u));
ins2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning::input> ins2 = std::move(ins2_);
- std::shared_ptr<C2NumbersStreamTuning::input> bins2(C2NumbersStreamTuning::input::alloc_shared(1));
- std::unique_ptr<C2NumbersStreamTuning::output> outs2_(C2NumbersStreamTuning::output::alloc_unique(1, 1u));
+ std::shared_ptr<C2NumbersStreamTuning::input> bins2(C2NumbersStreamTuning::input::AllocShared(1));
+ std::unique_ptr<C2NumbersStreamTuning::output> outs2_(C2NumbersStreamTuning::output::AllocUnique(1, 1u));
outs2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning::output> outs2 = std::move(outs2_);
- std::shared_ptr<C2NumbersStreamTuning::output> bouts2(C2NumbersStreamTuning::output::alloc_shared(1));
+ std::shared_ptr<C2NumbersStreamTuning::output> bouts2(C2NumbersStreamTuning::output::AllocShared(1));
{
static_assert(canCallSetPort(*bins3), "should be able to");
@@ -2239,7 +2239,7 @@
std::list<const C2FieldDescriptor> fields = int32Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::INT32, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2250,7 +2250,7 @@
std::list<const C2FieldDescriptor> fields = uint32Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::UINT32, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2261,7 +2261,7 @@
std::list<const C2FieldDescriptor> fields = int64Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::INT64, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2272,7 +2272,7 @@
std::list<const C2FieldDescriptor> fields = uint64Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::UINT64, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2283,24 +2283,24 @@
std::list<const C2FieldDescriptor> fields = floatValue.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::FLOAT, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
{
uint8_t initValue[] = "ABCD";
typedef C2GlobalParam<C2Setting, C2BlobValue, 0> BlobSetting;
- std::unique_ptr<BlobSetting> blobValue = BlobSetting::alloc_unique(6, C2ConstMemoryBlock<uint8_t>(initValue));
+ std::unique_ptr<BlobSetting> blobValue = BlobSetting::AllocUnique(6, C2ConstMemoryBlock<uint8_t>(initValue));
static_assert(std::is_same<decltype(blobValue->m.value), uint8_t[]>::value, "should be uint8_t[]");
EXPECT_EQ(0, memcmp(blobValue->m.value, "ABCD\0", 6));
EXPECT_EQ(6u, blobValue->flexCount());
std::list<const C2FieldDescriptor> fields = blobValue->FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::BLOB, fields.cbegin()->type());
- EXPECT_EQ(0u, fields.cbegin()->length());
+ EXPECT_EQ(0u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
- blobValue = BlobSetting::alloc_unique(3, C2ConstMemoryBlock<uint8_t>(initValue));
+ blobValue = BlobSetting::AllocUnique(3, C2ConstMemoryBlock<uint8_t>(initValue));
EXPECT_EQ(0, memcmp(blobValue->m.value, "ABC", 3));
EXPECT_EQ(3u, blobValue->flexCount());
}
@@ -2308,30 +2308,30 @@
{
constexpr char initValue[] = "ABCD";
typedef C2GlobalParam<C2Setting, C2StringValue, 0> StringSetting;
- std::unique_ptr<StringSetting> stringValue = StringSetting::alloc_unique(6, C2ConstMemoryBlock<char>(initValue));
- stringValue = StringSetting::alloc_unique(6, initValue);
+ std::unique_ptr<StringSetting> stringValue = StringSetting::AllocUnique(6, C2ConstMemoryBlock<char>(initValue));
+ stringValue = StringSetting::AllocUnique(6, initValue);
static_assert(std::is_same<decltype(stringValue->m.value), char[]>::value, "should be char[]");
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD\0", 6));
EXPECT_EQ(6u, stringValue->flexCount());
std::list<const C2FieldDescriptor> fields = stringValue->FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::STRING, fields.cbegin()->type());
- EXPECT_EQ(0u, fields.cbegin()->length());
+ EXPECT_EQ(0u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
- stringValue = StringSetting::alloc_unique(3, C2ConstMemoryBlock<char>(initValue));
+ stringValue = StringSetting::AllocUnique(3, C2ConstMemoryBlock<char>(initValue));
EXPECT_EQ(0, memcmp(stringValue->m.value, "AB", 3));
EXPECT_EQ(3u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique(11, "initValue");
+ stringValue = StringSetting::AllocUnique(11, "initValue");
EXPECT_EQ(0, memcmp(stringValue->m.value, "initValue\0", 11));
EXPECT_EQ(11u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique(initValue);
+ stringValue = StringSetting::AllocUnique(initValue);
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD", 5));
EXPECT_EQ(5u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique({ 'A', 'B', 'C', 'D' });
+ stringValue = StringSetting::AllocUnique({ 'A', 'B', 'C', 'D' });
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABC", 4));
EXPECT_EQ(4u, stringValue->flexCount());
}
@@ -2513,7 +2513,7 @@
public:
MyParamReflector(const MyComponentInstance *i) : instance(i) { }
- virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex paramIndex) override {
+ virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex paramIndex) const override {
switch (paramIndex.typeIndex()) {
case decltype(instance->mDomainInfo)::CORE_INDEX:
default:
@@ -2531,7 +2531,7 @@
c2_blocking_t mayBlock) const override {
(void)mayBlock;
for (C2FieldSupportedValuesQuery &query : fields) {
- if (query.field == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::value)) {
+ if (query.field() == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::value)) {
query.values = C2FieldSupportedValues(
false /* flag */,
&mDomainInfo.value
@@ -2702,7 +2702,7 @@
if (f.namedValues().size()) {
cout << ".named(";
const char *sep = "";
- for (const FD::named_value_type &p : f.namedValues()) {
+ for (const FD::NamedValueType &p : f.namedValues()) {
cout << sep << p.first << "=";
switch (f.type()) {
case C2Value::INT32: cout << get(p.second, (int32_t *)0); break;
diff --git a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
index f0e57e2..038be48 100644
--- a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
+++ b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
@@ -312,13 +312,15 @@
addr[C2PlanarLayout::PLANE_V] = nullptr;
FAIL() << "C2GraphicAllocation::map() failed: " << err;
}
+ mMappedRect = rect;
+ memcpy(mAddrGraphic, addr, sizeof(uint8_t*) * C2PlanarLayout::MAX_NUM_PLANES);
}
void unmapGraphic() {
ASSERT_TRUE(mGraphicAllocation);
// TODO: fence
- ASSERT_EQ(C2_OK, mGraphicAllocation->unmap(nullptr));
+ ASSERT_EQ(C2_OK, mGraphicAllocation->unmap(mAddrGraphic, mMappedRect, nullptr));
}
std::shared_ptr<C2BlockPool> makeGraphicBlockPool() {
@@ -330,6 +332,8 @@
std::shared_ptr<C2LinearAllocation> mLinearAllocation;
size_t mSize;
void *mAddr;
+ C2Rect mMappedRect;
+ uint8_t* mAddrGraphic[C2PlanarLayout::MAX_NUM_PLANES];
std::shared_ptr<C2Allocator> mGraphicAllocator;
std::shared_ptr<C2GraphicAllocation> mGraphicAllocation;
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
index b255eec..3d7fc8d 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorGralloc.cpp
@@ -213,9 +213,10 @@
virtual ~C2AllocationGralloc() override;
virtual c2_status_t map(
- C2Rect rect, C2MemoryUsage usage, int *fenceFd,
+ C2Rect rect, C2MemoryUsage usage, C2Fence *fence,
C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
- virtual c2_status_t unmap(C2Fence *fenceFd /* nullable */) override;
+ virtual c2_status_t unmap(
+ uint8_t **addr /* nonnull */, C2Rect rect, C2Fence *fence /* nullable */) override;
virtual C2Allocator::id_t getAllocatorId() const override { return mAllocatorId; }
virtual const C2Handle *handle() const override { return mLockedHandle ? : mHandle; }
virtual bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override;
@@ -263,16 +264,18 @@
return;
}
if (mLocked) {
- unmap(nullptr);
+ // implementation ignores addresss and rect
+ uint8_t* addr[C2PlanarLayout::MAX_NUM_PLANES] = {};
+ unmap(addr, C2Rect(), nullptr);
}
mMapper->freeBuffer(const_cast<native_handle_t *>(mBuffer));
}
c2_status_t C2AllocationGralloc::map(
- C2Rect rect, C2MemoryUsage usage, int *fenceFd,
+ C2Rect rect, C2MemoryUsage usage, C2Fence *fence,
C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
// TODO
- (void) fenceFd;
+ (void) fence;
(void) usage;
if (mBuffer && mLocked) {
@@ -326,6 +329,7 @@
addr[C2PlanarLayout::PLANE_V] = (uint8_t *)ycbcrLayout.cr;
layout->type = C2PlanarLayout::TYPE_YUV;
layout->numPlanes = 3;
+ layout->rootPlanes = 3;
layout->planes[C2PlanarLayout::PLANE_Y] = {
C2PlaneInfo::CHANNEL_Y, // channel
1, // colInc
@@ -336,6 +340,8 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_Y, // rootIx
+ 0, // offset
};
layout->planes[C2PlanarLayout::PLANE_U] = {
C2PlaneInfo::CHANNEL_CB, // channel
@@ -347,6 +353,8 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_U, // rootIx
+ 0, // offset
};
layout->planes[C2PlanarLayout::PLANE_V] = {
C2PlaneInfo::CHANNEL_CR, // channel
@@ -358,7 +366,20 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_V, // rootIx
+ 0, // offset
};
+ // handle interleaved formats
+ intptr_t uvOffset = addr[C2PlanarLayout::PLANE_V] - addr[C2PlanarLayout::PLANE_U];
+ if (uvOffset > 0 && uvOffset < (intptr_t)ycbcrLayout.chromaStep) {
+ layout->rootPlanes = 2;
+ layout->planes[C2PlanarLayout::PLANE_V].rootIx = C2PlanarLayout::PLANE_U;
+ layout->planes[C2PlanarLayout::PLANE_V].offset = uvOffset;
+ } else if (uvOffset < 0 && uvOffset > -(intptr_t)ycbcrLayout.chromaStep) {
+ layout->rootPlanes = 2;
+ layout->planes[C2PlanarLayout::PLANE_U].rootIx = C2PlanarLayout::PLANE_V;
+ layout->planes[C2PlanarLayout::PLANE_U].offset = -uvOffset;
+ }
break;
}
@@ -387,6 +408,7 @@
addr[C2PlanarLayout::PLANE_B] = (uint8_t *)pointer + 2;
layout->type = C2PlanarLayout::TYPE_RGB;
layout->numPlanes = 3;
+ layout->rootPlanes = 1;
layout->planes[C2PlanarLayout::PLANE_R] = {
C2PlaneInfo::CHANNEL_R, // channel
4, // colInc
@@ -397,6 +419,8 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_R, // rootIx
+ 0, // offset
};
layout->planes[C2PlanarLayout::PLANE_G] = {
C2PlaneInfo::CHANNEL_G, // channel
@@ -408,6 +432,8 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_R, // rootIx
+ 1, // offset
};
layout->planes[C2PlanarLayout::PLANE_B] = {
C2PlaneInfo::CHANNEL_B, // channel
@@ -419,6 +445,8 @@
8, // bitDepth
0, // rightShift
C2PlaneInfo::NATIVE, // endianness
+ C2PlanarLayout::PLANE_R, // rootIx
+ 2, // offset
};
break;
}
@@ -431,14 +459,17 @@
return C2_OK;
}
-c2_status_t C2AllocationGralloc::unmap(C2Fence *fenceFd /* nullable */) {
- // TODO: fence
+c2_status_t C2AllocationGralloc::unmap(
+ uint8_t **addr, C2Rect rect, C2Fence *fence /* nullable */) {
+ // TODO: check addr and size, use fence
+ (void)addr;
+ (void)rect;
c2_status_t err = C2_OK;
mMapper->unlock(
const_cast<native_handle_t *>(mBuffer),
- [&err, &fenceFd](const auto &maperr, const auto &releaseFence) {
+ [&err, &fence](const auto &maperr, const auto &releaseFence) {
// TODO
- (void) fenceFd;
+ (void) fence;
(void) releaseFence;
err = maperr2error(maperr);
if (err == C2_OK) {
diff --git a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
index a9613e4..6b0cffb 100644
--- a/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
+++ b/media/libstagefright/codec2/vndk/C2AllocatorIon.cpp
@@ -117,9 +117,9 @@
public:
/* Interface methods */
virtual c2_status_t map(
- size_t offset, size_t size, C2MemoryUsage usage, int *fence,
+ size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence,
void **addr /* nonnull */) override;
- virtual c2_status_t unmap(void *addr, size_t size, int *fenceFd) override;
+ virtual c2_status_t unmap(void *addr, size_t size, C2Fence *fenceFd) override;
virtual ~C2AllocationIon() override;
virtual const C2Handle *handle() const override;
virtual id_t getAllocatorId() const override;
@@ -218,8 +218,8 @@
return new Impl(ionFd, size, bufferFd, buffer, id, ret);
}
- c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd, void **addr) {
- (void)fenceFd; // TODO: wait for fence
+ c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence, void **addr) {
+ (void)fence; // TODO: wait for fence
*addr = nullptr;
if (mMapSize > 0) {
// TODO: technically we should return DUPLICATE here, but our block views don't
@@ -272,7 +272,7 @@
return err;
}
- c2_status_t unmap(void *addr, size_t size, int *fenceFd) {
+ c2_status_t unmap(void *addr, size_t size, C2Fence *fence) {
if (mMapFd < 0 || mMapSize == 0) {
return C2_NOT_FOUND;
}
@@ -284,8 +284,8 @@
if (err != 0) {
return c2_map_errno<EINVAL>(errno);
}
- if (fenceFd) {
- *fenceFd = -1; // not using fences
+ if (fence) {
+ *fence = C2Fence(); // not using fences
}
mMapSize = 0;
return C2_OK;
@@ -334,12 +334,12 @@
};
c2_status_t C2AllocationIon::map(
- size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd, void **addr) {
- return mImpl->map(offset, size, usage, fenceFd, addr);
+ size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence, void **addr) {
+ return mImpl->map(offset, size, usage, fence, addr);
}
-c2_status_t C2AllocationIon::unmap(void *addr, size_t size, int *fenceFd) {
- return mImpl->unmap(addr, size, fenceFd);
+c2_status_t C2AllocationIon::unmap(void *addr, size_t size, C2Fence *fence) {
+ return mImpl->unmap(addr, size, fence);
}
c2_status_t C2AllocationIon::status() const {
diff --git a/media/libstagefright/codec2/vndk/C2Buffer.cpp b/media/libstagefright/codec2/vndk/C2Buffer.cpp
index 47fdca1..dc765f5 100644
--- a/media/libstagefright/codec2/vndk/C2Buffer.cpp
+++ b/media/libstagefright/codec2/vndk/C2Buffer.cpp
@@ -414,6 +414,7 @@
if (mError != C2_OK) {
memset(&mLayout, 0, sizeof(mLayout));
memset(mData, 0, sizeof(mData));
+ memset(mOffsetData, 0, sizeof(mData));
} else {
// TODO: validate plane layout and
// adjust data pointers to the crop region's top left corner.
@@ -424,14 +425,16 @@
if (crop.left % colSampling || crop.right() % colSampling
|| crop.top % rowSampling || crop.bottom() % rowSampling) {
// cannot calculate data pointer
- mImpl->getAllocation()->unmap(nullptr);
+ mImpl->getAllocation()->unmap(mData, crop, nullptr);
memset(&mLayout, 0, sizeof(mLayout));
memset(mData, 0, sizeof(mData));
+ memset(mOffsetData, 0, sizeof(mData));
mError = C2_BAD_VALUE;
return;
}
- mData[planeIx] += (ssize_t)crop.left * mLayout.planes[planeIx].colInc
- + (ssize_t)crop.top * mLayout.planes[planeIx].rowInc;
+ mOffsetData[planeIx] =
+ mData[planeIx] + (ssize_t)crop.left * mLayout.planes[planeIx].colInc
+ + (ssize_t)crop.top * mLayout.planes[planeIx].rowInc;
}
}
}
@@ -441,12 +444,13 @@
// CHECK(error != C2_OK);
memset(&mLayout, 0, sizeof(mLayout));
memset(mData, 0, sizeof(mData));
+ memset(mOffsetData, 0, sizeof(mData));
}
public:
~Mapped() {
if (mData[0] != nullptr) {
- mImpl->getAllocation()->unmap(nullptr);
+ mImpl->getAllocation()->unmap(mData, mImpl->crop(), nullptr);
}
}
@@ -454,7 +458,7 @@
c2_status_t error() const { return mError; }
/** returns data pointer */
- uint8_t *const *data() const { return mData; }
+ uint8_t *const *data() const { return mOffsetData; }
/** returns the plane layout */
C2PlanarLayout layout() const { return mLayout; }
@@ -467,6 +471,7 @@
bool mWritable;
c2_status_t mError;
uint8_t *mData[C2PlanarLayout::MAX_NUM_PLANES];
+ uint8_t *mOffsetData[C2PlanarLayout::MAX_NUM_PLANES];
C2PlanarLayout mLayout;
};
diff --git a/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h b/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
index 7168498..f6d8b98 100644
--- a/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
+++ b/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
@@ -83,8 +83,5 @@
typedef void (*DestroyCodec2FactoryFunc)(::C2ComponentFactory*);
};
-namespace android {
- typedef ::C2ComponentFactory C2ComponentFactory;
-}
#endif // STAGEFRIGHT_CODEC2_COMPONENT_FACTORY_H_
diff --git a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
index 1accc2c..710e74b 100644
--- a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
+++ b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
@@ -62,7 +62,7 @@
#undef DEFINE_C2_ENUM_VALUE_AUTO_HELPER
#define DEFINE_C2_ENUM_VALUE_AUTO_HELPER(name, type, prefix, ...) \
-template<> C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
+template<> C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
return C2ParamUtils::sanitizeEnumValues( \
std::vector<C2Value::Primitive> { _C2_MAP(_C2_GET_ENUM_VALUE, type, __VA_ARGS__) }, \
{ _C2_MAP(_C2_GET_ENUM_NAME, type, __VA_ARGS__) }, \
@@ -71,7 +71,7 @@
#undef DEFINE_C2_ENUM_VALUE_CUSTOM_HELPER
#define DEFINE_C2_ENUM_VALUE_CUSTOM_HELPER(name, type, names, ...) \
-template<> C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
+template<> C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
return C2ParamUtils::customEnumValues( \
std::vector<std::pair<C2StringLiteral, name>> names); \
}
@@ -242,11 +242,11 @@
}
template<typename T>
- static C2FieldDescriptor::named_values_type sanitizeEnumValues(
+ static C2FieldDescriptor::NamedValuesType sanitizeEnumValues(
std::vector<T> values,
std::vector<C2StringLiteral> names,
C2StringLiteral prefix = NULL) {
- C2FieldDescriptor::named_values_type namedValues;
+ C2FieldDescriptor::NamedValuesType namedValues;
std::vector<C2String> sanitizedNames = sanitizeEnumValueNames(names, prefix);
for (size_t i = 0; i < values.size() && i < sanitizedNames.size(); ++i) {
namedValues.emplace_back(sanitizedNames[i], values[i]);
@@ -255,9 +255,9 @@
}
template<typename E>
- static C2FieldDescriptor::named_values_type customEnumValues(
+ static C2FieldDescriptor::NamedValuesType customEnumValues(
std::vector<std::pair<C2StringLiteral, E>> items) {
- C2FieldDescriptor::named_values_type namedValues;
+ C2FieldDescriptor::NamedValuesType namedValues;
for (auto &item : items) {
namedValues.emplace_back(item.first, item.second);
}
diff --git a/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h b/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
index c805830..34797a9 100644
--- a/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
+++ b/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
@@ -20,19 +20,19 @@
#include <C2Param.h>
struct C2_HIDE _C2ParamInspector {
- inline static uint32_t getIndex(const C2ParamField &pf) {
+ inline static uint32_t GetIndex(const C2ParamField &pf) {
return pf._mIndex;
}
- inline static uint32_t getOffset(const C2ParamField &pf) {
+ inline static uint32_t GetOffset(const C2ParamField &pf) {
return pf._mFieldId._mOffset;
}
- inline static uint32_t getSize(const C2ParamField &pf) {
+ inline static uint32_t GetSize(const C2ParamField &pf) {
return pf._mFieldId._mSize;
}
- inline static uint32_t getAttrib(const C2ParamDescriptor &pd) {
+ inline static uint32_t GetAttrib(const C2ParamDescriptor &pd) {
return pd._mAttrib;
}
@@ -40,8 +40,15 @@
C2ParamField CreateParamField(C2Param::Index index, uint32_t offset, uint32_t size) {
return C2ParamField(index, offset, size);
}
-};
+ inline static
+ C2ParamField CreateParamField(C2Param::Index index, _C2FieldId field) {
+ return C2ParamField(index, field._mOffset, field._mSize);
+ }
+
+ // expose attributes
+ typedef C2ParamDescriptor::attrib_t attrib_t;
+};
#endif // ANDROID_STAGEFRIGHT_C2PARAM_INTERNAL_H_
diff --git a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
index b57c2aa..3f09e0a 100644
--- a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
+++ b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
@@ -676,14 +676,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAac("aac", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("aac", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -697,12 +697,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAacDecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
index 6f1b325..74f5a7a 100644
--- a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
+++ b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
@@ -208,7 +208,7 @@
}
std::unique_ptr<C2StreamCsdInfo::output> csd =
- C2StreamCsdInfo::output::alloc_unique(encInfo.confSize, 0u);
+ C2StreamCsdInfo::output::AllocUnique(encInfo.confSize, 0u);
// TODO: check NO_MEMORY
memcpy(csd->m.value, encInfo.confBuf, encInfo.confSize);
ALOGV("put csd");
@@ -382,14 +382,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAacEnc("aacenc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("aacenc", id, deleter)
.inputFormat(C2FormatAudio)
@@ -403,12 +403,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAacEncFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
index 306d0a5..3c09e37 100644
--- a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
+++ b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
@@ -266,9 +266,9 @@
mBlocksPerSecond(0u, 0),
mParamReflector(new ParamReflector) {
ALOGV("in %s", __func__);
- mInputPortMime = C2PortMimeConfig::input::alloc_unique(strlen(CODEC_MIME_TYPE) + 1);
+ mInputPortMime = C2PortMimeConfig::input::AllocUnique(strlen(CODEC_MIME_TYPE) + 1);
strcpy(mInputPortMime->m.value, CODEC_MIME_TYPE);
- mOutputPortMime = C2PortMimeConfig::output::alloc_unique(strlen(MEDIA_MIMETYPE_VIDEO_RAW) + 1);
+ mOutputPortMime = C2PortMimeConfig::output::AllocUnique(strlen(MEDIA_MIMETYPE_VIDEO_RAW) + 1);
strcpy(mOutputPortMime->m.value, MEDIA_MIMETYPE_VIDEO_RAW);
mVideoSize.width = 320;
@@ -281,7 +281,7 @@
mMaxVideoSizeHint.width = H264_MAX_FRAME_WIDTH;
mMaxVideoSizeHint.height = H264_MAX_FRAME_HEIGHT;
- mOutputBlockPools = C2PortBlockPoolsTuning::output::alloc_unique({});
+ mOutputBlockPools = C2PortBlockPoolsTuning::output::AllocUnique({});
auto insertParam = [¶ms = mParams] (C2Param *param) {
params[param->index()] = param;
@@ -1328,14 +1328,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAvcDec("avc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("avc", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -1350,12 +1350,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAvcDecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp b/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
index 9ea3589..e105460 100644
--- a/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
+++ b/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
@@ -1044,7 +1044,7 @@
mSpsPpsHeaderReceived = true;
std::unique_ptr<C2StreamCsdInfo::output> csd =
- C2StreamCsdInfo::output::alloc_unique(s_encode_op.s_out_buf.u4_bytes, 0u);
+ C2StreamCsdInfo::output::AllocUnique(s_encode_op.s_out_buf.u4_bytes, 0u);
memcpy(csd->m.value, header, s_encode_op.s_out_buf.u4_bytes);
work->worklets.front()->output.configUpdate.push_back(std::move(csd));
@@ -1210,14 +1210,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAvcEnc("avcenc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("avcenc", id, deleter)
.inputFormat(C2FormatVideo)
@@ -1231,12 +1231,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAvcEncFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/cmds/codec2.cpp b/media/libstagefright/codecs/cmds/codec2.cpp
index 95b0c61..26f96c3 100644
--- a/media/libstagefright/codecs/cmds/codec2.cpp
+++ b/media/libstagefright/codecs/cmds/codec2.cpp
@@ -67,7 +67,7 @@
class LinearBuffer : public C2Buffer {
public:
explicit LinearBuffer(const std::shared_ptr<C2LinearBlock> &block)
- : C2Buffer({ block->share(block->offset(), block->size(), ::android::C2Fence()) }) {}
+ : C2Buffer({ block->share(block->offset(), block->size(), ::C2Fence()) }) {}
};
class Listener;
@@ -215,7 +215,7 @@
(void)component->setListener_vb(mListener, C2_DONT_BLOCK);
std::unique_ptr<C2PortBlockPoolsTuning::output> pools =
- C2PortBlockPoolsTuning::output::alloc_unique({ (uint64_t)C2BlockPool::BASIC_GRAPHIC });
+ C2PortBlockPoolsTuning::output::AllocUnique({ (uint64_t)C2BlockPool::BASIC_GRAPHIC });
std::vector<std::unique_ptr<C2SettingResult>> result;
(void)component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result);
component->start();
diff --git a/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp b/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
index a26dbb9..e830324 100644
--- a/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
+++ b/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
@@ -207,14 +207,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftG711(COMPONENT_NAME, id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder(COMPONENT_NAME, id, deleter)
.inputFormat(C2FormatCompressed)
@@ -228,12 +228,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftG711DecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
index c34a6f0..9e8b527 100644
--- a/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
@@ -398,14 +398,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftMP3("mp3", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("mp3", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -419,12 +419,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftMp3DecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/packages/MediaComponents/res/layout/media_controller.xml b/packages/MediaComponents/res/layout/media_controller.xml
index f9ebd44..73c1b38 100644
--- a/packages/MediaComponents/res/layout/media_controller.xml
+++ b/packages/MediaComponents/res/layout/media_controller.xml
@@ -71,7 +71,7 @@
android:orientation="horizontal">
<LinearLayout
- android:id="@+id/ad"
+ android:id="@+id/ad_external_link"
android:clickable="true"
android:gravity="center"
android:layout_width="wrap_content"
@@ -80,7 +80,8 @@
android:layout_centerVertical="true"
android:paddingLeft="5dip"
android:paddingRight="10dip"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:visibility="gone">
<TextView
android:id="@+id/ad_text"
@@ -88,7 +89,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingRight="5dip"
- android:text="Visit Advertiser"
+ android:text="@string/MediaControlView2_ad_text"
android:textSize="10sp"
android:textColor="#FFFFFFFF" />
@@ -163,14 +164,35 @@
android:textStyle="bold"
android:textColor="#BBBBBB" />
+ <TextView
+ android:id="@+id/ad_skip_time"
+ android:gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:textSize="12sp"
+ android:textColor="#FFFFFF"
+ android:visibility="gone" />
+
<LinearLayout
android:id="@+id/basic_controls"
+ android:gravity="center"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal" >
+ <TextView
+ android:id="@+id/ad_remaining"
+ android:gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:textSize="12sp"
+ android:textColor="#FFFFFF"
+ android:visibility="gone" />
+
<ImageButton
android:id="@+id/subtitle"
android:scaleType="fitCenter"
diff --git a/packages/MediaComponents/res/values/strings.xml b/packages/MediaComponents/res/values/strings.xml
index 35db0e5..333d400 100644
--- a/packages/MediaComponents/res/values/strings.xml
+++ b/packages/MediaComponents/res/values/strings.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
-<resources>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
<!-- Name for the default system route prior to Jellybean. [CHAR LIMIT=30] -->
<string name="mr_system_route_name">System</string>
@@ -92,4 +94,15 @@
<string name="VideoView2_error_text_unknown">Can\'t play this video.</string>
<!-- Button to close error alert when a video cannot be played. -->
<string name="VideoView2_error_button">OK</string>
+
+ <!-- Text for displaying ad skip wait time. -->
+ <string name="MediaControlView2_ad_skip_wait_time">
+ You can skip Ad in <xliff:g id="wait_time" example="5">%1$d</xliff:g>s
+ </string>
+ <!-- Text for displaying ad total remaining time. -->
+ <string name="MediaControlView2_ad_remaining_time">
+ Ad · <xliff:g id="remaining_time" example="1:15">%1$s</xliff:g> remaining
+ </string>
+ <!-- Placeholder text indicating that the user can press the button to go to an external website. -->
+ <string name="MediaControlView2_ad_text">Visit Advertiser</string>
</resources>
diff --git a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
index 318cbf9..e937659 100644
--- a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
@@ -33,6 +33,7 @@
import android.widget.ImageButton;
import android.widget.MediaControlView2;
import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
@@ -58,11 +59,15 @@
static final String KEY_STATE_CONTAINS_SUBTITLE = "StateContainsSubtitle";
static final String EVENT_UPDATE_SUBTITLE_STATUS = "UpdateSubtitleStatus";
+ // TODO: Remove this once integrating with MediaSession2 & MediaMetadata2
+ static final String KEY_STATE_IS_ADVERTISEMENT = "MediaTypeAdvertisement";
+ static final String EVENT_UPDATE_MEDIA_TYPE_STATUS = "UpdateMediaTypeStatus";
+
private static final int MAX_PROGRESS = 1000;
private static final int DEFAULT_PROGRESS_UPDATE_TIME_MS = 1000;
-
private static final int REWIND_TIME_MS = 10000;
private static final int FORWARD_TIME_MS = 30000;
+ private static final int AD_SKIP_WAIT_TIME_MS = 5000;
private MediaController mController;
private MediaController.TransportControls mControls;
@@ -71,8 +76,12 @@
private ProgressBar mProgress;
private TextView mEndTime, mCurrentTime;
private TextView mTitleView;
+ private TextView mAdSkipView, mAdRemainingView;
+ private View mAdExternalLink;
+ private View mRoot;
private int mDuration;
private int mPrevState;
+ private int mPrevLeftBarWidth;
private long mPlaybackActions;
private boolean mDragging;
private boolean mIsFullScreen;
@@ -81,6 +90,7 @@
private boolean mSubtitleIsEnabled;
private boolean mContainsSubtitle;
private boolean mSeekAvailable;
+ private boolean mIsAdvertisement;
private ImageButton mPlayPauseButton;
private ImageButton mFfwdButton;
private ImageButton mRewButton;
@@ -118,8 +128,9 @@
@Override
public void initialize(@Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
// Inflate MediaControlView2 from XML
- View root = makeControllerView();
- mInstance.addView(root);
+ mRoot = makeControllerView();
+ mRoot.addOnLayoutChangeListener(mTitleBarLayoutChangeListener);
+ mInstance.addView(mRoot);
}
@Override
@@ -140,6 +151,8 @@
@Override
public void setButtonVisibility_impl(int button, int visibility) {
+ // TODO: add member variables for Fast-Forward/Prvious/Rewind buttons to save visibility in
+ // order to prevent being overriden inside updateLayout().
switch (button) {
case MediaControlView2.BUTTON_PLAY_PAUSE:
if (mPlayPauseButton != null && canPause()) {
@@ -421,6 +434,10 @@
mCurrentTime = v.findViewById(R.id.time_current);
mFormatBuilder = new StringBuilder();
mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
+
+ mAdSkipView = v.findViewById(R.id.ad_skip_time);
+ mAdRemainingView = v.findViewById(R.id.ad_remaining);
+ mAdExternalLink = v.findViewById(R.id.ad_external_link);
}
/**
@@ -505,6 +522,36 @@
mCurrentTime.setText(stringForTime(currentPosition));
}
+ if (mIsAdvertisement) {
+ // Update the remaining number of seconds until the first 5 seconds of the
+ // advertisement.
+ if (mAdSkipView != null) {
+ if (currentPosition <= AD_SKIP_WAIT_TIME_MS) {
+ if (mAdSkipView.getVisibility() == View.GONE) {
+ mAdSkipView.setVisibility(View.VISIBLE);
+ }
+ String skipTimeText = ApiHelper.getLibResources().getString(
+ R.string.MediaControlView2_ad_skip_wait_time,
+ ((AD_SKIP_WAIT_TIME_MS - currentPosition) / 1000 + 1));
+ mAdSkipView.setText(skipTimeText);
+ } else {
+ if (mAdSkipView.getVisibility() == View.VISIBLE) {
+ mAdSkipView.setVisibility(View.GONE);
+ mNextButton.setEnabled(true);
+ mNextButton.clearColorFilter();
+ }
+ }
+ }
+ // Update the remaining number of seconds of the advertisement.
+ if (mAdRemainingView != null) {
+ int remainingTime =
+ (mDuration - currentPosition < 0) ? 0 : (mDuration - currentPosition);
+ String remainingTimeText = ApiHelper.getLibResources().getString(
+ R.string.MediaControlView2_ad_remaining_time,
+ stringForTime(remainingTime));
+ mAdRemainingView.setText(remainingTimeText);
+ }
+ }
return currentPosition;
}
@@ -693,6 +740,36 @@
}
};
+ // The title bar is made up of two separate LinearLayouts. If the sum of the two bars are
+ // greater than the length of the title bar, reduce the size of the left bar (which makes the
+ // TextView that contains the title of the media file shrink).
+ private final View.OnLayoutChangeListener mTitleBarLayoutChangeListener
+ = new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
+ int oldTop, int oldRight, int oldBottom) {
+ if (mRoot != null) {
+ int titleBarWidth = mRoot.findViewById(R.id.title_bar).getWidth();
+
+ View leftBar = mRoot.findViewById(R.id.title_bar_left);
+ View rightBar = mRoot.findViewById(R.id.title_bar_right);
+ int leftBarWidth = leftBar.getWidth();
+ int rightBarWidth = rightBar.getWidth();
+
+ RelativeLayout.LayoutParams params =
+ (RelativeLayout.LayoutParams) leftBar.getLayoutParams();
+ if (leftBarWidth + rightBarWidth > titleBarWidth) {
+ params.width = titleBarWidth - rightBarWidth;
+ mPrevLeftBarWidth = leftBarWidth;
+ } else if (leftBarWidth + rightBarWidth < titleBarWidth && mPrevLeftBarWidth != 0) {
+ params.width = mPrevLeftBarWidth;
+ mPrevLeftBarWidth = 0;
+ }
+ leftBar.setLayoutParams(params);
+ }
+ }
+ };
+
private void updateDuration() {
if (mMetadata != null) {
if (mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
@@ -711,6 +788,39 @@
}
}
+ private void updateLayout() {
+ if (mIsAdvertisement) {
+ mRewButton.setVisibility(View.GONE);
+ mFfwdButton.setVisibility(View.GONE);
+ mPrevButton.setVisibility(View.GONE);
+ mCurrentTime.setVisibility(View.GONE);
+ mEndTime.setVisibility(View.GONE);
+
+ mAdSkipView.setVisibility(View.VISIBLE);
+ mAdRemainingView.setVisibility(View.VISIBLE);
+ mAdExternalLink.setVisibility(View.VISIBLE);
+
+ mProgress.setEnabled(false);
+ mNextButton.setEnabled(false);
+ mNextButton.setColorFilter(R.integer.gray);
+ } else {
+ mRewButton.setVisibility(View.VISIBLE);
+ mFfwdButton.setVisibility(View.VISIBLE);
+ mPrevButton.setVisibility(View.VISIBLE);
+ mCurrentTime.setVisibility(View.VISIBLE);
+ mEndTime.setVisibility(View.VISIBLE);
+
+ mAdSkipView.setVisibility(View.GONE);
+ mAdRemainingView.setVisibility(View.GONE);
+ mAdExternalLink.setVisibility(View.GONE);
+
+ mProgress.setEnabled(true);
+ mNextButton.setEnabled(true);
+ mNextButton.clearColorFilter();
+ disableUnsupportedButtons();
+ }
+ }
+
private class MediaControllerCallback extends MediaController.Callback {
@Override
public void onPlaybackStateChanged(PlaybackState state) {
@@ -818,6 +928,12 @@
}
mContainsSubtitle = newSubtitleStatus;
}
+ } else if (event.equals(EVENT_UPDATE_MEDIA_TYPE_STATUS)) {
+ boolean newStatus = extras.getBoolean(KEY_STATE_IS_ADVERTISEMENT);
+ if (newStatus != mIsAdvertisement) {
+ mIsAdvertisement = newStatus;
+ updateLayout();
+ }
}
}
}
diff --git a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
index a8ce18b..805c262 100644
--- a/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/VideoView2Impl.java
@@ -27,6 +27,7 @@
import android.media.MediaPlayerInterface;
import android.media.Cea708CaptionRenderer;
import android.media.ClosedCaptionRenderer;
+import android.media.MediaMetadata2;
import android.media.Metadata;
import android.media.PlaybackParams;
import android.media.SRTRenderer;
@@ -107,6 +108,9 @@
private MediaRouter mMediaRouter;
private MediaRouteSelector mRouteSelector;
private Metadata mMetadata;
+ private MediaMetadata2 mMediaMetadata;
+ private boolean mNeedUpdateMediaType;
+ private Bundle mMediaTypeData;
private String mTitle;
private PlaybackState.Builder mStateBuilder;
@@ -235,6 +239,32 @@
}
@Override
+ public MediaMetadata2 getMediaMetadata_impl() {
+ return mMediaMetadata;
+ }
+
+ @Override
+ public void setMediaMetadata_impl(MediaMetadata2 metadata) {
+ // TODO: integrate this with MediaSession2#MediaItem2
+ mMediaMetadata = metadata;
+
+ // TODO: add support for handling website link
+ mMediaTypeData = new Bundle();
+ boolean isAd = metadata == null ?
+ false : metadata.getLong(MediaMetadata2.METADATA_KEY_ADVERTISEMENT) != 0;
+ mMediaTypeData.putBoolean(
+ MediaControlView2Impl.KEY_STATE_IS_ADVERTISEMENT, isAd);
+
+ if (mMediaSession != null) {
+ mMediaSession.sendSessionEvent(
+ MediaControlView2Impl.EVENT_UPDATE_MEDIA_TYPE_STATUS, mMediaTypeData);
+ } else {
+ // Update later inside OnPreparedListener after MediaSession is initialized.
+ mNeedUpdateMediaType = true;
+ }
+ }
+
+ @Override
public void setSubtitleEnabled_impl(boolean enable) {
if (enable != mSubtitleEnabled) {
selectOrDeselectSubtitle(enable);
@@ -866,6 +896,13 @@
if (mMediaSession != null) {
mMediaSession.setMetadata(builder.build());
+
+ // TODO: merge this code with the above code when integrating with MediaSession2.
+ if (mNeedUpdateMediaType) {
+ mMediaSession.sendSessionEvent(
+ MediaControlView2Impl.EVENT_UPDATE_MEDIA_TYPE_STATUS, mMediaTypeData);
+ mNeedUpdateMediaType = false;
+ }
}
}
};
diff --git a/services/minijail/Android.bp b/services/minijail/Android.bp
new file mode 100644
index 0000000..07a94cc
--- /dev/null
+++ b/services/minijail/Android.bp
@@ -0,0 +1,38 @@
+minijail_common_cflags = [
+ "-Wall",
+ "-Werror",
+]
+
+cc_defaults {
+ name: "libavservices_minijail_defaults",
+ srcs: ["minijail.cpp"],
+ cflags: minijail_common_cflags,
+ shared_libs: [
+ "libbase",
+ "libminijail",
+ ],
+}
+
+// Small library for media.extractor and media.codec sandboxing.
+cc_library_shared {
+ name: "libavservices_minijail",
+ defaults: ["libavservices_minijail_defaults"],
+ export_include_dirs: ["."],
+}
+
+// Small library for media.extractor and media.codec sandboxing.
+cc_library_shared {
+ name: "libavservices_minijail_vendor",
+ vendor: true,
+ defaults: ["libavservices_minijail_defaults"],
+ export_include_dirs: ["."],
+}
+
+// Unit tests.
+cc_test {
+ name: "libavservices_minijail_unittest",
+ defaults: ["libavservices_minijail_defaults"],
+ srcs: [
+ "av_services_minijail_unittest.cpp",
+ ],
+}
diff --git a/services/minijail/Android.mk b/services/minijail/Android.mk
deleted file mode 100644
index 67055a8..0000000
--- a/services/minijail/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-minijail_common_cflags := -Wall -Werror
-
-# Small library for media.extractor and media.codec sandboxing.
-include $(CLEAR_VARS)
-LOCAL_MODULE := libavservices_minijail
-LOCAL_SRC_FILES := minijail.cpp
-LOCAL_CFLAGS := $(minijail_common_cflags)
-LOCAL_SHARED_LIBRARIES := libbase libminijail
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Small library for media.extractor and media.codec sandboxing.
-include $(CLEAR_VARS)
-LOCAL_MODULE := libavservices_minijail_vendor
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := minijail.cpp
-LOCAL_CFLAGS := $(minijail_common_cflags)
-LOCAL_SHARED_LIBRARIES := libbase libminijail
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Unit tests.
-include $(CLEAR_VARS)
-LOCAL_MODULE := libavservices_minijail_unittest
-LOCAL_SRC_FILES := minijail.cpp av_services_minijail_unittest.cpp
-LOCAL_CFLAGS := $(minijail_common_cflags)
-LOCAL_SHARED_LIBRARIES := libbase libminijail
-include $(BUILD_NATIVE_TEST)