流媒体Live555学习(三)

OnDemandServerMediaSubSession

OnDemandServerMediaSubSessionServermediaSubSession的一个中间实现,定义了一些点播服务的特性

 

保护方法:

OnDemandServerMediaSubsession(UsageEnvironment&env, Boolean reuseFirstSource,

portNumBitsinitialPortNum = 6970);

构造方法,初始化变量,为连接的客户端创建一个HashTable

virtualchar const* sdpLines();

返回sdp信息;

-----------------------------------------------------------------------------------------------------------------------

内部实现:

如果fSdpLine已存在就直接返回,否则创建临时的FramSourceRTPSink,然后从RTPsink中得到SDPLine;

/*

FramedSource*inputSource = createNewStreamSource(0, estBitrate);

RTPSink* dummyRTPSink = createNewRTPSink(&dummyGroupsock, rtpPayloadType,inputSource);

setSDPLinesFromRTPSink(dummyRTPSink,inputSource, estBitrate);

*/

-----------------------------------------------------------------------------------------------------------------------------

virtualvoid getStreamParameters(unsigned clientSessionId,

   netAddressBits clientAddress,

                                   Portconst& clientRTPPort,

                                   Portconst& clientRTCPPort,

   int tcpSocketNum,

                                   unsignedchar rtpChannelId,

                                   unsignedchar rtcpChannelId,

                                  netAddressBits& destinationAddress,

   u_int8_t& destinationTTL,

                                   Boolean&isMulticast,

                                   Port&serverRTPPort,

                                   Port&serverRTCPPort,

                                   void*&streamToken);

创建FrameSourceRTPSink,及与RTPSink关联的RTPGroupSocketRTCPGroupSocket;如果有重用标记,则直接使用之前的sourcesink,不再创建;

virtualvoid startStream(unsigned clientSessionId, void* streamToken,

   TaskFunc* rtcpRRHandler,

   void* rtcpRRHandlerClientData,

   unsigned short& rtpSeqNum,

                           unsigned&rtpTimestamp,

   ServerRequestAlternativeByteHandler*serverRequestAlternativeByteHandler,

                           void*serverRequestAlternativeByteHandlerClientData);

启动streamToken对应流的传输;

streamState->startPlaying(destinations,

      rtcpRRHandler, rtcpRRHandlerClientData,

      serverRequestAlternativeByteHandler,serverRequestAlternativeByteHandlerClientData);

 

virtual char const* getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource);

新定义的方法,子类可以重新实现,用于获取什么信息?

virtualFramedSource* createNewStreamSource(unsigned clientSessionId,

      unsigned& estBitrate) = 0;

纯虚函数,创建FrameSource

virtualRTPSink* createNewRTPSink(Groupsock* rtpGroupsock,

    unsigned char rtpPayloadTypeIfDynamic,

    FramedSource* inputSource) = 0;

纯虚函数,创建RTPSink

成员变量

protected:

  char* fSDPLines;

SDP信息

  HashTable* fDestinationsHashTable;

目标地址

 

private:

  Boolean fReuseFirstSource;

是否重用source

  portNumBits fInitialPortNum;

可选port的起始值

  void* fLastStreamToken;

最近创建的token

  char fCNAME[100];

// for RTCP

  friend class StreamState;

一个用于传输的数据结构

 

StreamState

 

OnDemandServerMediaSubSession创建的数据结构,内部包含了用于数据传输的各种物件,如

Port const& serverRTPPort, Port const& serverRTCPPort,

RTPSink*rtpSink, FramedSource* mediaSource,

Groupsock*rtpGS, Groupsock* rtcpGS

 

类接口:

voidstartPlaying(Destinations* destinations,

    TaskFunc* rtcpRRHandler, void*rtcpRRHandlerClientData,

    ServerRequestAlternativeByteHandler*serverRequestAlternativeByteHandler,

                    void*serverRequestAlternativeByteHandlerClientData);

启动流播放;

内部会创建RTCPInstance,然后启动RTPSink播放

fRTPSink->startPlaying(*fMediaSource,afterPlayingStreamState, this);


MediaSession

 

MediaSessionclient端表示媒体流的结构,与server端的ServerMediaSession对应,内部会创建MediaSubSession

 

类接口:

static MediaSession* createNew(UsageEnvironment& env, char const* sdpDescription);

创建mediaSession,内部会调用newSession->initializeWithSDP(sdpDescription)来初始化媒体信息;

staticBoolean lookupByName(UsageEnvironment& env, char const* sourceName,

MediaSession*&resultSession);

查找指定sourceNameMediaSession是否存在,存在则返回到resultSession

(注:env只有一个MediaLookUpTable,所有创建的MediaSession在初始化的时候就会被添加到这个table里,具体操作在Medium的构造函数;)

 

保护方法:

virtualMediaSubsession* createNewMediaSubsession();

创建MediaSubSession,默认直接实例化一个MediaSubSession

BooleaninitializeWithSDP(char const* sdpDescription);

解析sdp初始化MediaSession;先解析MediaSession的参数,之后遇到"m="行,创建mediaSubSession,根据sdp初始化媒体信息,并添加到mediaSession的列表中;

 

MediaSubSession

 

MediaSubSession是子媒体流的结构,里面有大量的标识媒体信息的字段,一般都是通过解析SDP信息进行赋值;




你可能感兴趣的:(流媒体Live555学习(三))