Skip to content

Commit

Permalink
libstagefright_wfd: compilation fixes
Browse files Browse the repository at this point in the history
* Among others, adapt to the ABuffer API changes in
  "f03606d9 Move MediaBufferXXX from foundation to libmediaextractor"

Change-Id: Ie92fc035c6430f1458d45995a5b2627d0bc75122
Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: DennySPb <[email protected]>

libstagefright_wfd: Adapt to A11 changes

Change-Id: I69f13c93a68b1ad60e085000361331a3fdc98049
Signed-off-by: DennySPb <[email protected]>

libstagefright: Remove libmediaextractor dependency

Change-Id: Ifb564aafcf6f9bd45010500a589050b6577c0f7a
Signed-off-by: DennySPb <[email protected]>

Remove libmediaextractor dependency from libstagefright_wfd

Change-Id: I3d417d2f2ce468eb9d45f55f7818bb9a46348667
Signed-off-by: DennySPb <[email protected]>

libstagefright_wfd: Log MediaExtractor entry point to MediaMetrics

Change-Id: Ic8fac2cd5ee4d3bb59804e69efc1d5c482aa2417

Change-Id: Ie92fc035c6430f1458d45995a5b2627d0bc75122
Signed-off-by: Jprimero15 <[email protected]>
  • Loading branch information
vladimiroltean authored and fazilsheik96 committed Mar 1, 2025
1 parent c87d3d1 commit 14984c1
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 40 deletions.
1 change: 1 addition & 0 deletions media/libmedia/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ cc_library {
"libcamera_client",
"libstagefright_foundation",
"libgui",
"libui",
"libdl",
"libaudioclient",
"libmedia_codeclist",
Expand Down
4 changes: 2 additions & 2 deletions media/libmedia/IHDCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct BpHDCPObserver : public BpInterface<IHDCPObserver> {
}
};

IMPLEMENT_META_INTERFACE(HDCPObserver, "android.hardware.IHDCPObserver");
DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(HDCPObserver, "android.hardware.IHDCPObserver");

struct BpHDCP : public BpInterface<IHDCP> {
explicit BpHDCP(const sp<IBinder> &impl)
Expand Down Expand Up @@ -166,7 +166,7 @@ struct BpHDCP : public BpInterface<IHDCP> {
}
};

IMPLEMENT_META_INTERFACE(HDCP, "android.hardware.IHDCP");
DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(HDCP, "android.hardware.IHDCP");

status_t BnHDCPObserver::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
Expand Down
4 changes: 2 additions & 2 deletions media/libstagefright/SurfaceMediaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ status_t SurfaceMediaSource::stop()

#if DEBUG_PENDING_BUFFERS
for (size_t i = 0; i < mPendingBuffers.size(); ++i) {
ALOGI("%d: %p", i, mPendingBuffers.itemAt(i));
ALOGI("%zu: %p", i, mPendingBuffers.itemAt(i));
}
#endif

Expand Down Expand Up @@ -355,7 +355,7 @@ status_t SurfaceMediaSource::read(

(*buffer)->setObserver(this);
(*buffer)->add_ref();
(*buffer)->meta_data()->setInt64(kKeyTime, mCurrentTimestamp / 1000);
(*buffer)->meta_data().setInt64(kKeyTime, mCurrentTimestamp / 1000);
ALOGV("Frames encoded = %d, timestamp = %" PRId64 ", time diff = %" PRId64,
mNumFramesEncoded, mCurrentTimestamp / 1000,
mCurrentTimestamp / 1000 - prevTimeStamp / 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

#include <utils/threads.h>
#include <utils/Vector.h>
#include <media/MediaSource.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MediaBuffer.h>

#include <media/hardware/MetadataBufferType.h>

#include "foundation/ABase.h"
#include <media/stagefright/foundation/ABase.h>

namespace android {
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -187,7 +187,7 @@ class SurfaceMediaSource : public MediaSource,
size_t mNumPendingBuffers;

#if DEBUG_PENDING_BUFFERS
Vector<MediaBuffer *> mPendingBuffers;
Vector<MediaBufferBase *> mPendingBuffers;
#endif

// mCurrentTimestamp is the timestamp for the current texture. It
Expand Down
6 changes: 6 additions & 0 deletions media/libstagefright/wifi-display/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ cc_library_shared {
"libcutils",
"liblog",
"libmedia",
"libmedia_omx",
"libstagefright",
"libstagefright_foundation",
"libui",
"libgui",
"libutils",
],

header_libs: [
"libmediadrm_headers",
"libmediametrics_headers",
],

cflags: [
"-Wno-multichar",
"-Werror",
Expand Down
5 changes: 2 additions & 3 deletions media/libstagefright/wifi-display/MediaSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
#include "rtp/RTPSender.h"
#include "source/TSPacketizer.h"

#include "include/avc_utils.h"

#include <media/IHDCP.h>
#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
Expand Down Expand Up @@ -401,7 +400,7 @@ status_t MediaSender::packetizeAccessUnit(
bool manuallyPrependSPSPPS =
!info.mIsAudio
&& (info.mFlags & FLAG_MANUALLY_PREPEND_SPS_PPS)
&& IsIDR(accessUnit);
&& IsIDR(accessUnit->data(), accessUnit->size());

if (mHDCP != NULL && !info.mIsAudio) {
isHDCPEncrypted = true;
Expand Down
4 changes: 2 additions & 2 deletions media/libstagefright/wifi-display/rtp/RTPSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@

#include "RTPSender.h"

#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/ByteUtils.h>
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/ANetworkSession.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/Utils.h>

#include "include/avc_utils.h"

namespace android {

RTPSender::RTPSender(
Expand Down
27 changes: 16 additions & 11 deletions media/libstagefright/wifi-display/source/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
#include "Converter.h"

#include "MediaPuller.h"
#include "include/avc_utils.h"

#include <cutils/properties.h>
#include <gui/Surface.h>
#include <media/ICrypto.h>
#include <mediadrm/ICrypto.h>
#include <media/MediaCodecBuffer.h>
#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferBase.h>
#include <media/stagefright/MediaCodec.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/MediaBufferHolder.h>

#include <arpa/inet.h>

Expand Down Expand Up @@ -305,7 +306,7 @@ void Converter::onMessageReceived(const sp<AMessage> &msg) {
sp<ABuffer> accessUnit;
CHECK(msg->findBuffer("accessUnit", &accessUnit));

accessUnit->setMediaBufferBase(NULL);
accessUnit->meta()->setObject("mediaBufferHolder", sp<MediaBufferHolder>(nullptr));
}
break;
}
Expand All @@ -328,7 +329,7 @@ void Converter::onMessageReceived(const sp<AMessage> &msg) {
ALOGI("dropping frame.");
}

accessUnit->setMediaBufferBase(NULL);
accessUnit->meta()->setObject("mediaBufferHolder", sp<MediaBufferHolder>(nullptr));
break;
}

Expand Down Expand Up @@ -625,13 +626,17 @@ status_t Converter::feedEncoderInputBuffers() {
buffer->data(),
buffer->size());

MediaBuffer *mediaBuffer =
(MediaBuffer *)(buffer->getMediaBufferBase());
MediaBufferBase *mediaBuffer = NULL;
sp<RefBase> holder;

if (buffer->meta()->findObject("mediaBufferHolder", &holder)) {
mediaBuffer = (holder != nullptr) ?
static_cast<MediaBufferHolder*>(holder.get())->mediaBuffer() : nullptr;
}
if (mediaBuffer != NULL) {
mEncoderInputBuffers.itemAt(bufferIndex)->setMediaBufferBase(
mediaBuffer);
mEncoderInputBuffers.itemAt(bufferIndex)->meta()->setObject("mediaBufferHolder", new MediaBufferHolder(mediaBuffer));

buffer->setMediaBufferBase(NULL);
buffer->meta()->setObject("mediaBufferHolder", sp<MediaBufferHolder>(nullptr));
}
} else {
flags = MediaCodec::BUFFER_FLAG_EOS;
Expand Down Expand Up @@ -763,7 +768,7 @@ status_t Converter::doMoreWork() {
if (mNeedToManuallyPrependSPSPPS
&& mIsH264
&& (mFlags & FLAG_PREPEND_CSD_IF_NECESSARY)
&& IsIDR(buffer)) {
&& IsIDR(buffer->data(), buffer->size())) {
buffer = prependCSD(buffer);
}

Expand Down
11 changes: 6 additions & 5 deletions media/libstagefright/wifi-display/source/MediaPuller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferBase.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
#include <media/MediaBufferHolder.h>

namespace android {

Expand Down Expand Up @@ -138,7 +139,7 @@ void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
break;
}

MediaBuffer *mbuf;
MediaBufferBase *mbuf;
status_t err = mSource->read(&mbuf);

if (mPaused) {
Expand All @@ -163,7 +164,7 @@ void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
notify->post();
} else {
int64_t timeUs;
CHECK(mbuf->meta_data()->findInt64(kKeyTime, &timeUs));
CHECK(mbuf->meta_data().findInt64(kKeyTime, &timeUs));

sp<ABuffer> accessUnit = new ABuffer(mbuf->range_length());

Expand All @@ -177,9 +178,9 @@ void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
mbuf->release();
mbuf = NULL;
} else {
// video encoder will release MediaBuffer when done
// video encoder will release MediaBufferBase when done
// with underlying data.
accessUnit->setMediaBufferBase(mbuf);
accessUnit->meta()->setObject("mediaBufferHolder", new MediaBufferHolder(mbuf));
}

sp<AMessage> notify = mNotify->dup();
Expand Down
10 changes: 7 additions & 3 deletions media/libstagefright/wifi-display/source/PlaybackSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
#include "Converter.h"
#include "MediaPuller.h"
#include "RepeaterSource.h"
#include "include/avc_utils.h"
#include "WifiDisplaySource.h"

#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <media/IHDCP.h>
#include <media/IMediaHTTPService.h>
#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/ABitReader.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
Expand All @@ -43,6 +43,7 @@
#include <media/stagefright/NuMediaExtractor.h>
#include <media/stagefright/SurfaceMediaSource.h>
#include <media/stagefright/Utils.h>
#include <media/IOMX.h>

#include <OMX_IVCommon.h>

Expand Down Expand Up @@ -747,7 +748,7 @@ void WifiDisplaySource::PlaybackSession::onSinkFeedback(const sp<AMessage> &msg)

status_t WifiDisplaySource::PlaybackSession::setupMediaPacketizer(
bool enableAudio, bool enableVideo) {
mExtractor = new NuMediaExtractor;
mExtractor = new NuMediaExtractor(NuMediaExtractor::EntryPoint::OTHER);

status_t err = mExtractor->setDataSource(
NULL /* httpService */, mMediaPath.c_str());
Expand Down Expand Up @@ -1069,8 +1070,11 @@ status_t WifiDisplaySource::PlaybackSession::addVideoSource(
}

status_t WifiDisplaySource::PlaybackSession::addAudioSource(bool usePCMAudio) {
audio_attributes_t attr = AUDIO_ATTRIBUTES_INITIALIZER;
attr.source = AUDIO_SOURCE_REMOTE_SUBMIX;

sp<AudioSource> audioSource = new AudioSource(
AUDIO_SOURCE_REMOTE_SUBMIX,
&attr,
mOpPackageName,
48000 /* sampleRate */,
2 /* channelCount */);
Expand Down
8 changes: 4 additions & 4 deletions media/libstagefright/wifi-display/source/RepeaterSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferBase.h>
#include <media/stagefright/MetaData.h>

namespace android {
Expand Down Expand Up @@ -107,7 +107,7 @@ sp<MetaData> RepeaterSource::getFormat() {
}

status_t RepeaterSource::read(
MediaBuffer **buffer, const ReadOptions *options) {
MediaBufferBase **buffer, const ReadOptions *options) {
int64_t seekTimeUs;
ReadOptions::SeekMode seekMode;
CHECK(options == NULL || !options->getSeekTo(&seekTimeUs, &seekMode));
Expand Down Expand Up @@ -155,7 +155,7 @@ status_t RepeaterSource::read(
{
mBuffer->add_ref();
*buffer = mBuffer;
(*buffer)->meta_data()->setInt64(kKeyTime, bufferTimeUs);
(*buffer)->meta_data().setInt64(kKeyTime, bufferTimeUs);
++mFrameCount;
}
}
Expand All @@ -180,7 +180,7 @@ void RepeaterSource::onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case kWhatRead:
{
MediaBuffer *buffer;
MediaBufferBase *buffer;
status_t err = mSource->read(&buffer);

ALOGV("read mbuf %p", buffer);
Expand Down
4 changes: 2 additions & 2 deletions media/libstagefright/wifi-display/source/RepeaterSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct RepeaterSource : public MediaSource {
virtual sp<MetaData> getFormat();

virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options);
MediaBufferBase **buffer, const ReadOptions *options);

void onMessageReceived(const sp<AMessage> &msg);

Expand Down Expand Up @@ -50,7 +50,7 @@ struct RepeaterSource : public MediaSource {
sp<ALooper> mLooper;
sp<AHandlerReflector<RepeaterSource> > mReflector;

MediaBuffer *mBuffer;
MediaBufferBase *mBuffer;
status_t mResult;
int64_t mLastBufferUpdateUs;

Expand Down
6 changes: 3 additions & 3 deletions media/libstagefright/wifi-display/source/TSPacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <utils/Log.h>

#include "TSPacketizer.h"
#include "include/avc_utils.h"

#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
Expand Down Expand Up @@ -471,7 +471,7 @@ status_t TSPacketizer::packetize(
const sp<Track> &track = mTracks.itemAt(trackIndex);

if (track->isH264() && (flags & PREPEND_SPS_PPS_TO_IDR_FRAMES)
&& IsIDR(accessUnit)) {
&& IsIDR(accessUnit->data(), accessUnit->size())) {
// prepend codec specific data, i.e. SPS and PPS.
accessUnit = track->prependCSD(accessUnit);
} else if (track->isAAC() && track->lacksADTSHeader()) {
Expand Down Expand Up @@ -1039,7 +1039,7 @@ sp<ABuffer> TSPacketizer::prependCSD(
CHECK_LT(trackIndex, mTracks.size());

const sp<Track> &track = mTracks.itemAt(trackIndex);
CHECK(track->isH264() && IsIDR(accessUnit));
CHECK(track->isH264() && IsIDR(accessUnit->data(), accessUnit->size()));

int64_t timeUs;
CHECK(accessUnit->meta()->findInt64("timeUs", &timeUs));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "PlaybackSession.h"
#include "Parameters.h"
#include "rtp/RTPSender.h"
#include <media/stagefright/FoundationUtils.h>

#include <binder/IServiceManager.h>
#include <gui/IGraphicBufferProducer.h>
Expand Down

0 comments on commit 14984c1

Please sign in to comment.