Stream Library - Files

m.h

///

/// Copyright (c) 2019 AnyConnect Private Limited. All rights reserved.

/// Author(s): Nazmul Alam

///



#ifndef _STREAM_H_

#define _STREAM_H_



#include "Connect.h"



namespace com {         ///\< \namespace com

namespace anyconnect {  ///\< \namespace anyconnect

namespace stream {      ///\< \namespace stream



///

/// \brief Stream return states.

///

/// Defines Stream success and failure states.

///

enum class StreamRet {

    OK,                  ///\< Successful invocation.

    NOT_STARTED,         ///\< Call start() before calling APIs.

    INVALID_PARAMETERS,  ///\< Invalid parameters.

    FAIL,                ///\< Generic failure.

};



///

/// \brief Stream media types.

///

/// Supported media types: audio, video and image.

///

enum class MediaType {

    AUDIO,

    VIDEO,

    IMAGE

};



///

/// \brief Video resolutions.

///

/// Supported video resolutions.

///

enum class VideoResolution {

    WH_176x144,

    WH_192x144,

    WH_320x240,

    WH_352x288,

    WH_640x400,

    WH_640x480,

    WH_840x480,

    WH_848x480,

    WH_1280x720,

    WH_1920x1080,

    WH_3840x2160,

    WH_7680x4320,

    WH_15360x8640

};



///

/// \brief Image formats.

///

/// Supported image formats.

///

enum class ImageFormat {

    BMP,

    GIF,

    JPEG,

    PNG,

    RAW,

    SVG,

    TIFF

};



///

/// \brief Video codecs.

///

/// Supported video codecs.

///

enum class VideoCodec {

    H263,

    H264,

    H264_SVC,

    H265,

    RAW

};



///

/// \brief Recording trigger types.

///

/// Supported recording trigger types.

///

enum class RecordingTriggers {

    MOTION,

    SOUND,

    TIME

};



///

/// \brief Video capabilities.

///

/// Video capabilities.

///

struct VideoCapabilities {



    ///

    /// Video codec.

    ///

    VideoCodec videoCodec;



    ///

    /// Video resolution.

    ///

    VideoResolution videoResolution;



    ///

    /// Maximum video frame per second.

    ///

    int fps;



    ///

    /// Maximum video bitrate.

    ///

    long bitRate;



    ///

    /// List of recording triggers.

    ///

    std::vector\<RecordingTriggers> triggerList;

};



///

/// \brief Video quality profile.

///

/// Supported video quality profiles.

///

enum class VideoQualityProfile {

    HIGH_FRAME_RATE,  // Optimized image quality

    STANDARD_QUALITY,  // Optimized frame rate and image quality

    HIGH_IMAGE_QUALITY  // Optimized frame rate

};



///

/// \brief Audio Codecs.

///

/// Supported audio codecs.

///

enum class AudioCodec {

    AAC,

    G711,

    G722,

    OPUS,

    SIREN,

    SPEEX

};



///

/// \brief Audio sample rates.

///

/// Supported audio sample rates.

///

enum class SampleRate {

    Hz_8K,

    Hz_12K,

    Hz_16K,

    Hz_20K,

    Hz_32K,

    Hz_48K

};



///

/// \brief Input source status.

///

/// Defines input source states.

///

enum class InputSourceStatus {

    SUCCESS,

    BUSY,

    NOT_SUPPORTED,

    NOT_FOUND,

    INVALID,

    FAIL

};



///

/// \brief Stream transition state.

///

/// Indicates stopped/recovering/restarted/restart-failed/retrying state of a stream session.

///

enum class StreamTransitionState {

    STOPPED,

    RECOVERING,

    RESTARTED,

    RESTART_FAILED,

    RETRYING,

    RUNNING

};



///

/// \brief Audio capabilities.

///

/// Audio capabilities.

///

struct AudioCapabilities {



    ///

    /// Audio codec.

    ///

    AudioCodec audioCodec;



    ///

    /// Maximum audio sample rate.

    ///

    SampleRate audioSampleRate;



    ///

    /// Maximum audio bitrate.

    ///

    long bitRate;



    ///

    /// List of recording triggers.

    ///

    std::vector\<RecordingTriggers> triggerList;

};

// Buffer for Raw data 

// which will come from media layer 

typedef struct {

    int32_t   bufferSize;   ///\< Number of bytes in FIFO. Power of 2.

    int32_t   writeIndex;   ///\< Index of next writable byte.

    int32_t   readIndex;    ///\< Index of next readable byte.

    int32_t   bigMask;      ///\< Used for wrapping indices with extra bit to distinguish full/empty.

    int32_t   smallMask;    ///\< Used for fitting indices to buffer.

    int32_t   start_frame;

    std::string inputSource;///\< Used for input source name of this data.

    int width;

    int height;

    unsigned char *buffer;

    bool isMotionData;

    u_int64_t timestamp;

} RingBuffer;



///

/// \brief Stream sent and received media statistics.

///

/// Supported media types: audio, video and image.

///

struct StreamStatistics {



    ///

    /// Definition of a shared pointer to StreamStatistics.

    ///

    typedef std::shared_ptr\<StreamStatistics> Ptr;



    StreamStatistics();



    virtual ~StreamStatistics();



    ///

    /// Media codec type.

    ///

    std::string codecType;



    ///

    /// Media codec description.

    ///

    std::string codecDescription;



    ///

    /// The number of lost frames.

    ///

    unsigned int framesLost;



    ///

    /// The number of received frames.

    ///

    unsigned int framesReceived;



    ///

    /// The number of dropped frames. These frames are completely received,

    /// but not decoded and rendered, due to CPU overload.

    ///

    unsigned int framesDropped;



    ///

    /// The number of recovered frames. These frames are partially received but

    /// can be recovered.

    ///

    unsigned int framesRecovered;



    ///

    /// The number of displayed frames.

    ///

    unsigned int framesDisplayed;



    ///

    /// The number of impaired frames. These frames are partially received.

    ///

    unsigned int framesImpaired;



    ///

    /// Received frame rate.

    ///

    double frameRate;



    ///

    /// The number of received packets.

    ///

    unsigned int packetsReceived;



    ///

    /// The number of lost packets.

    ///

    unsigned int packetsLost;



    ///

    /// Bitrate of video payload.

    ///

    double bitRateVideoData;



    ///

    /// Bitrate of stream header. Includes TCP/IP header, RTP header, Video

    /// header and header extension.

    ///

    double bitRateOverHead;



    ///

    /// Packet loss rate.

    ///

    double packetLossRate;



    ///

    /// Received I-Frame rate.

    ///

    double iFrameRate;



    ///

    /// Received B-Frame rate.

    ///

    double bFrameRate;



    ///

    /// Received P-Frame rate.

    ///

    double pFrameRate;



    ///

    /// Video sending quality.

    ///

    int senderQualityFactor;



    ///

    /// Video resolution.

    ///

    VideoResolution videoResolution;



    ///

    /// Average delay in milliseconds for the preceding one second.

    ///

    int averageDelay;



    ///

    /// The jitter for the preceding one second.

    ///

    unsigned int jitter;



    ///

    /// The average packet round-trip time in milliseconds for the preceding one second.

    ///

    double averageRTT;



    ///

    /// The window size.

    ///

    unsigned int windowSize;



    ///

    /// The buffer size.

    ///

    unsigned int bufferSize;



    ///

    /// The number of frames sent.

    ///

    unsigned int framesSent;



    ///

    /// The number of sent packets.

    ///

    unsigned int packetsSent;



    ///

    /// Audio sample rate.

    ///

    SampleRate sampleRate;

};



///

/// \brief End Point Universally Unique Identifier.

///

typedef com::anyconnect::access::types::Endpoint EndPointUUID;



///

/// \brief Recorded media definition.

///

typedef std::string RecordingURL;



///

/// \brief Format of the frame.

///

typedef std::string Format;



///

/// \brief Structure of the frame.

///

typedef std::string Structure;



///

/// FrameProperties are different given the media type and the encoding scheme.

/// A frame is a coherent piece of data marked by the sampling timestamp value.

/// This is also called an access unit.

///

typedef struct {

    Format format;

    Structure structure;

} FrameProperties;



///

/// \brief QoS values in json format.

///

typedef std::string QoSjson;



///

/// Handler function for stopping Stream API session.

///

typedef std::function\<void()> stopHandler;



///

/// Handler function for stream request.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] status stream request status

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const int &status)> onStreamRequestHandler;



///

/// Handler function for stream receive.

///

/// \param[in] toEndPoint - stream sink endpoint UUID

/// \param[in] mediaType - selected media type

///

/// \return True - to accept the requested stream

///         False - to reject the requested stream

///

typedef std::function\<bool(const EndPointUUID &toEndPoint, MediaType mediaType)> onStreamReceiveHandler;



///

/// Handler function for stream start.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] connectionType stream's connection type

///

typedef std::function\<bool(const EndPointUUID &fromEndPoint, const std::string& connectionType)> onStreamStartHandler;



///

/// Handler function for stream stop.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] status stream stop status

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const int &status)> onStreamStopHandler;



///

/// Handler function for stream pause.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] mediaTypeList selected media types

/// \param[in] status stream pause status

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, const int &status)> onStreamPauseHandler;



///

/// Handler function for stream resume.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] mediaTypeList selected media types

/// \param[in] status stream resume status

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, const int &status)> onStreamResumeHandler;



///

/// Handler function for stream connectivity transition.

///

typedef std::function\<void(const EndPointUUID &fromEndpoint, const StreamTransitionState streamTransitionState, const std::string &connectionType)> onStreamConnectivityChangeHandler;







///

/// Handler function to notify video resolution change.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] updatedVideoResolution updated video resolution.

///

typedef std::function\<void(const EndPointUUID &fromEndpoint, VideoResolution &updatedVideoResolution)> onReceivedVideoResolutionChangeHandler;



///

/// Handler function to notify video specific data received.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] timestamp - time stamp of the video frame

/// \param[in] data - video specific data

///

typedef std::function\<void(const EndPointUUID &fromEndpoint, u_int32_t &ssrc, time_t timestamp, const std::string &data)> onReceivedVideoSpecificDataHandler;



///

/// Handler function for start recording.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] status requested recording status

///

typedef std::function\<bool(const EndPointUUID &fromEndPoint, const int &status)> onStartRecordingHandler;



///

/// Handler function for stop recording.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] status recording status

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const int &status)> onStopRecordingHandler;



///

/// Handler function for recording list.

///

/// \param[in] fromEndPoint stream source endpoint UUID

/// \param[in] recordingList List of recording URL

///

typedef std::function\<void(const EndPointUUID &fromEndPoint, const std::map\<MediaType, const std::vector\<RecordingURL>> &recordingList)> onRecordingListHandler;

    

///

/// Handler function for receive frame.

///

/// \param[in] fromEndpoint - stream source endpoint UUID

/// \param[in] mediaType - media type of the frame

/// \param[in] framePtr - frame data

/// \param[in] size - size of the frame

/// \param[in] frameProperties - properties of the frame

/// \param[in] timestamp - time stamp of the frame

///

typedef std::function\<void(const EndPointUUID &fromEndpoint, MediaType mediaType, void *framePtr, long size, FrameProperties frameProperties, time_t timestamp)> onReceiveFrameHandler;



///

/// Handler function for set input sources.

///

/// \param[in] inputSourceList List of input sources

/// \param[in] status List of input sources status

///

typedef std::function\<void(const std::vector\<std::string> &inputSourceList, const std::vector\<InputSourceStatus> &status)> onSetInputSourcesHandler;



///

/// Handler function for RawData 

/// \param[in] Buffer for Rawdata 

///

typedef std::function\<void(RingBuffer buffer)> onRawDataHandler;



///

/// \brief Interface for audio, video and image streaming.

///

/// Stream interface definition for the Stream object.

///

class Stream {

public:



    virtual ~Stream() {};



    ///

    /// Starting Stream library.

    ///

    /// Resources are allocated waiting in idle state for a request to come in

    /// or to send a request issued by the application.

    ///

    /// \return StreamRet::OK on successful resource allocation, other values on failure.

    ///

    virtual StreamRet start() = 0;



    ///

    /// Stopping Stream library.

    ///

    /// Graceful shutdown of recording and any other cloud service running,

    /// gracefully stops media processing.

    /// Close active streams and free resources.

    ///

    /// \param[in] handler - com::anyconnect::stream::stopHandler function invoked when

    /// stream has fully stopped. No callbacks will be invoked after stopHandler is called.

    ///

    /// \return StreamRet::OK on successful resource releasion, other values on failure.

    ///

    virtual StreamRet stop(stopHandler handler) = 0;



    ///

    /// Get the list of input sources.

    ///

    /// \param[in] mediaType - selected media type

    /// \param[in] sourceList - list of input sources for the mediaType

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet getInputSources(MediaType mediaType, std::vector\<std::string> &sourceList) = 0;



    ///

    /// Set the input sources.

    ///

    /// \param[in] mediaType - selected media type

    /// \param[in] sourceList - list of input sources are going to be used by stream library in the following streaming

    /// \param[in] handler - function pointer called on setting input sources

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet setInputSources(MediaType mediaType, const std::vector\<std::string> &sourceList, onSetInputSourcesHandler handler) = 0;



    ///

    /// Remove the input sources.

    ///

    /// \param[in] mediaType - selected media type

    /// \param[in] sourceList - list of input sources are going to be removed from stream library

    /// \param[in] handler - function pointer called on removing input sources

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet removeInputSources(MediaType mediaType, const std::vector\<std::string> &sourceList, onSetInputSourcesHandler handler) = 0;



    ///

    /// Set audio capabilities.

    ///

    /// \param[in] inputSource - the audio input source

    /// \param[in] audioCapabilities - the audio capabilities which are going to be used by stream library

    /// in the following streaming.

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet setAudioCapabilities(const std::string &inputSource, const AudioCapabilities &audioCapabilities) = 0;



    ///

    /// Set video capabilities.

    ///

    /// \param[in] inputSource - the video input source

    /// \param[in] videoCapabilities - the video capabilites which are going to be used by stream library

    /// in the following streaming.

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet setVideoCapabilities(const std::string &inputSource, const VideoCapabilities &videoCapabilities) = 0;



    ///

    /// \brief Attach the self-video preview window.

    ///

    /// Attaching the self-video preview window to render the captured

    /// video from the camera. This will start rendering self-camera video

    /// when stream start with any endpoint.

    ///

    /// Note: this API is only supported for Android and iOS platforms

    ///

    /// \param[in] viewId - ID of the view where self-video should render

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet attachPreviewVideoWindow(long long viewId) = 0;



    ///

    /// \brief Attach video window for remote.

    ///

    /// Attaching the video window to render the video received from

    /// remote endpoint. This will start rendering remote endpoint's

    /// video when library starts receiving video from remote endpoint.

    ///

    /// Note: this API is only supported for Android and iOS platforms

    /// and this API need to be invoked multiple times for multiple

    /// endpoint's video sources.

    ///

    /// \param[in] fromEndPoint - stream source endpoint UUID

    /// \param[in] viewId - ID of the view where remote video should render

    ///

    /// \return StreamRet::OK on success, other values on failure.

    ///

    virtual StreamRet attachVideoWindow(const EndPointUUID &fromEndPoint, long long viewId) = 0;



    ///

    /// Start a stream.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] mediaTypeList list of mediaTypes

    /// \param[in] handler function pointer called when the request is issued

    ///

    /// Note: this API can be invoked multiple times to stream with multiple

    /// remote endpoints.

    ///

    virtual void startStream(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, onStreamRequestHandler handler) = 0;



    ///

    /// Set callback to get notified when a stream requested.

    ///

    /// \param[in] handler function pointer called when a stream has been requested.

    ///

    virtual void onStreamReceive(onStreamReceiveHandler handler) = 0;



    ///

    /// Set callback to get notified when a stream started.

    ///

    /// \param[in] handler function pointer called when the stream has started.

    ///

    virtual void onStreamStart(onStreamStartHandler handler) = 0;



    ///

    /// Request to stop a stream.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID concerned by the stop request.

    /// \param[in] handler function pointer called when the stream has been stopped.

    ///

    virtual void stopStream(const EndPointUUID &fromEndPoint, onStreamStopHandler handler) = 0;



    ///

    /// Set callback to get notified when a stream stopped.

    ///

    /// \param[in] handler function pointer which will be called when any stream has been stopped.

    ///

    virtual void onStreamStop(onStreamStopHandler handler) = 0;



    ///

    /// Pause the transmission of selected media.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] mediaTypeList selected media types

    /// \param[in] handler function pointer called when the stream has been paused.

    ///

    virtual void pauseStream(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, onStreamPauseHandler handler) = 0;



    ///

    /// Set callback to get notified when a stream paused.

    ///

    /// \param[in] handler function pointer which will be called when any stream has been paused.

    ///

    virtual void onStreamPause(onStreamPauseHandler handler) = 0;



    ///

    /// Resume the transmission of selected media.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] mediaTypeList selected media types

    /// \param[in] handler function pointer called when the stream has been resumed.

    ///

    virtual void resumeStream(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, onStreamResumeHandler handler) = 0;



    ///

    /// Set callback to get notified when a stream resumed.

    ///

    /// \param[in] handler function pointer which will be called when any stream has been resumed.

    ///

    virtual void onStreamResume(onStreamResumeHandler handler) = 0;



    ///

    /// set callback to get notified when connectivity has changed for an ongoing stream session

    ///

    /// \param[in] handler function pointer which will be called when connectivity of an ongoing

    /// streaming has changed.

    ///

    virtual void onStreamConnectivityChange(onStreamConnectivityChangeHandler handler) = 0;



    ///

    /// set callback to get notified when video resolution has changed for an ongoing stream session

    ///

    /// \param[in] handler function pointer which will be called when video resolution of an ongoing

    /// streaming has changed.

    ///

    virtual void onReceivedVideoResolutionChange(onReceivedVideoResolutionChangeHandler handler) = 0;

    

    ///

    /// set callback to get notified when received video specific data

    ///

    /// \param[in] handler function pointer which will be called when video specific data of an ongoing

    /// streaming has received.

    ///

    virtual void onReceivedVideoSpecificData(onReceivedVideoSpecificDataHandler handler) = 0;



    ///

    /// Set video recording buffer.

    ///

    /// \param[in] bufferTime the time of the recording buffer in seconds.

    /// \param[in] duration the duration of the recording in seconds.

    ///

    virtual void setRecordingBuffer(int bufferTime, int duration) = 0;



    ///

    /// onStartRecordingHandler will tell if recording is started or not.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] mediaTypeList Selected media types (audio/video)

    /// \param[in] eventTrigger true if the recording initiated for an event.

    /// \param[in] handler function pointer for the callback.

    ///

    /// Note that, this API will be used by both the camera and the application

    /// to start the recording. When invoked from the camera the fromEndPoint will

    /// be empty.

    ///

    virtual bool startRecording(const EndPointUUID &fromEndPoint, time_t referenceTime, time_t actionTime, time_t duration, const std::vector\<MediaType> &mediaTypeList, const std::vector\<std::string> &sourceList, bool eventTrigger, onStartRecordingHandler handler) = 0;



    ///

    /// Request to stop the recording.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] mediaTypeList selected media types

    /// \param[in] handler function pointer for the callback.

    ///

    virtual void stopRecording(const EndPointUUID &fromEndPoint, const std::vector\<MediaType> &mediaTypeList, onStopRecordingHandler handler) = 0;



    ///

    /// Request the list of recordings from the endpoint.

    ///

    /// \param[in] fromEndPoint stream source endpoint UUID

    /// \param[in] startTime time of the newest recording.

    /// \param[in] endTime time of the oldest recording.

    /// \param[in] handler function pointer called when recording list has retrieved.

    ///

    virtual void getRecordingList(const EndPointUUID &fromEndPoint, std::time_t startTime, std::time_t endTime, onRecordingListHandler handler) = 0;



    ///

    /// Set callback to get notified when a recording completed.

    ///

    /// \param[in] handler function pointer which will be called when a recording has completed.

    ///

    virtual void onRecordingCompleted(onStopRecordingHandler handler) = 0;



    ///

    /// \brief Provide compressed frame.

    ///

    /// This will send the already encoded frame to the endpoint

    ///

    /// \param[in] toEndpoint - stream sink endpoint UUID

    /// \param[in] mediaType - selected media type

    /// \param[in] framePtr - frame data

    /// \param[in] size - size of the frame

    /// \param[in] frameProperties - properties of the frame

    /// \param[in] timestamp - time stamp of the frame

    ///

    virtual int pushEncodedFrame(const EndPointUUID &toEndpoint, MediaType mediaType, void *framePtr, long size, FrameProperties frameProperties, time_t timestamp) = 0;



    ///

    /// Set callback to get notified when a frame received.

    ///

    /// \param[in] handler function pointer which will be called when received a frame.

    ///

    virtual void onReceiveFrame(onReceiveFrameHandler handler) = 0;



    ///

    /// Set custom Video Quality Table in JSON format.

    ///

    virtual void setQoSTable(const QoSjson &table) = 0;



    ///

    /// Enable or Disable Video Quality Control.

    ///

    /// \param[in] enable - true enables it and false disables it.

    ///

    virtual void setQoS(bool enable) = 0;



    ///

    /// Enable or Disable Audio Acoustic Echo Cancellation.

    ///

    virtual void setAEC(bool enable) = 0;



    ///

    /// Enable or Disable Audio Automatic Gain Control.

    ///

    virtual void setAGC(bool enable) = 0;



    ///

    /// Select video quality profile.

    ///

    virtual void setVideoQualityProfile(VideoQualityProfile profile) = 0;



    ///

    /// Definition of a shared pointer to Stream.

    ///

    typedef std::shared_ptr\<Stream> Ptr;



    ///

    /// This will provide sending media statistics.

    ///

    /// \param[in] toEndpoint - stream sink endpoint UUID

    /// \param[in] mediaType - selected media type

    /// \param[in] streamStatistics - statistics of audio sending to endpoint

    ///

    virtual void getSendStatistics(const EndPointUUID &toEndpoint, MediaType mediaType, StreamStatistics::Ptr streamStatistics) = 0;



    ///

    /// This will provide receiving media statistics.

    ///

    /// \param[in] fromEndpoint - stream source endpoint UUID

    /// \param[in] mediaType - selected media type

    /// \param[in] streamStatistics - streamStatistics of audio receiving from endpoint

    ///

    virtual void getReceiveStatistics(const EndPointUUID &fromEndpoint, MediaType mediaType, StreamStatistics::Ptr streamStatistics) = 0;



    ///

    /// This will set RawData callback

    ///

    /// \param[in] handler - callback function for rawdata

    virtual void setRawDataCallback(onRawDataHandler handler) = 0;

};



///

/// \brief StreamBuilder builds a Stream object.

///

/// StreamBuilder builds a Stream object. It will return to

/// the caller an object which implements the Stream interface.

///

class StreamBuilder

{

private:

    com::anyconnect::access::Access::Ptr access;

    StreamBuilder(const StreamBuilder &rsb) = delete;

    unsigned int maxNetworkWaitTime;

    unsigned int receiveTimeout;

    std::string logDirectory;

    std::string pluginLibraryDirectory;



public:



    ///

    /// Definition of a shared pointer to StreamBuilder.

    ///

    typedef std::shared_ptr\<StreamBuilder> Ptr;



    StreamBuilder();

    virtual ~StreamBuilder();



    ///

    /// \brief Set Access object.

    ///

    /// Set Access object.

    ///

    /// \param[in] access - Access object.

    ///

    void setAccess(com::anyconnect::access::Access::Ptr access) {

        this->access = access;

    }



    ///

    /// \brief Get Access object.

    ///

    /// \return Access object.

    ///

    com::anyconnect::access::Access::Ptr getAccess() const {

        return access;

    }



    ///

    /// \brief Set the timeout for receiving media data.

    ///

    /// Set the timeout that Stream library will wait for receiving media data before

    /// closing any ongoing stream.

    ///

    /// \param[in] msTime - Time in milliseconds to wait for receiving media data before closing stream.

    ///

    void setReceiveTimeout(unsigned int msTime) {receiveTimeout = msTime;}

    

    ///

    /// \brief Get the timeout for receiving media data.

    ///

    /// Get the timeout that Stream library will wait for media data before closing any

    /// ongoing stream.

    ///

    /// \return unsigned int - Time to wait in milliseconds.

    ///

    unsigned int getReceiveTimeout() const {return receiveTimeout;}

    

    ///

    /// \brief Set the maximum network change time.

    ///

    /// Set the time that Connect will keep a connection open without an underlying path

    /// to get to the endpoint. (For example, if this value is greater than the time it takes

    /// to move from Wi-Fi to 4G, then the connection will not close.) The default value

    /// is 0, meaning that loss of network results in immediate close of connection.

    ///

    /// \param[in] msTime - Time to wait for a new network path in milliseconds.

    ///

    void setMaxNetworkChangeTime(unsigned int msTime) {maxNetworkWaitTime = msTime;}



    ///

    /// \brief Get the maximum network change time.

    ///

    /// Get the maximum time that Connect will keep a connection open without an underlying

    /// path to reach the endpoint.

    ///

    /// \return unsigned int - Time to wait in milliseconds.

    ///

    unsigned int getMaxNetworkChangeTime() const {return maxNetworkWaitTime;}



    ///

    /// \brief Set the logging directory for Stream library.

    ///

    /// Set the Stream library's logging directory.

    ///

    /// \param[in] logDirectory - log directory where Stream library will write the logs

    ///

    void setLogDirectory(const std::string &logDirectory) {this->logDirectory = logDirectory;}



    ///

    /// \brief Get the Stream library's logging directory.

    ///

    /// \return Stream library's logging directory.

    ///

    std::string getLogDirectory() const {

        return logDirectory;

    }



    ///

    /// \brief Set the plugin library's directory for Stream library.

    ///

    /// Set the directory of plugin library for Stream library.

    ///

    /// \param[in] pluginLibraryDirectory - event library's directory where the event library is available to be used by Stream library.

    ///

    void setPluginLibraryDirectory(const std::string &pluginLibraryDirectory) {this->pluginLibraryDirectory = pluginLibraryDirectory;}



    ///

    /// \brief Get the event library's directory.

    ///

    /// \return Event library's directory.

    ///

    std::string getPluginLibraryDirectory() const {

        return pluginLibraryDirectory;

    }



    ///

    /// Construct a Stream object using the builder.

    ///

    /// \return In success, returns Stream::Ptr containing Stream instance. In failure, returns null Stream::Ptr

    ///

    Stream::Ptr build() throw (std::runtime_error);

};



} //stream

} //anyconnect

} //com



#endif //_STREAM_H_