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();
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);
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();
}
CHECK(msg->findObject("source", &obj));
mSource = static_cast<Source *>(obj.get());
+
+ looper()->registerHandler(mSource);
break;
}
break;
}
+ case kWhatSourceNotify:
+ {
+ TRESPASS(); // TBD
+ break;
+ }
+
default:
TRESPASS();
break;
if (mSource != NULL) {
mSource->stop();
+
+ looper()->unregisterHandler(mSource->id());
+
mSource.clear();
}
}
}
+////////////////////////////////////////////////////////////////////////////////
+
+void NuPlayer::Source::onMessageReceived(const sp<AMessage> &msg) {
+ TRESPASS();
+}
+
} // namespace android
#include "NuPlayer.h"
+#include <media/stagefright/foundation/AMessage.h>
+
namespace android {
struct ABuffer;
-struct NuPlayer::Source : public RefBase {
+struct NuPlayer::Source : public AHandler {
enum Flags {
FLAG_SEEKABLE = 1,
FLAG_DYNAMIC_DURATION = 2,
};
- Source() {}
+ // The provides message is used to notify the player about various
+ // events.
+ Source(const sp<AMessage> ¬ify)
+ : mNotify(notify) {
+ }
virtual void start() = 0;
virtual void stop() {}
protected:
virtual ~Source() {}
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
virtual sp<MetaData> getFormatMeta(bool audio) { return NULL; }
+ sp<AMessage> dupNotify() const { return mNotify->dup(); }
+
private:
+ sp<AMessage> mNotify;
+
DISALLOW_EVIL_CONSTRUCTORS(Source);
};