C++/CLI Sample
Demonstrates how to create a C++/CLI library using the VideoXpert SDK
CPPCli::MediaControl Class Reference

The MediaControl class creates a controller object that provides the ability to create and control video streams. More...

#include <MediaControl.h>

Public Types

enum  Modes {
  Modes::Stopped,
  Modes::Live,
  Modes::Playback
}
 Values that represent the different playback modes. More...
 

Public Member Functions

delegate void TimestampCallbackDelegate (MediaController::TimestampEvent *timeEvent)
 The native event callback delegate. More...
 
delegate void TimestampEventDelegate (MediaEvent^ mediaEvent)
 The managed event delegate. More...
 
 MediaControl (DataSource^ videoSource, DataInterface^ videoInterface, DataSource^ audioSource, DataInterface^ audioInterface)
 Constructor. More...
 
virtual ~MediaControl ()
 Virtual destructor. More...
 
 !MediaControl ()
 Finaliser. More...
 
void GoToLive ()
 Call GoToLive on the stream. More...
 
void Pause ()
 Call Pause on the stream. More...
 
bool Play (float speed)
 Call Play on the stream. More...
 
bool Seek (System::DateTime time, float speed)
 Call Play on the stream with the supplied start time, resulting in a playback stream. More...
 
void SetDataSource (DataSource^ videoDataSource, DataInterface^ videoDataInterface, DataSource^ audioDataSource, DataInterface^ audioDataInterface)
 Set the stream to a new data source. More...
 
void SetVideoWindow (System::IntPtr windowHandle)
 Set the display window using the given window handle. More...
 
void Stop ()
 Call TearDown on the stream. More...
 

Package Functions

void _FireTimestampEvent (MediaController::TimestampEvent *timeEvent)
 

Package Attributes

MediaController::IController_control
 
TimestampCallbackDelegate_timestampCallback
 
TimestampEventDelegate_timestampEvent
 
DataSource_currentdataSource
 

Properties

DataSource^  CurrentDataSource [get]
 Gets the current data source. More...
 
bool IsPipelineActive [get]
 Get the status of the pipeline. More...
 
Modes Mode [get]
 Gets the current playback mode. More...
 

Events

TimestampEventDelegate^  TimestampEvent [add, remove]
 TimestampEvent is raised whenever a new timestamp is received from the stream. More...
 

Detailed Description

The MediaControl class creates a controller object that provides the ability to create and control video streams.

Definition at line 15 of file MediaControl.h.

Member Enumeration Documentation

Values that represent the different playback modes.

Enumerator
Stopped 

The stream is stopped.

Live 

The stream is playing live video.

Playback 

The stream is playing recorded video.

Definition at line 21 of file MediaControl.h.

21  {
23  Stopped,
24 
26  Live,
27 
29  Playback
30  };

Constructor & Destructor Documentation

CPPCli::MediaControl::MediaControl ( DataSource videoSource,
DataInterface videoInterface,
DataSource audioSource,
DataInterface audioInterface 
)

Constructor.

Parameters
videoSourceThe data source to use to create the video stream.
videoInterfaceThe data interface to use to create the video stream.
audioSourceThe data source to use to create the audio stream.
audioInterfaceThe data interface to use to create the audio stream.

Definition at line 9 of file MediaControl.cpp.

9  {
10  // Create a new MediaRequest object
12  if (videoSource != nullptr) {
13  request.dataSource = videoSource->_dataSource;
14  request.dataInterface = *videoInterface->_dataInterface;
15  }
16 
17  if (audioSource != nullptr) {
18  request.audioDataSource = audioSource->_dataSource;
19  request.audioDataInterface = *audioInterface->_dataInterface;
20  }
21 
22  // Get the MediaController which allows the client to control streams
23  MediaController::IController* control = nullptr;
24  MediaController::GetController(&request, &control);
25 
26  // Set the callback for timestamp events
28  control->AddObserver(MediaController::TimestampEventCallback(Marshal::GetFunctionPointerForDelegate(_timestampCallback).ToPointer()));
29 
30  _control = control;
31  _currentdataSource = videoSource;
32 }
VxSdk::IVxDataSource * dataSource
delegate void TimestampCallbackDelegate(MediaController::TimestampEvent *timeEvent)
The native event callback delegate.
VxSdk::IVxDataInterface dataInterface
void _FireTimestampEvent(MediaController::TimestampEvent *timeEvent)
TimestampCallbackDelegate^ _timestampCallback
Definition: MediaControl.h:145
VxSdk::IVxDataInterface audioDataInterface
void GetController(MediaRequest *request, IController **control)
DataSource^ _currentdataSource
Definition: MediaControl.h:147
MediaController::IController * _control
Definition: MediaControl.h:143
VxSdk::IVxDataSource * audioDataSource
void(* TimestampEventCallback)(TimestampEvent *)
virtual void AddObserver(TimestampEventCallback observer)=0
virtual CPPCli::MediaControl::~MediaControl ( )
inlinevirtual

Virtual destructor.

Definition at line 58 of file MediaControl.h.

58  {
59  this->!MediaControl();
60  }
MediaControl(DataSource^ videoSource, DataInterface^ videoInterface, DataSource^ audioSource, DataInterface^ audioInterface)
Constructor.
Definition: MediaControl.cpp:9
CPPCli::MediaControl::!MediaControl ( )

Finaliser.

Definition at line 34 of file MediaControl.cpp.

34  {
35  // Clear all subscriptions to the timestamp events
37  delete _control;
38  _control = nullptr;
39 }
virtual void ClearObservers()=0
MediaController::IController * _control
Definition: MediaControl.h:143

Member Function Documentation

void CPPCli::MediaControl::_FireTimestampEvent ( MediaController::TimestampEvent timeEvent)
package

Definition at line 99 of file MediaControl.cpp.

99  {
100  // Fire the notification if there is a subscription to the timestamp events
101  if (_timestampEvent != nullptr)
102  return _timestampEvent(gcnew MediaEvent(timeEvent));
103 }
TimestampEventDelegate^ _timestampEvent
Definition: MediaControl.h:146
void CPPCli::MediaControl::GoToLive ( )

Call GoToLive on the stream.

Definition at line 41 of file MediaControl.cpp.

41  {
42  _control->GoToLive();
43 }
MediaController::IController * _control
Definition: MediaControl.h:143
virtual bool GoToLive()=0
void CPPCli::MediaControl::Pause ( )

Call Pause on the stream.

Definition at line 45 of file MediaControl.cpp.

45  {
46  _control->Pause();
47 }
virtual void Pause()=0
MediaController::IController * _control
Definition: MediaControl.h:143
bool CPPCli::MediaControl::Play ( float  speed)

Call Play on the stream.

Parameters
speedThe playback speed. Negative values can be used for reverse playback.

Definition at line 49 of file MediaControl.cpp.

49  {
50  return _control->Play(speed);
51 }
virtual bool Play(float speed=0, unsigned int unixTime=0)=0
MediaController::IController * _control
Definition: MediaControl.h:143
bool CPPCli::MediaControl::Seek ( System::DateTime  time,
float  speed 
)

Call Play on the stream with the supplied start time, resulting in a playback stream.

Parameters
timeThe start time for playback.
speedThe playback speed. Negative values can be used for reverse playback.

Definition at line 53 of file MediaControl.cpp.

53  {
54  // Convert the seek time from a DateTime format to unix time format
55  System::TimeSpan ts = (time - System::DateTime(1970, 1, 1, 0, 0, 0));
56  unsigned int seekTime = safe_cast<unsigned int>(ts.TotalSeconds);
57 
58  return _control->Play(speed, seekTime);
59 }
virtual bool Play(float speed=0, unsigned int unixTime=0)=0
MediaController::IController * _control
Definition: MediaControl.h:143
void CPPCli::MediaControl::SetDataSource ( DataSource videoDataSource,
DataInterface videoDataInterface,
DataSource audioDataSource,
DataInterface audioDataInterface 
)

Set the stream to a new data source.

Parameters
videoDataSourceThe data source to use to create the video stream.
videoDataInterfaceThe data interface to use to create the video stream.
audioDataSourceThe data source to use to create the audio stream.
audioDataInterfaceThe data interface to use to create the audio stream.

Definition at line 61 of file MediaControl.cpp.

61  {
62  // Create a new MediaRequest object
64  if (videoSource != nullptr) {
65  request.dataSource = videoSource->_dataSource;
66  request.dataInterface = *videoInterface->_dataInterface;
67  }
68 
69  if (audioSource != nullptr) {
70  request.audioDataSource = audioSource->_dataSource;
71  request.audioDataInterface = *audioInterface->_dataInterface;
72  }
73 
74  // Update the stream settings for the MediaController using the MediaRequest
75  _control->NewRequest(request);
76  _currentdataSource = videoSource;
77 }
VxSdk::IVxDataSource * dataSource
VxSdk::IVxDataInterface dataInterface
VxSdk::IVxDataInterface audioDataInterface
DataSource^ _currentdataSource
Definition: MediaControl.h:147
MediaController::IController * _control
Definition: MediaControl.h:143
VxSdk::IVxDataSource * audioDataSource
virtual void NewRequest(MediaRequest &request)=0
void CPPCli::MediaControl::SetVideoWindow ( System::IntPtr  windowHandle)

Set the display window using the given window handle.

Parameters
windowHandleAn IntPtr to the window handle.

Definition at line 79 of file MediaControl.cpp.

79  {
80  // Set the display for the MediaController using windowHandle
81  HWND VideoWindow = static_cast<HWND>(windowHandle.ToPointer());
82  _control->SetWindow(VideoWindow);
83 }
virtual void SetWindow(void *handle)=0
MediaController::IController * _control
Definition: MediaControl.h:143
void CPPCli::MediaControl::Stop ( )

Call TearDown on the stream.

Definition at line 85 of file MediaControl.cpp.

85  {
86  _control->Stop();
87 }
virtual void Stop()=0
MediaController::IController * _control
Definition: MediaControl.h:143
delegate void CPPCli::MediaControl::TimestampCallbackDelegate ( MediaController::TimestampEvent timeEvent)

The native event callback delegate.

Parameters
timeEventThe time event sent from the stream.
delegate void CPPCli::MediaControl::TimestampEventDelegate ( MediaEvent mediaEvent)

The managed event delegate.

Parameters
mediaEventThe media event sent from the stream as a managed type.

Member Data Documentation

MediaController::IController* CPPCli::MediaControl::_control
package

Definition at line 143 of file MediaControl.h.

DataSource ^ CPPCli::MediaControl::_currentdataSource
package

Definition at line 147 of file MediaControl.h.

TimestampCallbackDelegate ^ CPPCli::MediaControl::_timestampCallback
package

Definition at line 145 of file MediaControl.h.

TimestampEventDelegate ^ CPPCli::MediaControl::_timestampEvent
package

Definition at line 146 of file MediaControl.h.

Property Documentation

DataSource^ CPPCli::MediaControl::CurrentDataSource
get

Gets the current data source.

The current data source.

Definition at line 114 of file MediaControl.h.

bool CPPCli::MediaControl::IsPipelineActive
get

Get the status of the pipeline.

Returns
True if pipeline is active, otherwise false.

Definition at line 122 of file MediaControl.h.

Modes CPPCli::MediaControl::Mode
get

Gets the current playback mode.

The current stream mode.

Definition at line 130 of file MediaControl.h.

Event Documentation

TimestampEventDelegate^ CPPCli::MediaControl::TimestampEvent
addremove

TimestampEvent is raised whenever a new timestamp is received from the stream.

Definition at line 137 of file MediaControl.h.


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