rtsp_streamer: Update to last api version

This commit is contained in:
Dario Casalinuovo 2016-11-17 17:46:02 +01:00
parent 91b1c40463
commit 413b622176
3 changed files with 36 additions and 40 deletions

View File

@ -19,26 +19,10 @@ RTSPMediaIO::RTSPMediaIO(BUrl ourUrl)
fClient(NULL),
fScheduler(NULL),
fLoopWatchVariable(0),
fLoopThread(-1),
fInitErr(B_ERROR)
fLoopThread(-1)
{
fScheduler = BasicTaskScheduler::createNew();
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
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
RTSPMediaIO::_LoopThread(void* data)
{
@ -98,6 +88,13 @@ RTSPMediaIO::LoopThread()
}
void
RTSPMediaIO::ShutdownLoop()
{
fLoopWatchVariable = 1;
}
HaikuRTSPClient::HaikuRTSPClient(UsageEnvironment& env, char const* rtspURL,
portNumBits tunnelOverHTTPPortNum, RTSPMediaIO* interface)
:

View File

@ -21,14 +21,14 @@ public:
RTSPMediaIO(BUrl ourUrl);
virtual ~RTSPMediaIO();
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 Open();
void LoopThread();
void ShutdownLoop();
private:
@ -42,8 +42,6 @@ private:
char fLoopWatchVariable;
thread_id fLoopThread;
status_t fInitErr;
};

View File

@ -17,13 +17,14 @@ RTSPStreamer::~RTSPStreamer()
status_t
RTSPStreamer::Sniff(const BUrl& url, BDataIO** source)
{
RTSPMediaIO* ret = new RTSPMediaIO(url);
if (ret->InitCheck() == B_OK) {
*source = ret;
RTSPMediaIO* outSource = new RTSPMediaIO(url);
status_t ret = outSource->Open();
if (ret == B_OK) {
*source = outSource;
return B_OK;
}
delete ret;
return B_ERROR;
delete outSource;
return ret;
}