Skip to content

Commit

Permalink
[droidmedia] Rename AsyncDecodingSource to AsyncCodecSource. JB#57149
Browse files Browse the repository at this point in the history
  • Loading branch information
d-grigorev committed Feb 8, 2022
1 parent f67927f commit 4d8c240
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ LOCAL_SRC_FILES := droidmedia.cpp \
private.cpp

ifeq ($(shell test $(ANDROID_MAJOR) -ge 7 && echo true),true)
LOCAL_SRC_FILES += AsyncDecodingSource.cpp
LOCAL_SRC_FILES += AsyncCodecSource.cpp
endif

LOCAL_SHARED_LIBRARIES := libc \
Expand Down
38 changes: 19 additions & 19 deletions AsyncDecodingSource.cpp → AsyncCodecSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

//#define LOG_NDEBUG 0
#include "AsyncDecodingSource.h"
#include "AsyncCodecSource.h"
#include <utils/Log.h>
#include <gui/Surface.h>
#if ANDROID_MAJOR >= 11
Expand Down Expand Up @@ -44,12 +44,12 @@ using namespace android;
typedef ABuffer MediaCodecBuffer;
#endif

#define LOG_TAG "AsyncDecodingSource"
#define LOG_TAG "AsyncCodecSource"



//static
sp<AsyncDecodingSource> AsyncDecodingSource::Create(
sp<AsyncCodecSource> AsyncCodecSource::Create(
const sp<MediaSource> &source, const sp<AMessage> &srcFormat,
bool isEncoder, uint32_t flags, const sp<ANativeWindow> &nativeWindow,
const sp<ALooper> &looper, const char *desiredCodec) {
Expand Down Expand Up @@ -84,15 +84,15 @@ sp<AsyncDecodingSource> AsyncDecodingSource::Create(
}

ALOGV("Attempting to allocate codec '%s'", componentName.c_str());
sp<AsyncDecodingSource> res = new AsyncDecodingSource(componentName, source, looper,
sp<AsyncCodecSource> res = new AsyncCodecSource(componentName, source, looper,
strcmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS) == 0);

if (res->mCodec != NULL) {
ALOGI("Successfully allocated codec '%s'", componentName.c_str());
if (res->configure(format, surface, isEncoder ? MediaCodec::CONFIGURE_FLAG_ENCODE : 0)) {
if (surface != nullptr) {
#if ANDROID_MAJOR > 7
nativeWindowConnect(nativeWindow.get(), "AsyncDecodingSource");
nativeWindowConnect(nativeWindow.get(), "AsyncCodecSource");
#else
native_window_api_connect(nativeWindow.get(),
NATIVE_WINDOW_API_MEDIA);
Expand All @@ -108,11 +108,11 @@ sp<AsyncDecodingSource> AsyncDecodingSource::Create(
}
}

ALOGE("No matching decoder! (mime: %s)", mime);
ALOGE("No matching codec! (mime: %s)", mime);
return nullptr;
}

AsyncDecodingSource::AsyncDecodingSource(
AsyncCodecSource::AsyncCodecSource(
const AString &codecName, const sp<MediaSource> &source, const sp<ALooper> &looper,
bool isVorbis)
: mComponentName(codecName),
Expand All @@ -127,18 +127,18 @@ AsyncDecodingSource::AsyncDecodingSource(

mCodec = MediaCodec::CreateByComponentName(mCodecLooper, mComponentName);

mReflector = new AHandlerReflector<AsyncDecodingSource>(this);
mReflector = new AHandlerReflector<AsyncCodecSource>(this);
mLooper->registerHandler(mReflector);
mNotify = new AMessage(0, mReflector);
}

AsyncDecodingSource::~AsyncDecodingSource() {
AsyncCodecSource::~AsyncCodecSource() {
mCodec->release();
mCodecLooper->stop();
mLooper->unregisterHandler(mReflector->id());
}

bool AsyncDecodingSource::configure(const sp<AMessage> format, const sp<Surface> surface, uint32_t flags) {
bool AsyncCodecSource::configure(const sp<AMessage> format, const sp<Surface> surface, uint32_t flags) {
mCodec->setCallback(mNotify);
status_t err = mCodec->configure(format, surface, nullptr /* crypto */, flags);
if (err != OK) {
Expand All @@ -159,7 +159,7 @@ bool AsyncDecodingSource::configure(const sp<AMessage> format, const sp<Surface>
return true;
}

status_t AsyncDecodingSource::start(MetaData *params) {
status_t AsyncCodecSource::start(MetaData *params) {
(void)params;
Mutexed<Output>::Locked me(mOutput);

Expand All @@ -181,7 +181,7 @@ status_t AsyncDecodingSource::start(MetaData *params) {
return res;
}

status_t AsyncDecodingSource::stop() {
status_t AsyncCodecSource::stop() {
Mutexed<Output>::Locked me(mOutput);
if (mState != STARTED && mState != ERROR) {
return -EINVAL;
Expand All @@ -207,17 +207,17 @@ status_t AsyncDecodingSource::stop() {
return res1 != OK ? res1 : res2;
}

sp<MetaData> AsyncDecodingSource::getFormat() {
sp<MetaData> AsyncCodecSource::getFormat() {
Mutexed<sp<MetaData>>::Locked meta(mMeta);
return *meta;
}

AsyncDecodingSource::Output::Output()
AsyncCodecSource::Output::Output()
: mReachedEOS(false),
mReading(false) {
}

status_t AsyncDecodingSource::read(
status_t AsyncCodecSource::read(
DroidMediaBuffer **buffer,
const ReadOptions *options) {
*buffer = nullptr;
Expand Down Expand Up @@ -267,7 +267,7 @@ status_t AsyncDecodingSource::read(
return res;
}

void AsyncDecodingSource::onMessageReceived(const sp<AMessage> &msg) {
void AsyncCodecSource::onMessageReceived(const sp<AMessage> &msg) {

if (mCodec == nullptr) {
return;
Expand Down Expand Up @@ -409,15 +409,15 @@ void AsyncDecodingSource::onMessageReceived(const sp<AMessage> &msg) {
} else if (cbID == MediaCodec::CB_ERROR) {
status_t err;
CHECK(msg->findInt32("err", &err));
ALOGE("Decoder (%s) reported error : 0x%d",
ALOGE("Codec (%s) reported error : 0x%d",
mComponentName.c_str(), err);
mState = ERROR;
} else {
ALOGE("Decoder (%s) unhandled callback id : 0x%d", mComponentName.c_str(), cbID);
ALOGE("Codec (%s) unhandled callback id : 0x%d", mComponentName.c_str(), cbID);
}
}

status_t AsyncDecodingSource::setParameters(const sp<AMessage> &params)
status_t AsyncCodecSource::setParameters(const sp<AMessage> &params)
{
if (mState == STARTED && mCodec.get()) {
return mCodec->setParameters(params);
Expand Down
14 changes: 7 additions & 7 deletions AsyncDecodingSource.h → AsyncCodecSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

#ifndef ASYNC_DECODING_SOURCE_H_
#define ASYNC_DECODING_SOURCE_H_
#ifndef ASYNC_CODEC_SOURCE_H_
#define ASYNC_CODEC_SOURCE_H_

#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/Mutexed.h>
Expand Down Expand Up @@ -46,9 +46,9 @@ struct MediaCodec;
class MetaData;
class Surface;

class AsyncDecodingSource : public MediaSource {
class AsyncCodecSource : public MediaSource {
public:
static sp<AsyncDecodingSource> Create(const sp<MediaSource> &source,
static sp<AsyncCodecSource> Create(const sp<MediaSource> &source,
const sp<AMessage> &format, bool isEncoder, uint32_t flags,
const sp<ANativeWindow> &nativeWindow, const sp<ALooper> &looper,
const char *desiredCodec = NULL);
Expand All @@ -57,7 +57,7 @@ class AsyncDecodingSource : public MediaSource {
const sp<Surface> surface,
uint32_t flags = 0);

virtual ~AsyncDecodingSource();
virtual ~AsyncCodecSource();

// starts this source (and its underlying source). |params| is ignored.
virtual status_t start(MetaData *params = NULL);
Expand All @@ -82,7 +82,7 @@ class AsyncDecodingSource : public MediaSource {
status_t setParameters(const sp<AMessage> &params);
private:
// Construct this using a codec, source and looper.
AsyncDecodingSource(
AsyncCodecSource(
const AString &codecName, const sp<MediaSource> &source, const sp<ALooper> &looper,
bool isVorbis);

Expand All @@ -92,7 +92,7 @@ class AsyncDecodingSource : public MediaSource {
sp<ALooper> mLooper;
sp<ALooper> mCodecLooper;
sp<AMessage> mNotify = 0;
sp<AHandlerReflector<AsyncDecodingSource> > mReflector;
sp<AHandlerReflector<AsyncCodecSource> > mReflector;
List<size_t> mAvailInputIndices;
Mutexed<sp<MetaData>> mMeta;
bool mUsingSurface;
Expand Down
10 changes: 5 additions & 5 deletions droidmediacodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <media/stagefright/OMXCodec.h>
#else
#include <media/hardware/MetadataBufferType.h>
#include "AsyncDecodingSource.h"
#include "AsyncCodecSource.h"
#endif

#if ANDROID_MAJOR >= 9 && ANDROID_MAJOR <= 10
Expand Down Expand Up @@ -481,7 +481,7 @@ class DroidMediaCodecBuilder {
//TODO: time-scale

#if ANDROID_MAJOR > 6
return android::AsyncDecodingSource::Create(src, format, true /* isEncoder */,
return android::AsyncCodecSource::Create(src, format, true /* isEncoder */,
flags(), window, looper);
#elif ANDROID_MAJOR == 6
return android::MediaCodecSource::Create(looper, format, src, NULL, flags());
Expand Down Expand Up @@ -528,7 +528,7 @@ class DroidMediaCodecBuilder {
src,
NULL, flags(), window);
#else
return android::AsyncDecodingSource::Create(src, nullptr, false /* isEncoder */,
return android::AsyncCodecSource::Create(src, nullptr, false /* isEncoder */,
flags(), window, looper);
#endif
}
Expand Down Expand Up @@ -1176,8 +1176,8 @@ bool droid_media_codec_set_video_encoder_bitrate(DroidMediaCodec *codec, int32_t
ALOGI("Setting video encoder bitrate to %d bps", bitrate);
android::sp<android::AMessage> params = new android::AMessage();
params->setInt32("video-bitrate", bitrate);
android::sp<android::AsyncDecodingSource> src =
static_cast<android::AsyncDecodingSource*>(codec->m_codec.get());
android::sp<android::AsyncCodecSource> src =
static_cast<android::AsyncCodecSource*>(codec->m_codec.get());
android::status_t err = src->setParameters(params);
return err == android::NO_ERROR;
#else
Expand Down

0 comments on commit 4d8c240

Please sign in to comment.