http_streamer: Sync with BAdapterIO changes
This commit is contained in:
@@ -59,7 +59,7 @@ public:
|
||||
delete request;
|
||||
}
|
||||
|
||||
off_t TotalSize() const
|
||||
off_t TotalSize() const
|
||||
{
|
||||
return fTotalSize;
|
||||
}
|
||||
@@ -74,43 +74,17 @@ private:
|
||||
|
||||
HTTPMediaIO::HTTPMediaIO(BUrl url)
|
||||
:
|
||||
BAdapterIO(
|
||||
B_MEDIA_STREAMING | B_MEDIA_SEEK_BACKWARD,
|
||||
B_INFINITE_TIMEOUT),
|
||||
fInitErr(B_ERROR)
|
||||
BAdapterIO(B_MEDIA_STREAMING | B_MEDIA_SEEK_BACKWARD, B_INFINITE_TIMEOUT),
|
||||
fContext(NULL),
|
||||
fReq(NULL),
|
||||
fListener(NULL),
|
||||
fUrl(url)
|
||||
{
|
||||
fContext = new BUrlContext();
|
||||
fContext->AcquireReference();
|
||||
|
||||
fListener = new FileListener(this);
|
||||
|
||||
fReq = BUrlProtocolRoster::MakeRequest(url,
|
||||
fListener, fContext);
|
||||
|
||||
if (fReq == NULL)
|
||||
return;
|
||||
|
||||
if (fReq->Run() < 0)
|
||||
return;
|
||||
|
||||
fInitErr = B_OK;
|
||||
}
|
||||
|
||||
|
||||
HTTPMediaIO::~HTTPMediaIO()
|
||||
{
|
||||
delete fReq;
|
||||
delete fListener;
|
||||
|
||||
fContext->ReleaseReference();
|
||||
delete fContext;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
HTTPMediaIO::InitCheck() const
|
||||
{
|
||||
return fInitErr;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,3 +108,44 @@ HTTPMediaIO::GetSize(off_t* size) const
|
||||
*size = fListener->TotalSize();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
HTTPMediaIO::Open()
|
||||
{
|
||||
fContext = new BUrlContext();
|
||||
fContext->AcquireReference();
|
||||
|
||||
fListener = new FileListener(this);
|
||||
|
||||
fReq = BUrlProtocolRoster::MakeRequest(fUrl,
|
||||
fListener, fContext);
|
||||
|
||||
if (fReq == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
if (fReq->Run() < 0)
|
||||
return B_ERROR;
|
||||
|
||||
return BAdapterIO::Open();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HTTPMediaIO::Close()
|
||||
{
|
||||
delete fReq;
|
||||
delete fListener;
|
||||
|
||||
fContext->ReleaseReference();
|
||||
delete fContext;
|
||||
|
||||
BAdapterIO::Close();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
HTTPMediaIO::SeekRequested(off_t position)
|
||||
{
|
||||
return BAdapterIO::SeekRequested(position);
|
||||
}
|
||||
|
||||
@@ -20,20 +20,24 @@ public:
|
||||
HTTPMediaIO(BUrl url);
|
||||
virtual ~HTTPMediaIO();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
virtual ssize_t WriteAt(off_t position,
|
||||
const void* buffer, size_t size);
|
||||
|
||||
virtual status_t SetSize(off_t size);
|
||||
virtual status_t GetSize(off_t* size) const;
|
||||
|
||||
virtual status_t Open();
|
||||
virtual void Close();
|
||||
|
||||
protected:
|
||||
virtual status_t SeekRequested(off_t position);
|
||||
|
||||
private:
|
||||
BUrlContext* fContext;
|
||||
BUrlRequest* fReq;
|
||||
FileListener* fListener;
|
||||
|
||||
status_t fInitErr;
|
||||
BUrl fUrl;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,13 +22,14 @@ HTTPStreamer::~HTTPStreamer()
|
||||
status_t
|
||||
HTTPStreamer::Sniff(const BUrl& url, BDataIO** source)
|
||||
{
|
||||
HTTPMediaIO* ret = new HTTPMediaIO(url);
|
||||
if (ret->InitCheck() == B_OK) {
|
||||
*source = ret;
|
||||
HTTPMediaIO* outSource = new HTTPMediaIO(url);
|
||||
status_t ret = outSource->Open();
|
||||
if (ret == B_OK) {
|
||||
*source = outSource;
|
||||
return B_OK;
|
||||
}
|
||||
delete ret;
|
||||
return B_ERROR;
|
||||
delete outSource;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user