-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWW_H264VideoServerMediaSubsession.cpp
84 lines (64 loc) · 2.29 KB
/
WW_H264VideoServerMediaSubsession.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "WW_H264VideoServerMediaSubsession.h"
WW_H264VideoServerMediaSubsession::WW_H264VideoServerMediaSubsession(UsageEnvironment & env, FramedSource * source) : OnDemandServerMediaSubsession(env, True)
{
m_pSource = source;
m_pSDPLine = 0;
}
WW_H264VideoServerMediaSubsession::~WW_H264VideoServerMediaSubsession(void)
{
if (m_pSDPLine)
{
free(m_pSDPLine);
}
}
WW_H264VideoServerMediaSubsession * WW_H264VideoServerMediaSubsession::createNew(UsageEnvironment & env, FramedSource * source)
{
return new WW_H264VideoServerMediaSubsession(env, source);
}
FramedSource * WW_H264VideoServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned & estBitrate)
{
return H264VideoStreamFramer::createNew(envir(), new WW_H264VideoSource(envir()));
}
RTPSink * WW_H264VideoServerMediaSubsession::createNewRTPSink(Groupsock * rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource * inputSource)
{
return H264VideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic);
}
char const * WW_H264VideoServerMediaSubsession::getAuxSDPLine(RTPSink * rtpSink, FramedSource * inputSource)
{
if (m_pSDPLine)
{
return m_pSDPLine;
}
m_pDummyRTPSink = rtpSink;
//mp_dummy_rtpsink->startPlaying(*source, afterPlayingDummy, this);
m_pDummyRTPSink->startPlaying(*inputSource, 0, 0);
chkForAuxSDPLine(this);
m_done = 0;
envir().taskScheduler().doEventLoop(&m_done);
m_pSDPLine = strdup(m_pDummyRTPSink->auxSDPLine());
m_pDummyRTPSink->stopPlaying();
return m_pSDPLine;
}
void WW_H264VideoServerMediaSubsession::afterPlayingDummy(void * ptr)
{
WW_H264VideoServerMediaSubsession * This = (WW_H264VideoServerMediaSubsession *)ptr;
This->m_done = 0xff;
}
void WW_H264VideoServerMediaSubsession::chkForAuxSDPLine(void * ptr)
{
WW_H264VideoServerMediaSubsession * This = (WW_H264VideoServerMediaSubsession *)ptr;
This->chkForAuxSDPLine1();
}
void WW_H264VideoServerMediaSubsession::chkForAuxSDPLine1()
{
if (m_pDummyRTPSink->auxSDPLine())
{
m_done = 0xff;
}
else
{
double delay = 1000.0 / (FRAME_PER_SEC); // ms
int to_delay = delay * 1000; // us
nextTask() = envir().taskScheduler().scheduleDelayedTask(to_delay, chkForAuxSDPLine, this);
}
}