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