Media Controller
A GStreamer implementation using the VideoXpert SDK
MediaController::Rtsp::Stream Class Reference

Represents an RTSP stream. More...

#include <RtspStream.h>

Public Member Functions

 Stream (MediaRequest &request, bool isVideo)
 Constructor. More...
 
virtual ~Stream ()
 Virtual destructor. More...
 
bool Play (float speed=0, unsigned int unixTime=0) override
 Call Play on the stream. More...
 
void PlayStream (float speed, unsigned int unixTime) override
 
void Pause () override
 Call Pause on the stream. More...
 
void Stop () override
 Call TearDown on the stream. More...
 
bool GoToLive () override
 Set the stream to Live and call Play. More...
 
void NewRequest (MediaRequest &request) override
 Set the stream to a new source. More...
 
bool Resume (float speed=0, unsigned int unixTime=0) override
 Send PLAY on an existing stream. More...
 
- Public Member Functions inherited from MediaController::StreamBase
virtual ~StreamBase ()
 Virtual destructor. More...
 
bool Play (float speed=0, unsigned int unixTime=0) override
 Call Play on the stream. More...
 
void Pause () override
 Call Pause on the stream. More...
 
void Stop () override
 Call TearDown on the stream. More...
 
void NewRequest (MediaRequest &request) override
 Set the stream to a new source. More...
 
GstWrapperGetGstreamer () const
 Get the current GStreamer wrapper instance. More...
 
unsigned int GetLastTimestamp () const
 Gets the current time of the stream. More...
 
Mode GetMode () override
 Get the current playback mode. More...
 
- Public Member Functions inherited from MediaController::IStream
virtual ~IStream ()
 Virtual destructor. More...
 

Private Attributes

Commands_rtspCommands
 
std::unique_ptr< KeepAlive_rtspKeepAlive
 

Additional Inherited Members

- Public Types inherited from MediaController::IStream
enum  Mode {
  kStopped,
  kLive,
  kPlayback
}
 Values that represent the different playback modes. More...
 
- Public Attributes inherited from MediaController::StreamBase
StreamStatestate
 The current state of the stream. More...
 
VxSdk::VxStreamProtocol::Value protocol
 The protocol of the stream. More...
 
- Protected Member Functions inherited from MediaController::StreamBase
 StreamBase (MediaRequest &request)
 Constructor. More...
 
- Protected Attributes inherited from MediaController::StreamBase
MediaRequest _mediaRequest
 
GstWrapper_gst
 

Detailed Description

Represents an RTSP stream.

Definition at line 18 of file RtspStream.h.

Inherits MediaController::StreamBase.

Constructor & Destructor Documentation

Rtsp::Stream::Stream ( MediaRequest request,
bool  isVideo 
)

Constructor.

Parameters
requestThe requested media.
isVideoSpecifies wheather this Stream handles audio or video.

Definition at line 14 of file RtspStream.cpp.

14  :
15  StreamBase(request),
16  _rtspCommands(new Commands(request.dataInterface.dataEndpoint, isVideo)),
17  _rtspKeepAlive() {
18 }
std::unique_ptr< KeepAlive > _rtspKeepAlive
Definition: RtspStream.h:42
VxSdk::IVxDataInterface dataInterface
The protocol to use for the new video stream.
Definition: MediaRequest.h:26
StreamBase()
Default constructor.
Definition: StreamBase.cpp:10
Rtsp::Stream::~Stream ( )
virtual

Virtual destructor.

Definition at line 20 of file RtspStream.cpp.

20  {
21  this->_rtspKeepAlive.reset(nullptr);
22  delete _rtspCommands;
23  _rtspCommands = nullptr;
24 }
std::unique_ptr< KeepAlive > _rtspKeepAlive
Definition: RtspStream.h:42

Member Function Documentation

bool Rtsp::Stream::GoToLive ( )
overridevirtual

Set the stream to Live and call Play.

Implements MediaController::IStream.

Definition at line 78 of file RtspStream.cpp.

78 { return true; }
void Rtsp::Stream::NewRequest ( MediaRequest request)
overridevirtual

Set the stream to a new source.

Parameters
requestThe new MediaRequest to reset the stream to.

Implements MediaController::IStream.

Definition at line 90 of file RtspStream.cpp.

90  {
92 }
VxSdk::IVxDataInterface dataInterface
The protocol to use for the new video stream.
Definition: MediaRequest.h:26
void ResetPath(const std::string &streamUri)
Reset the RTSP stream location.
void Rtsp::Stream::Pause ( )
overridevirtual

Call Pause on the stream.

Implements MediaController::IStream.

Definition at line 62 of file RtspStream.cpp.

62  {
63  // Pause the stream.
64  this->_rtspCommands->Pause();
65  this->_gst->Pause();
66  this->state = new PausedState();
67 }
void Pause() const
Set the pipeline state to paused.
Definition: GstWrapper.cpp:540
void Pause()
Send the PAUSE method and read the server response.
StreamState * state
The current state of the stream.
Definition: StreamBase.h:49
Represents a stream that is currently in the paused state.
Definition: StreamState.h:71
bool Rtsp::Stream::Play ( float  speed = 0,
unsigned int  unixTime = 0 
)
overridevirtual

Call Play on the stream.

Parameters
speedThe playback speed. Negative values can be used for reverse playback. A value of 0 will resume a paused stream.
unixTimeThe start time for playback. A value of 0 will start a live stream.

Implements MediaController::IStream.

Definition at line 26 of file RtspStream.cpp.

26  {
27  if (this->_gst->GetMode() != IController::kStopped)
28  this->Stop();
29 
30  if (speed == 0 && unixTime == 0)
32  else
34 
35  // Send the sequence of RTSP commands needed to start a new stream.
36  if (!this->_rtspCommands->Options())
37  return false;
38 
39  if (!this->_rtspCommands->Describe(true))
40  return false;
41 
42  if (!this->_rtspCommands->Setup(true))
43  return false;
44 
45  if (this->_rtspCommands->SetupStream(this->_gst, speed, unixTime))
46  return true;
47 
48  return false;
49 }
void SetMode(Controller::Mode mode)
Set the playback mode.
Definition: GstWrapper.cpp:319
bool Setup(bool firstAttempt=false)
Send the SETUP method and read the server response.
The stream is playing live video.
Definition: IStream.h:21
void Stop() override
Call TearDown on the stream.
Definition: RtspStream.cpp:69
bool SetupStream(GstWrapper *gstwrapper, float speed=0, unsigned int unixTime=0)
Send the PLAY method with a Range header and read the server response.
The stream is playing recorded video.
Definition: IStream.h:24
The stream is stopped.
Definition: IStream.h:18
bool Options()
Send the OPTIONS method and read the server response.
bool Describe(bool firstAttempt=false)
Send the DESCRIBE method and read the server response.
Controller::Mode GetMode() const
Get the current playback mode.
Definition: GstWrapper.h:90
void Rtsp::Stream::PlayStream ( float  speed,
unsigned int  unixTime 
)
overridevirtual

Implements MediaController::IStream.

Definition at line 51 of file RtspStream.cpp.

51  {
52  this->_rtspCommands->PlayStream(this->_gst);
53  this->_gst->Play(speed == 0 ? 1 : speed);
54 
55  // Start the keep alive loop in a new thread.
56  if (!this->_rtspKeepAlive)
57  this->_rtspKeepAlive = make_unique<KeepAlive>(this->_rtspCommands);
58 
59  this->state = new PlayingState();
60 }
std::unique_ptr< KeepAlive > _rtspKeepAlive
Definition: RtspStream.h:42
void PlayStream(GstWrapper *gstwrapper)
Create a pipe line
StreamState * state
The current state of the stream.
Definition: StreamBase.h:49
void Play(float speed=1.0f)
Set the pipeline state to playing and update the speed value for determining the framerate.
Definition: GstWrapper.cpp:531
Represents a stream that is currently in the playing state.
Definition: StreamState.h:55
bool Rtsp::Stream::Resume ( float  speed = 0,
unsigned int  unixTime = 0 
)
overridevirtual

Send PLAY on an existing stream.

Parameters
speedThe playback speed. Negative values can be used for reverse playback. A value of 0 will resume a paused stream.
unixTimeThe start time for playback. A value of 0 will start a live stream.

Reimplemented from MediaController::StreamBase.

Definition at line 80 of file RtspStream.cpp.

80  {
81  bool ret = this->_rtspCommands->SetupStream(this->_gst, speed, unixTime);
82  if (ret)
83  this->_rtspCommands->PlayStream(this->_gst);
84 
85  this->_gst->Play(speed == 0 ? 1 : speed);
86  this->state = new PlayingState();
87  return ret;
88 }
bool SetupStream(GstWrapper *gstwrapper, float speed=0, unsigned int unixTime=0)
Send the PLAY method with a Range header and read the server response.
void PlayStream(GstWrapper *gstwrapper)
Create a pipe line
StreamState * state
The current state of the stream.
Definition: StreamBase.h:49
void Play(float speed=1.0f)
Set the pipeline state to playing and update the speed value for determining the framerate.
Definition: GstWrapper.cpp:531
Represents a stream that is currently in the playing state.
Definition: StreamState.h:55
void Rtsp::Stream::Stop ( )
overridevirtual

Call TearDown on the stream.

Implements MediaController::IStream.

Definition at line 69 of file RtspStream.cpp.

69  {
70  // Signal the keep alive thread to shut down.
71  this->_rtspKeepAlive.reset();
72  this->_rtspCommands->Teardown();
73  this->_gst->ClearPipeline();
75  this->state = new StoppedState();
76 }
void SetMode(Controller::Mode mode)
Set the playback mode.
Definition: GstWrapper.cpp:319
Represents a stream that is currently in the stopped state.
Definition: StreamState.h:86
void Teardown()
Send the TEARDOWN method and read the server response.
The stream is stopped.
Definition: IStream.h:18
std::unique_ptr< KeepAlive > _rtspKeepAlive
Definition: RtspStream.h:42
void ClearPipeline()
Clear the pipeline and display window.
Definition: GstWrapper.cpp:544
StreamState * state
The current state of the stream.
Definition: StreamBase.h:49

Member Data Documentation

Commands* MediaController::Rtsp::Stream::_rtspCommands
private

Definition at line 41 of file RtspStream.h.

std::unique_ptr<KeepAlive> MediaController::Rtsp::Stream::_rtspKeepAlive
private

Definition at line 42 of file RtspStream.h.


The documentation for this class was generated from the following files: