Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ab368af authored by Andreas Huber's avatar Andreas Huber
Browse files

Groundwork to support bidirectional, asynchronous communication

between NuPlayer and its sources.

Change-Id: I1989022d806206b926555add3aa5c1fcf37aa78d
parent c41c9323
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@
namespace android {

NuPlayer::GenericSource::GenericSource(
        const sp<AMessage> &notify,
        const char *url,
        const KeyedVector<String8, String8> *headers,
        bool uidValid,
        uid_t uid)
    : mDurationUs(0ll),
    : Source(notify),
      mDurationUs(0ll),
      mAudioIsVorbis(false) {
    DataSource::RegisterDefaultSniffers();

@@ -48,8 +50,10 @@ NuPlayer::GenericSource::GenericSource(
}

NuPlayer::GenericSource::GenericSource(
        const sp<AMessage> &notify,
        int fd, int64_t offset, int64_t length)
    : mDurationUs(0ll),
    : Source(notify),
      mDurationUs(0ll),
      mAudioIsVorbis(false) {
    DataSource::RegisterDefaultSniffers();

+4 −1
Original line number Diff line number Diff line
@@ -32,12 +32,15 @@ struct MediaSource;

struct NuPlayer::GenericSource : public NuPlayer::Source {
    GenericSource(
            const sp<AMessage> &notify,
            const char *url,
            const KeyedVector<String8, String8> *headers,
            bool uidValid = false,
            uid_t uid = 0);

    GenericSource(int fd, int64_t offset, int64_t length);
    GenericSource(
            const sp<AMessage> &notify,
            int fd, int64_t offset, int64_t length);

    virtual void start();

+3 −1
Original line number Diff line number Diff line
@@ -34,10 +34,12 @@
namespace android {

NuPlayer::HTTPLiveSource::HTTPLiveSource(
        const sp<AMessage> &notify,
        const char *url,
        const KeyedVector<String8, String8> *headers,
        bool uidValid, uid_t uid)
    : mURL(url),
    : Source(notify),
      mURL(url),
      mUIDValid(uidValid),
      mUID(uid),
      mFlags(0),
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ struct LiveSession;

struct NuPlayer::HTTPLiveSource : public NuPlayer::Source {
    HTTPLiveSource(
            const sp<AMessage> &notify,
            const char *url,
            const KeyedVector<String8, String8> *headers,
            bool uidValid = false,
+29 −6
Original line number Diff line number Diff line
@@ -145,12 +145,14 @@ void NuPlayer::setDriver(const wp<NuPlayerDriver> &driver) {
void NuPlayer::setDataSource(const sp<IStreamSource> &source) {
    sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());

    sp<AMessage> notify = new AMessage(kWhatSourceNotify, id());

    char prop[PROPERTY_VALUE_MAX];
    if (property_get("media.stagefright.use-mp4source", prop, NULL)
            && (!strcmp(prop, "1") || !strcasecmp(prop, "true"))) {
        msg->setObject("source", new MP4Source(source));
        msg->setObject("source", new MP4Source(notify, source));
    } else {
        msg->setObject("source", new StreamingSource(source));
        msg->setObject("source", new StreamingSource(notify, source));
    }

    msg->post();
@@ -176,13 +178,15 @@ void NuPlayer::setDataSource(
        const char *url, const KeyedVector<String8, String8> *headers) {
    sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());

    sp<AMessage> notify = new AMessage(kWhatSourceNotify, id());

    sp<Source> source;
    if (IsHTTPLiveURL(url)) {
        source = new HTTPLiveSource(url, headers, mUIDValid, mUID);
        source = new HTTPLiveSource(notify, url, headers, mUIDValid, mUID);
    } else if (!strncasecmp(url, "rtsp://", 7)) {
        source = new RTSPSource(url, headers, mUIDValid, mUID);
        source = new RTSPSource(notify, url, headers, mUIDValid, mUID);
    } else {
        source = new GenericSource(url, headers, mUIDValid, mUID);
        source = new GenericSource(notify, url, headers, mUIDValid, mUID);
    }

    msg->setObject("source", source);
@@ -192,7 +196,9 @@ void NuPlayer::setDataSource(
void NuPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
    sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());

    sp<Source> source = new GenericSource(fd, offset, length);
    sp<AMessage> notify = new AMessage(kWhatSourceNotify, id());

    sp<Source> source = new GenericSource(notify, fd, offset, length);
    msg->setObject("source", source);
    msg->post();
}
@@ -273,6 +279,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
            CHECK(msg->findObject("source", &obj));

            mSource = static_cast<Source *>(obj.get());

            looper()->registerHandler(mSource);
            break;
        }

@@ -714,6 +722,12 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatSourceNotify:
        {
            TRESPASS();  // TBD
            break;
        }

        default:
            TRESPASS();
            break;
@@ -1169,6 +1183,9 @@ void NuPlayer::performReset() {

    if (mSource != NULL) {
        mSource->stop();

        looper()->unregisterHandler(mSource->id());

        mSource.clear();
    }

@@ -1210,4 +1227,10 @@ void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) {
    }
}

////////////////////////////////////////////////////////////////////////////////

void NuPlayer::Source::onMessageReceived(const sp<AMessage> &msg) {
    TRESPASS();
}

}  // namespace android
Loading