houxiao
2017-08-16 663104b9be90ed303b87c8acddac8421583a9e39
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
//
//  LiveServerMediaSubsession.cpp
//  FFmpegRTSPServer
//
//  Created by Mina Saad on 9/22/15.
//  Copyright (c) 2015 Mina Saad. All rights reserved.
//
 
#include "LiveServerMediaSubsession.h"
#include "H264FramedSource.h"
 
namespace MESAI
{
 
LiveServerMediaSubsession * LiveServerMediaSubsession::createNew(UsageEnvironment& env, StreamReplicator* replicator)
{
    return new LiveServerMediaSubsession(env,replicator);
}
 
FramedSource* LiveServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate)
{
    FramedSource* source = m_replicator->createStreamReplica();
    estBitrate = 512 * 1024 * 8;//#todo
    return H264VideoStreamDiscreteFramer::createNew(envir(), source);
}
 
RTPSink* LiveServerMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock,  unsigned char rtpPayloadTypeIfDynamic, FramedSource* inputSource)
{
    return H264VideoRTPSink::createNew(envir(), rtpGroupsock,rtpPayloadTypeIfDynamic);
}
 
char const* LiveServerMediaSubsession::sdpLines()
{
    if (m_SDPLines.empty())
    {
        m_SDPLines.assign(OnDemandServerMediaSubsession::sdpLines());
 
        H264FramedSource* framedSource = nullptr;
        {
            FramedSource* _framedSource = m_replicator->inputSource();
            framedSource = dynamic_cast<H264FramedSource*>(_framedSource);
        };
 
        if (framedSource != nullptr)
        {
            m_SDPLines.append(framedSource->getAuxLine());
        }
    }
 
    return m_SDPLines.c_str();
}
 
}