00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef MN_RTP_DECODER_STREAM_HANDLER_H
00025
#define MN_RTP_DECODER_STREAM_HANDLER_H
00026
00027
#include <sys/types.h>
00028
00029
#include "SH.h"
00030
#include "SHEndpoint.h"
00031
#include "SHEndpointSpec.h"
00032
#include "var_type.h"
00033
#include "MNTimerCall.h"
00034
#include "lcrtp/MNLCRTPdefs.h"
00035
#include "lcrtp/MNLCRTPLossList.h"
00036
#include "sdp/PayloadTypes.h"
00037
#include "sdp/PayloadTypeEntry.h"
00038
#include "MNTFRCRecv.h"
00039
00040
class MNRTP;
00041
class MNUDPSocket;
00042
class MNRTPDecoderBase;
00043
class RetransRecvBase;
00044
class MNRope;
00045
00046
namespace SH
00047 {
00048
00049
class RTPDecoderSH;
00050
class RTPDecoderSinkEndpointSpec;
00051
class RTPDecoderSourceEndpointSpec;
00052
class RTPDecoderSinkEndpoint;
00053
class RTPDecoderSourceEndpoint;
00054
00059
00060
00061
00062
00063 class RTPDecoderSinkEndpoint
00064 :
public SinkEndpoint
00065 {
00066
public:
00067
RTPDecoderSinkEndpoint(
RTPDecoderSH* mySH );
00068
virtual ~RTPDecoderSinkEndpoint( );
00069
00070
virtual SH_RC push(
DataPtr item );
00071
00072
RTPDecoderSH*
dsh();
00073 };
00074
00075
00076
00077
00078
00079 class RTPDecoderSourceEndpoint
00080 :
public SourceEndpoint
00081 {
00082
public:
00083
RTPDecoderSourceEndpoint(
RTPDecoderSH* mySH );
00084
virtual ~RTPDecoderSourceEndpoint( );
00085
00086
virtual SH_RC pull(
DataPtr& item,
00087
SourceUnit su =
UnitDefault,
00088 size_t amount = 0 );
00089
00090
RTPDecoderSH*
dsh();
00091 };
00092
00122 class RTPDecoderSH
00123 :
public Base
00124 {
00125
MNRTPDecoderBase* _codec;
00126
RetransRecvBase* _retrans;
00127
00128
SA_HAS_ORDERED_DATA _hasOrderedData;
00129
00130
const SDP::PayloadTypeTable* _payload_types;
00131
SA_RTP_RTP_PAYLOAD_TYPE _rtp_pt;
00132
SA_RTP_INT_PAYLOAD_TYPE _int_pt;
00133
SA_RTP_INT_RETRANS_TYPE _int_rt;
00134
00135
00136
SA_RTP_SEQ_LISTEN _rtp_seq;
00137
SA_RTP_TIME_LISTEN _rtp_time;
00138
00139
00140
SA_IGNORE_SYNC_TIMESTAMP _ignore_sync_ts;
00141
unsigned _syncTimestamp;
00142
struct timeval _syncTime;
00143
bool _hasBeenSynced;
00144
00145
MNRope* _decodedDataRope;
00146
00147
bool _gotFirstPacket;
00148
00149
ProtectedVarEnum<streamer_state_t> _streamer_state;
00150
00154
SH_RC verify_codec( );
00155
00159
MNSelector& _sel;
00160
void set_retrans(
MNSelector& sel );
00161
00162
00163
00164
MNTFRCRecv* _tfrc;
00165
00166
public:
00172
void set_payload_types(
const SDP::PayloadTypeTable* ptt_ptr);
00173
00174
00175
SH_RC push_decode(
DataPtr item );
00176
SH_RC pull_decode(
DataPtr& item );
00177
00201
DataPtr evalLCRTPPacket(
MNRTPPacketPtr packet,
00202
MNRope*& payload,
00203 u_int64_t& bytecount );
00204
00205
00206
void tfrc_packet_received(
MNRope*& payload,
00207
MNRTPPacketPtr packet);
00208
void send_feedback(
u_int32 ssrc,
LCfeedb_tfrc_t* reply);
00209
00223
DataPtr evalRTPPacket(
MNRTPPacketPtr packet,
00224
MNRope*& payload,
00225 u_int64_t& bytecount);
00232
void evalSyncTimestamp(
unsigned rtpTimestamp,
struct timeval& resPT);
00233
00241
void evalSyncRTCP(
u_int32 ntp_upper,
u_int32 ntp_lower,
u_int32 rtpTimestamp);
00242
00247 inline void resetSyncTime() { _syncTime.tv_sec = _syncTime.tv_usec = 0; }
00248
00249
public:
00250
RTPDecoderSH(
SHGraphManager* mgr,
00251
u_int32_t runtimeId,
00252
MNSelector& sel );
00253
00254
virtual ~RTPDecoderSH();
00255
00256
private:
00257
00262
RTPDecoderSH(
const RTPDecoderSH& );
00263
00268
RTPDecoderSH& operator=(
const RTPDecoderSH& );
00269
00270
public:
00273
virtual SH_RC initSH();
00276
virtual SH_RC uninitSH();
00277
00280
virtual SH_RC startStreaming();
00283
virtual SH_RC stopStreaming();
00284
00285
00286
00287
00288
public:
00289
00290
00291
00292
00293
00294
protected:
00295
friend class RTPDecoderSinkEndpoint;
00296
friend class RTPDecoderSourceEndpoint;
00297
00302
friend class LossList;
00303
00304
virtual void pushReport(
ReportPtr report, Base::Direction d );
00305
00306 SinkEndpoint*
_in_ep_a[1];
00307 SourceEndpoint*
_out_ep_a[1];
00308 RTPDecoderSinkEndpoint _inEP;
00309 RTPDecoderSourceEndpoint _outEP;
00310
00311
public:
00312
virtual SinkEndpoint**
getSinkSpecs();
00313
virtual SourceEndpoint**
getSourceSpecs();
00314
00324
virtual bool isConnected() const ;
00325 };
00326
00328
00329 };
00330
00331 #endif
00332