rtsp_streamer: Update to last api version

This commit is contained in:
Dario Casalinuovo
2016-11-17 17:47:45 +01:00
parent 91b1c40463
commit 413b622176
3 changed files with 36 additions and 40 deletions
@@ -19,26 +19,10 @@ RTSPMediaIO::RTSPMediaIO(BUrl ourUrl)
fClient(NULL), fClient(NULL),
fScheduler(NULL), fScheduler(NULL),
fLoopWatchVariable(0), fLoopWatchVariable(0),
fLoopThread(-1), fLoopThread(-1)
fInitErr(B_ERROR)
{ {
fScheduler = BasicTaskScheduler::createNew(); fScheduler = BasicTaskScheduler::createNew();
fEnv = BasicUsageEnvironment::createNew(*fScheduler); fEnv = BasicUsageEnvironment::createNew(*fScheduler);
fClient = new HaikuRTSPClient(*fEnv, fUrl.UrlString(),
0, this);
if (fClient == NULL)
return;
fClient->sendDescribeCommand(continueAfterDESCRIBE);
fLoopThread = spawn_thread(_LoopThread, "two minutes hate thread",
B_NORMAL_PRIORITY, this);
if (fLoopThread <= 0 || resume_thread(fLoopThread) != B_OK)
return;
fInitErr = fClient->WaitForInit(5000000);
} }
@@ -54,20 +38,6 @@ RTSPMediaIO::~RTSPMediaIO()
} }
status_t
RTSPMediaIO::InitCheck() const
{
return fInitErr;
}
void
RTSPMediaIO::ShutdownLoop()
{
fLoopWatchVariable = 1;
}
ssize_t ssize_t
RTSPMediaIO::WriteAt(off_t position, const void* buffer, size_t size) RTSPMediaIO::WriteAt(off_t position, const void* buffer, size_t size)
{ {
@@ -82,6 +52,26 @@ RTSPMediaIO::SetSize(off_t size)
} }
status_t
RTSPMediaIO::Open()
{
fClient = new HaikuRTSPClient(*fEnv, fUrl.UrlString(),
0, this);
if (fClient == NULL)
return B_ERROR;
fClient->sendDescribeCommand(continueAfterDESCRIBE);
fLoopThread = spawn_thread(_LoopThread, "two minutes hate thread",
B_NORMAL_PRIORITY, this);
if (fLoopThread <= 0 || resume_thread(fLoopThread) != B_OK)
return B_ERROR;
return fClient->WaitForInit(5000000);
}
int32 int32
RTSPMediaIO::_LoopThread(void* data) RTSPMediaIO::_LoopThread(void* data)
{ {
@@ -98,6 +88,13 @@ RTSPMediaIO::LoopThread()
} }
void
RTSPMediaIO::ShutdownLoop()
{
fLoopWatchVariable = 1;
}
HaikuRTSPClient::HaikuRTSPClient(UsageEnvironment& env, char const* rtspURL, HaikuRTSPClient::HaikuRTSPClient(UsageEnvironment& env, char const* rtspURL,
portNumBits tunnelOverHTTPPortNum, RTSPMediaIO* interface) portNumBits tunnelOverHTTPPortNum, RTSPMediaIO* interface)
: :
@@ -21,14 +21,14 @@ public:
RTSPMediaIO(BUrl ourUrl); RTSPMediaIO(BUrl ourUrl);
virtual ~RTSPMediaIO(); virtual ~RTSPMediaIO();
status_t InitCheck() const;
virtual ssize_t WriteAt(off_t position, virtual ssize_t WriteAt(off_t position,
const void* buffer, const void* buffer,
size_t size); size_t size);
virtual status_t SetSize(off_t size); virtual status_t SetSize(off_t size);
virtual status_t Open();
void LoopThread(); void LoopThread();
void ShutdownLoop(); void ShutdownLoop();
private: private:
@@ -42,8 +42,6 @@ private:
char fLoopWatchVariable; char fLoopWatchVariable;
thread_id fLoopThread; thread_id fLoopThread;
status_t fInitErr;
}; };
@@ -17,13 +17,14 @@ RTSPStreamer::~RTSPStreamer()
status_t status_t
RTSPStreamer::Sniff(const BUrl& url, BDataIO** source) RTSPStreamer::Sniff(const BUrl& url, BDataIO** source)
{ {
RTSPMediaIO* ret = new RTSPMediaIO(url); RTSPMediaIO* outSource = new RTSPMediaIO(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;
} }