-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include testing version rtsp_streamer
* Rewritten from scratch to use live555 and BAdapterIO.
- Loading branch information
Showing
8 changed files
with
760 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
SubDir HAIKU_TOP src add-ons media plugins rtsp_streamer ; | ||
|
||
UsePrivateHeaders media shared ; | ||
|
||
# TODO: Investigate this | ||
SubDirC++Flags -w ; | ||
|
||
local architectureObject ; | ||
for architectureObject in [ MultiArchSubDirSetup ] { | ||
on $(architectureObject) { | ||
|
||
UseBuildFeatureHeaders live555 ; | ||
|
||
Includes [ FGristFiles | ||
rtsp.cpp | ||
RTSPStreamerPlugin.cpp | ||
RTSPMediaIO.cpp ] | ||
: [ BuildFeatureAttribute live555 : headers ] ; | ||
|
||
Addon [ MultiArchDefaultGristFiles rtsp_streamer ] : | ||
RTSPStreamerPlugin.cpp | ||
RTSPMediaIO.cpp | ||
rtsp.cpp | ||
: | ||
[ BuildFeatureAttribute live555 : libraries ] | ||
be media network bnetapi shared | ||
[ TargetLibstdc++ ] [ TargetLibsupc++ ] | ||
; | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright 2016, Dario Casalinuovo. All rights reserved. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
|
||
|
||
#include "RTSPMediaIO.h" | ||
|
||
|
||
#define LIVE555_VERBOSITY 1 | ||
|
||
|
||
RTSPMediaIO::RTSPMediaIO(BUrl* ourUrl) | ||
: | ||
BAdapterIO( | ||
B_MEDIA_STREAMING | B_MEDIA_MUTABLE_SIZE | B_MEDIA_SEEK_BACKWARD, | ||
B_INFINITE_TIMEOUT), | ||
fUrl(ourUrl), | ||
fInitErr(B_OK), | ||
fScheduler(NULL), | ||
fEnv(NULL), | ||
loopWatchVariable(0) | ||
{ | ||
fScheduler = BasicTaskScheduler::createNew(); | ||
fEnv = BasicUsageEnvironment::createNew(*fScheduler); | ||
|
||
HaikuRTSPClient* client = new HaikuRTSPClient(*fEnv, fUrl->UrlString(), | ||
0, BuildInputAdapter()); | ||
if (client == NULL) { | ||
fInitErr = B_ERROR; | ||
return; | ||
} | ||
|
||
client->sendDescribeCommand(continueAfterDESCRIBE); | ||
|
||
fEnv->taskScheduler().doEventLoop(&loopWatchVariable); | ||
|
||
fInitErr = client->WaitForInit(5000000); | ||
} | ||
|
||
|
||
RTSPMediaIO::~RTSPMediaIO() | ||
{ | ||
} | ||
|
||
|
||
status_t | ||
RTSPMediaIO::InitCheck() const | ||
{ | ||
return fInitErr; | ||
} | ||
|
||
|
||
ssize_t | ||
RTSPMediaIO::WriteAt(off_t position, const void* buffer, size_t size) | ||
{ | ||
return B_NOT_SUPPORTED; | ||
} | ||
|
||
|
||
HaikuRTSPClient::HaikuRTSPClient(UsageEnvironment& env, char const* rtspURL, | ||
portNumBits tunnelOverHTTPPortNum, BInputAdapter* inputAdapter) | ||
: | ||
RTSPClient(env, rtspURL, LIVE555_VERBOSITY, "Haiku RTSP Streamer", | ||
tunnelOverHTTPPortNum, -1), | ||
iter(NULL), | ||
session(NULL), | ||
subsession(NULL), | ||
streamTimerTask(NULL), | ||
duration(0.0f), | ||
fInputAdapter(inputAdapter) | ||
{ | ||
fInitPort = create_port(1, "RTSP Client wait port"); | ||
} | ||
|
||
|
||
status_t | ||
HaikuRTSPClient::WaitForInit(bigtime_t timeout) | ||
{ | ||
status_t status = B_ERROR; | ||
read_port_etc(fInitPort, NULL, &status, | ||
sizeof(status), B_RELATIVE_TIMEOUT, timeout); | ||
|
||
close_port(fInitPort); | ||
delete_port(fInitPort); | ||
return status; | ||
} | ||
|
||
|
||
void | ||
HaikuRTSPClient::NotifyError() | ||
{ | ||
status_t status = B_ERROR; | ||
write_port(fInitPort, NULL, &status, sizeof(status)); | ||
} | ||
|
||
|
||
void | ||
HaikuRTSPClient::NotifySucces() | ||
{ | ||
status_t status = B_OK; | ||
write_port(fInitPort, NULL, &status, sizeof(status)); | ||
} | ||
|
||
|
||
HaikuRTSPClient::~HaikuRTSPClient() | ||
{ | ||
delete iter; | ||
if (session != NULL) { | ||
UsageEnvironment& env = session->envir(); | ||
env.taskScheduler().unscheduleDelayedTask(streamTimerTask); | ||
Medium::close(session); | ||
} | ||
} | ||
|
||
|
||
BInputAdapter* | ||
HaikuRTSPClient::GetInputAdapter() const | ||
{ | ||
return fInputAdapter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2016, Dario Casalinuovo. All rights reserved. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef _RTSP_MEDIA_IO_H | ||
#define _RTSP_MEDIA_IO_H | ||
|
||
|
||
#include <AdapterIO.h> | ||
#include <Url.h> | ||
|
||
#include "rtsp.h" | ||
|
||
|
||
class RTSPMediaIO : public BAdapterIO | ||
{ | ||
public: | ||
RTSPMediaIO(BUrl* ourUrl); | ||
virtual ~RTSPMediaIO(); | ||
|
||
status_t InitCheck() const; | ||
|
||
virtual ssize_t WriteAt(off_t position, const void* buffer, | ||
size_t size); | ||
private: | ||
BUrl* fUrl; | ||
|
||
TaskScheduler* fScheduler; | ||
UsageEnvironment* fEnv; | ||
char loopWatchVariable; | ||
|
||
status_t fInitErr; | ||
}; | ||
|
||
|
||
class HaikuRTSPClient : public RTSPClient | ||
{ | ||
public: | ||
HaikuRTSPClient(UsageEnvironment& env, | ||
char const* rtspURL, | ||
portNumBits tunnelOverHTTPPortNum, | ||
BInputAdapter* fInputAdapter); | ||
|
||
BInputAdapter* GetInputAdapter() const; | ||
|
||
status_t WaitForInit(bigtime_t timeout); | ||
|
||
void NotifyError(); | ||
void NotifySucces(); | ||
|
||
protected: | ||
virtual ~HaikuRTSPClient(); | ||
|
||
public: | ||
|
||
MediaSubsessionIterator* iter; | ||
MediaSession* session; | ||
MediaSubsession* subsession; | ||
TaskToken streamTimerTask; | ||
double duration; | ||
|
||
private: | ||
BInputAdapter* fInputAdapter; | ||
port_id fInitPort; | ||
}; | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
#include "RTSPStreamerPlugin.h" | ||
|
||
#include "RTSPMediaIO.h" | ||
|
||
|
||
RTSPStreamer::RTSPStreamer() | ||
{ | ||
} | ||
|
||
|
||
RTSPStreamer::~RTSPStreamer() | ||
{ | ||
} | ||
|
||
|
||
status_t | ||
RTSPStreamer::Sniff(BUrl* url, BDataIO** source) | ||
{ | ||
RTSPMediaIO* ret = new RTSPMediaIO(url); | ||
if (ret->InitCheck() == B_OK) { | ||
*source = ret; | ||
return B_OK; | ||
} | ||
delete ret; | ||
return B_ERROR; | ||
} | ||
|
||
|
||
Streamer* | ||
RTSPStreamerPlugin::NewStreamer() | ||
{ | ||
return new RTSPStreamer(); | ||
} | ||
|
||
|
||
MediaPlugin *instantiate_plugin() | ||
{ | ||
return new RTSPStreamerPlugin(); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef _RTSP_STREAMER_PLUGIN_H | ||
#define _RTSP_STREAMER_PLUGIN_H | ||
|
||
#include "StreamerPlugin.h" | ||
|
||
class RTSPStreamer : public Streamer { | ||
public: | ||
RTSPStreamer(); | ||
virtual ~RTSPStreamer(); | ||
|
||
virtual status_t Sniff(BUrl* url, BDataIO** source); | ||
}; | ||
|
||
|
||
class RTSPStreamerPlugin : public StreamerPlugin { | ||
public: | ||
virtual Streamer* NewStreamer(); | ||
}; | ||
|
||
#endif // _RTSP_STREAMER_PLUGIN_H |
Oops, something went wrong.