#ifndef H264_LIVE_SERVER_MEDIASESSION_HH_
#define H264_LIVE_SERVER_MEDIASESSION_HH_

#include<mutex>

#include "liveMedia.hh"
#include "OnDemandServerMediaSubsession.hh"
#include "LiveSourceWithx264.hh"

class H264LiveServerMediaSession:public OnDemandServerMediaSubsession{
public:
    static H264LiveServerMediaSession* createNew(UsageEnvironment& env, bool reuseFirstSource);
    void checkForAuxSDPLine1();
    void afterPlayingDummy1();
    void LiveStream_cameraFrameData(unsigned char* mFrameByte, unsigned mFrameSize, struct timeval mPresentationTime,uint64_t timeStamp);
protected:
    H264LiveServerMediaSession(UsageEnvironment& env, bool reuseFirstSource);
    virtual ~H264LiveServerMediaSession(void);
    void setDoneFlag() { fDoneFlag = ~0; }
    virtual char const* getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource);
    virtual FramedSource* createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate);
    virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* inputSource);

public:
    LiveSourceWithx264 *liveVideosource;
    TaskScheduler* live555TaskScheduler = NULL;
    EventTriggerId eventTriggerId;
    char videoSPSData[100];
    char videoPPSData[100];
    std::string streamName;
    int spsSize;
    int ppsSize;
    std::mutex mtx;
    char liveSourceAvailable;
    std::queue<QUEUE> camQueue;
private:
    char* fAuxSDPLine;
    char fDoneFlag;
    RTPSink* fDummySink;
};
#endif
