Guest User

Untitled

a guest
Dec 27th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. #include "H264LiveServerMediaSession.h"
  2.  
  3. //------------------------------------------------------------------------------
  4. H264LiveServerMediaSession*
  5. H264LiveServerMediaSession::createNew(UsageEnvironment& env,
  6. bool reuseFirstSource)
  7. {
  8. return new H264LiveServerMediaSession(env, reuseFirstSource);
  9. }
  10.  
  11. H264LiveServerMediaSession::H264LiveServerMediaSession(UsageEnvironment& env,
  12. bool reuseFirstSource)
  13. :OnDemandServerMediaSubsession(env,reuseFirstSource),
  14. fAuxSDPLine(NULL),
  15. fDoneFlag(0),
  16. fDummySink(NULL)
  17. {
  18. //Do nothing
  19. }
  20.  
  21. //------------------------------------------------------------------------------
  22. H264LiveServerMediaSession::~H264LiveServerMediaSession(void)
  23. {
  24. delete[] fAuxSDPLine;
  25. }
  26.  
  27. //------------------------------------------------------------------------------
  28. static void afterPlayingDummy(void* clientData)
  29. {
  30. H264LiveServerMediaSession *session = (H264LiveServerMediaSession*)clientData;
  31. session->afterPlayingDummy1();
  32. }
  33.  
  34. //------------------------------------------------------------------------------
  35. void H264LiveServerMediaSession::afterPlayingDummy1()
  36. {
  37. envir().taskScheduler().unscheduleDelayedTask(nextTask());
  38. setDoneFlag();
  39. }
  40.  
  41. //------------------------------------------------------------------------------
  42. static void checkForAuxSDPLine(void* clientData)
  43. {
  44. H264LiveServerMediaSession* session = (H264LiveServerMediaSession*)clientData;
  45. session->checkForAuxSDPLine1();
  46. }
  47.  
  48. //------------------------------------------------------------------------------
  49. void H264LiveServerMediaSession::checkForAuxSDPLine1()
  50. {
  51. char const* dasl;
  52. if(fAuxSDPLine != NULL)
  53. {
  54. setDoneFlag();
  55. }
  56. else if(fDummySink != NULL && (dasl = fDummySink->auxSDPLine()) != NULL)
  57. {
  58. fAuxSDPLine = strDup(dasl);
  59. fDummySink = NULL;
  60. setDoneFlag();
  61. }
  62. else
  63. {
  64. int uSecsDelay = 10;
  65. nextTask() = envir().taskScheduler().scheduleDelayedTask(uSecsDelay, (TaskFunc*)checkForAuxSDPLine, this);
  66. }
  67. }
  68.  
  69. //------------------------------------------------------------------------------
  70. char const* H264LiveServerMediaSession::getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource)
  71. {
  72. if(fAuxSDPLine != NULL) return fAuxSDPLine;
  73. if(fDummySink == NULL)
  74. {
  75. fDummySink = rtpSink;
  76. fDummySink->startPlaying(*inputSource, afterPlayingDummy, this);
  77. checkForAuxSDPLine(this);
  78. }
  79.  
  80. envir().taskScheduler().doEventLoop(&fDoneFlag);
  81. return fAuxSDPLine;
  82. }
  83.  
  84. //------------------------------------------------------------------------------
  85. FramedSource*
  86. H264LiveServerMediaSession::createNewStreamSource(unsigned clientSessionID,
  87. unsigned& estBitRate)
  88. {
  89. /* comments from original source code*/
  90. // Based on encoder configuration i kept it 90000
  91. estBitRate = 90000;
  92. LiveSourceWithx264 *source = LiveSourceWithx264::createNew(envir());
  93. /* comments from original source code*/
  94. // are you trying to keep the reference of the source somewhere? you
  95. // shouldn't.
  96. // Live555 will create and delete this class object many times. if you store
  97. // it somewhere you will get memory access violation. instead you should
  98. // configure you source to always read from your data source.
  99. return H264VideoStreamDiscreteFramer::createNew(envir(),source);
  100. }
  101.  
  102. //------------------------------------------------------------------------------
  103. RTPSink*
  104. H264LiveServerMediaSession::
  105. createNewRTPSink(Groupsock* rtpGroupsock,
  106. unsigned char rtpPayloadTypeIfDynamic,
  107. FramedSource* inputSource)
  108. {
  109. return H264VideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic);
  110. }
Advertisement
Add Comment
Please, Sign In to add comment